electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Articles  |  Radio
 |  Media  |  Forum  |  Links  |  Store
Forum with support of Syndicator RSS
 FAQFAQ   CalendarCalendar   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   LinksLinks GalleryGallery 
 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
Transferring Sound Between Applications
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
Inventor



Joined: Oct 13, 2007
Posts: 1166
Location: Florida, USA
Audio files: 50

PostPosted: Tue Mar 25, 2008 1:14 pm    Post subject: Transferring Sound Between Applications
Subject description: How can Guitar Lab and Synth Lab share sounds?
Reply with quote  Mark this post and the followings unread

Now that I have both Guitar Lab and Synth Lab, I'm reminded of kijjaz's comments about making everything work together in ChucK. I'd like to take a guitar riff from Guitar Lab and send it into Synth Lab so I can create effects using Synth Lab's capabilites, for example. I would like to do this by adding code that allows me to silence Guitar Lab's DAC output (perhaps with the existing volume slider), and send Guitar Lab's audio to Synth Lab. The sound would then be processed by Synth Lab and sent to Synth Lab's DAC output.

The problem is they are two separate programs and I don't know how to send audio from one to another. It must be very simple for ChucK to do this, yet I don't know how. Perhaps I should use OSC? Can you 'splain it to me? Thanks.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Inventor



Joined: Oct 13, 2007
Posts: 1166
Location: Florida, USA
Audio files: 50

PostPosted: Tue Mar 25, 2008 2:33 pm    Post subject: Reply with quote  Mark this post and the followings unread

OK, I read about inter-shred communication using public classes and created the following two source code files. They ChucK up just fine without error, but I hear no sound. If I set the first file's volume to 1 I hear the sinosc coming from the first file but that's not inter-shred communcation. The first file should be sending the sinosc output to the second file if I understand it right. Why don't I hear any sound?

Code:
// test of sending music from one ChucK file to another, sender
// copyright 2008 Les Hall
// This software is protected by the GNU General Public License

// create a simple example sound source, connected to DAC
SinOsc sinosc => Gain volume => dac;
sinosc.freq (200);  // a pleasant sounding tone
volume.gain (0);  // silence the output of the sender

// define a public class for inter shred communication
public class Communication {
    Gain buffer;
    public void connect_to_output (UGen ugen) {
        buffer => ugen;
    }
    public void connect_to_input (UGen ugen) {
        ugen => buffer;
    }
}

// create an instance of the inter shred communication class
Communication sender;

// connect the sound source to the public class gain element
sender.connect_to_input (sinosc);

// allow time to pass
day => now;



Code:
// test of sending music from one ChucK file to another, receiver
// copyright 2008 Les Hall
// This software is protected by the GNU General Public License

// create an instance of the inter shred communication class
Communication receiver;

// make a patch
Gain input => dac;
input.gain (1);

// connect to the sender public class
receiver.connect_to_output (input);

// allow time to pass
day => now;
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Frostburn



Joined: Dec 12, 2007
Posts: 211
Location: Finland
Audio files: 7

PostPosted: Tue Mar 25, 2008 2:54 pm    Post subject: Reply with quote  Mark this post and the followings unread

Try this:
First file:
Code:
public class Communication{
        static Gain @ buffer;
}

//We need to do this outside the class constructor for now
Gain theBuffer @=> Communication.buffer;

Second file:
Code:
TriOsc t => Communication.buffer;
while(second => now);

Third file:
Code:
Communication.buffer => dac;
while(second => now);

_________________
To boldly go where no man has bothered to go before.
Back to top
View user's profile Send private message
Inventor



Joined: Oct 13, 2007
Posts: 1166
Location: Florida, USA
Audio files: 50

PostPosted: Tue Mar 25, 2008 4:46 pm    Post subject: Reply with quote  Mark this post and the followings unread

That works like a charm, Frostburn, and it required very little modification to the existing code. Now I can send audio from Guitar Lab to Synth Lab which enables me to experiment with guitar effects long before I buy a real guitar and hook it up to my computer (if I ever do that).

The only problem is that now I have 537 shreds and things are getting rather slow. No matter, I'll try to find a way to ease the CPU burden somehow. The other thing is that now one must run Communcation.ck along with Guitar Lab or Synth Lab even if you are only running just one of them. But that's no big deal either.

I must say your knowledge of ChucK and object oriented programming in general is quite impressive, especially since I actually find the OOP concepts difficult to understand for the most part. Don't let it go to your head, but you have my compliments.
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
Music123.com - Customer Appreciation Sale Extended! - Save Up To $80 Off Your Order - Sale Ends Soon!

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, 2004, 2005, 2006 and 2007 by electro-music.com