Re: [music-dsp] pitch shifting in frequency domain Re: FFT for realtime synthesis?

2018-10-30 Thread gm

Ok, heres a final idea, can't test any of this so it's pure science fiction:


-Take a much larger FFT spectrogramme offline, with really fine overlap 
granularity.


-Take the cesptrum, identify regions/groups of transients by new peaks 
in the cepstrum.


-Pick peaks in the spectrum, by amplitudes and the phase releationship 
around the peaks.


-Seperate sinusoids from noise this way.

-Compress the peaks (without the surrounding regions) and noise into 
smaller spectra.

(but how? - can you simply add those that fall into the same bins?)

Now use these smaller spectra to synthesize in realtime.

Use the original phases on transient partial groups and events to 
preserve waveshapes on transients.

Use random phases for the noise like components.
Use accumulated phases everywhere else.


Not sure if any of this makes sense.
I am curious about the spectrum compression part, would this work and if 
not why not?







___
dupswapdrop: music-dsp mailing list
[email protected]
https://lists.columbia.edu/mailman/listinfo/music-dsp



Re: [music-dsp] pitch shifting in frequency domain Re: FFT for realtime synthesis?

2018-10-29 Thread robert bristow-johnson







 Original Message 

Subject: Re: [music-dsp] pitch shifting in frequency domain Re: FFT for 
realtime synthesis?

From: "gm" 

Date: Mon, October 29, 2018 7:57 pm

To: [email protected]

--



>

> About such sophisticated things as intra frame corrections, besides that

> it might well be above my head

> I first have to get a basic frequency domain shift to work in a decent

> quality...

>

> Meanwhile I found what was broken, the shifted frequencies phases were

> wrong, but quality is still

> dissapointing compared to the time stretch version.

>
it just seems to me, mr. g, that implementing this *first* as a time-scaling 
version (so, being not-real-time you would be processing a sound file into 
another sound file) would be the simplest thing.� then deal with pitch-shifting 
by resampling the time-stretched result so that it's
back to the original length.
don't bother with the intra-frame corrections.� �it's not worth it.� but the 
phase adjustment on each recognized sinusoid between frames should be done to 
keep it glitch-free.� but it could still mangle attacks and other
transient.
�
--


r b-j� � � � � � � � � � � � �[email protected]



"Imagination is more important than knowledge."

�
�
�
�
___
dupswapdrop: music-dsp mailing list
[email protected]
https://lists.columbia.edu/mailman/listinfo/music-dsp

Re: [music-dsp] pitch shifting in frequency domain Re: FFT for realtime synthesis?

2018-10-29 Thread gm




Unfortunately I would have to stick with the "sliding" PD phase locking 
structure from the book for now,
iterating through the spectrum to search for peaks and identify groups 
will add too many frames of additional latency in Reaktor.


But for me this method unfortunately defintively gave worse results than 
without phase locking for music.

It actually sounded broken in some cases, when pitch shifted in frequency.

Both at 22050 and 11025 Hz SR with a 1024 FFT so it's not just a 
question of frequency resolution.

or rather, it probably is, but 4096 @ 44.1 kHz would not solve the problem.
On the other hand, on some speech sample I found an improvement.

(It might be, of course, that I am still doing something else wrong...
Also I might be fooled a little bit because it's louder without phase 
locking since summing the adjacent bins
will decrease the peak bins amplitude so it seems to sound better 
without when you switch it on and off.)


At least meanwhile I understand why and how the method is expected to 
work and I like it's approach.


If s.o. is interested I can post another audio example but I think I've 
spammed the list enough so far...


About such sophisticated things as intra frame corrections, besides that 
it might well be above my head
I first have to get a basic frequency domain shift to work in a decent 
quality...


Meanwhile I found what was broken, the shifted frequencies phases were 
wrong, but quality is still

dissapointing compared to the time stretch version.

I also made a quick test where adjacent amplitudes around peaks where 
simply set to zero
(which doesn't require additional latency here since I can do it on the 
output stream)
and that definitively sounds better on up shifts, so I assume I really 
do need something to treat the phases around peaks

but I am not sure whats an efficient way yet that I can implement.
Maybe it's just that, setting some bins to zero?

Maybe I need to explain that the FFT I made for Reaktor provides a 
constant stream of values like
an audio stream and you have to work on that, sample by sample, or else 
you need a frame

of latency to store the values and work on them, again, sample by sample.
This makes prototyping a little bit odd and laborious, but in the end it 
forces you to choose
efficient solutions, thats why I like Miller Puckets version of the 
phase locking, it just didn't work so well here.


___
dupswapdrop: music-dsp mailing list
[email protected]
https://lists.columbia.edu/mailman/listinfo/music-dsp



Re: [music-dsp] pitch shifting in frequency domain Re: FFT for realtime synthesis?

2018-10-29 Thread Scott Cotton
On Mon, 29 Oct 2018 at 20:09, gm  wrote:

> That's understood.
>
> What is not completely understood by me is the technique in the paper, and
> the very much related technique from the book.
> How can this apply to arbitrary signals when it relies on sinusioids
> seperated by several bins?
>
For music, it is a fairly close approximation during the "sustain" part of
notes.


>
> Also it seems I dont understand where the artefacts in my pitch shift come
> from.
> They seem to have to do with phases but it's not understood how exactly.
>
> What is understood is that the neighbouring bins of a sinusoidal peak
> have a phase -pi apart.
>
> I dont see the effect of this though, they rotate in the same direction,
> at the same speed.
>
> But why is there no artefact of this kind when the signal is only
> stretched,
> but not shifted?
>

