Hi, I have an array of strings (p1) that contains the same names of SndBuff instances (kk sn), I would like to pass the strings of the array to trigger samples and I don't know how to do it. Here is some test code: SndBuf kk => dac; SndBuf sn => dac; me.dir() + "/audio/kick_01.wav" => kk.read; me.dir() + "/audio/snare_01.wav" => sn.read; kk.samples() => kk.pos; sn.samples() => sn.pos; while( true ) { ["kk", "sn"] @=> string p1[]; for( 0 => int i; i < p1.cap(); i++) { 0 => p1[i].pos; // not working 0.25::second => now; } } Thanks, Federico López
Hi Federico. ChucK has a nice feature called Associative Arrays. Basically you will create an empty array of SndBufs, and then create new ones with the string as the array index: SndBuf buf[0]; // declare empty array new SndBuf @=> buf["kk"]; // creates new SndBuf associated with array index "kk" new SndBuf @=> buf["sn"]; // creates new SndBuf associated with array index "sn" buf["kk"] => dac; buf["sn"] => dac; me.dir() + "/audio/kick_01.wav" => buf["kk"].read; me.dir() + "/audio/snare_01.wav" => buf["sn"].read; buf["kk"].samples() => buf["kk"].pos; buf["sn"].samples() => buf["sn"].pos; ["kk", "sn"] @=> string p1[]; while( true ) { for( 0 => int i; i < p1.cap(); i++) { 0 => buf[ p1[i] ].pos; 0.25::second => now; } } //--END Joel On 07/06/2014 06:13 PM, Federico Lopez wrote:
Hi, I have an array of strings (p1) that contains the same names of SndBuff instances (kk sn), I would like to pass the strings of the array to trigger samples and I don't know how to do it.
Here is some test code:
SndBuf kk => dac; SndBuf sn => dac;
me.dir() + "/audio/kick_01.wav" => kk.read; me.dir() + "/audio/snare_01.wav" => sn.read;
kk.samples() => kk.pos; sn.samples() => sn.pos;
while( true ) { ["kk", "sn"] @=> string p1[];
for( 0 => int i; i < p1.cap(); i++) { 0 => p1[i].pos; // not working 0.25::second => now; } }
Thanks,
Federico López
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
Hi Federico, If you want to use pos function of SndBuf object. You should use SndBuf object directly. To do this, use a SndBuf array instead of a string array in your while loop. Happy ChucKing, Julien On 07/07/2014 01:13, Federico Lopez wrote:
Hi, I have an array of strings (p1) that contains the same names of SndBuff instances (kk sn), I would like to pass the strings of the array to trigger samples and I don't know how to do it.
Here is some test code:
SndBuf kk => dac; SndBuf sn => dac;
me.dir() + "/audio/kick_01.wav" => kk.read; me.dir() + "/audio/snare_01.wav" => sn.read;
kk.samples() => kk.pos; sn.samples() => sn.pos;
while( true ) { ["kk", "sn"] @=> string p1[];
for( 0 => int i; i < p1.cap(); i++) { 0 => p1[i].pos; // not working 0.25::second => now; } }
Thanks,
Federico López
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
Joel, Julien, Thanks for your responses, sorry my late response, I was fixing my audio set-up after a alsa-jack-pulseAudio disaster. Joel solution was what I was looking for, thanks a lot, and I will explore Associative Arrays. best regards, Federico Lopez PD: This solution is part of an initial attempt to do some live code environment for pattern based music in ChucK with inspired in nice features of Tidal, https://github.com/son0p/liveCodeEvironmentChucK On Tue, Jul 8, 2014 at 4:28 AM, Julien Saint-Martin < julien.saintmartin@googlemail.com> wrote:
Hi Federico,
If you want to use pos function of SndBuf object. You should use SndBuf object directly. To do this, use a SndBuf array instead of a string array in your while loop.
Happy ChucKing, Julien
On 07/07/2014 01:13, Federico Lopez wrote:
Hi, I have an array of strings (p1) that contains the same names of SndBuff instances (kk sn), I would like to pass the strings of the array to trigger samples and I don't know how to do it.
Here is some test code:
SndBuf kk => dac; SndBuf sn => dac;
me.dir() + "/audio/kick_01.wav" => kk.read; me.dir() + "/audio/snare_01.wav" => sn.read;
kk.samples() => kk.pos; sn.samples() => sn.pos;
while( true ) { ["kk", "sn"] @=> string p1[];
for( 0 => int i; i < p1.cap(); i++) { 0 => p1[i].pos; // not working 0.25::second => now; } }
Thanks,
Federico López
_______________________________________________ chuck-users mailing listchuck-users@lists.cs.princeton.eduhttps://lists.cs.princeton.edu/mailman/listinfo/chuck-users
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
Unsubscribe
On Wed, Jul 16, 2014 at 2:50 PM, Federico Lopez
Joel, Julien, Thanks for your responses, sorry my late response, I was fixing my audio set-up after a alsa-jack-pulseAudio disaster.
Joel solution was what I was looking for, thanks a lot, and I will explore Associative Arrays.
best regards,
Federico Lopez
PD: This solution is part of an initial attempt to do some live code environment for pattern based music in ChucK with inspired in nice features of Tidal, https://github.com/son0p/liveCodeEvironmentChucK
On Tue, Jul 8, 2014 at 4:28 AM, Julien Saint-Martin < julien.saintmartin@googlemail.com> wrote:
Hi Federico,
If you want to use pos function of SndBuf object. You should use SndBuf object directly. To do this, use a SndBuf array instead of a string array in your while loop.
Happy ChucKing, Julien
On 07/07/2014 01:13, Federico Lopez wrote:
Hi, I have an array of strings (p1) that contains the same names of SndBuff instances (kk sn), I would like to pass the strings of the array to trigger samples and I don't know how to do it.
Here is some test code:
SndBuf kk => dac; SndBuf sn => dac;
me.dir() + "/audio/kick_01.wav" => kk.read; me.dir() + "/audio/snare_01.wav" => sn.read;
kk.samples() => kk.pos; sn.samples() => sn.pos;
while( true ) { ["kk", "sn"] @=> string p1[];
for( 0 => int i; i < p1.cap(); i++) { 0 => p1[i].pos; // not working 0.25::second => now; } }
Thanks,
Federico López
_______________________________________________ chuck-users mailing listchuck-users@lists.cs.princeton.eduhttps://lists.cs.princeton.edu/mailman/listinfo/chuck-users
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
participants (4)
-
Federico Lopez
-
Joel Matthys
-
Julien Saint-Martin
-
Unok Ewave