Audio processing: Writing a pitch shifting echo effect

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일

1 개 추천

have a look into the shiftPitch() function, you can find it here https://de.mathworks.com/help/audio/ref/shiftpitch.html

댓글 수: 2

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개)

카테고리

도움말 센터File Exchange에서 Audio Processing Algorithm Design에 대해 자세히 알아보기

질문:

2021년 5월 18일

편집:

2021년 5월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by