Author |
Message |
Dr. Spankenstein
Joined: Mar 03, 2007 Posts: 136 Location: Cambridge
Audio files: 1
|
Posted: Sun Jan 13, 2008 4:58 am Post subject:
Buffer arrays and simultaneous play |
|
|
How do I get a buffer array to have 2 separate instances playing at different times. The code I'm using below can't seem to do that:
Code: |
SndBuf Buffer[512];
Buffer[1] => Pan2 Pan => Gain Gain => dac;
Buffer[0] => Pan2 Pan2 => Gain;
1.0 => Gain.gain;
"DC_Kit03_175_Loop3.wav" => Buffer[0].read;
"DC_Kit03_175_Loop3.wav" => Buffer[1].read;
0.0 => Buffer[0].gain;
0.0 => Buffer[1].gain;
1 => Buffer[0].loop;
1 => Buffer[1].loop;
-1.0 => Pan.pan;
1.0 => Pan2.pan;
while (true)
{
0.5 => Buffer[0].gain;
2.2::second => now;
0.5 => Buffer[1].gain;
}
// ChucK plays them both in Unison as opposed to two separate instances overlapping?
|
Can anyone help?
Thanks,
Rhys |
|
Back to top
|
|
|
Kassen
Janitor
Joined: Jul 06, 2004 Posts: 7678 Location: The Hague, NL
G2 patch files: 3
|
Posted: Sun Jan 13, 2008 5:53 am Post subject:
|
|
|
Ah, yes.
The issue is that SndBuf starts with two defaults that work together to make a sound start to play as soon as it's loaded. These are;
Buf.pos(0) and buf.rate(1).
So; as soon as a file is loaded ChucK sees the read pointer is at the start and movinf forwards at speed 1 resluting in instant playback, for two buffers that hold the same fle this means they will behave the same.
I myself always stop this by going;
buf.samples() => buf.pos;
Immediately after loading a file (this won't work for looping buffers, I fear as those don't stop at the end).
Then it's up to you to define *how* the two are different, if I were you I'd start by setting Buffer[0].rate to a nice fraction or ratio of 1, for example 1.5 or .75 or 2, the more complex the fraction the longer it'll take for them to line up again.
Also exciting as a bonus tip;
buffer[0].samples()::samp => dur loop_length;
will give you the exact duration of your sample in time, you can use this to time your loop, of course you can use fractions of that as well....
Happy remixing! _________________ Kassen |
|
Back to top
|
|
|
Dr. Spankenstein
Joined: Mar 03, 2007 Posts: 136 Location: Cambridge
Audio files: 1
|
Posted: Sun Jan 13, 2008 8:30 am Post subject:
|
|
|
Thanks Kassen, I was having a funny five minutes and forgot about the default thang.
Rhys |
|
Back to top
|
|
|
Kassen
Janitor
Joined: Jul 06, 2004 Posts: 7678 Location: The Hague, NL
G2 patch files: 3
|
Posted: Mon Jan 14, 2008 6:13 am Post subject:
|
|
|
Dr. Spankenstein wrote: | Thanks Kassen, I was having a funny five minutes and forgot about the default thang.
Rhys |
Random defaults would certainly make life exciting!
I see where you are coming from, those VA synths tend to start oscilators with a random phase, ChucK never does this, unless you explicidly define it. _________________ Kassen |
|
Back to top
|
|
|
|