# [PD] spectral mapping, anyone?

peiman khosravi peimankhosravi at gmail.com
Tue Nov 26 15:07:55 CET 2013

```Hello,

Yes, your description of warp is correct.

Partial detection is more tricky because often the energy in 4 or more FFT
bins amounts to one partial. So firstly, you need to derive the partials
from the FFT data, then you need to quantise the partials' frequencies.

One possible cheat would be to trace the loudest FFT-bins and then transfer
their energy to the bins whose frequencies are nearest to the harmonics of
a given fundamental.

If I'm not mistaken, at a sampling rate of 44100 and an FFT size of 4096,
the frequency of bin 10 would be calculated as (44100/4096)*10=107.66. Just
note that only FFT-size/2+1 bins are usable. That's the Nyquist frequency
(half of the sampling frequency). If you take 107.66 as your fundamental
(and zero all the bins below that) then you can do the following:

For each analysis window...
1- Detect the next FFT bin whose magnitude is above a certain threshold
2- Transfer the frequency and amplitude content of this bin to the nearest
harmonic of the fundamental. So for input bin 15 (and a fundamental
frequency of 107.66) this would be bin 20. The bin number to frequency
mapping is linear so it's easy to calculate.

Even, using fiddle~, you can get the fundamental frequency from the input
and have it change dynamically from window to window.

You're likely to get some bubbly artefacts thought, but once you have a
basic working patch you should be able to fine tune it. So you may want to
group the bins so that you transfer not just the energy in one bin but also
the bins around it. You might also want to do some averaging of the
amplitude of 6 windows or so to avoid rapidly changing values, before you
pass the signal into a threshold detector. I can do this in Csound but I'm
not that familiar with how FFT works in PD and I don't have a patch that
does this. If I get the time I might make one next weekend though and post
it here.

P

<http://spectralkimia.wordpress.com/>*

On 26 November 2013 11:48, Eran Sachs <eransachs at hotmail.com> wrote:

> Peiman,
> It works great! I've been messing various sounds all day now, plus there's
> a thing in my computer with Barry Vercoe's name on it which I find oddly
> elevating.
> However, if I understand the wrap function correctly, it substitutes bin
> values for values of other bins through whatever function you apply. But
> the bins are still all derived from the FFT procedure. Or am I missing
> something there?
>
> What I would like to do is to move from bins to partials, so that they are
> essentially mapped to harmonic overtones of a given fundamental according
> to nearest match. Like a clever phase-vocoder Autotune of some kind.
>
> Is there a way to do that, to the best of anyone's knowledge?
>
> Much obliged,
> E.
> ------------------------------
> Date: Mon, 25 Nov 2013 15:12:50 +0000
>
> Subject: Re: [PD] spectral mapping, anyone?
> From: peimankhosravi at gmail.com
> To: eransachs at hotmail.com
> CC: porres at gmail.com; jaime.oliver2 at gmail.com; pd-list at iem.at
>
> yes csound6 should work on windows too as far as I know.
>
>
>
>
> *www.peimankhosravi.co.uk <http://www.peimankhosravi.co.uk> || RSS Feed
> <http://spectralkimia.wordpress.com/>*
>
>
> On 24 November 2013 22:06, Eran Sachs <eransachs at hotmail.com> wrote:
>
> Thanks Peiman.
> Alas, I'm living the life of a PC/Windows user. AFAICT, no csound6?
> Z
>
> ------------------------------
> Date: Sun, 24 Nov 2013 20:27:39 +0000
>
> Subject: Re: [PD] spectral mapping, anyone?
> From: peimankhosravi at gmail.com
> To: eransachs at hotmail.com
> CC: porres at gmail.com; jaime.oliver2 at gmail.com; pd-list at iem.at
>
>
> With spectral warping you can do any frequency-based manipulation,
> depending on the transfer function. I have one for pd but it requires
> Csound to be installed and a couple of other externals. See attached. On an
> intel mac and with pd vanilla 4.5.3/4 this should just work out of the box
> as long as you have csound 6 installed.
>
> P
>
>
>
>
>
>
> *www.peimankhosravi.co.uk <http://www.peimankhosravi.co.uk> || RSS Feed
> <http://spectralkimia.wordpress.com/>*
>
>
> On 24 November 2013 20:12, Eran Sachs <eransachs at hotmail.com> wrote:
>
> oops, I messed up the names. sorry. Once more, with feeling:
>
> Josep,
> Making harmonic sounds sound inharmonic can be down with spectral
> shifting. Try looking at Hilbert~ or at spec2_shift~ on extended.
>
> But Alexandre, I'd also would be interested in stuff that can manipulate
> the spectrum.
> I also made a little graphic control to all the cross-synthesis objects in
> FFTease. if anyone is interested I can post.
>
> A few years ago I tried to replicate the technique that Trevor Wishart
> refers to as "Spectral Focusing", namely - one that moves the other way -
> from inharmonic to harmonic sonds, by moving from bins to partials (a
> little like FFTease's pvtune~, but moving bins to nearest matching partial
> ).
>
> I'm still looking for such an object. Does anyone have any suggestions?
>
> Zax.
>
> ------------------------------
> From: eransachs at hotmail.com
> To: porres at gmail.com; jaime.oliver2 at gmail.com
> Date: Sun, 24 Nov 2013 21:58:50 +0200
>
> CC: pd-list at iem.at
> Subject: Re: [PD] spectral mapping, anyone?
>
> Alexandre,
> Making harmonic sounds sound inharmonic can be down with spectral
> shifting. Try looking at Hilbert~ or at spec2_shift~ on extended.
>
> But Jaime, I'd also would be interested in that.
> A few years ago I tried to replicate the technique that Trevor Wishart
> refers to as "Spectral Focusing", namely - one that moves the other way -
> from inharmonic to harmonic sonds, by moving from bins to partials (a
> little like FFTease's pvtune~, but moving bins to nearest matching partial
> ).
>
> I'm still looking for such an object. Does anyone have any suggestions?
>
> Zax.
>
>
> ------------------------------
> Date: Sun, 24 Nov 2013 01:05:29 -0200
> From: porres at gmail.com
> To: jaime.oliver2 at gmail.com
> CC: pd-list at iem.at
> Subject: Re: [PD] spectral mapping, anyone?
>
> Hi, I'm Alexandre, I can send you stuff
>
> cheers
>
>
> 2013/11/11 Jaime E Oliver <jaime.oliver2 at gmail.com>
>
> These are older, but I understand E. Lyon might re-release them?
>
> http://www.somasa.qub.ac.uk/~elyon/LyonSoftware/MaxMSP/FFTease/
>
> J
>
>
>
> On Nov 11, 2013, at 7:23 AM, Jeppi Jeppi <jeppiot at hotmail.com> wrote:
>
> Hi,
> just looking for some ready to be used spectral mapping effects
> implemented in pd, anything available?
> Specifically, just a way to slightly remap harmonics to make pitched
> sounds inharmonic.
> There is a paper by Alexandre
> http://www.uni-weimar.de/medien/wiki/images/Dissonance_Model_Toolbox_in_Pure_Data.pdf but
> I couldn't find the link to the sources.
>
>
> Josep m
>
> _______________________________________________
> Pd-list at iem.at mailing list
> UNSUBSCRIBE and account-management ->
> http://lists.puredata.info/listinfo/pd-list
>
>
>
> _______________________________________________
> Pd-list at iem.at mailing list
> UNSUBSCRIBE and account-management ->
> http://lists.puredata.info/listinfo/pd-list
>
>
>
> _______________________________________________ Pd-list at iem.at mailing
> list UNSUBSCRIBE and account-management ->
> http://lists.puredata.info/listinfo/pd-list
>
> _______________________________________________ Pd-list at iem.at mailing
> list UNSUBSCRIBE and account-management ->
> http://lists.puredata.info/listinfo/pd-list
>
> _______________________________________________
> Pd-list at iem.at mailing list
> UNSUBSCRIBE and account-management ->
> http://lists.puredata.info/listinfo/pd-list
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20131126/00511592/attachment-0001.htm>
```