<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 @=&gt; buf["kk"]; // creates new SndBuf
        associated with array index "kk"</tt><tt><br>
      </tt><tt>new SndBuf @=&gt; buf["sn"]; // creates new SndBuf
        associated with array index "sn"</tt><tt><br>
      </tt><tt>buf["kk"] =&gt; dac;</tt><tt><br>
      </tt><tt>buf["sn"] =&gt; dac;</tt><tt><br>
      </tt><tt>me.dir() + "/audio/kick_01.wav" =&gt; buf["kk"].read;</tt><tt><br>
      </tt><tt>me.dir() + "/audio/snare_01.wav" =&gt; buf["sn"].read;</tt><tt><br>
      </tt><tt>buf["kk"].samples() =&gt; buf["kk"].pos;</tt><tt><br>
      </tt><tt>buf["sn"].samples() =&gt; buf["sn"].pos;</tt><tt><br>
      </tt><tt><br>
      </tt><tt>["kk", "sn"] @=&gt; string p1[];</tt><tt><br>
      </tt><tt><br>
      </tt><tt>while( true )</tt><tt><br>
      </tt><tt>{</tt><tt><br>
      </tt><tt>&nbsp;&nbsp;&nbsp; for( 0 =&gt; int i; i &lt; p1.cap(); i++)</tt><tt><br>
      </tt><tt>&nbsp;&nbsp;&nbsp; {</tt><tt><br>
      </tt><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0 =&gt; buf[ p1[i] ].pos;</tt><tt><br>
      </tt><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0.25::second =&gt; now;</tt><tt><br>
      </tt><tt>&nbsp;&nbsp;&nbsp; }</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&nbsp; SndBuff&nbsp; 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 =&gt; dac;<br>
            SndBuf sn =&gt; dac;<br>
            <br>
            me.dir() + "/audio/kick_01.wav" =&gt; kk.read;<br>
            me.dir() + "/audio/snare_01.wav" =&gt; sn.read;<br>
            <br>
            kk.samples() =&gt; kk.pos;<br>
            sn.samples() =&gt; sn.pos;<br>
            <br>
            while( true )<br>
            {<br>
            &nbsp;&nbsp;&nbsp; ["kk", "sn"] @=&gt; string p1[];<br>
            <br>
            &nbsp;&nbsp;&nbsp; for( 0 =&gt; int i; i &lt; p1.cap(); i++)<br>
            &nbsp;&nbsp;&nbsp; {<br>
            &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 0 =&gt; p1[i].pos; // not working <br>
            &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 0.25::second =&gt; now;<br>
            &nbsp;&nbsp;&nbsp; }<br>
            }<br>
            <br>
          </div>
          Thanks, <br>
          <br>
        </div>
        Federico L&oacute;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>