<div dir="ltr"><div>Hi Maria,</div><div><br></div><div>me.dir() doesn&#39;t accept strings but integers (or no arguments at all) to return the path, starting from the current folder (ie the folder where the ChucK script/program resides).</div><div>Assuming your ChucK program is saved in a folder called: &quot;~/Users/Me/Documents/ChucKFiles&quot; if you use me.dir() this will return the path I just specified, if you use me.dir(1) it would be the parent folder so: &quot;~/Users/Me/Documents&quot;, me.dir(2) returns: &quot;~/Users/Me&quot; and so on.</div><div>Then SndBuf method &#39;pos&#39; wants an integer as an argument, since the argument represents the position (playhead starting point) expressed in samples (hence why integers).</div><div><br></div><div>I would recommend to always check the errors reported on the console monitor, even if sometimes they can be &#39;cryptic&#39;, most of the time will help you debugging the issue.</div><div>Useful to report the errors you get on the console here on the mailing list as well when asking for help :)</div><div><br></div><div>now you code could look something like the following:</div><div><br></div><div>//--------------------------------------------------------------------------------</div><div>// Using SndBuf to play a sound file<br>// by ChucK Programmer, December 2050<br>SndBuf mySound =&gt; dac;<br><br>// path + filename (assuming the &#39;audio&#39; folder is in the same<br>// folder as the script itself)<br>me.dir() + &quot;/audio/123.wav&quot; =&gt; string filename;<br>// tell SndBuf to read this file<br>filename =&gt; mySound.read;<br>// set gain<br>0.5 =&gt; mySound.gain;<br>// play sound from the beginning<br>0 =&gt; mySound.pos;<br>// advance time so we can hear it<br>second =&gt; now;</div><div>//--------------------------------------------------------------------------------</div><div><br></div><div>Cheers,</div><div>Mario<br></div><div><br> </div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, 16 Dec 2019 at 18:41, maria p cruz &lt;<a href="mailto:maria.indigo7325987@gmail.com">maria.indigo7325987@gmail.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hi Everyone!</div><div>Wath is wrong in this code?</div><div><br></div><div><br></div>// Using SndBuf to play a sound file<br>// by ChucK Programmer, December 2050<br>SndBuf mySound =&gt; dac;<br>// get file path<br>me.dir(C:\Program Files (x86)\ChucK\audio\123.wav) =&gt; string path;<br>// sound file we want to play<br>&quot;/audio/123.wav&quot; =&gt; string filename;<br>// + sign connects strings together!<br>path+filename =&gt; filename;<br>// tell SndBuf to read this file<br>filename =&gt; mySound.read;<br>// set gain<br>0.5 =&gt; mySound.gain;<br>// play sound from the beginning<br>0.1 =&gt; mySound.pos;<br>// advance time so we can hear it<br>second =&gt; now;<br>//<br></div>
_______________________________________________<br>
chuck-users mailing list<br>
<a href="mailto:chuck-users@lists.cs.princeton.edu" target="_blank">chuck-users@lists.cs.princeton.edu</a><br>
<a href="https://lists.cs.princeton.edu/mailman/listinfo/chuck-users" rel="noreferrer" target="_blank">https://lists.cs.princeton.edu/mailman/listinfo/chuck-users</a><br>
</blockquote></div>