Author |
Message |
Dr. Spankenstein
Joined: Mar 03, 2007 Posts: 136 Location: Cambridge
Audio files: 1
|
Posted: Wed Sep 12, 2007 6:41 am Post subject:
SndBuf question... |
|
|
Hello!
I'm having a problem with ChucK's sound buffers. When I read a file into the buffer it automatically plays next time I allow time to pass.
How do I read a new sound file into buffer without it playing when time passes and only when I tell it to play? (Silencing the gain on that buffer is not an option neither)
I.e.
Code: |
SndBuf Buffer1;
Gain Gain;
Buffer1 => Gain => dac;
0 => Buffer1.loop;
1 => Buffer1.gain;
"KICK.wav" => Buffer1.read;
1::second => now; // Automatically plays KICK.wav which I'm not after
1::second => now;
// KICK.wav still only plays automatically once until I reset Buffer1.pos
//If I read the same (or different) file again then once again it automatically plays back when time passes (how do I stop this from happening without silencing the Buffer.gain?)
"KICK.wav" => Buffer1.read;
1::second => now;
|
Many thanks,
Rhys
PS. I hope everyone has been enjoying the summer (if they were lucky enough to get one these past couple of months)! |
|
Back to top
|
|
|
Kassen
Janitor
Joined: Jul 06, 2004 Posts: 7678 Location: The Hague, NL
G2 patch files: 3
|
Posted: Wed Sep 12, 2007 7:30 am Post subject:
Re: SndBuf question... |
|
|
Dr. Spankenstein wrote: | Hello!
I'm having a problem with ChucK's sound buffers. When I read a file into the buffer it automatically plays next time I allow time to pass.
How do I read a new sound file into buffer without it playing when time passes and only when I tell it to play? (Silencing the gain on that buffer is not an option neither)
|
Yes, that's right.
This is because SndBuf starts with a default rate of 1 and default position of 0 samples.
Changing either will prevent this behaviour so right after loading a file you can use;
0 => buf.rate; //prevent it from playing at all.
Or you can use;
buf.samples() => buf.pos; //set playback to the end of the buffer where it will get stuck
Both work equally well but if you like to start file playback by using;
0 => buf.pos;
Then the second one is the most convenient as it will work without touching the playback speed, itÅ› the version I myself tend to use.
Both methods could result in DC offset when using samples that don't start&stop at a zero crossing.
Oh, and summer has been great for me, hope you're having a good time too! _________________ Kassen |
|
Back to top
|
|
|
moudi
Joined: Oct 07, 2006 Posts: 63 Location: Bern Switzerland
|
Posted: Wed Sep 12, 2007 7:35 am Post subject:
|
|
|
hi
every ugen has some standard control parameters as gain, last ...
and there is also a parameter .op() who handles the operation mode of the ugen.
if you set .op(0) there will be no output at all.
set it back to .op(1) and the ugen operates in normal mode again.
there are some more possibilities for example fm synthesis and so on.
i hope this helps?
jassas
/moudi
edit: ah, kassen was faster... but as you can see there are many ways... |
|
Back to top
|
|
|
|