Use of Audio loop

Hello All . I don’t have experience with openframeworks at all . I just need to know how it implements Audio loop in contrast to the one using draw loop in processing-sound . That being said I am familiar with processing’ code .

look at the examples in examples/sound

basicaly you use the ofSoundStream class with the added functions

void ofApp::audioIn(float * input, int bufferSize, int nChannels);

void ofApp::audioOut(float * output, int bufferSize, int nChannels);

The examples will make it more clear

I am interested in knowing it’s internal design implementation someone told me that this loop is sample accurate while the one used in processing’s one is frame dependant(draw function) . What feature it has which makes it different . ?

the audio in and audio out functions are not dependent on the update or draw functions. They are called separately and are not bound to the graphics stack as far as I know. Internally, I think these functions are used as callbacks to whatever audio library is chosen by your platform. Whenever more audio is needed, the audio out function will be called, and whenever new audio is received, the audio in function is called.

Yes, they run on a different thread that is called sampleRate/bufferSize times per second if I’m not mistaken. In RTaudio there’s only one call for both functions that gives the audio in and sends the audio out, both as interleaved buffers

(I don’t know how audio ins implemented in processing, but in oF using a loop the size of the buffer inside the audio functions gives you a per sample audio function)

@cabral1349 could you tell me more about it . See in processing the draw loop is dependant on frame rate and not on the sample rate unlike oF . So how is this feature implemented ? How actually is the looping made possible .

So, the draw loop is independent from the audioIn/audioOut loops.

The draw loop works at framerate while the audio loop works at samplerate/buffersize.

If you look at the audioIn and audioOut examples provided with openframeworks you’ll understand clearly! They are different threads, separte things. The audio loop is created using the RTaudio API, I don’t know about the draw loop (probably openGL).
For further on how the audio callback is done at it’s core, look at the RTaudio documentation.

right so i had a look over it’s API at https://github.com/openframeworks/openFrameworks/tree/master/libs/rtAudio . Had a look over RTaudio.h file can’t really make sure what’s libRTaudio.a file is for . Can it be done in java does a separate library like this exists or would i have to do this using jni interface ?
Could you also give me the link to class of ofBaseSoundInput.h and ofBaseSoundOutput.h wherein implementation of AudioIn and AudioOut is given @cabral1349 .

Well, there are differences between c++ and java that go beyond the user, it’s on the conception of the language.
The .a file is probably a compiled library, so you don’t have access to the code that’s inside of it.
I can’t help further then that =/
Here’s the rtaudio webpage, maybe there’s something in there for you
https://www.music.mcgill.ca/~gary/rtaudio/

Alrighty thanx …