patch for pitch to color

ethor's icon

hi all, as a jackaroo I'm looking for a patch which can pick a color based on incoming sound pitch (voice). I there anybody who can help me? thnx

metamax's icon

Pitch and beat detection aren't necessarily trivial. A voice isn't just a "a pitch". It's more complex. Your sound source will influence your method. Search the forum for different approaches.

Once you have actual pitch data (frequency values, MIDI notes, etc), you can choose how to map the values to color. In general, you are probably best sticking with a hue-based color space like HSL, HSV, etc. because the variables are more analogous to sound. One of the more common ways is to scale the 12 semitones to 360 degrees of hue. You can also map amplitude to lightness or duration to saturation. Things like that.

ethor's icon

thnx for your reply.. I was thinking of fiddle...but I like your 'simple' idea.. [though even that's kind of complicated for me:-p]

metamax's icon

Once you get your sound source / pitch detection thing figured out, post a patch and I will help you turn the data to color. Good luck with your project.

ethor's icon

really? great thanks in advance..

ethor's icon

this what I've got so far..

try-volume-pitch-essential.maxpat
Max Patch
metamax's icon

Here is something that uses pitch~ to convert input tones to color. Specifically, frequency to hue and amplitude to value. Frequency changes the "color" and gain control the overall "brightness" or value of the color.

Hue is polar and measured in degrees.. so you need to set a frequency range to map to 0-360.

Using cycle~ as a source makes it a bit clearer to illustrate. You can always plug in a different sound source.

Also, this patch uses a jasch object (hsv2rgb), so you'll need to grab that library if you don't have it. Otherwise, I can post an hsv2rgb abstraction built with max objects as an alternative.

Max Patch
Copy patch and select New From Clipboard in Max.

ethor's icon

wow that's really great! thanks very much.
I'm trying to figure out about the hsv2rgb thingy.. If understand it right: it's a small piece that arranges HSV to RGB. I found it on jash-downloads and I installed it in max/file/install (hope this is right)
anyway great thanks to you Metamax. but if I run into problems with this project can I ask you again?

metamax's icon

Yeah, it takes hue, saturation and value and converts them to red, green and blue.

The benefit of using HSV or HSL colorspace is that it puts all of the hue info into one channel (rather than needing 3 as with RGB) and it allows you to control brightness and colorfulness separately.

metamax's icon

Oh and yeah, I'll help you out. But you will learn more if you do it yourself. Sometimes you just have to sit with it.. until your brain hurts.

ethor's icon

yeah right! You gave me a good start though. I'm working with the patch right now, and trying to understand it better. Anyway, thanks again for your help and when I get this project working I'll post it to you.
cheers!

ethor's icon

Hi there again, I almost got it.. do you have for me [pitch~ 2048 512 4096 blackman72 0 1 10 3] or is it just the pitch~ object?

metamax's icon

Not sure I understand your question. You included the pitch~ object in your original patch. That's why I used it. It's a CNMAT external. Everything after the ~ is an argument.

ethor's icon

never mind.. got it!!

ethor's icon

I promised to post the patch for my installation so here it is.. It just needs some minor justifications
many thanks for your contribution!

Synesthesia_DEF.maxpat
Max Patch