soundtouch change pitch matlab implementation

function output = changePitch(input, pitchInSemitones)

% one octave is 12 semitones

octave = pitchInSemitones / 12;

%0.69314718056 is In2. go up one octave corresponds to twice the freqency;

pitchChange = exp(0.69314718056  * octave);

rate = 1 * pitchChange;

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');

原文地址:https://www.cnblogs.com/fellow1988/p/10004593.html