electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Radio
 |  Media  |  Forum  |  Wiki  |  Links
Forum with support of Syndicator RSS
 FAQFAQ   CalendarCalendar   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   LinksLinks
 RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in  Chat RoomChat Room 
 Forum index » DIY Hardware and Software » ChucK programming language
Buffer arrays and simultaneous play
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [4 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
Dr. Spankenstein



Joined: Mar 03, 2007
Posts: 136
Location: Cambridge
Audio files: 1

PostPosted: Sun Jan 13, 2008 4:58 am    Post subject: Buffer arrays and simultaneous play Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message
Kassen
Janitor
Janitor


Joined: Jul 06, 2004
Posts: 7678
Location: The Hague, NL
G2 patch files: 3

PostPosted: Sun Jan 13, 2008 5:53 am    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Send e-mail Visit poster's website
Dr. Spankenstein



Joined: Mar 03, 2007
Posts: 136
Location: Cambridge
Audio files: 1

PostPosted: Sun Jan 13, 2008 8:30 am    Post subject: Reply with quote  Mark this post and the followings unread

Thanks Kassen, I was having a funny five minutes and forgot about the default thang.

Embarassed

Rhys
Back to top
View user's profile Send private message
Kassen
Janitor
Janitor


Joined: Jul 06, 2004
Posts: 7678
Location: The Hague, NL
G2 patch files: 3

PostPosted: Mon Jan 14, 2008 6:13 am    Post subject: Reply with quote  Mark this post and the followings unread

Dr. Spankenstein wrote:
Thanks Kassen, I was having a funny five minutes and forgot about the default thang.

Embarassed

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
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [4 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
 Forum index » DIY Hardware and Software » ChucK programming language
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Forum with support of Syndicator RSS
Powered by phpBB © 2001, 2005 phpBB Group
Copyright © 2003 through 2009 by electro-music.com - Conditions Of Use