Author |
Message |
mubase

Joined: Mar 24, 2011 Posts: 117 Location: London UK
Audio files: 5
|
Posted: Sat Apr 25, 2015 5:19 am Post subject:
Arduino wavetable synthesis: Implementing an envelope. |
 |
|
Hi everyone.
I am going a bit nuts trying to implement a simple decay to a wavetable synth I am working on using an ATXmega board and the Arduino IDE.
I can output a sine wavetable through the DAC quite easily. I use a calculated wavetable in an array of 256 values with a maximum value of 4095 as the DAC is 12 bits.
I can then use an accumulator and phase incrementer to get a wide frequency scale.
The output from the dac is done inside a timer overflow IRQ with a sample rate of around 31250Hz.
I would like to know how to implement an envelope. A simple decaying envelope to start with. So, say, I press a button and on button press detect, start the sound and decay. I want to do it using another wavetable containing a simple ramp wave to start with. Can some one explain to me how I would go about this?
The basic snippet of code that is playing the wave looks like this:
Code: | accumulator += accumulatorSteps; /* advance accumulator */
waveStep =( accumulator>>8);
output=(sine[waveStep]);
dac.write(output);//*decay[d])); |
accumulator steps is the value of the frequency.
Thanks,
Steve>S _________________ There's a crack in everything...Thats how glue manufacturers make a living. |
|
Back to top
|
|
 |
elmegil

Joined: Mar 20, 2012 Posts: 2179 Location: Chicago
Audio files: 16
|
Posted: Sat Apr 25, 2015 10:03 am Post subject:
|
 |
|
Multiplication
Seriously; you'll need to scale the result appropriately, but that's really what is going on.
PS: Make sure you use integer math as much as possible; probably would want to pre-scale your wavetables. |
|
Back to top
|
|
 |
mubase

Joined: Mar 24, 2011 Posts: 117 Location: London UK
Audio files: 5
|
Posted: Fri May 01, 2015 4:51 am Post subject:
Arduino wavetable synthesis: Imple.. :SOLVED |
 |
|
Hi Elmegil.
Yep. Thanks. My problem was scaling.
All working well now.
Also, I've migrated from xmega to stm32f4 on Arduino IDE. So much faster and nicer.
I'm now doing experiments with rudimentary (and i say RUDIMENTARY) synchronous granular synthesis.  _________________ There's a crack in everything...Thats how glue manufacturers make a living. |
|
Back to top
|
|
 |
|