I think the big picture answer to this last question is:  time stretch is
(or at least can be done) by a continuous factor
while bin shifting is inherently quantised.  Moreover the quantised nature
of the bins isn't really the same as say breaking
down a continuous interval into a set of contiguous equi-sized intervals,
because of the sinc shaped appearance of frequencies in the quantised
domain and edge effects.   I guess in theory one could find a set of  sines
whose projection onto the bins results in the frequency domain picture you
get, but this would be computationally quite expensive compared to bin
shifting (and is normally approximated by peak finding).

If when you are shifting bins, each bin ends up with the value of some
single bin from the original, then the phase
could be close.  But then you might be missing some input data in your
transform.  On the other hand, If the target value of a bin combines
several input bins, then the phase will likely be messed up most of the
time because you're encoding 2 or more distinct phase values into one.

Otherwise, for more precise treatment of phase than wrap/unwrap, see this
chapter  pages
118-120.

I also myself found it difficult to wrap my head around why TSM gives
better pitch shift than directly, the above is what I arrived at, and I
find it convincing.  Frequency domain pitch shift I think can only be as
good as TSM based pitch shift if the frequency domain is treated
continuously rather than in bins.  If you do that, then you no longer have
FFT, and things get costly and complicated fast.

Hope that helps
Scott






> Am 29.10.2018 um 19:50 schrieb Scott Cotton:
>
>
>
> On Mon, 29 Oct 2018 at 19:12, gm  wrote:
>
>>
>>
>> Am 29.10.2018 um 05:43 schrieb Ethan Duni:
>> > You should have a search for papers by Jean Laroche and Mark Dolson,
>> > such as "About This Phasiness Business" for some good information on
>> > phase vocoder processing. They address time scale modification mostly
>> > in that specific paper, but many of the insights apply in general, and
>> > you will find references to other applications.
>> >
>> > Ethan
>>
>> I think the technique from the paper only applies for monophonic
>> harmonic input -?
>> It picks amplitude peaks and reconstructs the phase on bins around them
>> depending on the synthetic phase and
>> neighbouring input phase. I dont really see what it should do exactly
>> tbh, but
>> the criterion for a peak is that it is larger than four neighbouring
>> bins so this doesn't apply to arbitrary signals, I think.
>>
>> I also tried Miller Puckets phase locking mentioned in his book The
>> Theory and Technique of Electronic
>> Music and also mentioned in the paper,
>> but a) I don't hear any difference and b) I don't see how and why it
>> should work.
>>
>>  From the structure displayed in the book, he adds two neighbouring
>> complex numbered bins,
>> multiplied. That is, he multiplies their real and imaginary part
>> respectivly
>> and adds that to the values of the bin - (Fig 9.18 p. 293).
>> Unfortunately this is not explained in detail,
>>
>> I don't see what that would do other than adding a tiny perturbation to
>> isolated peaks
>> and somehwat larger one to neighbouring bins of peaks?
>> I don't see how this should lock phases of neighbouring bins?
>>
>> And again this doesn't apply to arbitrary signals?
>>
>
> No phase vocoder applies to arbitrary signals.  PVs work for polyphonic
> input where
> -  the change in frequency over time is slow; specifically slow enough so
> that the
> frequency calculation step over one hop can estimate "the" frequency over
> the corresponding time slice.
> -  there is at most one sinusoidal "component" per bin (this is
> unrealistic for many reasons), meaning
> the time slice needs to be large enough and FFT large enough to
> distinguish.
>
> Note the above can't handle, for example, onsets for most musical
> instruments.
>
> Nonetheless, the errors when these conditions do not hold are such that
> some are able to make
> decent sounding TSM/pitch change phase vocoders for a widER variety of
> 

Re: [music-dsp] pitch shifting in frequency domain Re: FFT for realtime synthesis?

2018-10-29 Thread robert bristow-johnson





my comments below are about time-scaling without pitch shifting.� a time-scaler 
coupled with resampling (like sample-rate conversion) will make you a pitch 
shifter.



 Original Message 

Subject: Re: [music-dsp] pitch shifting in frequency domain Re: FFT for 
realtime synthesis?

From: "gm" 

Date: Mon, October 29, 2018 2:12 pm

To: [email protected]

--



>

>

> Am 29.10.2018 um 05:43 schrieb Ethan Duni:

>> You should have a search for papers by Jean Laroche and Mark Dolson,

>> such as "About This Phasiness Business" for some good information on

>> phase vocoder processing. They address time scale modification mostly

>> in that specific paper, but many of the insights apply in general, and

>> you will find references to other applications.

>>
...

>

> I also tried Miller Pucketts phase locking mentioned in his book The

> Theory and Technique of Electronic�Music and also mentioned in the paper,

> but a) I don't hear any difference and b) I don't see how and why it

> should work.

