function output = changePitch(input, pitchInSemitones)input
% one octave is 12 semitonesit
octave = pitchInSemitones / 12;io
%0.69314718056 is In2. go up one octave corresponds to twice the freqency;function
pitchChange = exp(0.69314718056 * octave);co
rate = 1 * pitchChange;vr
tempo = 1 / pitchChange;
if rate < 1
output = changeRate(input, rate, 'cubic');
output = changeTempo(output ,fs, tempo);
else
output = changeTempo(input, fs, tempo);
output = changeRate(output, fs, rate);
end
end
main.m:
clc;
clear all;
[input fs] = wavread('input.wav');
pitchInSemitones = 2;
output = changePitch(input, pitchInSemitones);
wavwrite(output, fs, 'output.wav');