Friday, August 6, 2010

OpenJDK and PulseAudio

When using OpenJDK on Linux with PulseAudio a javasound audio device called "PulseAudio Mixer" shows up. Selecting this in Frinika gives very choppy and unusable audio for the time being. However if using the latest version of Ubuntu (and possibly other Linux'es), this provides an ALSA device called "default" that is really a PulseAudio device. By selecting the "default" javasound audio device Frinika will use PulseAudio (through ALSA), and you'll be able to play audio from other programs and Frinika simultaneously.

Tuesday, August 3, 2010

Demonstration videos on YouTube

These are really older demonstration videos - but I uploaded them to youtube so that they're more easily accessible:



Behind the scenes - how sound is produced in Frinika

Frinika uses the Toot audio framework for bringing all the audio together and sending it to the audio ouput. Toot provides effect plugins and advanced mixing features, not to mention a versatile model for developing audio applications.

Here's a quick example of how to get Toot "up and sounding":



JavaSoundAudioServer as = new JavaSoundAudioServer();
final AudioProcess output = as.openAudioOutput("plughw:0,0", "Line Out");
final AudioBuffer buffer = as.createAudioBuffer("test");
as.setClient(new AudioClient() {

double wavePos = 0;

public void work(int nFrames) {
float[] channel0 = buffer.getChannel(0);
for(int n=0;n<nFrames;n++)
{
double sample = Math.sin(wavePos);
wavePos+=Math.PI*2*440.0/44100.0;
channel0[n] = (float)sample;
}

output.processAudio(buffer);
}

public void setEnabled(boolean enabled) {
}
});
as.start();


Note that the audio output "plughw:0,0" is Linux specific and should be replaced with the name of the Javasound audio output of your platform.