�
wow!� my experience from a long time ago is that it makes a BIG FUCKING 
difference.� before Miller Puckett's observation, if we were doing the basic 
Portnoff PV, the phase adjustment made to one bin could be (and from numerical 
issues, often was) wildly different from the
phase adjustment made to the adjacent bin.� that will for sure fuck up the 
sinusoid.� all you have to worry about, to do Miller Puckett's correction is to 
use a **single** phase adjustment for the whole lobe or bump or peak 
corresponding to a single sinusoid, and then your sinusoid will
splice nicely to the corresponding sinusoid of the previous frame.� but if, for 
a single lobe, the phase adjustment is wild and crazy for each bin, you will 
mangle that sinusoid.
but Miller's thing doesn't take care of the other phasiness problem that Jean 
and Mark were dealing with and
that is waveshape variance due to different harmonics (of the same tonal 
instrument) being shifted by different amounts of time (a time-domain WSOLA 
time-scaler doesn't have that problem.)� that, and the transient problem (how 
to keep your PV from mangling an attack transient), are the main
problems with PV or even with sinusoidal modeling.� i dunno how Melodyne does 
it.


the last i worked on this seriously is 17 years ago.� i gotta paper and old 
MATLAB�that demonstrates how to timescale each sinusoidal component *within* a 
single frame.� there are still the issues of phase adjustment to make that 
sinuosoid splice nicely to the previous frame.�
and a swept-frequency sine sounded just fine.� the bigger problem was not the 
slow sweep (the regular PV did fine with a slow sweep) but was about the fast 
sweep.� that's when this intraframe correction was useful.� i offered this code 
up before, but again, of someone wants either or
both this 2001 paper or the MATLAB code from that project, i can send it to you 
(just email me).� it turned out that the intraframe correction didn't help 
audibly, but we could show that it helped visually with a changing frequency.
�
--


r b-j� � � � � � � � � � � � �[email protected]



"Imagination is more important than knowledge."

�
�
�
�
___
dupswapdrop: music-dsp mailing list
[email protected]
https://lists.columbia.edu/mailman/listinfo/music-dsp

Re: [music-dsp] pitch shifting in frequency domain Re: FFT for realtime synthesis?

2018-10-29 Thread gm

That's understood.

What is not completely understood by me is the technique in the paper, 
and the very much related technique from the book.
How can this apply to arbitrary signals when it relies on sinusioids 
seperated by several bins?


Also it seems I dont understand where the artefacts in my pitch shift 
come from.

They seem to have to do with phases but it's not understood how exactly.

What is understood is that the neighbouring bins of a sinusoidal peak
have a phase -pi apart.

I dont see the effect of this though, they rotate in the same direction, 
at the same speed.


But why is there no artefact of this kind when the signal is only stretched,
but not shifted?


Am 29.10.2018 um 19:50 schrieb Scott Cotton:



On Mon, 29 Oct 2018 at 19:12, gm > wrote:




Am 29.10.2018 um 05:43 schrieb Ethan Duni:
> You should have a search for papers by Jean Laroche and Mark
Dolson,
> such as "About This Phasiness Business" for some good
information on
> phase vocoder processing. They address time scale modification
mostly
> in that specific paper, but many of the insights apply in
general, and
> you will find references to other applications.
>
> Ethan

I think the technique from the paper only applies for monophonic
harmonic input -?
It picks amplitude peaks and reconstructs the phase on bins around
them
depending on the synthetic phase and
neighbouring input phase. I dont really see what it should do exactly
tbh, but
the criterion for a peak is that it is larger than four neighbouring
bins so this doesn't apply to arbitrary signals, I think.

I also tried Miller Puckets phase locking mentioned in his book The
Theory and Technique of Electronic
Music and also mentioned in the paper,
but a) I don't hear any difference and b) I don't see how and why it
should work.

 From the structure displayed in the book, he adds two neighbouring
complex numbered bins,
multiplied. That is, he multiplies their real and imaginary part
respectivly
and adds that to the values of the bin - (Fig 9.18 p. 293).
Unfortunately this is not explained in detail,

I don't see what that would do other than adding a tiny
perturbation to
isolated peaks
and somehwat larger one to neighbouring bins of peaks?
I don't see how this should lock phases of neighbouring bins?

And again this doesn't apply to arbitrary signals?


No phase vocoder applies to arbitrary signals.  PVs work for 
polyphonic input where
-  the change in frequency over time is slow; specifically slow enough 
so that the
frequency calculation step over one hop can estimate "the" frequency 
over the corresponding time slice.
-  there is at most one sinusoidal "component" per bin (this is 
unrealistic for many reasons), meaning
the time slice needs to be large enough and FFT large enough to 
distinguish.


Note the above can't handle, for example, onsets for most musical 
instruments.


Nonetheless, the errors when these conditions do not hold are such 
that some are able to make
decent sounding TSM/pitch change phase vocoders for a widER variety of 
input.


If you put a chirp into a PV and change the rate of frequency change 
of the chirp, you'll hear the slow frequency
change problem. Before you hear it, you'll see it in the form of 
little steps in the waveform


Scott





___
dupswapdrop: music-dsp mailing list
[email protected] 
https://lists.columbia.edu/mailman/listinfo/music-dsp



--
Scott Cotton
http://www.iri-labs.com




___
dupswapdrop: music-dsp mailing list
[email protected]
https://lists.columbia.edu/mailman/listinfo/music-dsp


___
dupswapdrop: music-dsp mailing list
[email protected]
https://lists.columbia.edu/mailman/listinfo/music-dsp

Re: [music-dsp] pitch shifting in frequency domain Re: FFT for realtime synthesis?

2018-10-29 Thread Scott Cotton
On Mon, 29 Oct 2018 at 19:12, gm  wrote:

