# Polyphonic pitch tracking

**URL:** <https://forum.csound.com/t/polyphonic-pitch-tracking/423>\
**Category:** General\
**Created:** [July 29, 2021, 4:02pm UTC](https://forum.csound.com/t/polyphonic-pitch-tracking/423 "2021-07-29T16:02:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![musicmichaelc](https://forum.csound.com/letter_avatar_proxy/v4/letter/m/ebca7d/32.png) [@musicmichaelc](https://forum.csound.com/u/musicmichaelc)\
**Post date:** [July 29, 2021, 4:02pm UTC](https://forum.csound.com/t/polyphonic-pitch-tracking/423/1 "2021-07-29T16:02:52Z")

</div>

I’ve been looking for ways to track multiple pitches (the frequencies of _multiple fundamental pitches_ and their relative amplitudes) such as when several voices / chords are being played on a piano. The Csound manual only mentioned monophonic pitch tracking opcodes as far as I could tell…

Does anyone happen to know of a **plugin or custom opcode** for Csound that would be capable of doing this?

Though I’d prefer if it were possible to do this _directly within Csound,_ I’m of course open to different ideas, e.g. someone suggested to try [connecting csound to pure data,](https://listserv.heanet.ie/cgi-bin/wa?A2=CSOUND;c56870cb.2107) and I’ve heard of people accomplishing something like this in python, e.g. with `librosa` (though I’m not sure of all the details and how well these work in real time)…

---

<div class="post-metadata">

**Author:** ![rory](https://forum.csound.com/user_avatar/forum.csound.com/rory/32/7_2.png) [@rory](https://forum.csound.com/u/rory)\
**Post date:** [July 29, 2021, 6:50pm UTC](https://forum.csound.com/t/polyphonic-pitch-tracking/423/2 "2021-07-29T18:50:09Z")

</div>

It’s a while since I used Pd, but do you know the name of the object that can do this, i.e., will break a chord into its various different pitches?

---

<div class="post-metadata">

**Author:** ![musicmichaelc](https://forum.csound.com/letter_avatar_proxy/v4/letter/m/ebca7d/32.png) [@musicmichaelc](https://forum.csound.com/u/musicmichaelc)\
**Post date:** [July 29, 2021, 7:42pm UTC](https://forum.csound.com/t/polyphonic-pitch-tracking/423/3 "2021-07-29T19:42:33Z")

</div>

Me too—haven’t used it for a long time, and unfortunately I don’t know yet what the name of the object is—someone suggested it on the [mailing list](https://listserv.heanet.ie/cgi-bin/wa?A2=CSOUND;c56870cb.2107) that I mentioned above, but _for some reason I can’t post any replies there despite having signed up, so I couldn’t ask any follow-up questions…_

---

<div class="post-metadata">

**Author:** ![rory](https://forum.csound.com/user_avatar/forum.csound.com/rory/32/7_2.png) [@rory](https://forum.csound.com/u/rory)\
**Post date:** [July 30, 2021, 8:15am UTC](https://forum.csound.com/t/polyphonic-pitch-tracking/423/4 "2021-07-30T08:15:32Z")

</div>

I don’t think there is anything in Pd that can do this out of the box. I think you would be faced with the same complex issues in Pd as in Csound. If there was something that did this in Pd we could look at porting the object to a Csound opcode.

---

<div class="post-metadata">

**Author:** ![g\_b](https://forum.csound.com/user_avatar/forum.csound.com/g_b/32/208_2.png) [@g\_b](https://forum.csound.com/u/g_b)\
**Post date:** [August 26, 2021, 4:18pm UTC](https://forum.csound.com/t/polyphonic-pitch-tracking/423/5 "2021-08-26T16:18:26Z")

</div>

I’m not aware of such an object in Pd, but I used sigmund~ in the past, with decent results: you don’t have polyphonic tracking, but you can choose how many partials you want to track.  
The overall results depend strongly by the characteristics of the instruments you want to track.

Separating instruments is very difficult: you can try using [timbreID](https://puredata.info/downloads/timbreid) to recognise the instruments that are playing (you need to train the object with prerecorded data, and I don’t know how many instruments can be detected at the same time), but then you will also need to add some logic to extract each instrument from the mix and send it to sigmund~ to track it.  
In the case of a piano, once extracted, you can set how many partials you want to detect. The results won’t be that accurate (it depends on how many notes you play together), but it’s a start!

EDIT:  
Attached a cleaned version of the patch I was using, it can be extended to listen for any number of inputs.  
It already uses timbreID to track the spread of the signal, it shouldn’t be too difficult to use its other analysis capabilities.  
You will need Pd-Extended for this to work, if I remember correctly.  
[MIA\_1.6.pd.zip](https://forum.csound.com/uploads/short-url/s32ZXq3g0x7xL8fnv1f9eb48I9u.zip) (6.1 KB)

EDIT 2:  
It seems that such a tool exists for SuperCollider:

> **[GitHub - musicmichaelc/PolyPitch: The PolyPitch extension for SuperCollider by...](https://github.com/musicmichaelc/PolyPitch)**
>
> The PolyPitch extension for SuperCollider by Nick Collins - GitHub - musicmichaelc/PolyPitch: The PolyPitch extension for SuperCollider by Nick Collins

maybe someone could port it to Csound?
