<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">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:<br>
<br>
<tt>SndBuf buf[0]; // declare empty array</tt><tt><br>
</tt><tt>new SndBuf @=> buf["kk"]; // creates new SndBuf
associated with array index "kk"</tt><tt><br>
</tt><tt>new SndBuf @=> buf["sn"]; // creates new SndBuf
associated with array index "sn"</tt><tt><br>
</tt><tt>buf["kk"] => dac;</tt><tt><br>
</tt><tt>buf["sn"] => dac;</tt><tt><br>
</tt><tt>me.dir() + "/audio/kick_01.wav" => buf["kk"].read;</tt><tt><br>
</tt><tt>me.dir() + "/audio/snare_01.wav" => buf["sn"].read;</tt><tt><br>
</tt><tt>buf["kk"].samples() => buf["kk"].pos;</tt><tt><br>
</tt><tt>buf["sn"].samples() => buf["sn"].pos;</tt><tt><br>
</tt><tt><br>
</tt><tt>["kk", "sn"] @=> string p1[];</tt><tt><br>
</tt><tt><br>
</tt><tt>while( true )</tt><tt><br>
</tt><tt>{</tt><tt><br>
</tt><tt> for( 0 => int i; i < p1.cap(); i++)</tt><tt><br>
</tt><tt> {</tt><tt><br>
</tt><tt> 0 => buf[ p1[i] ].pos;</tt><tt><br>
</tt><tt> 0.25::second => now;</tt><tt><br>
</tt><tt> }</tt><tt><br>
</tt><tt>}</tt><tt><br>
</tt><tt>//--END</tt><br>
<br>
Joel<br>
<br>
<br>
On 07/06/2014 06:13 PM, Federico Lopez wrote:<br>
</div>
<blockquote
cite="mid:CAGRUFnDsTZ3DJUUk3JzVEpe3--96Jmqr24LZvOUKvugYAzR+ag@mail.gmail.com"
type="cite">
<div dir="ltr">
<div>
<div>
<div>
<div>Hi, <br>
</div>
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.<br>
<br>
</div>
Here is some test code:<br>
<br>
SndBuf kk => dac;<br>
SndBuf sn => dac;<br>
<br>
me.dir() + "/audio/kick_01.wav" => kk.read;<br>
me.dir() + "/audio/snare_01.wav" => sn.read;<br>
<br>
kk.samples() => kk.pos;<br>
sn.samples() => sn.pos;<br>
<br>
while( true )<br>
{<br>
["kk", "sn"] @=> string p1[];<br>
<br>
for( 0 => int i; i < p1.cap(); i++)<br>
{<br>
0 => p1[i].pos; // not working <br>
0.25::second => now;<br>
}<br>
}<br>
<br>
</div>
Thanks, <br>
<br>
</div>
Federico López<br>
<br>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
chuck-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:chuck-users@lists.cs.princeton.edu">chuck-users@lists.cs.princeton.edu</a>
<a class="moz-txt-link-freetext" href="https://lists.cs.princeton.edu/mailman/listinfo/chuck-users">https://lists.cs.princeton.edu/mailman/listinfo/chuck-users</a>
</pre>
</blockquote>
<br>
</body>
</html>