>
>
> Am 29.10.2018 um 05:43 schrieb Ethan Duni:
> > You should have a search for papers by Jean Laroche and Mark Dolson,
> > such as "About This Phasiness Business" for some good information on
> > phase vocoder processing. They address time scale modification mostly
> > in that specific paper, but many of the insights apply in general, and
> > you will find references to other applications.
> >
> > Ethan
>
> I think the technique from the paper only applies for monophonic
> harmonic input -?
> It picks amplitude peaks and reconstructs the phase on bins around them
> depending on the synthetic phase and
> neighbouring input phase. I dont really see what it should do exactly
> tbh, but
> the criterion for a peak is that it is larger than four neighbouring
> bins so this doesn't apply to arbitrary signals, I think.
>
> I also tried Miller Puckets phase locking mentioned in his book The
> Theory and Technique of Electronic
> Music and also mentioned in the paper,
> but a) I don't hear any difference and b) I don't see how and why it
> should work.
>
>  From the structure displayed in the book, he adds two neighbouring
> complex numbered bins,
> multiplied. That is, he multiplies their real and imaginary part
> respectivly
> and adds that to the values of the bin - (Fig 9.18 p. 293).
> Unfortunately this is not explained in detail,
>
> I don't see what that would do other than adding a tiny perturbation to
> isolated peaks
> and somehwat larger one to neighbouring bins of peaks?
> I don't see how this should lock phases of neighbouring bins?
>
> And again this doesn't apply to arbitrary signals?
>

No phase vocoder applies to arbitrary signals.  PVs work for polyphonic
input where
-  the change in frequency over time is slow; specifically slow enough so
that the
frequency calculation step over one hop can estimate "the" frequency over
the corresponding time slice.
-  there is at most one sinusoidal "component" per bin (this is unrealistic
for many reasons), meaning
the time slice needs to be large enough and FFT large enough to distinguish.

Note the above can't handle, for example, onsets for most musical
instruments.

Nonetheless, the errors when these conditions do not hold are such that
some are able to make
decent sounding TSM/pitch change phase vocoders for a widER variety of
input.

If you put a chirp into a PV and change the rate of frequency change of the
chirp, you'll hear the slow frequency
change problem. Before you hear it, you'll see it in the form of little
steps in the waveform

Scott






>
> ___
> dupswapdrop: music-dsp mailing list
> [email protected]
> https://lists.columbia.edu/mailman/listinfo/music-dsp
>
>

-- 
Scott Cotton
http://www.iri-labs.com
___
dupswapdrop: music-dsp mailing list
[email protected]
https://lists.columbia.edu/mailman/listinfo/music-dsp

Re: [music-dsp] pitch shifting in frequency domain Re: FFT for realtime synthesis?

2018-10-29 Thread gm




Am 29.10.2018 um 19:12 schrieb gm:


From the structure displayed in the book, he adds two neighbouring 
complex numbered bins,
multiplied. That is, he multiplies their real and imaginary part 
respectivly
and adds that to the values of the bin - (Fig 9.18 p. 293). 
Unfortunately this is not explained in detail, 


Sorry I misinterpreted the figure, he doesn't do that but just seems to 
add the bins.

The multiplication seems to be a flag to switch this on and off.
Still I dont see what that would do other then adding an unwanted 
pertubation,

and it sounds worse actually.
Probably I am missing something essential.

___
dupswapdrop: music-dsp mailing list
[email protected]
https://lists.columbia.edu/mailman/listinfo/music-dsp



Re: [music-dsp] pitch shifting in frequency domain Re: FFT for realtime synthesis?

2018-10-29 Thread gm




Am 29.10.2018 um 05:43 schrieb Ethan Duni:
You should have a search for papers by Jean Laroche and Mark Dolson, 
such as "About This Phasiness Business" for some good information on 
phase vocoder processing. They address time scale modification mostly 
in that specific paper, but many of the insights apply in general, and 
you will find references to other applications.


Ethan


I think the technique from the paper only applies for monophonic 
harmonic input -?
It picks amplitude peaks and reconstructs the phase on bins around them 
depending on the synthetic phase and
neighbouring input phase. I dont really see what it should do exactly 
tbh, but
the criterion for a peak is that it is larger than four neighbouring 
bins so this doesn't apply to arbitrary signals, I think.


I also tried Miller Puckets phase locking mentioned in his book The 
Theory and Technique of Electronic

Music and also mentioned in the paper,
but a) I don't hear any difference and b) I don't see how and why it 
should work.


From the structure displayed in the book, he adds two neighbouring 
complex numbered bins,

multiplied. That is, he multiplies their real and imaginary part respectivly
and adds that to the values of the bin - (Fig 9.18 p. 293). 
Unfortunately this is not explained in detail,


I don't see what that would do other than adding a tiny perturbation to 
isolated peaks

and somehwat larger one to neighbouring bins of peaks?
I don't see how this should lock phases of neighbouring bins?

And again this doesn't apply to arbitrary signals?

___
dupswapdrop: music-dsp mailing list
[email protected]
https://lists.columbia.edu/mailman/listinfo/music-dsp



Re: [music-dsp] pitch shifting in frequency domain Re: FFT for realtime synthesis?

2018-10-29 Thread gm

Thanks for tip, I had a brief look at this paper before.
I think the issue it adresses is not the problem I encounter now.
But it might be interesting again at a later stage or if I return to the 
time domain pitch shift.


This is how I do it now, it seems simple & correct but I am not 100% sure,
it still sounds bad except for zero pitch shifts, pure timestretches 
without pitch shift sound ok-ish though
Especially compared to the previous version with time domain pitch 
shifting it sounds much worse.


