Audio processing: Writing a pitch shifting echo effect

4 ビュー (過去 30 日間)
Matt Brazel
Matt Brazel 2021 年 5 月 18 日
編集済み: Jonas 2021 年 5 月 20 日
Hi everyone,
I'm extremely new to programming but I'm trying to write an echo audio effect that pitch-shifts each repeat by a specified amount (e.g. 1 semitone). This would mean it preserves the original signal and only shifts the repeats. So far I've sourced some code for a reliable echo effect, but I'm lost on how to implement the pitch shift within the feedback loop. Here is the code for the echo as it is now.
function [delayed] = delay(sound, feedback, delaytime, fs)
if nargin == 4
delay_samples = floor(delaytime./1000.*fs);
else
delay_samples = floor(delaytime);
end
delayed = sound;
for sample = delay_samples + 1: length(sound)
if(sample - delay_samples > 0)
delayed(sample) = sound(sample) + feedback*(delayed(sample-delay_samples));
end
end
Any help would be appreciated,
Thanks

採用された回答

Jonas
Jonas 2021 年 5 月 18 日
have a look into the shiftPitch() function, you can find it here https://de.mathworks.com/help/audio/ref/shiftpitch.html
  2 件のコメント
Matt Brazel
Matt Brazel 2021 年 5 月 20 日
Thank you for your response. Yes, I've come across this function. I guess my biggest problem at the moment is figuring out how to implement it with the delay function in the way that I described above.
Jonas
Jonas 2021 年 5 月 20 日
編集済み: Jonas 2021 年 5 月 20 日
if i see that correctly your echo is just a delayed copy of the original with a factor for smaller amplitude. for that you dont need a for loop but i think it is something like that (here everything is a column vector):
withEcho=original+someFactor*[zeros(nrOfDelayDamples,1); original(nrOfDelaySamples+1:end,1)]
in this form you can apply the mentioned function directly to the echo part
if you want to add more than one repetition of the pite original you can solve that by a for loop like
withEcho=original;
for echoNr=1:4
withEcho=withEcho+someFactor/echoNr*[zeros(nrOfDelayDamples*echoNr,1); original(nrOfDelaySamples*echoNr+1:end,1)];
end
of course it is a question of style how you let decrease the echo for further repetitions, if you include the echoed signal in the higher order echoes and in this case the signal will be exactly as long as the original which is rough at the ending ;)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAudio Processing Algorithm Design についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by