Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reduce playback speed of PCM data?

Folks,

In my Android application, I record audio and play it back. The user is usually a singer.

I now need the ability to play the audio back at reduced speed.

As I understand, PCM data is simply a mix of sine waves at different frequencies. There is one dominant wave (highest magnitude) that results in the musical notes of the song.

To reduce the speed by 2 times, at first I thought I will just duplicate each sample. For example, if the sampled input PCM values are 20000, 25000, 30000, ..., I will play back 20000, 20000, 25000, 25000, 30000, 30000. However, this doesn't seem to be the right solution. All I seem to be doing here is increasing the wavelength (therefore frequency) of the sine waves. I think this will result in changing the voice/notes.

Can someone please suggest how to reduce or increase the speed?

Thank you in advance for your help.

Regards, Peter

like image 487
Peter Avatar asked Feb 02 '26 06:02

Peter


1 Answers

If by speed you mean varying the voice in the PCM data from slow (tall giant) to fast (chipmunk) then

you might want to look at this algorithm for pitch shifting.. The idea is to get the right sampling rate as per the pitch that you want.

like image 72
Reno Avatar answered Feb 04 '26 23:02

Reno