Apply an ADSR to an Audio

42 views
Skip to first unread message

Victor Martinez

unread,
Aug 13, 2024, 1:28:07 PM8/13/24
to Mozzi-users
Can you point me to an example on how to apply an ADSR to an Audio signal ?
The audio will be capture on pin A0 and will output using PWM on pin 9.

The idea is to be able to modify the audio signal using ARDUINO UNO and Mozzi.

I already tested the example, AUDIO_INPUT.INO on Audio IN and send it direct to output via PWM. 


Thanks,
Victor Martinez

Mozzi-users

unread,
Aug 13, 2024, 8:43:12 PM8/13/24
to Mozzi-users
There are some examples in Mozzi examples 07.Envelopes.

Victor Martinez

unread,
Aug 13, 2024, 9:20:58 PM8/13/24
to Mozzi-users
Thanks. But I am confused ..... Are these examples (07 Envelopes) triggered by MIDI? (Note ON , Note off)

I am looking for an example that read the analog signal on A0 , generate and apply an ADSR and output via PCM.
The "trigger" for the ADSR will be threshold value from the analog signal.
 
Thanks,
Victor Martinez

Mozzi-users

unread,
Aug 14, 2024, 5:58:26 AM8/14/24
to Mozzi-users
If you have an ADSR declared at the top of your file (following the ADSR_Audio_Rate_Envelope example),
ADSR <MOZZI_AUDIO_RATE, MOZZI_AUDIO_RATE> envelope;

Then in updateControl() or setup() you can..
Set the levels and times...
envelope.setADLevels(attack_level,decay_level);
envelope.setTimes(attack,decay,sustain,release_ms);

And in updateControl(), when your trigger conditions are met:
Start the envelope (it looks like MIDI, but "noteOn()" in Mozzi's ADSR just means "start" ... might have been better to call it "start"!)
envelope.noteOn();

Then in updateAudio(), in this example, for an audio rate envelope,
envelope.update();

Reply all
Reply to author
Forward
0 new messages