How to Audio Library?

Status
Not open for further replies.

Revalogics

Well-known member
Hi everyone! Is there any documentation on how to make an audio library object?
I tried looking at Audio library files and I don't understand most of it, especially how audio data is processed.
I'd like to develop new objects, and perhaps share them with everyone.
Annotations (comments) on audio library files would be a great help.

I have the following in my mind: (don't know if all of them are possible)
• Additive synthesis - create exotic waveforms
• Amplitude-modulated oscillator with different waveforms
• Frequency-modulated oscillator with different waveforms
• Phase-modulated oscillator with different waveforms
• Soundfont player - use Teensy as wavetable synth
• Vocoder object (unlike from my previous post (hardcoded vocoder))
• Pitch Shifter
• Oscillators with presettable waveform using float arrays or equations?
• etcetera...
 
Hi everyone! Is there any documentation on how to make an audio library object?

Yes, here:

https://www.pjrc.com/teensy/td_libs_AudioNewObjects.html


• Amplitude-modulated oscillator with different waveforms

Maybe use the multiply effect?

https://www.pjrc.com/teensy/gui/?info=AudioEffectMultiply


• Soundfont player - use Teensy as wavetable synth

Take a look at this:

https://github.com/TeensyAudio/Wavetable-Synthesis


I'm sure a lot of people would love an implementation of those other features!
 
Thanks guys for the help!
I found THIS (anything about ARM Cortex M4 DSP instructions and stuff). I think this is compatible with my Teensy 3.6.
Also, I found "dspinst.h" inside Audio Library and it explained everything about DSP algorithms.
I'll be studying about these and probably create my very first Audio Library object.
 
Paul, What does these do? It's in the "dspinst.h" header file.

//get Q from PSR
get_q_psr(void)
//clear Q BIT in PSR
clr_q_psr(void)
 
What does these do?

Those access the saturation status bit, which certain ARM instructions set if their math has a saturation condition.

To learn more about the ARM registers and instruction set, you should get Joseph Yiu's book.

https://www.amazon.com/dp/0124080820

This info can also be found in the ARM documentation. The main one is ARM document number DDI0403E (useful for google search). But ARM's reference material is much harder to read than Yiu's book, and lacks a lot of useful tips on how to actually make use of the features which are scattered throughout the book.
 
Thanks Paul for the help, but I don't know how to buy stuffs overseas (I bought my Teensy from a local electronics store that happens to be importing stuffs from Adafruit), I'm just a student :).

BTW, I have my first working Audio Library object with me, I don't know if this will be useful for anyone, it's an Envelope Follower.
It takes an input, extracts its envelope, and outputs the envelope. It works much like by joining AudioAnalyzePeak and AudioSynthWaveformDc together, but with decay added.
My Vocoder object is still in progress (it uses my Envelope Follower).
 
I found this HERE. It says this function returns the free memory between stack and heap.
It does not compile for Teensy (Teensy 3.6, in my case). Any ideas how to measure free memory in Teensy? I'm suspecting some memory leaks in my Envelope Follower object, although all used and allocated audio blocks by it is properly released.
Code:
int freeRam () 
{
  extern int __heap_start, *__brkval; 
  int v; 
  return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval); 
}
 
The audio library uses its own memory pool, which you allocate with AudioMemory() at the beginning of your program. If your object is leaking audio memory, it will be in this fixed pre-allocated memory, not within the normal heap as that Adafruit tutorial describes.

You can call AudioMemoryUsage() to find out how much of the memory is currently allocated. You'll get an integer from 0 to the amount you reserved with AudioMemory(). More details here:

https://www.pjrc.com/teensy/td_libs_AudioConnection.html
 
Thanks Paul for the help, that makes sense to me.

However, I noticed that AudioMemoryUsageMax() (for me) retuns 255 as maximum value. I'm using Teensyduino 1.37 and Teensy 3.6 and a sketch with a delay object where I adjust the delay time frequently. Same case happens (255 max memory) in my faulty Envelope Follower object. Even I use AudioMemory(1000) or more, I'm still fixed at most 255. Is this a bug, or is it normal?
 
Last edited:
Status
Not open for further replies.
Back
Top