Audio - 2 octave down pitch shift

Status
Not open for further replies.

swarfrat

Active member
I was looking to do an octave pitch shift, and I have a couple teensy 3.0's laying around. Basically this is supposed to be a polyphonic octave effect, and I'd like to shift down 2 octaves, fixed interval. My toddler son loves music and playing with daddy. He just got his first toy acoustic guitar. But his absolute favorite instrument is the bass, which isn't real friendly to little hands, even for grade school kids. So I was thinking about picking up one of those tiny travel electric guitars, and building the octave shift into it.) This is a toy still, although I'm hoping it's an incredibly cool toy.

Basically electric guitar signal is limited to about 5khz. Itty bitty guitars are typically tuned up a fifth, but an octave is possible with the right string gauge. I was thinking about buffering the pickup output, LPF at about 1khz (highest fundamental is around 640Hz, assuming on octave above "standard" tuning), sampling at 8Khz, and pitch shifting 2 octaves down (2khz), LPF that about 700 Hz or so and mix it back in with the original signal.

So I started looking for pitch shifting techniques, and it appears most stuff is generalized and so requires more complex techniques than I think I need for a divide by 2 and 4 pitch shift. I'm not sure I have enough power to FFT in real time at 8hz (is that overly cautious?) Can I just window filter and stretch my samples, or do I need SOLA or something else to pitch shift by integer octaves in the time domain?

Alternatively, I have some individual piezo guitar saddles laying around, I could digitize them and just do the old analog flip-flop algorithm in the Teensy. Actually I could do better than the old "analog" octave pedals like the Boss OC-2, since I have a polyphonic pickup handy and I should be able to do some time domain filtering on the square waves internally to the Teensy before spitting them out. I guess I'll then just use a PWM out, and LPF the heck out of it. 2Khz LPF should be plenty for a micro "bass" guitar, particularly if I have the option of mixing in the direct signal.
 
I've been doing some more thinking, and I like the per string processing rather than just doing 2 octaves down on a summed mix. The highest frequency I'd need to detect is 784 Hz, the lowest possible would be about 110 Hz. The options I've thought of are:

1) Feed a highly clipped square wave signal to a digital pin, detect changes for frequency detection, filter the output square wave down. This requires some sort of amplitude modulation though - so I also need a per string envelope detection. This can be done at a much slower sample rate though. Like 400 Hz would be plenty fast. So we have frequency detect, divide, digital filtering, digital mixing - PWM out.

2) Alternatively, feed a LPF filtered unclipped waveform per string to Analog inputs. I'd need to be able to get reliable frequency detection, so assuming 800 Hz highest input, I think maybe an 8khz sample rate (again, x 4 inputs). Now, rather than attempt a complex pitch shift algorithm, I can simply double the samples, and start over each positive going zero crossing, so I'm actually skipping half the samples, and the ones that get played take twice as long to come out as they came in. So I need to watch each incoming string and mark the beginning of the last cycle. Once the output cycle being played reaches the end, we skip ahead in the buffer to the most recent incoming cycle.

Since I know the frequency range for each string, they can each be filtered pretty heavily to the range of interest.
 
Hi swarfrat, how did things go with your octave pitch shifter? Were you doing this before the Audio library existed?
 
Status
Not open for further replies.
Back
Top