1.loop through bins -

    calculate input phase difference

    subtract phase step of hop size of the original bin //= 
phase-frequency-deviation


    multiply by frequency factor

    add phase step of hop size of the target bin

    wrap into -pi...pi range

    accumulate to bins phaseaccumulator

 end loop

2.loop through bins 
    calculate spectral envelopes/formant correction
 end loop

3.loop through bins 
    shift bins
 end loop

4.iFFT


for 2., the formant correction, you have to do this before the bin shift :

loop through bins -
    smooth amplitude spectrum according to ERB scale or similar
- end loop

loop through bins -
    shift bins of a copy of the smoothed spectrum in oppsite direction 
(1/freq factor)

    // smooth again, or don't, or use MIPmapping )
    calculate amplitudes * spectrale envelope 2 / spectral envelope 1
- end loop


this seems correct (?) and does both, pitch shifting and time stretching
However, it doesnt sound good, it actually sounds kind of resonant, and 
tinny

(noise elements seem to be converted to ringing sinusoids) and strange
except when the shift is 0, and also sounds better for downshifts then 
for upshifts


also missing is a transient detection (in time domain?) to reset phases
to the original phases, and a noise / sinusiod detection, which might 
improve things


part of the bad sound may just be the fromant correction, it sounds a 
little bit like there were

two voices speaking in synch, another part is the low number of overlaps
example:
https://soundcloud.com/traumlos_kalt/freq-domain-pv-shift-test-4e-2f-4c-test-2/s-6SJ93
1024 @ 22050 kHz











___
dupswapdrop: music-dsp mailing list
[email protected]
https://lists.columbia.edu/mailman/listinfo/music-dsp

Re: [music-dsp] pitch shifting in frequency domain Re: FFT for realtime synthesis?

2018-10-28 Thread Ethan Duni
You should have a search for papers by Jean Laroche and Mark Dolson, such
as "About This Phasiness Business" for some good information on phase
vocoder processing. They address time scale modification mostly in that
specific paper, but many of the insights apply in general, and you will
find references to other applications.

Ethan

On Sun, Oct 28, 2018 at 4:45 PM gm  wrote:

>
>
> Am 28.10.2018 um 22:28 schrieb gm:
> > I am thinking now that resetting the phase to the original when the
> > amplitude exceeds the previous value
> > is probably wrong too, because the phase should be different when
> > shifted to a different bin
> > if you want to preserve the waveshape
> > I am not sure about this, but when you think of a minimum phase
> > waveshape the phases are all different, depending on the frequency.
>
> This whole phase resetting I had is nonsens:
>
> consider for instance speech, the partials meander from bin to bin
> from one frame to the next, so you always have the case that the amplitude
> is larger than it was in the previous frame, but that is not a transient
> where you would want to reset phase.
>
> On the other hand it sounds tinny when the phases are always running freely
> and transients don't have the waveshapes they should have when you
> stretch time and shift pitch.
>
> So you would need partial tracking or something to that effect I assume.
>
> Also the formant correction I described worked pretty well in the "TDM"
> version but
> not well in the phase vocoder version, I dont know why, cause I am doing
> it the same way.
> ___
> dupswapdrop: music-dsp mailing list
> [email protected]
> https://lists.columbia.edu/mailman/listinfo/music-dsp
>
>
___
dupswapdrop: music-dsp mailing list
[email protected]
https://lists.columbia.edu/mailman/listinfo/music-dsp

Re: [music-dsp] pitch shifting in frequency domain Re: FFT for realtime synthesis?

2018-10-28 Thread gm




Am 28.10.2018 um 22:28 schrieb gm:
I am thinking now that resetting the phase to the original when the 
amplitude exceeds the previous value
is probably wrong too, because the phase should be different when 
shifted to a different bin

if you want to preserve the waveshape
I am not sure about this, but when you think of a minimum phase
waveshape the phases are all different, depending on the frequency.


This whole phase resetting I had is nonsens:

consider for instance speech, the partials meander from bin to bin
from one frame to the next, so you always have the case that the amplitude
is larger than it was in the previous frame, but that is not a transient
where you would want to reset phase.

On the other hand it sounds tinny when the phases are always running freely
and transients don't have the waveshapes they should have when you
stretch time and shift pitch.

So you would need partial tracking or something to that effect I assume.

Also the formant correction I described worked pretty well in the "TDM" 
version but
not well in the phase vocoder version, I dont know why, cause I am doing 
it the same way.

___
dupswapdrop: music-dsp mailing list
[email protected]
https://lists.columbia.edu/mailman/listinfo/music-dsp



Re: [music-dsp] pitch shifting in frequency domain Re: FFT for realtime synthesis?

2018-10-28 Thread gm



there had been a mistake in my structure which caused the phase to be 
set to zero

now it sounds more like the original when there is no pitch shift applied
(which is a good indicator that there is something wrong when it does not)

https://soundcloud.com/traumlos_kalt/freq-domain-pv-shift-test-3b-22050-2/s-5pAUL
however it sounds as bad as before when shifted (1024 @ 22050 Hz again)

I am thinking now that resetting the phase to the original when the 
amplitude exceeds the previous value
is probably wrong too, because the phase should be different when 
shifted to a different bin

if you want to preserve the waveshape
I am not sure about this, but when you think of a minimum phase
waveshape the phases are all different, depending on the frequency.
___
dupswapdrop: music-dsp mailing list
[email protected]
https://lists.columbia.edu/mailman/listinfo/music-dsp



