Question about creating new audio objects

Status
Not open for further replies.
I am familiar with an audio callback that gets called when the audio buffer needs to be filled. Does the update function operate in the same way?

Yes, it's basically the same idea. Except instead of getting the buffer pointers passed as function inputs, you call receiveReadOnly(channel) or receiveWritable(channel) to get the buffers of incoming samples, and you can allocate more buffers as you need. Then after you've done whatever DSP work you like, you call transmit(buffer, channel) function rather than putting the data into a buffer you got as a function input, and call release(buffer) when you're done.

The interrupts have priority levels, so your update() function runs as a relatively low interrupt priority where it still blocks the main program, but does not block most other time-sensitive interrupts.
 
Paul thanks for the quick reply and info! Most of my code is in C, is there a way to create an audio object in C or do I just need to wrap those functions in a AudioStream class?
 
No, you have to use the audio class.

A tip: remember that you can also get back a NULL pointer for the audio blocks at any time. On T4, you have to add cache-handling, too (If it is an input or output object)

Easiest is to just copy the code from the existing objects...
 
Thanks Frank I did exactly as you suggested and got it working pretty easily. I have another questions (sorry I'm new :D), is it possible to create audio objects on the fly? Like after the program is running be able to create a new audio object, wire it up and then use it? Then destroy it and create new ones as you please?
 
is it possible to create audio objects on the fly? Like after the program is running be able to create a new audio object, wire it up and then use it? Then destroy it and create new ones as you please?

That's a question i'd like an answer to as well. I'd like to create an audio analyser tool that can switch between different 'screens', each screen having a different function. When one screen is showing i'd like the other audio objects to not be running (e.g. turn off FFT1024 when the Peak or RMS objects are running), so creating them on the fly when they are needed would be the best way to implement that.

Thanks

NM
 
Last edited:
Thanks Frank I did exactly as you suggested and got it working pretty easily. I have another questions (sorry I'm new :D), is it possible to create audio objects on the fly? Like after the program is running be able to create a new audio object, wire it up and then use it? Then destroy it and create new ones as you please?
Not using the official core and Audio library, but I've done some work on that - please see this thread which has links to my github repositories. I've not had any reports of bugs / difficulties using, but I suspect that's because it's a bit of a niche use case.

Please note that the recent update added the ability to turn updates on and off for audio objects not connected to the "main" update list (see page 7 of the Dynamic Audio Library pdf), and by default the updates are on and thus consume CPU without contributing to audible output. This change was to preserve compatibility with the standard "static" audio library. Obviously if you destroy an audio object then it doesn't consume CPU...

Cheers

Jonathan
 
That's a question i'd like an answer to as well. I'd like to create an audio analyser tool that can switch between different 'screens', each screen having a different function. When one screen is showing i'd like the other audio objects to not be running (e.g. turn off FFT1024 when the Peak or RMS objects are running), so creating them on the fly when they are needed would be the best way to implement that.
As noted above, I've done a dynamic audio library. With that, creating and destroying on the fly is one approach, but you could also switch to "don't update if not connected to the main update list" mode, and then just use the connect() / disconnect() functions to control CPU usage, and leave all audio and connection objects in existence. That would reduce the possibility of heap fragmentation.

Cheers

Jonathan
 
Thanks Jonathan, that sounds exactly like what i need, especially the connect/disconnect part.

I'll give it a go and update you on any problems if i find them.

Cheers

NM
 
Status
Not open for further replies.
Back
Top