[aubio-user] Phase vocoder: Custom bands

Thomas Fischer Thomas.Fischer at xjtlu.edu.cn
Fri Nov 24 01:57:26 CET 2017


Dear Paul,

OK - I am beginning to get my head around how this works. And my code now works well enough for the demonstration I need. Thank you very much for your kind advice!

Just one question to make sure I am getting this right:

FFT produces as many 'bins' in the frequency domain as there are samples in the time domain. That means that the bins of the output will in every case be determined by the frequencies actually present in the input signal?

In other words: There is no way for spec_weight to target specific frequency bands in absolute terms when the contents of the input signal is unknown/random, and this results in a different (relative) range of frequency bins?

Does that make sense?
Tom

PS: Your thesis looks astonishing. I hope you enjoy your work as much as it looks you do.


________________________________________
From: aubio-user [aubio-user-bounces at aubio.org] on behalf of Paul Brossier [piem at aubio.org]
Sent: Tuesday, November 21, 2017 7:48 PM
To: aubio-user at aubio.org
Subject: Re: [aubio-user] Phase vocoder: Custom bands

On 11/21/2017 10:09 AM, Thomas Fischer wrote:
> Dear Paul,
>
> thank you for your reply and for your helpful suggestion - this looks
> very promising.
> Unfortunately, I haven't been able to get this to work. Please see my
> attempt below. It returns this error:
>
> spectrum.norm *= spec_weight
> ValueError: operands could not be broadcast together with shapes (257,)
> (2048,) (257,)

Hello Thomas,

As the error message indicates, both vectors should have the same size.
If you create a phase vocoder with size N, the norm vector will be N/2+1
long.

Here you used win_s = 512, so spec_weight should be 257 long.

Best, Paul

>
> What am I doing wrong?
>
> Thanks a lot and best regards,
> Tom
>
>>>>
>
> #! /usr/bin/env python
>
> import sys
> from aubio import source, sink, pvoc
> from numpy import arange, exp, zeros, ones, concatenate
>
> if len(sys.argv) < 2:
>     print('usage: %s <inputfile> <outputfile>' % sys.argv[0])
>     sys.exit(1)
>
> samplerate = 0
> if len(sys.argv) > 3: samplerate = int(sys.argv[3])
> f = source(sys.argv[1], samplerate, 256)
> samplerate = f.samplerate
> g = sink(sys.argv[2], samplerate)
>
> win_s = 512 # fft size
> hop_s = win_s // 2 # hop size
> pv = pvoc(win_s, hop_s) # phase vocoder
>
> # spectral weighting vector
> spec_weight = concatenate ( [
>     zeros(88),
>     ones(25),
>     zeros(165),
>     ones(25),
>     zeros(165),
>     ones(25),
>     zeros(165),
>     ones(25),
>     zeros(165),
>     ones(25),
>     zeros(165),
>     ones(25),
>     zeros(165),
>     ones(25),
>     zeros(165),
>     ones(25),
>     zeros(165),
>     ones(25),
>     zeros(165),
>     ones(25),
>     zeros(165),
>     ones(25),
>     zeros(35)
>      ])
>
> total_frames, read = 0, hop_s
> while read:
>     # get new samples
>     samples, read = f()
>     # compute spectrum
>     spectrum = pv(samples)
>     # apply weight to spectral amplitudes
>     spectrum.norm *= spec_weight
>     # resynthesise modified samples
>     new_samples = pv.rdo(spectrum)
>     # write to output
>     g(new_samples, read)
>     total_frames += read
>
>
>
>
>
> _______________________________________________
> aubio-user mailing list
> aubio-user at aubio.org
> https://lists.aubio.org/listinfo/aubio-user
>

_______________________________________________
aubio-user mailing list
aubio-user at aubio.org
https://lists.aubio.org/listinfo/aubio-user


More information about the aubio-user mailing list