Re: [music-dsp] pitch shifting in frequency domain Re: FFT for realtime synthesis?

2018-10-28 Thread gm



Am 28.10.2018 um 18:05 schrieb Scott Cotton:


- you need two up to 200 tap FIR filters for a spectral envelope
on an ERB scale (or similar) at this FFT size (you can
precalculate this
offline though)


Could you explain more about this?  What exactly are you doing with 
ERB and offline calculation of

spectral envelopes?

I am not using ERB at the moment I was thinking ahead how to do it more 
properly.


What I do at the moment is filter the amplitude spectrum with a
moving average FIR filter, I am using 5 bins average on the lower bands
and 40 bins on the highest bands, (for an FFT size of 1024 at 22050 
sample rate)

blending between filter lengths dependeing on the log 2 of the bin number.

In other words, I double the moving average filter each octave.

I filter forwards and backwards through the bins.

This is my spectral envelope, wich I use to whiten the original signal
(devide the original spectrums amplitudes with the smoothed spectrums 
amplitudes)
and then use a shifted version of the avaraged spectrum to imprint the 
corrected formants

(mulitplying, like vocoding) on the whitened spectrum.

To do this more properly, I assume that the averaging filters should be 
based on an ERB scale
though what I do is somewhar similar. Then you would need to average 
abou 200 samples

for the highest ERB bands.

My idea was to use the phase vocoder in a sample slicer, so that you can 
stretch

and pitch shift samples slices, with reconstructed formants.
For this youd could precalculate the forward FFT, the spectral 
envelopes, and the phase
differences/frequencies, so you only have the latency and CPU of the 
inverse transform.


___
dupswapdrop: music-dsp mailing list
[email protected]
https://lists.columbia.edu/mailman/listinfo/music-dsp

Re: [music-dsp] pitch shifting in frequency domain Re: FFT for realtime synthesis?

2018-10-28 Thread Scott Cotton
On Sun, 28 Oct 2018 at 16:47, gm  wrote:

> to sum it up, assumptions:
>
> - for the phase vocoder approach you need an FFT size of 4096 @ 44.1 kHz
> SR and
> - 8 or rather 16 overlaps at this FFT size and SR for a decent quality
>

The coincides with what I've played with.  But the FFT size is also a
function of
frequency range of input.  For audio a common lower bound on frequency is
20hz, which
gives an FFT of 1/20th of a second to be able to distinguish 1 sinusoid per
bin, as per pv
assumptions.  This already is way higher than latency for interactive apps.


>
> - you need two up to 200 tap FIR filters for a spectral envelope
> on an ERB scale (or similar) at this FFT size (you can precalculate this
> offline though)
>

Could you explain more about this?  What exactly are you doing with ERB and
offline calculation of
spectral envelopes?




>
> - if you calculate a 4096 iFFT just in time (one bin per sample) you
> have a latency of
> ~100 ms with these parameters, sped up with 16 simultanoues FFT overlaps
> 100/16 = ~5ms,
> which would be usable
>
> not sure if all of these assumptions are correct, but
> I assume these are the reasons why we dont see so many real time
> applications
> with this technique
>
> It's doable, but on the border of what is practically useful (in a VST
> for instance) I think
>

I thinks that's why it requires so much work to tune everything to make it
work
reasonably for a why variety of inputs.  Once you calculate the
requirements, it's only
doable for a limited frequency range and type of input.

Perhaps sub-band decomposition and then FFT techniques on the sub-bands
would help.

Scott


>
>
>
> Am 28.10.2018 um 14:19 schrieb gm:
> >
> >
> > Am 28.10.2018 um 10:46 schrieb Scott Cotton:
> >> - the quantised pitch shift is only an approximation of a continuous
> >> pitch shift because
> >> the sinc shaped realisation of a pure sine wave in the quantised
> >> frequency domain can occur
> >> at different distances from the bin centers for different sine waves,
> >> shifting bins doesn't do this
> >> and thus isn't 100% faithful.
> >
> > I think this is one of the problems, frequency wise it seems to work
> > better at 11025 Hz sample rate with 1024 FFT size
> > so I assume you would really need 4096 and 8 overlaps minimum for 44 kHz
> > Its hard to tell because I can't test more than 4 overlaps in Reaktor
> > right now, it will get too complictated
> > and with that temporal spacing it's diffcult to judge if a larger FFT
> > is all thats needed
> >
> > I am not sure if I calculate the principal value of the phase
> > difference correctly
> > I just wrap it back into the -pi..pi range, which seems right to me
> > but maybe I am missing something
> >
> >> From the sound clip, I'd guess that you might have some other
> >> problems related to normalising the
> >> synthesis volume/power
> >
> > that's possible, but either I don't understand this point or it
> > wouldn't matter so much?
> >
> >>
> >> The best quality commonly used pitch shift comes from a phase vocoder
> >> TSM: stretch the time
> >> and then resample (or vice versa) so that the duration of input
> >> equals that of output.
> >
> > that's what I did before but I am hoping to get something that is more
> > suitable for real time,
> > with less latency, calculating the forward transform and spectral
> > envelopes offline
> >
> >
> >
> > ___
> > dupswapdrop: music-dsp mailing list
> > [email protected]
> > https://lists.columbia.edu/mailman/listinfo/music-dsp
> >
>
> ___
> dupswapdrop: music-dsp mailing list
> [email protected]
> https://lists.columbia.edu/mailman/listinfo/music-dsp
>
>

