[chuck-users] SndBuf Error.

Hugh Rawlinson hughr2005 at gmail.com
Mon Dec 16 15:22:58 EST 2019


Hi,

The relevant code is here:

```
me.dir(C:\Program Files (x86)\ChucK\audio\123.wav) => string path;
```

At this point, the string "path" is "C:\Program Files
(x86)\ChucK\audio\123.wav".

```
"/audio/123.wav" => string filename;
// + sign connects strings together!
path+filename => filename;
```

so when you concatenate it with the "filename" string, you end up with a
string with the contents "C:\Program Files
(x86)\ChucK\audio\123.wav/audio/123.wav", which is not the correct path.

The correct code might look like this:

```
// get file path
me.dir("C:\Program Files (x86)\ChucK\audio\") => string path;
// sound file we want to play
"123.wav" => string filename;
// + sign connects strings together!
path+filename => filename;
```

I haven't been able to test this, since I'm not at a Windows computer right
now, but if my understanding is correct, it should work.

Hope that helps!

Best,

Hugh

On Mon, 16 Dec 2019 at 13:41, maria p cruz <maria.indigo7325987 at gmail.com>
wrote:

> Hi Everyone!
> Wath is wrong in this code?
>
>
> // Using SndBuf to play a sound file
> // by ChucK Programmer, December 2050
> SndBuf mySound => dac;
> // get file path
> me.dir(C:\Program Files (x86)\ChucK\audio\123.wav) => string path;
> // sound file we want to play
> "/audio/123.wav" => string filename;
> // + sign connects strings together!
> path+filename => filename;
> // tell SndBuf to read this file
> filename => mySound.read;
> // set gain
> 0.5 => mySound.gain;
> // play sound from the beginning
> 0.1 => mySound.pos;
> // advance time so we can hear it
> second => now;
> //
> _______________________________________________
> chuck-users mailing list
> chuck-users at lists.cs.princeton.edu
> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20191216/14d2b257/attachment.html>


More information about the chuck-users mailing list