real time audio creation

Started by codifies, November 08, 2015, 22:01:28

Previous topic - Next topic

codifies

Does anyone know how to do real time audio output...?

basically I want to have a continuously playing ring buffer, and be able to query at any particular time where the current output pointer is (so I can fill the buffer up behind it)

I'd like to be able to mix different signal sources in real time to create a simple synthesiser, I've made a simple logic editor where the gates are wired together with nice curvy "wires" rendered in javafx, and thought it might be nice to use the graphics part of the application to make a synth gui...

If anyone can show me code to fill an audio output buffer in real time I'd really appreciate it...

Tia!

abcdef

Lets break down your problem a bit as you ask quite a few things

1) How do you do real time audio output

This is accomplished with openal,

Check out some examples here :
https://github.com/LWJGL/lwjgl3/tree/master/modules/core/src/test/java/org/lwjgl/demo/openal

3) I'd like to have a continuously playing ring buffer

In openal load all you data in initially and then set the below for the source

alSourcei(source, AL_LOOPING, 1); enables it for a source and
alSourcei(source, AL_LOOPING, 0); disables it.

4) I'd like to be able to mix different signal sources in real time to create a simple synthesiser

You just need to create different sources and play them at the same time. If you wish to mix the signal's at the binary data level then I am unable to help you.

5) If anyone can show me code to fill an audio output buffer in real time

You need to have the data in PCM format. The STB extension of LWJGL has a way to load Ogg Vorbis file. The link above has an example of how to do this. If you wish to load other types or load other libraries you will need to see if a 3rd party API does this or do this yourself.

philfrei

[EDIT: I just found this followup post by codifies that looks like it is an answer to this question.]