Doing my own OSC code.

Before I re-invent the wheel, just checking if maybe someone already came up with a simple way to create an OSC that is fast to calculate using PWM output.

I'm not looking into any fancy stuff, but something that is simply fast. :wink: Otherwise I will try to come up with my own. I already got 6 voices of fixed-pitch no-envelope drum-sounds from a single ATmega328 Arduino chip, now I want to check how I could add some SAW sounds. (not pulse) Also without envelope, as I'm using 8-bit and the envelope sounds pretty bad with 8-bits. :wink:

Best Regards, WilliamK

Hi,

Using DDS, it should be easy .. (saw or other waveform using wavetable)
see there :

http://interface.khm.de/index.php/lab/experiments/arduino-dds-sinewave-generator/
or
http://mouro.info/signal-generator-using-arduino-and-dds/

Or maybe i didn't catch exactly what you want to do :slight_smile:

Regards,

xray303

Thanks bud, I already know how to output the audio, just need to figure out a nice way to create a sawtooth which is guided by midi without using too many cycles. :wink: I will brainstorm more in a few days, but thanks for now, I will check the links tomorrow.

Best Regards, WilliamK

Hi,

But doing audio with DDS or a single sawthooth is done the same way .. ? no
See here a AVR mini DDS function generator controlled by serial port but is done in ASM and the output is a R2R, you could try to recover some part of the code which seems to be quite optimized.

http://www.myplace.nu/avr/minidds/index.htm
Just take a look if it can help you to get some very fast code . (normally doing some ASM could be quite faster)

Best Regards, xray303

Oh, thanks bud, that's great, will take a closer look at it during the week. :drooling_face:

Wk

Generally you have two choices, look up table or calculation. With a saw tooth wave calculation is a simple addition operation and is quick and easy.
But I am sure you know this so maybe I am missing the point.

You could put one cycle of the waveform in a wavetable
and use phase accumulators. You can get by with less
than one cycle if you exploit symmetry.

My preference is to use one cycle. This makes it easier
to change waveforms.

My numerically controlled oscillator code is at
http://wiblocks.luciani.org/docs/app-notes/nb1a-nco.html

(* jcl*)