Arduino Forum

Using Arduino => Audio => Topic started by: WilliamK Govinda on Mar 06, 2011, 11:00 pm

Title: Doing my own OSC code.
Post by: WilliamK Govinda on Mar 06, 2011, 11:00 pm
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. ;-) 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. ;-)

Best Regards, WilliamK
Title: Re: Doing my own OSC code.
Post by: xray303 on Mar 07, 2011, 12:11 am
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 :)

Regards,

xray303
Title: Re: Doing my own OSC code.
Post by: WilliamK Govinda on Mar 07, 2011, 12:19 am
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. ;-) I will brainstorm more in a few days, but thanks for now, I will check the links tomorrow.

Best Regards, WilliamK
Title: Re: Doing my own OSC code.
Post by: xray303 on Mar 07, 2011, 12:35 am
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

Title: Re: Doing my own OSC code.
Post by: WilliamK Govinda on Mar 07, 2011, 12:39 am
Oh, thanks bud, that's great, will take a closer look at it during the week.  :smiley-fat:

Wk
Title: Re: Doing my own OSC code.
Post by: Grumpy_Mike on Mar 07, 2011, 10:34 pm
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.
Title: Re: Doing my own OSC code.
Post by: jluciani on Mar 10, 2011, 01:27 am
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*)