Compare commits

...

10 commits

5 changed files with 85 additions and 8 deletions

View file

@ -1 +1 @@
# Lamentations I: Remembering Clive Wearing
# Remembering Clive Wearing

View file

@ -0,0 +1,54 @@
#include <TimerOne.h> // Include Timer1 library
// Pin outputs for the 18 lights
int AC_pin_offsets[18] = {22, 24, 26, 28, 30, 23, 25, 27, 29, 32, 34, 36, 38, 31, 33, 35, 37, 39};
int freq = 50; // 50 for EU and 60 for US
int dims[18]; // dimmer values
unsigned char clock_tick; // variable for Timer1
char incomingByte;
int val = 0;
int light = 0;
int delim = 0;
void setup() {
Serial.begin(115200);
for(int i = 0; i < 18; i++){
dims[i] = 215;
pinMode(AC_pin_offsets[i], OUTPUT);
};
attachInterrupt(0, zero_crosss_int, RISING);
Timer1.initialize(1000000 / (freq * 2) / 256); // 8 bit control
Timer1.attachInterrupt(timerIsr); // attach the service routine here
}
// this is the dimmer
void timerIsr() {
clock_tick++;
for(int i = 0; i < 18; i++) {
if (dims[i] == clock_tick) {
digitalWrite(AC_pin_offsets[i], HIGH); // triac on
delayMicroseconds(10); // triac On propogation delay (for 60Hz use 8.33, for 50Hz use 10)
digitalWrite(AC_pin_offsets[i], LOW); //triac off
}
};
}
// function to be fired at the zero crossing to dim the light
void zero_crosss_int() {
clock_tick=0;
}
void loop(){
if (Serial.available() > 0) { // something came across serial
while(1) {
incomingByte = Serial.read();
if(incomingByte == -1) {break;};
if(incomingByte < 0) {val = 256 + incomingByte;} else {val = incomingByte;};
if(val == 253) {delim = 1; continue;};
if(val == 254) {delim = 0; continue;};
if(delim == 0) light = val;
if(delim == 1) dims[light] = val;
}
}
}

Binary file not shown.

View file

@ -9,14 +9,18 @@ No GUI, just keycodes:
<ctrl + r> = run synth, <ctrl + p> = pause synth
<ctrl + s> = trigger start / fade in, <ctrl + e> = trigger end / fade out, <ctrl + t> = trigger wake
When ~arduino == 1 (true), the app assumes that an arduino is reachable, otherwise errors will be thrown
When automate == 1 (true), the trigger keys are disabled and the following lists in the SynthDef are used:
startTimes, wakeTimes, and endTimes
This launches the synth in a paused state to give the user time to put the visuals in full screen.
To start the synth, <ctrl + r> must be executed
*/
var automate = 1;
var dir = thisProcess.nowExecutingPath.dirname;
var automate = 1;
~arduino = 1;
~fadeInTrigBus = Bus.control(s); ~wakeTrigBus = Bus.control(s); ~fadeOutTrigBus = Bus.control(s);
"remembering_clive_wearing_visuals.scd".loadRelative(true, {
"remembering_clive_wearing_synthdef.scd".loadRelative(true, {

View file

@ -1,8 +1,8 @@
(
// VISUALS
// Init vars and window
var projectionWin, scoreWin, osc_func, run = true, blend = {0} ! 27;
projectionWin = Window.new("Lamentations I: Remembering Clive Wearing", Rect(500, 500, 750, 500)).front;
var projectionWin, arduino_port, osc_func, brightness = {0} ! 27, refresh_func;
projectionWin = Window.new("Remembering Clive Wearing", Rect(500, 500, 750, 500)).front;
projectionWin.background = Color.black;
// Keybinds (these can be change if conflicting with system keybinds)
@ -13,7 +13,7 @@ projectionWin.view.keyDownAction = { |doc, char, mod, unicode, keycode, key|
// <esc> = exit full screen
{mod == 0 && key == 16777216} {projectionWin.endFullScreen}
// <ctrl + r> = run synth
{mod == 262144 && key == 82} {~flicker.run}
{mod == 262144 && key == 82} {refresh_func.fork(AppClock); ~flicker.run}
// <ctrl + p> = pause synth
{mod == 262144 && key == 80} {~flicker.run(false)}
// <ctrl + s> = start / fade in
@ -24,8 +24,11 @@ projectionWin.view.keyDownAction = { |doc, char, mod, unicode, keycode, key|
{mod == 262144 && key == 84} {~wakeTrigBus.set(1)}
};
// Connect arduino; edit first arg / port to match index or name of port: SerialPort.listDevices
if(~arduino == 1, { arduino_port = SerialPort("/dev/ttyACM0", 115200)}, {});
// Get control signals from SynthDef
osc_func = OSCFunc.new({arg msg, time; blend[msg[2]] = msg[3]},'/tr', s.addr);
osc_func = OSCFunc.new({arg msg, time; brightness[msg[2]] = msg[3]; },'/tr', s.addr);
// Draw the window
projectionWin.drawFunc = {
@ -43,12 +46,28 @@ projectionWin.drawFunc = {
Pen.addOval(innerSquare);
Pen.fillRadialGradient(innerSquare.center, innerSquare.center,
(innerSquare.width / 16), (innerSquare.width / 2),
Color.black.blend(Color.new255(255, 214, 170, 255), pow(blend[(i * 9) + j], 0.5)),
Color.black.blend(Color.new255(255, 214, 170, 255), pow(brightness[(i * 9) + j], 0.5)),
Color.black);
} ! 9 } ! 2
};
projectionWin.refresh;
// Refresh function
{ while { run } { projectionWin.refresh; 30.reciprocal.wait; } }.fork(AppClock);
refresh_func = { while { true } {
// updateProjection
projectionWin.refresh;
if(~arduino == 1, {
// set min and max Brightness between 0 and 1 depending on wattage of light
// it is best to keep the min slightly higher than 0 to keep the light from turning completely off
{|i| var minBrightness = 0.15, maxBrightness = 0.65;
arduino_port.put(i);
arduino_port.put(253);
arduino_port.put(((((brightness[i] * (maxBrightness - minBrightness)) + minBrightness) - 1).abs * 256).asInteger);
arduino_port.put(254);
} ! 18 }, {});
// delay
30.reciprocal.wait; } };
)