diff --git a/build.xml b/build.xml index 49296fa..816694a 100644 --- a/build.xml +++ b/build.xml @@ -115,7 +115,7 @@ - + diff --git a/examples/IO/LowLevelEngine/LowLevelEngine.pde b/examples/IO/LowLevelEngine/LowLevelEngine.pde index 7fb2f40..ec2035c 100644 --- a/examples/IO/LowLevelEngine/LowLevelEngine.pde +++ b/examples/IO/LowLevelEngine/LowLevelEngine.pde @@ -1,25 +1,34 @@ import processing.sound.*; -import com.jsyn.devices.*; import com.jsyn.Synthesizer; -import com.jsyn.devices.jportaudio.JPortAudioDevice; void setup() { - // get hardware device information + // print audio device information to the console Sound.list(); - AudioDeviceManager m = Sound.getAudioDeviceManager(); - println("Audio device manager: " + m); - if (m instanceof JPortAudioDevice) { - println("Using the PortAudio device for 24 bit support on Windows"); - } - - - // get synthesis runtime information - Synthesizer s = Sound.getSynthesizer(); - // a lot of this information can be gleaned with one look by calling Sound.status(); - println("Current CPU usage: " + s.getUsage()); + // to improve support for USB audio interfaces on Windows, it is possible to + // use the PortAudio library, which is however not enabled by default. The + // listing above might therefore not have given accurate input/output channel + // numbers. The library automatically loads PortAudio drivers when + // Sound.outputDevice() is called on a device that it is unable to use + // correctly with the default drivers, OR you can always load them explicitly + // using MultiChannel.usePortAudio(). + if (MultiChannel.usePortAudio()) { + // if PortAudio was loaded successfully, the ids and names of the sound + // devices (and possibly their number of input/output channels) will have + // changed! + Sound.list(); + } + + // the Sound.status() method prints some general information about the current + // memory and CPU usage of the library to the console + Sound.status(); + + // to get programmatic access to the same information (and more), you can get + // and inspect the JSyn Synthesizer class yourself: + Synthesizer s = Sound.getSynthesizer(); + println("Current CPU usage: " + s.getUsage()); } diff --git a/examples/IO/MultiChannelOutput/MultiChannelOutput.pde b/examples/IO/MultiChannelOutput/MultiChannelOutput.pde index ff980b7..62f8f82 100644 --- a/examples/IO/MultiChannelOutput/MultiChannelOutput.pde +++ b/examples/IO/MultiChannelOutput/MultiChannelOutput.pde @@ -5,12 +5,18 @@ SinOsc sines[]; void setup() { size(640, 360); background(255); - - + + // some multi-channel USB audio interfaces don't show the correct number of + // output channels on Windows. If this is the case, try loading PortAudio + // support at the very top of your sketch with the following command (see the + // LowLevelEngine example for details): + //MultiChannel.usePortAudio(); + boolean foundMultiChannel = false; - for (int i = 0; i < Sound.list(true).length; i++) { + String[] deviceNames = Sound.list(); + for (int i = 0; i < deviceNames.length; i++) { if (MultiChannel.availableChannels(i) > 2) { - println("Found a multi-channel device: " + Sound.list(true)[i]); + println("Found a multi-channel device: " + deviceNames[i]); Sound.outputDevice(i); foundMultiChannel = true; break; @@ -21,16 +27,22 @@ void setup() { } println("Playing back different sine waves on the " + MultiChannel.availableChannels() + " different channels"); - float freq = 100; sines = new SinOsc[MultiChannel.availableChannels()]; // loop through all channels and start one sine wave on each + float frequency = 100; for (int i = 0; i < sines.length; i++) { MultiChannel.activeChannel(i); // create and start the sine oscillator. sines[i] = new SinOsc(this); + sinces[i].freq(frequency); sines[i].play(); + // add a nice theatrical break + delay(500); + + // increase frequency on the next channel by one semitone + frequency = frequency * 1.05946; } }