-- 
Scott Cotton
http://www.iri-labs.com
___
dupswapdrop: music-dsp mailing list
[email protected]
https://lists.columbia.edu/mailman/listinfo/music-dsp

Re: [music-dsp] pitch shifting in frequency domain Re: FFT for realtime synthesis?

2018-10-28 Thread gm

to sum it up, assumptions:

- for the phase vocoder approach you need an FFT size of 4096 @ 44.1 kHz 
SR and

- 8 or rather 16 overlaps at this FFT size and SR for a decent quality

- you need two up to 200 tap FIR filters for a spectral envelope
on an ERB scale (or similar) at this FFT size (you can precalculate this 
offline though)


- if you calculate a 4096 iFFT just in time (one bin per sample) you 
have a latency of
~100 ms with these parameters, sped up with 16 simultanoues FFT overlaps 
100/16 = ~5ms,

which would be usable

not sure if all of these assumptions are correct, but
I assume these are the reasons why we dont see so many real time 
applications

with this technique

It's doable, but on the border of what is practically useful (in a VST 
for instance) I think




Am 28.10.2018 um 14:19 schrieb gm:



Am 28.10.2018 um 10:46 schrieb Scott Cotton:
- the quantised pitch shift is only an approximation of a continuous 
pitch shift because
the sinc shaped realisation of a pure sine wave in the quantised 
frequency domain can occur
at different distances from the bin centers for different sine waves, 
shifting bins doesn't do this

and thus isn't 100% faithful.


I think this is one of the problems, frequency wise it seems to work 
better at 11025 Hz sample rate with 1024 FFT size

so I assume you would really need 4096 and 8 overlaps minimum for 44 kHz
Its hard to tell because I can't test more than 4 overlaps in Reaktor 
right now, it will get too complictated
and with that temporal spacing it's diffcult to judge if a larger FFT 
is all thats needed


I am not sure if I calculate the principal value of the phase 
difference correctly
I just wrap it back into the -pi..pi range, which seems right to me 
but maybe I am missing something


From the sound clip, I'd guess that you might have some other 
problems related to normalising the

synthesis volume/power


that's possible, but either I don't understand this point or it 
wouldn't matter so much?




The best quality commonly used pitch shift comes from a phase vocoder 
TSM: stretch the time
and then resample (or vice versa) so that the duration of input 
equals that of output.


that's what I did before but I am hoping to get something that is more 
suitable for real time,
with less latency, calculating the forward transform and spectral 
envelopes offline




___
dupswapdrop: music-dsp mailing list
[email protected]
https://lists.columbia.edu/mailman/listinfo/music-dsp



___
dupswapdrop: music-dsp mailing list
[email protected]
https://lists.columbia.edu/mailman/listinfo/music-dsp



Re: [music-dsp] pitch shifting in frequency domain Re: FFT for realtime synthesis?

2018-10-28 Thread gm




Am 28.10.2018 um 10:46 schrieb Scott Cotton:
- the quantised pitch shift is only an approximation of a continuous 
pitch shift because
the sinc shaped realisation of a pure sine wave in the quantised 
frequency domain can occur
at different distances from the bin centers for different sine waves, 
shifting bins doesn't do this

and thus isn't 100% faithful.


I think this is one of the problems, frequency wise it seems to work 
better at 11025 Hz sample rate with 1024 FFT size

so I assume you would really need 4096 and 8 overlaps minimum for 44 kHz
Its hard to tell because I can't test more than 4 overlaps in Reaktor 
right now, it will get too complictated
and with that temporal spacing it's diffcult to judge if a larger FFT is 
all thats needed


I am not sure if I calculate the principal value of the phase difference 
correctly
I just wrap it back into the -pi..pi range, which seems right to me but 
maybe I am missing something


From the sound clip, I'd guess that you might have some other problems 
related to normalising the

synthesis volume/power


that's possible, but either I don't understand this point or it wouldn't 
matter so much?




The best quality commonly used pitch shift comes from a phase vocoder 
TSM: stretch the time
and then resample (or vice versa) so that the duration of input equals 
that of output.


that's what I did before but I am hoping to get something that is more 
suitable for real time,
with less latency, calculating the forward transform and spectral 
envelopes offline




___
dupswapdrop: music-dsp mailing list
[email protected]
https://lists.columbia.edu/mailman/listinfo/music-dsp



Re: [music-dsp] pitch shifting in frequency domain Re: FFT for realtime synthesis?

2018-10-28 Thread Scott Cotton
Dear Peter,

There are numerous (academic) sources which cite phase vocoding as a
"solved problem" when used
in conjunction with transient detection and phase locking.  I don't
entirely agree with that assessment.

Phase vocoders often have limitations around the following
1. integer vs real/float stretch factors
2. total amount of stretch (some phase vocoders deteriorate a lot as the
stretch factor approaches 2 or 1/2.
Given 1) above, this can also mean no stretch factors are in fact useful.
3. synthesis power/volume often is a rough approximation
4. windowing conditions often don't readily scale to different overlap
factors, constraining the available quality/cost tradeoffs available.
5. real time dynamic  pv can introduce additional artefacts at points where
the stretch factor changes.

I'm sure existing pv authors have more to say.  There are also related
sines + noise decompositions, and a
lot of academic reading material.   Many pv authors report that getting it
to work is much harder than textbooks lead one to believe.  Often there are
problems  associated with computing/estimating the principal value of a
phase difference for
frequency estimation.

