Re: [music-dsp] ± 45° Hilbert transformer using pair of IIR APFs

2017-02-05 Thread robert bristow-johnson







 Original Message 

Subject: Re: [music-dsp] � 45� Hilbert transformer using pair of IIR APFs

From: "Eric Brombaugh" 

Date: Sun, February 5, 2017 8:22 pm

To: "A discussion list for music-related DSP" 

--



>

> On Feb 5, 2017, at 12:54 PM, robert bristow-johnson wrote:

>

>> using the analytic filter to get the instantaneous amplitude envelope (and, 
>> also, instantaneous frequency by differentiating phase) is something that 
>> works only with single sinusoids that are AM'd or FM'd. for music, i think i 
>> would LPF the square of the signal (or run an efficient sliding
max algorithm, we discussed this a while back) and work with that.
>

> I'm curious what aspects of a music make the complex magnitude of the 
> analytic signal inappropriate for estimating the envelope? In communications 
> signal processing we use this often, even for signals that are fairly 
> wide-band with respect to the sample rate and it seems to work.

>
well, with a single sinusoid, there should be no intermodulation product so the 
analytic envelope should be exactly correct. �but consider:
�
� � x(t) �= �g1(t) cos(w1 t) �+ g2(t) cos(w2 t)
which has for it's Hilbert
� �
y(t) �= �g1(t) sin(w1 t) �+ g2(t) sin(w2 t)
�

and analytic signal

�

� � a(t) �= �x(t) + j y(t)


� � a(t) �= �g1(t) cos(w1 t) �+ g2(t) cos(w2 t) + j( g1(t) sin(w1 t) �+ g2(t) 
sin(w2 t) )


� � |a(t)|^2 �= �|g1(t)|^2 �+ �|g2(t)|^2 �+ �2 g1(t) 
g2(t) cos( (w1-w2) t )

�

the last term on the right needs to be sorta filtered 
out with a LPF to get the correct square of envelope, no?

�

my feeling is that if we're gonna have to put up with 
the vagaries (delay, etc) of a LPF anyway, better to just square and filter the 
signal.

�

and i dunno what sorta mess this becomes if you had two 
sinusoids and were using the analytic signal to derive the instantaneous 
frequency.



>> but the reason i am most interested is in a frequency shifter. like the ham 
>> radio single-sideband (SSB) thingie. this is not a pitch shifter and detunes 
>> harmonic overtones into the inharmonic. but it is totally glitch-free and 
>> can sometimes be handy to detune something slightly so that
there is not a buildup of energy at a specific frequency (when there is 
feedback of some sort). pitch shifters can do that too, but time-domain pitch 
shifters might have glitches for non-monotonic input and frequency-domain pitch 
shifters have a huge throughput delay. also, this glitch-free
frequency shifting can be slowly modulated. might be useful for chorusing. 
combined with a pitch shifter and pitch detector, you can shift harmonics 
without shifting the fundamental (i.e. pitch it up with a pitch shifter and 
then bring back down the fundamental to the original pitch.)
>

> Yes - the Bode-style frequency shifter is a fun and useful effect. I've done 
> several of them for modular synthesizers using these IIR all-pass structures:

>

> With a dsPIC - http://www.modcan.com/bmodules/dualfs.html

>

> With an STM32F303 - http://modcan.com/emodules/dualfreqshifter.html

>

> Also with a dsPIC - http://synthtech.com/eurorack/E560/

>

> There are example soundfiles at the above sites showing some of the subtle 
> and radical variations that are possible with different amounts of shift, 
> feedback and various shifting waveforms.

>
kewl. �what kinda number crunching can a dsPIC do? �i know what a PIC is. �so, 
how wide is the word and how many MIPS can a dsPIC do? �i guess it's time for 
me to google search it.
now, here is the touchy question: care to tell us how you designed the
coefficients for the APF pairs?

