-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathIl-Bianco-MIDI.scd
201 lines (164 loc) · 4.2 KB
/
Il-Bianco-MIDI.scd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
// *******
// MIDI
// *******
// Il Bianco e Dolce Cigno (2015)
// MIDIDefs
// REC for all loops
MIDIdef.noteOn(\loopRec, {arg val, note;
var loopNumber = case
{note==48} {0}
{note==53} {1}
{note==55} {2}
{note==57} {3}
{note==60} {4}
{note==62} {5}
{note==65} {6};
"loop number % %\n".postf(loopNumber);
case
{ ~loopRecState[loopNumber]==0 }
{ ~startRecording.value(loopNumber) }
{ ~loopRecState[loopNumber]==1 }
{ ~stopRecording.value(loopNumber) };
},
// for recording, listen only for the following MIDI notes:
noteNum: [48, 53, 55, 57, 60, 62, 65]
); // end of MIDIdef loopRec
// A variable to keep state of pause:
~loop0pause = 0;
// PAUSE for loop0 only
MIDIdef.noteOn(\loop0pause, {
// Pause pressed while loop0 is recording?
// stop recording, do nothing else.
//
// Pause pressed while loop0 is playing?
// pause it.
//
// Pause pressed while loop0 is paused?
// resume from where it left off.
case
{ ~loopRecState[0]==1 }
{ ~stopRecording.value(0) }
{~loop0pause==0}
{ // Pause
~loopSynth[0].set(\pause, 0);
~loop0pause = 1;
"PAUSE".postln;
}
{~loop0pause==1}
{ // Unpause
~loopSynth[0].run(true);
~loopSynth[0].set(\pause, 1);
~loop0pause = 0;
"UNPAUSE".postln;
}; // end case
},
noteNum: 49); // end of MIDIdef loop0pause
// ONCE for loop0 only
MIDIdef.noteOn(\loop0once, {
// ONCE pressed while loop0 is recording or playing?
// stop recording or playing.
// Then play the loop right away.
if(~loopSynth[0].notNil, // is it doing something? (playing or recording?)
{
if(~loopRecState[0]==1, // if recording...
{ ~stopRecording.value(0) }, // ...then stop recording
{ ~loopSynth[0].set(\freeMe, 0) } // ... else, stop playing
)
}
);
// Now start playing from beginning:
~loopSynth[0] = Synth("playStereo", [
\dur, ~loopRecTime[0],
\amp, 1 ],
target: ~loopGroup);
},
noteNum: [50, 51]);
// end of MIDIdef loop0once (also D# to mimic SooperLooper)
// OVERDUB key
~overdubOnOff = 0;
~overdubNode = nil;
MIDIdef.noteOn(\overdub, {
// E natural (midi 52) triggers the overdub moment.
// All happens automatically in the Synth:
// start overdub synth, fadeIn input volume,
// start playback soon after, stop overdub, stop playback, etc.
// This MIDIdef starts the synth if it was off;
// or frees the synth if it was running.
if(~overdubOnOff==0,
{
~overdubNode = Synth("recStereoOverdub", target: ~loopGroup);
~overdubOnOff = 1;
"Starting rec overdub...".postln;
},
{
~overdubNode.release;
~overdubOnOff = 0;
"Overdubbed note released".postln;
}
);
},
noteNum: 52);
// end of MIDIdef overdub
// Synth playDelays:
// Sharp keys trigger playback with delay line for mono loops
MIDIdef.noteOn(\onces, {arg vel, note;
var loopNumber;
case
{note==54} { loopNumber = 1 }
{note==56} { loopNumber = 2 }
{note==58} { loopNumber = 3 }
{note==61} { loopNumber = 4 }
{note==63} { loopNumber = 5 }
{note==66} { loopNumber = 6 };
Synth("playDelay", [
\bufnum, ~buffers[loopNumber],
\delayTime, rrand(3, 8),
\decayTime, vel.linlin(0, 127, 15, 40),
\amp, vel/127,
\dur, ~loopRecTime[loopNumber],
], target: ~loopGroup);
[note, "looping!"].postln;
},
noteNum: [54, 56, 58, 61, 63, 66]; // only listen to these
);
// End of playDelays
// Stereo Loop master volume output:
MIDIdef.cc(\stereoLoopOutVolume, {arg val;
~stereoLoopMasterOutVolume.value = val/127;
["main volume", val].postln;
},
ccNum: 7;
);
// Mono Loops master volume output:
MIDIdef.cc(\monoLoopsOutVolume, {arg val;
~monoLoopsMasterOutVolume.value = val/127;
["aleatoric loops volume", val].postln;
},
ccNum: 1;
);
/*
// DEPRECATED
// Input level of loop0 input bus (stereo mix of all mics)
// This is for the smooth sustained chord moment
MIDIdef.cc(\loop0inVolume, {arg val;
~stereoLoopInputBusVolume.value = val/127;
},
ccNum: 73 // knob 1
);
*/
// Play silent higher notes just to test MIDI connection
MIDIdef.noteOn(\test, {arg val, note;
var noteName =
case
{note==67} {"G5"}
{note==68} {"G#5"}
{note==69} {"A5"}
{note==70} {"Bb5"}
{note==71} {"B5"}
{note==72} {"C6"};
"TEST: % %\n".postf(noteName);
},
noteNum: [67, 68, 69, 70, 71, 72]
);
"End of MIDIdefs file; play a key between G5-C6 for a silent test.".postln;
// end of MIDI block