Audio processing: Writing a pitch shifting echo effect

5 views (last 30 days)
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

Accepted Answer

Jonas
Jonas on 18 May 2021
have a look into the shiftPitch() function, you can find it here https://de.mathworks.com/help/audio/ref/shiftpitch.html
  2 Comments
Matt Brazel
Matt Brazel on 20 May 2021
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 on 20 May 2021
Edited: Jonas on 20 May 2021
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 ;)

Sign in to comment.

More Answers (0)

Categories

Find more on Audio Processing Algorithm Design in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!