Forums

frequency/pitch shifting

Started by David Reid April 20, 2004
I'm doing some audio programming to be used in a flight trainer.
Previously, directsound was being used to perform all audio playback.  Now
though, due to the need to do realtime capture and playback, we've switched
to using ASIO because of the low latency associated with it.

Anyway, Directsound had methods for doing things like volume, pan, and
frequency control, but now with ASIO, this has to be done manually (by me
;) ).  I understand volume and pan control, but i can't seem to find any web
resources that discuss frequency shifting in enough detail for me to come up
with at least a basic algorithm.  I understand that this is probably not a
simple topic, but i'd like to be able to get started with this even if
performance/quality is not optimized.

Can anyone suggest a website that discusses this in some detail, with or
without sample C/C++ code (my background is computer/electrical engineering,
so i can understand anything meant for an undergrad level course and maybe a
little beyond that)?  Or if someone can explain the concept of frequency
shifting.

Thanks a lot,

david


http://www.dspdimension.com/start.html

-- 

"Things should be described as simply as possible, but no 
simpler."

                                              A. Einstein
David,

first you should be clear about what you actually want to achieve.

A frequency shift shifts all frequencies in a sound by the same amount
in Hz, distorting it in an "unnatural" way. A pitch shift does not -
ideally, it will shift the perceived pitch on a note scale to become
sharp or flat.

Feel free to visit my web site at http://www.dspdimension.com for more
information.

--smb

Stephan M. Bernsee wrote:

> David, > > first you should be clear about what you actually want to achieve. > > A frequency shift shifts all frequencies in a sound by the same amount > in Hz, distorting it in an "unnatural" way. A pitch shift does not - > ideally, it will shift the perceived pitch on a note scale to become > sharp or flat. > > Feel free to visit my web site at http://www.dspdimension.com for more > information.
Good to see you here again Stephan! Would you care to tell us where your GPL scaling library stands? Bob -- "Things should be described as simply as possible, but no simpler." A. Einstein
Bob Cain wrote in message news:
> > Good to see you here again Stephan! Would you care to tell > us where your GPL scaling library stands? >
...on http://www.clearscale.org...? ;-) I'll be working on it over the summer. Right now I have some of my students collect some test files and write up a batch script to test various methods, which is rather tedious if you do it manually. But I already have a working prototype that I'm going to test further and I'll update the page as I go. Also, I'll most probably be at the Linux Audio developer conference held next week in Karlsruhe/ZKM to talk about the latest development in this regard. The link is http://www.zkm.de/lad (I'm not on the list of speakers because I learned about the LAD in February - I'm just there for a chat). Regards, --smb
Yes, thank you stephan.  I meant to write back saying that i want to do
pitch shifting.

An example of this would be scaling the pitch of an engine sound so that if
the scale factor is > 1 the engine sounds as if its going "faster", and if
it's less than one, it sounds "slower".

I've checked out dspdimension, and a few other sites, including clearscale.

David

"Stephan M. Bernsee" <stephan.bernsee@web.de> wrote in message
news:38ab652c.0404202125.22e6904@posting.google.com...
> David, > > first you should be clear about what you actually want to achieve. > > A frequency shift shifts all frequencies in a sound by the same amount > in Hz, distorting it in an "unnatural" way. A pitch shift does not - > ideally, it will shift the perceived pitch on a note scale to become > sharp or flat. > > Feel free to visit my web site at http://www.dspdimension.com for more > information. > > --smb
Well, considering the fact that a motor noise is a cyclostationary
signal rather than a (musically) harmonic signal and since you
indicate that you wish to increase the "speed" of that cycle, maybe a
sample rate conversion to transpose it (musically speaking) would be
better suited?

Pitch shifting will only change the pitch, not the cycle. IOW: it will
not sound faster, just higher... I'm not sure if that is what you
want, considering the application...

--smb

"David Reid" wrote in message 
> Yes, thank you stephan. I meant to write back saying that i want to do > pitch shifting. > > An example of this would be scaling the pitch of an engine sound so that if > the scale factor is > 1 the engine sounds as if its going "faster", and if > it's less than one, it sounds "slower". > > I've checked out dspdimension, and a few other sites, including clearscale. > > David
Well, i think that's what DirectSound allows you to do when you change the
buffer frequency.  If the sample rate of the sound is 44100 and you multiply
by 1.08 approx, the buffer will now contain data for 48kHz playback, which
when played back at 44.1kHz would yield a "faster" sound.  This method was
acceptable for the company so that's what im trying to achieve but using a
different sound API (ASIO).  So i have to do the sample rate conversions
myself.

I've started looking at the osalp on sourceforge, it has a class that does
sample rate conversions.  i think that will be good enough for what i want
to do, but we'll see how it goes.

Thanks for all your help.
"Stephan M. Bernsee" <stephan.bernsee@web.de> wrote in message
news:38ab652c.0404210941.59373723@posting.google.com...
> Well, considering the fact that a motor noise is a cyclostationary > signal rather than a (musically) harmonic signal and since you > indicate that you wish to increase the "speed" of that cycle, maybe a > sample rate conversion to transpose it (musically speaking) would be > better suited? > > Pitch shifting will only change the pitch, not the cycle. IOW: it will > not sound faster, just higher... I'm not sure if that is what you > want, considering the application... > > --smb > > "David Reid" wrote in message > > Yes, thank you stephan. I meant to write back saying that i want to do > > pitch shifting. > > > > An example of this would be scaling the pitch of an engine sound so that
if
> > the scale factor is > 1 the engine sounds as if its going "faster", and
if
> > it's less than one, it sounds "slower". > > > > I've checked out dspdimension, and a few other sites, including
clearscale.
> > > > David

Stephan M. Bernsee wrote:

> Bob Cain wrote in message news: > >>Good to see you here again Stephan! Would you care to tell >>us where your GPL scaling library stands? >> > > > ...on http://www.clearscale.org...? > > ;-) > > I'll be working on it over the summer. Right now I have some of my > students collect some test files and write up a batch script to test > various methods, which is rather tedious if you do it manually. But I > already have a working prototype that I'm going to test further and > I'll update the page as I go. > > Also, I'll most probably be at the Linux Audio developer conference > held next week in Karlsruhe/ZKM to talk about the latest development > in this regard. > > The link is http://www.zkm.de/lad (I'm not on the list of speakers > because I learned about the LAD in February - I'm just there for a > chat). >
Thanks, I can't tell you how much I applaud your willingness to take this on. There is such a dearth of high quality public domain technology for this. Many projects will benefit. Many Thanks, Bob -- "Things should be described as simply as possible, but no simpler." A. Einstein

Oh, I failed to ask.  Please, oh please, make it 
continuously variable under a contour while you're at it.  :-)


Bob
-- 

"Things should be described as simply as possible, but no 
simpler."

                                              A. Einstein