--
r b-j � � � � � � � � �r...@audioimagination.com
"Imagination is more important than knowledge."
�
___
dupswapdrop: music-dsp mailing list
music-dsp@music.columbia.edu
https://lists.columbia.edu/mailman/listinfo/music-dsp

Re: [music-dsp] ± 45° Hilbert transformer using pair of IIR APFs

2017-02-05 Thread Eric Brombaugh

On Feb 5, 2017, at 12:54 PM, robert bristow-johnson wrote:

> using the analytic filter to get the instantaneous amplitude envelope (and, 
> also, instantaneous frequency by differentiating phase) is something that 
> works only with single sinusoids that are AM'd or FM'd.  for music, i think i 
> would LPF the square of the signal (or run an efficient sliding max 
> algorithm, we discussed this a while back) and work with that.

I'm curious what aspects of a music make the complex magnitude of the analytic 
signal inappropriate for estimating the envelope? In communications signal 
processing we use this often, even for signals that are fairly wide-band with 
respect to the sample rate and it seems to work.

> but the reason i am most interested is in a frequency shifter.  like the ham 
> radio single-sideband (SSB) thingie.  this is not a pitch shifter and detunes 
> harmonic overtones into the inharmonic.  but it is totally glitch-free and 
> can sometimes be handy to detune something slightly so that there is not a 
> buildup of energy at a specific frequency (when there is feedback of some 
> sort).  pitch shifters can do that too, but time-domain pitch shifters might 
> have glitches for non-monotonic input and frequency-domain pitch shifters 
> have a huge throughput delay.  also, this glitch-free frequency shifting can 
> be slowly modulated.  might be useful for chorusing.  combined with a pitch 
> shifter and pitch detector, you can shift harmonics without shifting the 
> fundamental (i.e. pitch it up with a pitch shifter and then bring back down 
> the fundamental to the original pitch.)

Yes - the Bode-style frequency shifter is a fun and useful effect. I've done 
several of them for modular synthesizers using these IIR all-pass structures:

With a dsPIC - http://www.modcan.com/bmodules/dualfs.html

With an STM32F303 - http://modcan.com/emodules/dualfreqshifter.html

Also with a dsPIC - http://synthtech.com/eurorack/E560/

There are example soundfiles at the above sites showing some of the subtle and 
radical variations that are possible with different amounts of shift, feedback 
and various shifting waveforms.

Eric
___
dupswapdrop: music-dsp mailing list
music-dsp@music.columbia.edu
https://lists.columbia.edu/mailman/listinfo/music-dsp



Re: [music-dsp] ± 45° Hilbert transformer using pair of IIR APFs

2017-02-05 Thread robert bristow-johnson







 Original Message 

Subject: Re: [music-dsp] � 45� Hilbert transformer using pair of IIR APFs

From: "Ethan Fenn" 

Date: Sun, February 5, 2017 1:39 pm

To: music-dsp@music.columbia.edu

--



> Some very interesting references.

>

> I'm curious what uses people find for the Hilbert transform for in audio.

> An instantaneous amplitude envelope, for use in compressors and other

> envelope-driven effects? Or something else?
using the analytic filter to get the instantaneous amplitude envelope (and, 
also, instantaneous frequency by differentiating phase) is something that works 
only with single sinusoids that are AM'd or FM'd. �for music, i think i would 
LPF
the square of the signal (or run an efficient sliding max algorithm, we 
discussed this a while back) and work with that.
it can also be used to measure phase shift from input to output in a noisy 
environment at specific frequencies (without the phase lag vs. phase lead 
ambiguity).
but
the reason i am most interested is in a frequency shifter. �like the ham radio 
single-sideband (SSB) thingie. �this is not a pitch shifter and detunes 
harmonic overtones into the inharmonic. �but it is totally glitch-free and can 
sometimes be handy to detune something slightly so that
there is not a buildup of energy at a specific frequency (when there is 
feedback of some sort). �pitch shifters can do that too, but time-domain pitch 
shifters might have glitches for non-monotonic input and frequency-domain pitch 
shifters have a huge throughput delay. �also, this
glitch-free frequency shifting can be slowly modulated. �might be useful for 
chorusing. �combined with a pitch shifter and pitch detector, you can shift 
harmonics without shifting the fundamental (i.e. pitch it up with a pitch 
shifter and then bring back down the fundamental to the
original pitch.)



