Tutorial On Writing Directly to Audio Shield Output?

Status
Not open for further replies.

IWorkInPixels

New member
The Project:
I've got a Teensy 3.6 and an audio shield, and I'd like to write my own additive synth from scratch... I want to have just one array of points for a sine wave, and then every time I want to generate a new sample I do the following:


Code:
while (there are more partials) { 
    Select a sample for the current partial from the array based on the desired frequency and phase for oscillator and the sample from the last cycle for that partial
    Multiply by current value of EG for this partial
    Add the resulting sample value to the output accumulator
}
Multiply by compression factor to compress the resulting waveform so that clipping doesn't occur (map max value during the past 1s to 1.0 volume) 
Multiply by current value of overall instrument EG
Write the resulting sample to the audio buffer
Update the previous values for all all partials and EGs
Check to see if any new MIDI messages have come in over USB. If so, adjust desired frequencies accordingly
// See how many sines can fit in this and still get real time audio out of a Teensy 3.6

And then each patch could have as many or as few sine waves as it needs up to the amount that I can reliably add in and still get real time functionality out of the thing.

Does this sound doable? And are there any tutorials on how to write directly to the output buffer of the audio shield so I could start writing this synth?
 
And are there any tutorials on how to write directly to the output buffer of the audio shield so I could start writing this synth?

Maybe this can help?

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

The basic idea is you write to a buffer of 128 sample each time your update() function is called. The output code uses the samples from that buffer, if you've made a connection from your object to the output object.
 
Status
Not open for further replies.
Back
Top