| Author |
Message |
Inventor

Joined: Oct 13, 2007 Posts: 1168 Location: Florida, USA
Audio files: 50
|
Posted: Tue Mar 25, 2008 1:14 pm Post subject:
Transferring Sound Between Applications Subject description: How can Guitar Lab and Synth Lab share sounds? |
 |
|
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
|
|
 |
Inventor

Joined: Oct 13, 2007 Posts: 1168 Location: Florida, USA
Audio files: 50
|
Posted: Tue Mar 25, 2008 2:33 pm Post subject:
|
 |
|
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
|
|
 |
Frostburn

Joined: Dec 12, 2007 Posts: 212 Location: Finland
Audio files: 7
|
Posted: Tue Mar 25, 2008 2:54 pm Post subject:
|
 |
|
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
|
|
 |
Inventor

Joined: Oct 13, 2007 Posts: 1168 Location: Florida, USA
Audio files: 50
|
Posted: Tue Mar 25, 2008 4:46 pm Post subject:
|
 |
|
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
|
|
 |
|