Hi,i created a basic wavetable synthesizer that gets it's input over midi and outputs through a single PWM pin.I have a problem now:Everytime a note starts to play, i hear a "click"-noise. However this only happens when there is a pause between the new an the old note. If two notes are exactly aligned behind each other in the midi, there is no click. So i guess the "click" thing has something to do with the PWM going "LOW" in the pause between two notes.But then again, if there are 2 or more notes playing at the same time (i.e. bassline and strings) and there is a pause in for example the bassline channel, the click also appears ...so the PWM-pin-going-low-thing might not be it after all.

I have a sort-of similar problem - I use Tone to make a little warble, sort of sounds like a cell phone ring.Imagine dee-dle-dee-dle-dee-dle-dee-dle-deeee - and this afwul farty kind of noise as it turns off. I have 5 boxes - 4 smaller, 1 larger. All the same circuit, output pin driving a mosfet then the speaker. Only the larger box makes the noise. Nothing I've tried stops it. And nice & loud too as the MOSFET switches ~ 3W across the speaker (12V source thru a 34 ohm resistor into capacitor coupled 4 ohm speaker).

Exactly. Looking at your code, you tried to put a simple LPF-like smoothing, which theoretically would work. But the problem is, even if the PWM carrier ramps up to full volume, the arduino output itself is still jumping directly to 5v.

I had the same problem with my synth. The problem could be solved by having the output centered on the middle of the output range, rather than just adding waveforms to 0. Add a capacitor in series to nix the DC offset, and the middle PWM value will become the new "0" point.This was actually a problem for me, because no analog LPF's can filter out all of the carrier wave. I ended up getting a nice SPI DAC, since I use my synth for my electronic music-making, and the PWM wave, albeit inaudible, messed up recordings.

...Imagine dee-dle-dee-dle-dee-dle-dee-dle-deeee - and this afwul farty kind of noise as it turns off....We just laugh about it now, especially when people hear it.

If it were fart sounds i could maybe live with it as a "feature" But unfortunally it really does sound more like going rampage on a old TV's antenna...white noise kind of thing

Quote

Exactly. Looking at your code, you tried to put a simple LPF-like smoothing, which theoretically would work. But the problem is, even if the PWM carrier ramps up to full volume, the arduino output itself is still jumping directly to 5v.

I had the same problem with my synth. The problem could be solved by having the output centered on the middle of the output range, rather than just adding waveforms to 0. Add a capacitor in series to nix the DC offset, and the middle PWM value will become the new "0" point.This was actually a problem for me, because no analog LPF's can filter out all of the carrier wave. I ended up getting a nice SPI DAC, since I use my synth for my electronic music-making, and the PWM wave, albeit inaudible, messed up recordings.

Good idea! So i would convert my wavetables from uint to int and use values between -128 and 128. Initial value for the pwm out would be 128. I will give it a try next week Also, which Hardware DAC are you using? I planned on using a DAC also, but never found a nice one (and no, i don't want to use a R2R ladder ).

In the meantime i update my Synth code a bit. I now have 16 channels with 4 voices each, giving me a total of 64 voices (i plan on adding a more intelligent channel->voice algorythm later where a channel looks for a free voice on NoteOn and simply uses it). I can also change wavetables on the fly. Next step is to add a touchpanel so i can change the ADSR curve on the fly. After that comes storing/loading the ADSR to/from SD/MMC. Can't wait to get this finished

The best performance and value for money for audio DAC has to be I2S delta-sigma DACs - however they are hard to drive requiring 3 related clocks and bits have to be serially fed to them at Mb/s rates. 24 bit stereo at 48kHz sample rate for under a dollar in surface mount packages (WM8759GED, WM8524GED).The Arduino isn't really fast enough to drive such a DAC (and do anything else useful!)

Other high resolution 5V or 3V3 ADCs are usually expensive and surface mount. LTC2642CMS is a fast SPI 16 bit DAC as an example, not very cheap, surface mount only...

[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

There's an SPI interface on it, so super easy to interface. 12bit audio on each channel, 2 channels if you get the 4922 chip.

And they're extremely low noise. You just have to (as I just found out) put a very low lowpass filter on the Vref pins, not directly connect them to 5v. I mean really low; I'm using one with a cutoff of around 0.03Hz.

I'll go for the MCP4922 first as i can get it cheap from a local shop. I'll keep the LTC2642CMS in mind though and get myself one of these the next time i buy something at farnell.com .

In the meantime i implemented FM Synthesis in addition to wavetable synthesis. I can either use both together (choose wavetables for fm modulator and carrier) or only use wavetables like before. This can be set per Voice, so you don't have to use FM Synthesis for everything if you don't want to.Next is adding an envelope to both the modulator volume and pitch to get more action in there (i'm currently "emulating" the envelope curves by hand )

I'll upload a new sample track of the FM Synthesis stuff once i have the DAC working.

Again, thanks for the help so far!

[edit]Oh well, i'm having to much fun here So here's an example of the current status. No DAC yet.