Pitch Shifter: crossfade frequency
Moderator: frank
Pitch Shifter: crossfade frequency
We all know that the pitch shifter algo has some tremolo-like artifacts due to the crossfading between samples. That tremolo rate is somewhat proportional to the pitch shifting frequency (slower at lower pitch and faster at higher pitch). I tried a lot of things to get rid of it or, at least, reduce it drasticly. I was thinking, there's a way to calculate that "tremolo" frequency?.
-
- Posts: 338
- Joined: Mon Nov 12, 2012 1:12 pm
- Contact:
Re: Pitch Shifter: crossfade frequency
I don't exactly know the answer but I do recall some SpinCAD simulations that helped me understand what was going on. The following thoughts are somewhat distant memories and should be validated against... "reality" (cough).
When you're doing pitch shifting, you're cross fading the pitch shifted signal with the pitch shifted signal delayed by half a pitch shifter buffer length (this fading gets rid of the glitches). So, there's a comb filtering type phenomenon that occurs because depending on the frequency component in question, that time is going to be somewhere along the continuum of in phase to out of phase. If you consider a single component (sine wave) against that, if it's out of phase, it will cancel completely and if it's in phase it will come through.
So I think that the warbling effect is a combination somehow of the pitch shift buffer length, pitch shift interval, sampling rate, and the signal itself. BUT I COULD BE WRONG!
When you're doing pitch shifting, you're cross fading the pitch shifted signal with the pitch shifted signal delayed by half a pitch shifter buffer length (this fading gets rid of the glitches). So, there's a comb filtering type phenomenon that occurs because depending on the frequency component in question, that time is going to be somewhere along the continuum of in phase to out of phase. If you consider a single component (sine wave) against that, if it's out of phase, it will cancel completely and if it's in phase it will come through.
So I think that the warbling effect is a combination somehow of the pitch shift buffer length, pitch shift interval, sampling rate, and the signal itself. BUT I COULD BE WRONG!
Re: Pitch Shifter: crossfade frequency
Totally agree with you Larry. My purpose trying to get the "tremolo" (to call it somehow) is try to cancel it somehowDigital Larry wrote: ↑Wed Mar 04, 2020 7:00 am I don't exactly know the answer but I do recall some SpinCAD simulations that helped me understand what was going on. The following thoughts are somewhat distant memories and should be validated against... "reality" (cough).
When you're doing pitch shifting, you're cross fading the pitch shifted signal with the pitch shifted signal delayed by half a pitch shifter buffer length (this fading gets rid of the glitches). So, there's a comb filtering type phenomenon that occurs because depending on the frequency component in question, that time is going to be somewhere along the continuum of in phase to out of phase. If you consider a single component (sine wave) against that, if it's out of phase, it will cancel completely and if it's in phase it will come through.
So I think that the warbling effect is a combination somehow of the pitch shift buffer length, pitch shift interval, sampling rate, and the signal itself. BUT I COULD BE WRONG!
Re: Pitch Shifter: crossfade frequency
Not really possible to cancel it as it is dependent on the signal so at one frequency it may have no tremolo effect but will at another frequency. And the signal is the thing we cannot control, the end user has all the control.
You will have zero tremolo effect when you have exactly 2 full waves of the signal in the buffer as the cross fading between the 2 pointers will always occur at the same point in the signals. I would expect the tremolo effect to be most apparent when 3 full waves are in the buffer and return back to no effect when you have 4 full waves. This will continue, no effect at multiples of 2 full waves in the buffer and the effect getting worse then better as the signal transitions between these multiples.
So you could determine the expected tremolo effect if you know the buffer length and the signal going into the buffer but the signal is rarely a simple sine wave and not something you will know in advance.
You will have zero tremolo effect when you have exactly 2 full waves of the signal in the buffer as the cross fading between the 2 pointers will always occur at the same point in the signals. I would expect the tremolo effect to be most apparent when 3 full waves are in the buffer and return back to no effect when you have 4 full waves. This will continue, no effect at multiples of 2 full waves in the buffer and the effect getting worse then better as the signal transitions between these multiples.
So you could determine the expected tremolo effect if you know the buffer length and the signal going into the buffer but the signal is rarely a simple sine wave and not something you will know in advance.
Frank Thomson
Experimental Noize
Experimental Noize
Re: Pitch Shifter: crossfade frequency
I understand, though that could be something like that. perhaps some heavy compression or limiting will do the trick or at least smooth it a little bit. The trick will be to set well the threshold, obviously at low signal levels below threshold will reapearfrank wrote: ↑Wed Mar 04, 2020 9:08 am Not really possible to cancel it as it is dependent on the signal so at one frequency it may have no tremolo effect but will at another frequency. And the signal is the thing we cannot control, the end user has all the control.
You will have zero tremolo effect when you have exactly 2 full waves of the signal in the buffer as the cross fading between the 2 pointers will always occur at the same point in the signals. I would expect the tremolo effect to be most apparent when 3 full waves are in the buffer and return back to no effect when you have 4 full waves. This will continue, no effect at multiples of 2 full waves in the buffer and the effect getting worse then better as the signal transitions between these multiples.
So you could determine the expected tremolo effect if you know the buffer length and the signal going into the buffer but the signal is rarely a simple sine wave and not something you will know in advance.
Re: Pitch Shifter: crossfade frequency
You can't eliminate it. Larry's explanation in terms of comb filter is spot on.
As posted on this forum before (Don Stavely I think), you can reduce the frequency of the tremolo at the expense of increased latency. For example, if you are pitch-shifting by an octave, rather than do that in one step, you could use 2 delay lines in series, each shifting up by 6 semitones. You get double the latency, but half the tremolo rate. You can reduce the latency a little by writing into each delay line 1/8 of the way in rather than at the start. The following does that
As posted on this forum before (Don Stavely I think), you can reduce the frequency of the tremolo at the expense of increased latency. For example, if you are pitch-shifting by an octave, rather than do that in one step, you could use 2 delay lines in series, each shifting up by 6 semitones. You get double the latency, but half the tremolo rate. You can reduce the latency a little by writing into each delay line 1/8 of the way in rather than at the start. The following does that
Code: Select all
MEM tmp 1 ; Temp memory for pitch shift
MEM delA 4096 ; Delay lines
MEM delB 4096 ; Delay lines
EQU lp REG0 ; Anti-alias LPF
;-------------- Initialize LFOs etc -------------------
SKP RUN,end_init
WLDR RMP0,6786,4096 ; Ramp LFO for pitch-up sqrt(2)
end_init:
;-------------- Sum L and R inputs ---------------
RDAX ADCL,1.0
RDAX ADCR,1.0
;---- Anti-alias LPF before the pitch shift up ---
RDFX lp,0.544 ; 4096 Hz ==> 1 - exp(-2*pi*4096/32768) ==> 0.544
WRAX lp,1.0
;----------- Octave up in two stages -------------
WRA delA+512,0.0
CHO RDA,RMP0,REG|COMPC,delA
CHO RDA,RMP0,0,delA+1
WRA tmp,0.0
CHO RDA,RMP0,RPTR2|COMPC,delA
CHO RDA,RMP0,RPTR2,delA+1
CHO SOF,RMP0,NA|COMPC,0
CHO RDA,RMP0,NA,tmp
WRA delB+512,0.0
CHO RDA,RMP0,REG|COMPC,delB
CHO RDA,RMP0,0,delB+1
WRA tmp,0.0
CHO RDA,RMP0,RPTR2|COMPC,delB
CHO RDA,RMP0,RPTR2,delB+1
CHO SOF,RMP0,NA|COMPC,0
CHO RDA,RMP0,NA,tmp
WRAX DACL,0
Re: Pitch Shifter: crossfade frequency
Dr Alx,
How did you calculate the ramp speed of 6786
It works, but doesn't seem to fit into the equation in the FV-1 application notes.
How did you calculate the ramp speed of 6786
Code: Select all
WLDR RMP0,6786,4096 ; Ramp LFO for pitch-up sqrt(2)
Re: Pitch Shifter: crossfade frequency
Nevermind I got it.
Where N = 0.5
C = (2^14)*((2^N)-1) = 6786.47500...
Cool trick. Sounds good too.
Where N = 0.5
C = (2^14)*((2^N)-1) = 6786.47500...
Cool trick. Sounds good too.