Antimon
Joined: Jan 18, 2005 Posts: 4145 Location: Sweden
Audio files: 371
G2 patch files: 100
|
Posted: Sun Jan 27, 2008 8:02 am Post subject:
monome + LiSa |
|
|
Did my first attempt at using LiSa. That's a nice UGen!
Also posted here:
http://post.monome.org/comments.php?DiscussionID=677&page=1#Item_1
There's a lot of talk at the monome site about doing new batches of 256s and 40h kits and other stuff. If you are interested in having a simple interface to ChucK I really recommend checking these out. The 128s and 64s are priceworthy IMO, if you are the kind of person who likes to throw together a new ChucK program, mess around with it and maybe drop it to do another. With the monome you have great interface while doing this.
Code: | //====================================//
// Stefan's little live sampler //
// by Stefan Blixt //
// 2008-01-27 //
// last update: 2008-01-27 //
//====================================//
// Hook up a radio or your own stuff or something else to the main input and go crazy.
// Adjust monome size below.
// global values of interest
16 => int monome_width;
16 => int monome_height;
1::second => dur loopLength;
10::ms => dur crossfade;
//==== OSC ====
OscSend xmit;
xmit.setHost("localhost", 8080);
OscRecv orec;
8000 => orec.port;
orec.listen();
orec.event("/256/press,i,i,i") @=> OscEvent pressEvent;
OscRecv tickOrec;
8001 => tickOrec.port;
tickOrec.listen();
tickOrec.event("/myclock/tick,i") @=> OscEvent oscTickEvent;
fun void lightColumn(int x, int state, int mask1, int mask2) {
xmit.startMsg("/256/led_col", "i i i");
x => xmit.addInt;
if (state == 0) {
0 => xmit.addInt;
0 => xmit.addInt;
} else {
mask1 => xmit.addInt;
mask2 => xmit.addInt;
}
}
class Loops {
// practical values
dur localLoopLength;
localLoopLength / monome_width => dur slotLength;
//signal chain
adc => Gain flatGain => LiSa loopme => dac;
adc => LPF lpf => loopme;
1000.0 => lpf.freq;
adc => HPF hpf => loopme;
6000.0 => hpf.freq;
localLoopLength => loopme.duration;
int voices[2];
loopme.getVoice() => voices[0];
loopme.getVoice() => voices[1];
loopme.rate(voices[0], 0.9);
loopme.rate(voices[1], 0.9);
loopme.rampUp(voices[0], crossfade);
loopme.rampUp(voices[1], crossfade);
loopme.rampDown(voices[0], crossfade);
loopme.rampDown(voices[1], crossfade);
// Graphics
int mask1;
int mask2;
fun void init(float divider, int inmask1, int inmask2) {
inmask1 => mask1;
inmask2 => mask2;
loopLength / divider => localLoopLength;
localLoopLength / monome_width => slotLength;
localLoopLength => loopme.duration;
}
fun void playLisasSlots() {
while (true) {
0 => int voiceCounter;
for (0::ms => dur currentTime; currentTime < localLoopLength; slotLength +=> currentTime) {
(currentTime / slotLength) $ int => int column;
lightColumn(column, 1, mask1, mask2);
voiceCounter++ => int voice;
if (voiceCounter >= 2) {
0 => voiceCounter;
}
loopme.playPos(voices[voice], currentTime);
loopme.play(voices[voice], 1);
slotLength => now;
loopme.play(voices[voice], 0);
lightColumn(column, 0, mask1, mask2);
}
}
}
}
monome_height / 4 => int loopAmount;
Loops loops[loopAmount];
loops[0].init(1, 0x0f, 0x00);
loops[1].init(1.5, 0xf0, 0x00);
spork ~ loops[0].playLisasSlots();
spork ~ loops[1].playLisasSlots();
if (loopAmount > 2) {
loops[2].init(0.75, 0x0, 0xf);
loops[3].init(0.5, 0x0, 0xf0);
spork ~ loops[2].playLisasSlots();
spork ~ loops[3].playLisasSlots();
}
//======== Input ==========
fun void keyPressed(int x, int y) {
if (x < monome_width && y < monome_height) {
y % 4 => int row;
loops[y/4] @=> Loops @ loop;
0.0 => loop.flatGain.gain;
0.0 => loop.lpf.gain;
0.0 => loop.hpf.gain;
if (row == 0) {
1.0 => loop.flatGain.gain;
} else if (row == 1) {
1.0 => loop.lpf.gain;
} else if (row == 2) {
1.0 => loop.hpf.gain;
}
x * loop.slotLength => loop.loopme.recPos;
1 => loop.loopme.record;
loop.slotLength => now;
0 => loop.loopme.record;
}
}
fun void keyReleased(int x, int y) {
}
//==== Startup graphic ====
xmit.startMsg("/256/clear", "i");
0 => xmit.addInt;
1::ms => now;
xmit.startMsg("/256/led_col", "i i i");
5 => xmit.addInt;
255 => xmit.addInt;
255 => xmit.addInt;
xmit.startMsg("/256/led_col", "i i i");
10 => xmit.addInt;
255 => xmit.addInt;
255 => xmit.addInt;
1::second => now;
xmit.startMsg("/256/clear", "i");
0 => xmit.addInt;
while (true) {
pressEvent => now;
while (pressEvent.nextMsg() != 0) {
pressEvent.getInt() => int x;
pressEvent.getInt() => int y;
pressEvent.getInt() => int state;
if (state == 1) {
keyPressed(x, y);
} else {
keyReleased(x, y);
}
}
}
|
_________________ Antimon's Window
@soundcloud @Flattr home - you can't explain music |
|