forked from collexion/wavepool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
looper.ck
137 lines (111 loc) · 2.51 KB
/
looper.ck
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
// Live looping setup using an FCB1010, Ax100, TouchOSC
adc => LiSa looper => dac;
adc => JCRev r => dac;
float stringVol[6];
int stringPitch[6];
float stringFreq[6];
0 => int octaveShift;
0 => r.mix;
40::second => looper.duration;
1 => looper.loop;
1 => looper.loopRec;
1 => looper.play;
1.0 => looper.rate;
MidiIn min;
MidiMsg msg;
MidiIn midiFootController;
if ( !midiFootController.open(8) )
{
<<<"Failed to open MIDIsport front panel for FCB1010">>>;
me.exit();
}
<<< "Opened footcontroller on ", midiFootController >>>;
spork ~ FootpedalMIDIController(midiFootController);
//open midi receiver, exit on fail
if ( !min.open(1) )
{
<<<"Failed to open MIDI input">>>;
me.exit();
}
<<< "Opened MIDI input ", min >>>;
fun void FootpedalMIDIController(MidiIn fc)
{
now => time loopStart;
while (true)
{
fc => now;
while(fc.recv(msg))
{
msg.data1 & 15 => int channel;
msg.data1 / 16 => int command;
<<< channel, command, msg.data2, msg.data3 >>>;
if (channel == 6 && command == 9 && msg.data2 == 1)
{
<<< "RECORD" >>>;
if (msg.data3 > 0)
{
now => loopStart;
0::samp => looper.recPos => looper.playPos;
1 => looper.record;
}
else if (msg.data3 == 0)
{
0 => looper.record;
1 => looper.loop;
1 => looper.play;
now - loopStart => looper.loopEnd;
<<< "Loop from ", loopStart, " to ", now >>>;
}
}
}
}
}
fun void ProcessMidiGuitar(MidiIn midiGuitarIn)
{
while( true )
{
// wait on midi event
midiGuitarIn => now;
// receive midimsg(s)
while( midiGuitarIn.recv( msg ) )
{
msg.data1 & 15 => int channel;
msg.data1 / 16 => int command;
<<< channel, command, msg.data2, msg.data3 >>>;
if (command == 9)
{
//spork ~ MandoNote(mando, msg.data2 + 12);
//spork ~ PluckString(channel, msg.data2);
msg.data2 => stringPitch[channel];
Std.mtof(12*octaveShift + stringPitch[channel]) => stringFreq[channel];
msg.data3 => stringVol[channel];
//mando[channel].noteOn(msg.data3/127.0);
}
else if (command == 8)
{
//mando[channel].noteOff(msg.data3/127.0);
0 => stringVol[channel];
}
else if (command == 14)
{
// pitch bend
Std.mtof(12*octaveShift + stringPitch[channel] + 12*(msg.data3*128 + msg.data2)/8192.0) => stringFreq[channel];
}
else if (command == 11)
{
// CC
if (msg.data2 == 7)
{
for (0 => int i; i<6; ++i)
{
//0.1 * msg.data3/127.0 => mando[i].gain;
}
}
}
}
}
}
while (true)
{
1::second => now;
}