electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Articles  |  Radio
 |  Media  |  Forum  |  Wiki  |  Links  |  Store
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 
Live streaming at radio.electro-music.com

  host / artist show at your time
  EdisonRex Edison's Electronic Review (Cancelled tonight due to travel)
Please visit the chat
 Forum index » DIY Hardware and Software » ChucK programming language
sample class
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [5 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
jirko



Joined: Dec 15, 2009
Posts: 59

PostPosted: Thu May 06, 2010 8:56 am    Post subject: sample class Reply with quote  Mark this post and the followings unread

Hi there,

I've made a small sample class for overloading. The class is working so far, but when I try to load two sample at the same time only one of them plays.
Sure I'm missing something here:



Code:

"filenpath" => string file_1;
"filenpath" => string file_2;


class sample
{
    SndBuf sam_one => ADSR sam_one_env =>dac;
    sam_one_env.set( 1::ms, 200::ms, 0.75, 200::ms);
   
    fun void sample_trigger(string file, float rate, int duration)
    {
        sam_one.pos(0);
        sam_one.rate(rate);
        file=>sam_one.read;
        sam_one_env.keyOn(1);
        duration::ms=>now;
        sam_one_env.keyOff(1);
    }
   
}   
       
sample SF;

spork~SF.sample_trigger(file_1, 1, 200);   
 
spork~SF.sample_trigger(file_2, 1, 200);

2::second=>now;
Back to top
View user's profile Send private message
vrachnasormora



Joined: Mar 22, 2007
Posts: 42
Location: Preveza,Greece

PostPosted: Thu May 06, 2010 11:57 am    Post subject: Reply with quote  Mark this post and the followings unread

Hi,
I think you need two instances of sample class in order to load two different sounds because you have only one SndBuf object used by the class

Andreas
Back to top
View user's profile Send private message
jirko



Joined: Dec 15, 2009
Posts: 59

PostPosted: Thu May 06, 2010 12:31 pm    Post subject: Reply with quote  Mark this post and the followings unread

Hi Andreas,

maybe I'm miss understanding the way a class works, but if your're in right, where is the goal making a non public class?

What I want to do is just to create an object and call them with different parameters, without the need to rewrite the code again and again..

thanks!
Back to top
View user's profile Send private message
kkissinger



Joined: Mar 28, 2006
Posts: 1189
Location: Kansas City, Mo USA
Audio files: 26

PostPosted: Thu May 06, 2010 12:43 pm    Post subject: Reply with quote  Mark this post and the followings unread

Just create two sample objects, say SF and SF1.

I think you could code:

sample SF, SF1;

spork~SF.sample_trigger(file_1, 1, 200);

spork~SF1.sample_trigger(file_2, 1, 200);

_________________
-- Kevin
http://kevinkissinger.com
Back to top
View user's profile Send private message Visit poster's website
jirko



Joined: Dec 15, 2009
Posts: 59

PostPosted: Thu May 06, 2010 1:01 pm    Post subject: Reply with quote  Mark this post and the followings unread

yes, that's it! thanks a lot!!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [5 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
Niio1

Please support our site. If you click through and buy from
our affiliate partners, we earn a small commission.


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