--
r b-j � � � � � � � � �r...@audioimagination.com
"Imagination is more important than knowledge."
___
dupswapdrop: music-dsp mailing list
music-dsp@music.columbia.edu
https://lists.columbia.edu/mailman/listinfo/music-dsp

Re: [music-dsp] ± 45° Hilbert transformer using pair of IIR APFs

2017-02-05 Thread Ethan Fenn
Some very interesting references.

I'm curious what uses people find for the Hilbert transform for in audio.
An instantaneous amplitude envelope, for use in compressors and other
envelope-driven effects? Or something else?

-Ethan



On Sun, Feb 5, 2017 at 10:13 AM, Eric Brombaugh  wrote:

> Yes, I'm using the Hilbert transform to generate an analytic signal for
> use in a Bode-style frequency shifter and also in single-sideband modulator
> and demodulators. The image rejection metric is a critical aspect of the
> performance of these systems and is related to the error from true 90deg
> phase shift.
>
> For my optimization I started with the original 8th order set that was
> given and then used a polynomial curve fit to interpolate those values from
> 8th order to 12th order. Then using those values as a starting point, I
> went into an iterated optimization which dithered the coefficients and
> evaluated the phase shift error, saving any set that reduced the error. The
> end result provided a noticeable improvement in the image rejection and
> I've been using those coefficients in some of my radio designs. One of them
> is in github here:
>
> https://github.com/emeb/iceRadio/blob/master/MCU/f303_ice5_rxadc/audio.c
>
> As I said earlier, this approach to extending the performance of the
> filter is rather "brute force and ignorance", but it got the job done and
> the shift from 8 to 12 poles didn't present a significant increase in the
> computational cost - I've been using ARM Cortex M4F processors with
> single-precision floating point hardware to implement these filters and
> they work well.
>
> Eric
>
> On Feb 4, 2017, at 11:25 PM, robert bristow-johnson wrote:
>
> >
> > by "image rejection", do you mean, for an analytic filter:
> >
> > a[n] = x[n] + j*y[n]
> >
> >where y[n] = Hilbert{ x[n] }
> >
> > the gain difference between the positive and negative frequencies?
> >
> > i guess you're right.  looks like -44 dB on Olli's graph.  that's not so
> great, i guess.
> >
> > is your optimized filter 8th order?  8 real poles or are there some
> complex-conjugate poles in there? i haven't groked why Olli seems to think
> that real poles, symmetrical about the origin, is the best way. it seems
> like a restriction that might cause one to miss the optimum.
> >
> > can you tell us how you designed or optimize the pole loci, Eric?  other
> than some kinda brute force method (perhaps Greg's FDLS) i am still
> thinking about how to approach that.  APFs so the gains stay 1 and we don't
> care about the phase as long as the difference is 90°.  still don't know
> how i might set up an optimization problem.  probably the best measure is
> the negative frequency rejection with regard to the positive frequency gain.
> >
> > r b-j
> >
> >
> >
> >  Original Message
> 
> > Subject: Re: [music-dsp] ± 45° Hilbert transformer using pair of IIR APFs
> > From: "Eric Brombaugh" 
> > Date: Sat, February 4, 2017 10:28 pm
> > To: r...@audioimagination.com
> > music-dsp@music.columbia.edu
> > 
> --
> >
> > > IIRC, when I implemented Olli's coefficients I was seeing about 40dB
> image rejection. My optimized filter gave more like 58dB.
> > >
> > > Eric
> > >
> > > On Feb 4, 2017, at 7:25 PM, robert bristow-johnson wrote:
> > >
> > >>
> > >> sunuvubych Olli. i shoulda known about this.
> > >>
> > >> i dunno Eric, 2/100 radian is about ±0.5°. that's what Olli is
> indicating on Figure 3. appears to be an 8th-order using 4 pole pairs about
> the origin on the real line. (i'm just now groking his design methodology.)
> and he seems to have exceedingly low amplitude variation in the Analytic
> Filter magnitude response. dunno what is lackluster about that. (but i
> haven't checked this out, yet.)
> > >>
> > >> i know that because you can sorta treat group delay (which is a
> function solely of phase) like gain in an all-pass filter, for the purposes
> of optimal filter design technique (like Parks-McClellan or Prony). maybe
> that's what Olli is doing.
> > >>
> > >>
> > >> --
> > >>
> > >> r b-j r...@audioimagination.com
> > >>
> > >> "Imagination is more important than knowledge."
> > >>
> > >>
> > >>
> > >>  Original Message
> 
> > >> Subject: Re: [music-dsp] ± 45° Hilbert transformer using pair of IIR
> APFs
> > >>
> > From: "Eric Brombaugh" 
> > >> Date: Sat, February 4, 2017 8:55 pm
> > >> To: music-dsp@music.columbia.edu
> > >> 
> --
> > >>
> > >> > The original Csound source has a set of coefficients for this type
> of
> > >> > hilbert transform but they don't say how the coefficients were
> derived
> > >> > and the performance is fairly lackluster. The only reference I've
> come
> > >> > across for this was 

Re: [music-dsp] ± 45° Hilbert transformer using pair of IIR APFs

2017-02-05 Thread Eric Brombaugh
Yes, I'm using the Hilbert transform to generate an analytic signal for use in 
a Bode-style frequency shifter and also in single-sideband modulator and 
demodulators. The image rejection metric is a critical aspect of the 
performance of these systems and is related to the error from true 90deg phase 
shift.

For my optimization I started with the original 8th order set that was given 
and then used a polynomial curve fit to interpolate those values from 8th order 
to 12th order. Then using those values as a starting point, I went into an 
iterated optimization which dithered the coefficients and evaluated the phase 
shift error, saving any set that reduced the error. The end result provided a 
noticeable improvement in the image rejection and I've been using those 
coefficients in some of my radio designs. One of them is in github here:

https://github.com/emeb/iceRadio/blob/master/MCU/f303_ice5_rxadc/audio.c

As I said earlier, this approach to extending the performance of the filter is 
rather "brute force and ignorance", but it got the job done and the shift from 
8 to 12 poles didn't present a significant increase in the computational cost - 
I've been using ARM Cortex M4F processors with single-precision floating point 
hardware to implement these filters and they work well.

Eric

On Feb 4, 2017, at 11:25 PM, robert bristow-johnson wrote:

>  
> by "image rejection", do you mean, for an analytic filter:
> 
> a[n] = x[n] + j*y[n]
> 
>where y[n] = Hilbert{ x[n] }
> 
> the gain difference between the positive and negative frequencies? 
> 
> i guess you're right.  looks like -44 dB on Olli's graph.  that's not so 
> great, i guess.
> 
> is your optimized filter 8th order?  8 real poles or are there some 
> complex-conjugate poles in there? i haven't groked why Olli seems to think 
> that real poles, symmetrical about the origin, is the best way. it seems like 
> a restriction that might cause one to miss the optimum.
> 
> can you tell us how you designed or optimize the pole loci, Eric?  other than 
> some kinda brute force method (perhaps Greg's FDLS) i am still thinking about 
> how to approach that.  APFs so the gains stay 1 and we don't care about the 
> phase as long as the difference is 90°.  still don't know how i might set up 
> an optimization problem.  probably the best measure is the negative frequency 
> rejection with regard to the positive frequency gain.
> 
> r b-j
> 
>  
> 
>  Original Message 
> Subject: Re: [music-dsp] ± 45° Hilbert transformer using pair of IIR APFs
> From: "Eric Brombaugh" 
> Date: Sat, February 4, 2017 10:28 pm
> To: r...@audioimagination.com
> music-dsp@music.columbia.edu
> --
> 
> > IIRC, when I implemented Olli's coefficients I was seeing about 40dB image 
> > rejection. My optimized filter gave more like 58dB.
> >
> > Eric
> >
> > On Feb 4, 2017, at 7:25 PM, robert bristow-johnson wrote:
> >
> >>
> >> sunuvubych Olli. i shoulda known about this.
> >>
> >> i dunno Eric, 2/100 radian is about ±0.5°. that's what Olli is indicating 
> >> on Figure 3. appears to be an 8th-order using 4 pole pairs about the 
> >> origin on the real line. (i'm just now groking his design methodology.) 
> >> and he seems to have exceedingly low amplitude variation in the Analytic 
> >> Filter magnitude response. dunno what is lackluster about that. (but i 
> >> haven't checked this out, yet.)
> >>
> >> i know that because you can sorta treat group delay (which is a function 
> >> solely of phase) like gain in an all-pass filter, for the purposes of 
> >> optimal filter design technique (like Parks-McClellan or Prony). maybe 
> >> that's what Olli is doing.
> >>
> >>
> >> --
> >>
> >> r b-j r...@audioimagination.com
> >>
> >> "Imagination is more important than knowledge."
> >>
> >>
> >>
> >>  Original Message 
> >> Subject: Re: [music-dsp] ± 45° Hilbert transformer using pair of IIR APFs
> >>
> From: "Eric Brombaugh" 
> >> Date: Sat, February 4, 2017 8:55 pm
> >> To: music-dsp@music.columbia.edu
> >> --
> >>
> >> > The original Csound source has a set of coefficients for this type of
> >> > hilbert transform but they don't say how the coefficients were derived
> >> > and the performance is fairly lackluster. The only reference I've come
> >> > across for this was Olli Niemitalo's:
> >> >
> >> > http://yehar.com/blog/?p=368
> >> >
> >> > He gives a bit of theory, but the filter pair he provides doesn't give
> >> > great performance.
> >> >
> >> > I was able to use Olli's filter as a starting point for optimization of
> >> > a higher order AP set that gave almost 20dB better image rejection. I
> >> > interpolated the originals to a higher order and then used simulated
> >> > annealing 

Re: [music-dsp] ± 45° Hilbert transformer using pair of IIR APFs

2017-02-05 Thread Olli Niemitalo
typofix: "and their companion poles" -> "and their companion zeros"

-olli

On Sun, Feb 5, 2017 at 1:52 PM, Olli Niemitalo  wrote:

> 90 deg phase difference all-pass filter pairs... Lemme wave my hands a bit:
>
> It's been years, but I recall I first tried a structure with complex
> conjugate pairs of poles (and their companion poles to make the filters
> all-pass). Globally optimizing that using Differential Evolution, the poles
> "wanted to be" near the real line. The ripples in the phase response
> difference of the optimized filters got finer by having two real poles in
> place of each complex conjugate pair of poles. The real poles and real
> zeros of the two filter paths alternate on the real line like a zebra
> stripe black pearl white pearl necklace. One of the paths is delayed
> (z^-1) by one sample, which gives the "center pearl" pole. I think the
> alternating order reflects the fact that a first-order all-pass filter
> gives a 180 deg phase shift end-to-end, and alternating the poles of the
> two paths corrects the phase response difference up and down so that we can
> stay approximately half-way between 0 deg and 180 deg, at 90 deg. One
> optimization here was to make the filter requirements symmetric around
> frequency pi/4, so that each positive pole can have a negative companion
> pole. This symmetry simplifies the all-pass filter computation.
>
> Artur Krukowski's papers were always over my head.
>
> -olli
>
___
dupswapdrop: music-dsp mailing list
music-dsp@music.columbia.edu
https://lists.columbia.edu/mailman/listinfo/music-dsp

Re: [music-dsp] ± 45° Hilbert transformer using pair of IIR APFs

2017-02-05 Thread Olli Niemitalo
90 deg phase difference all-pass filter pairs... Lemme wave my hands a bit:

It's been years, but I recall I first tried a structure with complex
conjugate pairs of poles (and their companion poles to make the filters
all-pass). Globally optimizing that using Differential Evolution, the poles
"wanted to be" near the real line. The ripples in the phase response
difference of the optimized filters got finer by having two real poles in
place of each complex conjugate pair of poles. The real poles and real
zeros of the two filter paths alternate on the real line like a zebra
stripe black pearl white pearl necklace. One of the paths is delayed
(z^-1) by one sample, which gives the "center pearl" pole. I think the
alternating order reflects the fact that a first-order all-pass filter
gives a 180 deg phase shift end-to-end, and alternating the poles of the
two paths corrects the phase response difference up and down so that we can
stay approximately half-way between 0 deg and 180 deg, at 90 deg. One
optimization here was to make the filter requirements symmetric around
frequency pi/4, so that each positive pole can have a negative companion
pole. This symmetry simplifies the all-pass filter computation.

Artur Krukowski's papers were always over my head.

-olli
___
dupswapdrop: music-dsp mailing list
music-dsp@music.columbia.edu
https://lists.columbia.edu/mailman/listinfo/music-dsp

Re: [music-dsp] ± 45° Hilbert transformer using pair of IIR APFs

2017-02-05 Thread Laurent de Soras

robert bristow-johnson wrote:


cool, so it appears from your comments to be real poles.
complex conjugate poles are not considered in the design.  i
wonder why that is?


I’m not the author of the formula, I just implemented it
and don’t understand how it produces these filters.
I guess the poles are real in both all-pass filter chains,
but once they are summed, the resulting filter exhibits
complex conjugate poles.




___
dupswapdrop: music-dsp mailing list
music-dsp@music.columbia.edu
https://lists.columbia.edu/mailman/listinfo/music-dsp

Re: [music-dsp] ± 45° Hilbert transformer using pair of IIR APFs

2017-02-05 Thread robert bristow-johnson



�
cool, so it appears from your comments to be real poles. �complex conjugate 
poles are not considered in the design. �i wonder why that is?
r b-j


 Original Message 

Subject: Re: [music-dsp] � 45� Hilbert transformer using pair of IIR APFs

From: "Laurent de Soras" 

Date: Sun, February 5, 2017 3:03 am

To: r...@audioimagination.com

music-dsp@music.columbia.edu

--



> robert bristow-johnson wrote:

>>

>> so Olli, how do you get your coefficients? (if i may ask?)

>

> If I may reply, I wrote long time ago a C++ library implementing

> this kind of polyphase halfband filter, including a coefficient

> calculator involving elliptic stuff (way beyond my knowledge).

> Check the PolyphaseIir2Designer class:

> 

>

> There is also an ARM/NEON implementation below, not published in

> the main release yet:

> 

>

>





--
r b-j � � � � � � � � �r...@audioimagination.com
"Imagination is more important than knowledge."
___
dupswapdrop: music-dsp mailing list
music-dsp@music.columbia.edu
https://lists.columbia.edu/mailman/listinfo/music-dsp

Re: [music-dsp] ± 45° Hilbert transformer using pair of IIR APFs

2017-02-05 Thread Laurent de Soras

robert bristow-johnson wrote:


so Olli, how do you get your coefficients?  (if i may ask?)


If I may reply, I wrote long time ago a C++ library implementing
this kind of polyphase halfband filter, including a coefficient
calculator involving elliptic stuff (way beyond my knowledge).
Check the PolyphaseIir2Designer class:


There is also an ARM/NEON implementation below, not published in
the main release yet:


___
dupswapdrop: music-dsp mailing list
music-dsp@music.columbia.edu
https://lists.columbia.edu/mailman/listinfo/music-dsp