# Using DirectSound to change the pitch of voice

This topic is 4385 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello everyone, Using Directsound, i can record my voice through webcam (with microphone was integrating on)to a wave file. And now i want to change the voice was recorded, mean i want to change the pitch of the voice. It's said that DirectSound can do that,right??? So can you direct me where to get example source code do my asking as above with using directsound? Or can you have any helping for me?? I need sample (source code is very good for me) and i want to add to my application, so i many thanks to you.

##### Share on other sites
i have been looking in Sample (C++)folder of DirectX with hoping i will find a sample how directsound can change pitch of voice, but i can not find any sample.

if you know, can show to me?
i thanks to any help from you.

##### Share on other sites
You'll need to look into the DirectSoundBuffer SetFrequency call, which needs to be enabled when you create the buffer though the caps flag. This will alter the pitch but will also alter the speed the sample plays at.

I'm getting slightly concerned by all these posts about diguising your voice though. You haven't kidnapped someone, have you?

one post
another one

##### Share on other sites
does "pitch" mean just "tone of voice" high or low?
or
mean "changing tone without changing playing time"?

if first 1, it simple

buffer::SetFrequency( "value u want to" );

of course in order to change frequency
dont forget following setting when initialize the buffer.

DSBUFFERDESC dsbd;  dsbd.dwFlags = DSBCAPS_CTRLPAN | DSBCAPS_CTRLVOLUME | DSBCAPS_CTRLFREQUENCY;

##### Share on other sites
Setting te frequancy will indeed change the pitch of your sample, however a nicer technique would be to do a fourier transform, then shift stuff in the frequency domain (or strech it). As long as you keep the number of samples the same you can change the pitch w/o changing the speed at which it plays (ie: you wont change the time it takes to play the sample).

Note that heavy distortion will make your voice sound a little odd (as if talking throug a plastic tube). On the other hand you can do some really neat tricks in the frequency domain which help to "brighten up" the sound recorded from mics. Also I am unsure wich platform you are targeting because a fourier transform can be very CPU intensive (should be doable realtime on a regular PC). Look for Fast Fourir Transform in the internet.

##### Share on other sites
First for toan1982:

Look in the DirectSound SDK Documentation for "Frequency" This will change pitch but also playback speed. But if what you want is change pitch but maintain speed (The recording will play for the same amount of time) then that is the same answer i seek ... just in reverse.

To Egelsoft:

Your last post is the first one i've seen in days that sounds like you could actually help me. I will offer specifics below and I think your answer would help the original poster as well.

I have a dictation recorder/player component I wrote in C#. I have a stream and can access my 16bit mono voice data directly. What I am trying to do is to slow the playback down while preserving the original pitch. This permits a listener to in effect say "please repeat that more slowly". Yet the player would not make the voice sound like bowser.

I know I need to FFT the data and get back MORE samples with the SAME PITCH when I de-transform it. I just don't know where to start. I have a free copy of the ExoCortex.DSP if you are familiar with that.

Any help is appreciated

1. 1
2. 2
JoeJ
17
3. 3
4. 4
frob
11
5. 5

• 13
• 16
• 13
• 20
• 13
• ### Forum Statistics

• Total Topics
632181
• Total Posts
3004625

×