Octave generator with small buffer

Algorithm development and general DSP issues

Moderator: frank

Post Reply
Fulcrum
Posts: 7
Joined: Tue Oct 04, 2011 10:48 am

Octave generator with small buffer

Post by Fulcrum »

Hello Frank,

The question is the following: in the octave generator if we use the buffer size 4096 there is a slight delay in the signal (really small, but annoying), if we reduce the buffer size (to 2048, 1024, or 512) then the delay disappears, but the pitch is not exact (not an octave shift, but just a bit not in tune).

Is it possible to get an octave up/down, using the small buffer size (2048, 1024, 512)? If so, where can the mistake be and why can the pitch be wrong?
frank
Posts: 1244
Joined: Wed Oct 19, 2005 12:26 pm
Contact:

Post by frank »

It should be doing a full octave up but you may not hear it for low frequencies when using a shorter buffer. The way this pitch shifter works is by playing the buffer faster than data is coming in and if you use a short buffer then you may have less than a full cycle of a particular frequency in the buffer and it will not sound properly shifted.
Frank Thomson
Experimental Noize
Fulcrum
Posts: 7
Joined: Tue Oct 04, 2011 10:48 am

Post by Fulcrum »

Thanks a lot for the reply!
Am I assuming correctly: the full cycle of frequency doesn't "get on board" because the chip response (feedback, samples-in frequency, not sure how I should call it in English, but I hope I'm making the point) is not fast enough for smaller buffer. Which means if we could use faster response it could work fine then? Can it be tweaked somehow then? is there some variable responsible for it, or is it just a constant value?

If I'm not expressing my thoughts clear enough please let me know and I'll try to rephrase.
frank
Posts: 1244
Joined: Wed Oct 19, 2005 12:26 pm
Contact:

Post by frank »

It is simply that the buffer is too small to hold a full cycle.

As an example, a 512 long buffer at a 48KHz sample rate would hold a single cycle of about 97Hz. Any lower frequency would be less than a single cycle in the buffer.

A 4096 long buffer can hold a single cycle of about 11Hz so the longer buffer can hold a much lower frequency but it will have a longer delay than the shorter buffer.

A faster sample rate would not help and would make it worse with the smaller buffer.
Frank Thomson
Experimental Noize
Fulcrum
Posts: 7
Joined: Tue Oct 04, 2011 10:48 am

Post by Fulcrum »

Oh, I see now :)
So I guess producing a pitch shifter without this delay is physically impossible

goddamn physics :)

Thanks anyways, have to confess I've learned a lot about sound processing thanks to your company already and still so much more to learn!

You're awesome! keep it up
diydsp
Posts: 7
Joined: Tue Dec 06, 2011 6:28 pm

Post by diydsp »

Believe it or not, pitch-shifting is one of the hardest algorithms around. There are dozens of ways to do it. Usually, the challenges are 1. quality, 2. delay, 3. minimum of processing power. Also, algorithms vary depending on whether the material is speech, music, or other.

In workstation software these days, lots and lots of cpu power is used. The sound can be split into multiple bands. Also, buffers can be synchronized to events like detected transients, etc. Other improvements involve predicting the formants of the sound, inverting them, transforming, then reapplying formants.

Note that when you search in "the literature," you may have to look for "pitch-scaling" as well as "pitch-shifting." I just tried to do a google search for you on "pitch-scaling algorithms," but too many articles came up!

This is one good link I read on the subject years ago, but the basics are still the same: http://www.dspdimension.com/admin/time-pitch-overview/

Good luck on your adventure!
Post Reply