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 
go to the radio page Live at electro-music.com radio 1 Please visit the chat
poster
 Forum index » DIY Hardware and Software » ChucK programming language
SndBuf question...
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [3 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: Wed Sep 12, 2007 6:41 am    Post subject: SndBuf question... Reply with quote  Mark this post and the followings unread

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
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: Wed Sep 12, 2007 7:30 am    Post subject: Re: SndBuf question... Reply with quote  Mark this post and the followings unread

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



Joined: Oct 07, 2006
Posts: 63
Location: Bern Switzerland

PostPosted: Wed Sep 12, 2007 7:35 am    Post subject: Reply with quote  Mark this post and the followings unread

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... Very Happy
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [3 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