Reputation: 35
Good morning, I'm having trouble with pitch finding and shifting in MATLAB. The program compiles but when i try to sound the shifted track it exits a strange sound and the pitch found isn't correct. What's the problem?
[audioIn,fs] = audioread('Silae.wav');
[f0,idx] = pitch(audioIn,fs);
subplot(3,1,1) %2.1.1
plot(audioIn)
ylabel('Amplitude')
subplot(3,1,2) %2.1.2
plot(idx,f0)
ylabel('Pitch (Hz)')
xlabel('Sample Number')
[f1,idx] = pitch(audioIn,0.3*fs);
subplot(3,1,3)
plot(idx,f1)
ylabel('Pitch n (Hz)')
xlabel('Sample Number n')
[f1,idx] = pitch(audioIn,3*fs); %2 o 4
subplot(3,1,3)
plot(idx,f1)
ylabel('Pitch n (Hz)')
xlabel('Sample Number n')
sound(audioIn);
Upvotes: 1
Views: 512
Reputation: 1550
The function pitch
returns the fundamental frequencies of the audio vector audioIn
and the locations of these frequencies. This function does not modify its input, so when you do pitch(audioIn,0.3*fs)
, audioIn
will remain unchanged.
So, regarding to what you perform on audioIn
, your code could be summarized as:
[audioIn,fs] = audioread('Silae.wav');
sound(audioIn);
By default, the function sound
(without argument about Fs):
sound(y) sends audio signal y to the speaker at the default sample rate of 8192 hertz.
So, the problem is, if your input Silae.wav
file is at 44100 Hz, by playing it at 8192 Hz, you will play it about 5 times slower that you should, making it weird and deep sound.
Upvotes: 3