I've not yet made a good pv myself, except perhaps using too
computationally costly altos,
so take with a grain of  salt.  I'd be interested in hearing others'  ideas
around current pv limitations and quality too.

Scott






On Sun, 28 Oct 2018 at 11:22, Peter P.  wrote:

> Dear Scott,
>
> * Scott Cotton  [2018-10-28 10:49]:
> > I don't know if you're "doing it the right way", however, pitch shift by
> > bin shifting has
> > the following problems:
> >
> > -edge effects (using windowing can help)
> > - pitch shift up puts some frequencies above nyquist limit, they need to
> be
> > elided
> > - the quantised pitch shift is only an approximation of a continuous
> pitch
> > shift because
> > the sinc shaped realisation of a pure sine wave in the quantised
> frequency
> > domain can occur
> > at different distances from the bin centers for different sine waves,
> > shifting bins doesn't do this
> > and thus isn't 100% faithful.
> >
> > From the sound clip, I'd guess that you might have some other problems
> > related to normalising the
> > synthesis volume/power
> >
> > The best quality commonly used pitch shift comes from a phase vocoder
> TSM:
> > stretch the time
> > and then resample (or vice versa) so that the duration of input equals
> that
> > of output.  Phase vocoders
> > however vary a lot in the quality of sound they produce, some are even as
> > bad or worse than the example
> > you provided.
>
> Thank you for this nice explanation, I wonder if you could even add a
> few more lines to it regarding the quality of phase vocoders. Your text
> ended when it was getting even more exciting. :)
>
> Thanks!
> P
> ___
> dupswapdrop: music-dsp mailing list
> [email protected]
> https://lists.columbia.edu/mailman/listinfo/music-dsp
>
>

-- 
Scott Cotton
http://www.iri-labs.com
___
dupswapdrop: music-dsp mailing list
[email protected]
https://lists.columbia.edu/mailman/listinfo/music-dsp

Re: [music-dsp] pitch shifting in frequency domain Re: FFT for realtime synthesis?

2018-10-28 Thread Peter P.
Dear Scott,

* Scott Cotton  [2018-10-28 10:49]:
> I don't know if you're "doing it the right way", however, pitch shift by
> bin shifting has
> the following problems:
> 
> -edge effects (using windowing can help)
> - pitch shift up puts some frequencies above nyquist limit, they need to be
> elided
> - the quantised pitch shift is only an approximation of a continuous pitch
> shift because
> the sinc shaped realisation of a pure sine wave in the quantised frequency
> domain can occur
> at different distances from the bin centers for different sine waves,
> shifting bins doesn't do this
> and thus isn't 100% faithful.
> 
> From the sound clip, I'd guess that you might have some other problems
> related to normalising the
> synthesis volume/power
> 
> The best quality commonly used pitch shift comes from a phase vocoder TSM:
> stretch the time
> and then resample (or vice versa) so that the duration of input equals that
> of output.  Phase vocoders
> however vary a lot in the quality of sound they produce, some are even as
> bad or worse than the example
> you provided.

Thank you for this nice explanation, I wonder if you could even add a
few more lines to it regarding the quality of phase vocoders. Your text
ended when it was getting even more exciting. :)

Thanks!
P
___
dupswapdrop: music-dsp mailing list
[email protected]
https://lists.columbia.edu/mailman/listinfo/music-dsp



Re: [music-dsp] pitch shifting in frequency domain Re: FFT for realtime synthesis?

2018-10-28 Thread Scott Cotton
I don't know if you're "doing it the right way", however, pitch shift by
bin shifting has
the following problems:

-edge effects (using windowing can help)
- pitch shift up puts some frequencies above nyquist limit, they need to be
elided
- the quantised pitch shift is only an approximation of a continuous pitch
shift because
the sinc shaped realisation of a pure sine wave in the quantised frequency
domain can occur
at different distances from the bin centers for different sine waves,
shifting bins doesn't do this
and thus isn't 100% faithful.

>From the sound clip, I'd guess that you might have some other problems
related to normalising the
synthesis volume/power

The best quality commonly used pitch shift comes from a phase vocoder TSM:
stretch the time
and then resample (or vice versa) so that the duration of input equals that
of output.  Phase vocoders
however vary a lot in the quality of sound they produce, some are even as
bad or worse than the example
you provided.

Hope that helps
Scott



On Sun, 28 Oct 2018 at 02:34, gm  wrote:

>
> Now I tried pitch shifting in the frequency domain instead of time
> domain to get rid of one transform step, but it sounds bad and phasey etc.
>
> I do it like this:
>
> multiply phase difference with frequency factor and add to accumulated
> phase,
> and shift bins according to frequency factor
>
> again there is a formant correction, and the phase is reset to the
> original phase
> if the amplitude is larger than it was in the previous frame
>
> with a 1024 FFT size it doesn't work at 44 kHz, it works @ 22050 kHz but
> sounds
> like there is a flanger going on, and especially the bass seems odd
> https://soundcloud.com/traumlos_kalt/freq-domain-p-shift-test-1/s-QZBEr
>
> first original then resynthesized
>
> is this the quality that is to be expected with this approach?
> am I doing it the right way?
>
>
> ___
> dupswapdrop: music-dsp mailing list
> [email protected]
> https://lists.columbia.edu/mailman/listinfo/music-dsp
>
>

-- 
Scott Cotton
http://www.iri-labs.com
___
dupswapdrop: music-dsp mailing list
[email protected]
https://lists.columbia.edu/mailman/listinfo/music-dsp