MATLAB Answers

How can I alter the speed of a wav file without altering its pitch?

88 ビュー (過去 30 日間)
Nick
Nick 2013 年 11 月 18 日
編集済み: Brian Hemmat 2020 年 4 月 5 日
I'm trying to be able to load a wav file, and either speed it up or slow it down. I've tried only changing the sampling frequency, but that changes the pitch of the signal. I find that the problem keeps becoming more and more complex as I go through to problem, so any help at all would be valuable. here's what I've attempted to do so far, but I only get static when I play back the file:
clear
[fName, pName] = uigetfile('*.wav');
[sig, fs, nbits] = wavread([pName fName]);
n = 2; %speed by which file will be altered
for x = 2:(length(sig)-1);
newFreq(x) = fs/(2*pi)*acos((sig(x+1)+sig(x-1))/(2*sig(x)));
newFreq(length(sig)) = 0;
end
Fs = fs*n;
t = 0:1/Fs:(length(newFreq)-1)/Fs;
newSig = cos(2*pi*newFreq.*t);
size(newSig)
newerSig = transpose(newSig);
size(newerSig)
myAP = audioplayer(newSig,Fs);
playblocking(myAP);

  3 件のコメント

dpb
dpb 2013 年 11 月 18 日
What would speeding up or slowing down be other than changing pitch?
Not clear what you think you're trying to do here.
Nick
Nick 2013 年 11 月 18 日
sorry, I'll try and be more clear. imagine that the file is a song that is the voice of someone singing. I want the song to sound the same, but I want it to be slower. When I only change the sampling frequency, the voice of the singer will get deeper and deeper as the sampling frequency gets lower, and I'm unsure of how to eliminate that effect.
Bilal AKBANA
Bilal AKBANA 2020 年 4 月 3 日
Look at my answer clicking here

Sign in to comment.

回答 (2 件)

dpb
dpb 2013 年 11 月 18 日
編集済み: dpb 2013 年 11 月 19 日
Oh, tempo-changing...tough nut to crack starting blindly...
Might check the File Exchange and see if there're any submissions on the subject.

  0 件のコメント

Sign in to comment.


Brian Hemmat
Brian Hemmat 2018 年 3 月 29 日
編集済み: Brian Hemmat 2020 年 4 月 5 日
Typically, you would use a phase vocoder. The Pitch Shifting and Time Dilation Using a Phase Vocoder example in Audio Toolbox walks you through the algorithm.
Starting in R2019b, you can use the stretchAudio function or the audioTimeScaler object (for streaming).

  0 件のコメント

Sign in to comment.


Translated by