Synth Dreams pt. 2

First, some sounds I recorded demoing how I can control frequency of a 74C14 oscillator with an Arduino:

synth-chomp1.mp3 (warning: generally noisy as hell)

Kinda fun, but not exactly the direction I'm trying to go in. To get the pitch accuracy I want will require some more thinking.

So last time I got the Arduino MIDI-IN working and a simple square wave oscillator based on a 74C14 going. In order to control the frequency and pitch, I thought it'd be a good idea to try and use a digital pot (AD5206/AD5204) to control the oscillator frequency value with the Arduino, based on this project I found. This actually sorta failed miserably (albeit in an interesting/good way) as the digital pot only has 256 linear steps between it's minimum and maximum values. What this means is that when I tried to put it into the equation for the RC circuit (see example circuit) to map it to piano key notes it sounded really smooth on the lower frequencies but less and less smooth (and way off a piano tuning) as it swept up to the higher frequencies. This makes sense based on how we hear pitches - it's logarithmic. We hear the perceived interval between "A-220 and A-440" as the same as between "A-440 and A-880". Here's a graph of what that looks like. Higher octave intervals have a greater frequency distance between notes. Since the 256 values are distributed linearly over the total frequency range, but perceived pitch is logarithmic, this means the pitch resolution gets increasingly worse the higher the desired pitch.

Anyway I played with the value of the capacitor to see if I could find a value that could at least get me *close* to notes on a piano, and allow me to change notes with the Arduino. Here's a giant spreadsheet that shows what I ended up with, based on some numbers taken from this wikipedia article.

The result? I can make tons of Pac Man sounds, just listen to the samples I recorded. But I just can't get the pitch accuracy I want with the octave range I want. I'd like to get *some* sort of control over the pitch so it could be used melodically. It's sorta close, and then again not at all. I could get a digital pot with a better resolution, or try to map it nonlinearly, but that means more money and not necessarily perfect results (just *less* glitchy pitchy). It might make more sense to just hardwire 12 oscillators and use the Arduino to just control the volume and mix of each oscillator as they are triggered, and divide down to get more octaves. Also I like this approach because I could sort of manually adjust the "tuning" of each note with a tiny potentiometer, sort of like a guitar.

There is probably a way to hack it together with the approach I was trying, but part of my goal here is to keep things simple and obvious. The lesson I learned is that trying to control analog components with a digital component means discrete values will fuck up your day, unless you really, really like Pac Man.

( categories: )
xbeethovenx (not verified) says:


aaron (not verified) says:

you might also want to check this guy's stuff out.

aaron (not verified) says:

you might want to check this guy's stuff out

zirafa says:

Nice, I wonder if he's using Arduino's PWM pins to generate the sounds...