RGB colour analysis...

madmaxmsp@hotmail.com's icon

Hello forum users,

I am attempting to create an RGB colour to sound frequency converter and I am hoping to use the light frequency scale (visible light spectrum) in relation to sound frequency (20 to 20,000Hz).

Please see the link below for the visible light spectrum colour scale.

Lower light frequencies (red, orange, yellow) will relate to low sound frequencies rising up the sound frequency spectrum to high frequencies representing blues, purples and violets.

I was wondering if such a thing had been done before within the Cycling 74 world and if not if anyone has any suggestions as to how this could be done.

I'm currently reviewing ideas using simple mathematics, with greater/less than or = to objects being used to categorise sections of the RGB colour scale and sound frequency scale. However, this will be time consuming and assistance would be appreciated!

Thank you,

Max.

Gregory Taylor's icon

Providing you have some facility with using Max generally, it's
not all that difficult to to, but the issue is going to be that of
making
decisions on how you want to map the input data to output data.
In my experience that's strictly idiosyncratic territory: there'll be
as many mappings as people who've tried to do it.

The good news about working with Max is that once you come
up with a basic framework, you can tweak it to your heart's
content. You could even wind up deciding that it's not such an
interesting idea, even. But the cool bit about Max is that
you can actually come to the point of discarding an idea,
instead of having spent so many hours on something that you're
kind of committed to do *something* with it since it took you so
much time. And that's a good thing.

gregory

Have you taken a look at how RGB values map to the "color
wheel?" There are some things there that you may find bedeviling
on their own terms....

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

Joost Rekveld's icon

Hi,

this idea has been around about as long as the spectrum has been around
for
(the first recorded attempt to play colour-music along these lines
dates from 1742, mind you)

if you're interested, you could read:

http://www.lumen.nu/rekveld/files.html
scroll down and click on 'Rimington'

these efforts were basically abandoned because colour is not very
similar to pitch, you need three dimensions to describe colour, and one
to describe pitch.

This is not to discourage you, I think any linkage between anything can
yield interesting results, but I would regret it if you'd suddenly
start thinking low sound are red and high sounds blue because of
looking at the spectrum...

to do it, i think you need to convert RGB to HSL or HSV (there are
objects in jitter to do this),
and map the hue in some way to your sound frequency..

i'm curious,

Joost.

Gregory Taylor's icon

On May 23, 2006, at 5:15 PM, Joost Rekveld wrote:

> This is not to discourage you, I think any linkage between anything
> can yield interesting results, but...

one word: metasynth!

lists@lowfrequency.or's icon

Those are definitely interesting, but the link between color and
sound is WAY older.
Athanasius Kircher wrote about it in the 1600s, Goethe theorized
about them, and now recently there is a lot of research that shows
that portions of the brain that process color also process sound.
Check out Synesthaesia on google if you're interested in one aspect
of it.

It's all arbotrary, though; there is no universal formula for
converting color to sound, so whatever you come up with will be
right. Less arbitrary is the relationship between luminosity and
sound, where dark implies a "heavier" object, and light implies, of
course, a "lighter" object. So you could calculate the luminosity of
an arbitrary color palette, and fit it into a scale that way.

Another interesting relationship is how we perceive individual colors
in darkness/lightness - I found a book on color perception with a
table showing human perception of colors shown under low-light to
bright light, showing how above a certain threshold we perceive
yellow as yellow but below it, it appears brownish. If I were to
create a map, I'd use that as a guide, it was (slightly) more linear
than the 3D HSV space. Sorry but I can't find the reference right
now, unfortunately.

-evan

Joost Rekveld's icon
madmaxmsp@hotmail.com's icon

Thanks for your replies, this post has certainly revealed some extremely interesting information!

My work is fairly basic at this stage. I have created a patch that allows for scanning of an image using a mouse or tablet. I have managed to source X/Y co-ordinates, R/G/B values and control over a 4 output panning area from this patch so far. The final element is to add a sound conversion stage and the heart of this will be a colour to sound frequency conversion, alongide saturation values, 4-speaker panning and pressure (if tablet pen is used).

By reviewing the swatch object I can see that RGB values correspond to the light spectrum (in regards to the swatch's arrangement from left to right). The values are clear, with Red creating 255-0-0, with green increasing to form orange and then yellow, then red removed to form green, blue added to form light blue and green removed to create darker shades of blue with red added once again to create purple and finally violet. Saturation corresponds vaguely to the brightness of the colour (I will most probably use this value to control volume).

I was wondering what process I might use to map this R/G/B value change to the sound frequency spectrum. As noted, I can source RGB values from scanning an image, I now want to relate them to a particular frequency and my knowledge of mathematics is too minimal to do so! I would like to follow the light frequency spectrum as noted before (this is quite important as rules will be written to assist listeners).

All help would be very welcome. I've played with less/greater than or equal to arrangements but I end up in quite a mess! I would like the frequency flow to be as smooth as possible, without painful jumps from frequency to frequency (red going suddenly to violet might cause a few issues)!

All advice welcome as always. Thanks for your help so far.

Max.

Jean-Marc Pelletier's icon

I think you need to study colourspaces a bit more thoroughly. http://en.wikipedia.org/wiki/Colorspace

RGB is but one of many possible ways to represent colour data. For what you want to do, it is far from the most useful. As has been previously mentioned, what you are looking for is hue. This can be obtained in Jitter using the jit.rgb2hsl object. Instead of containing argb values, your 4-plane matrices will now hold alpha, hue, saturation and luminosity.

What your are seeking to do is map hue to pitch. There is a problem, however. Hue is a circle. A pixel with a hue of 0, and one with a hue of 255 are both going to look red. Not only that, saturation and luminosity being equal, they are going to be all but indistinguishable from each other. Think of hue as a chronometre: if I measure something occuring at 59 seconds, and the next event is at 2 seconds, you'd be wrong to think the two events were 57 seconds appart. Hence, you have a problem: mapping something cyclical (hue) to something linear (pitch).

> By reviewing the swatch object I can see that RGB values correspond to the light spectrum (in regards to the swatch's arrangement from left to right). The values are clear, with Red creating 255-0-0, with green increasing to form orange and then yellow, then red removed to form green, blue added to form light blue and green removed to create darker shades of blue with red added once again to create purple and finally violet. Saturation corresponds vaguely to the brightness of the colour (I will most probably use this value to control volume).
>

cw's icon

well.. could always link hue to a shepard scale. thats plenty circular :)

also, to deal with the sudden jumps, try smoothing the data out with a line~ object using the time inlet to control slew.