A while back I multiplied musical pitch frequencies up to their visual spectrum equivalents. Everything worked out fine across the spectrum, yet the notes ‘G’ and ‘G#’ were converted into the same exact RGB value (R = 255, G = 0, B = O) in my conversion program (Spectra). Since this one hitch is all that is messing up the conversion, is there anything I can do to force a differentation between them?
There is no difference between the RGB values of those frequencies; in an intensity-mapping system (RGBY), there might be a slight difference in Y, but it won’t be visible. Everything between 430 and 460 is pretty much red, red, red.
Okay, I’m a musical ignoramus, but were G and G# the two highest frequencies you were trying to map?
IIRC, “R= 255, G = 0, B = 0” is the maximum “red” setting in the various graphics editing programs that I’ve used. So maybe it’s just that you maxed out the red and it couldn’t set any value higher than 255.
Note that all of the pure spectral colors (those in a rainbow) are generally the furthest outside the gamut of an RGB color space, and so suffer the worst approximations.
I don’t know what algorithm Spectra uses to convert light frequencies to RGB values, but perhaps if you could get it to produce 16-bit component values instead of 8-bit, you’d see a difference — in the numbers, if not in the appearance on the screen.
In which case maybe you could transpose your frequencies down a semitone such that 430 is the highest it goes.
No; the pitch ‘F#’ at 407 THz was actually the furthest towards the red end of the spectrum, and translated to ‘Free Speech Red’ (or Crimson Red). The RGB approximation for this frequency was R = 187, G = O, B = 0.
Well, I don’t know about the algorithm, but the RGB color space doesn’t cover everything. The furthest red would probably translate a bit darker, so that 187 red makes sense, but I’d guess that G and G# are both brighter than the brightest red RGB can display.
To test my hypothesis, what does the following A translate to? Is it a pretty substantia jump, as 187,0,0 is to 255,0,0?
The following A translates to dark orange…R = 255, G = 111, B = 0 (It basically just adds 111-green and keeps rest same)
The answer is pretty much given above, but it is worth laying it out.
RGB is not a useful colour space. Especially not if you are using an 8 bit version, but even with infinite precision, it does not cover the full range of human perception of colour. It is not in the least surprising that you get a range of pure spectral colours that map to the same RGB value. As pointed out above, almost all pure spectral colours do not fall within the gamut of RGB at all, so actually an attempt to do the frequency to RGB mapping is bogus even for those values that appear to produce a discrete mapping. Or to put it another way, if you took a pure spectral colour, found the RGB value, and then compared the colour generated from the RGB with the original pure spectral colour, your eyes would see different colours. (The RGB colour space is derived from the common coloured phosphors used in CRT tubes, it has no useful role as a general way of describing colour.)
If you want to talk frequency to colour you should use the CIE value of colour. Pure spectral colours that are visible to humans do have a unique value in this space.
I was going to suggest you’d need to allow negative values to accurately represent colors, but that seems to mostly be necessary between green and blue, and might not solve the problem. See the second image in the section the CIE RGB color space. You’re having problems at the right side of that image, where green and blue are both zero and red isn’t. To solve your problem, it seems like letting G be midway between F# and G#, say (221, 0, 0), would be reasonable.
Note that the color space on a monitor, if that’s what you’re using, is smaller than shown in the first image in that section (i.e., the triangle is smaller).
In fact — though I don’t know what the OP’s purpose is exactly — I think it would be better to map musical notes to hue angles, with one semi-tone corresponding to 30 degrees, so that an octave makes a full circle.
petew83, is there a reason you need to mathematically calculate the colors? Can you just modify the color correspondance you have to make it better aesthetically?
That is an interesting idea, although it needs a special implementation. The simple HSV colour representation fails in the same manner that RGB does. However if you take the angle from the centre of the CIE space to the location of the colour you could do this. To be more true to the eye, and also to get an octave cycle you would need to modify the idea slightly. Only those colours along the curved perimeter of the CIE space are pure spectral colours. Everything else, including the straight line across the bottom are colours that our eyes see, but are made up of a mix of spectral colours.
So, a simple transform that takes the angle fro the centre (i.e. the white position at 0.33 0.33) to the desired colour, and then does a linear transform to elide the straight line across the bottom. You would need to modify the this slightly - the eye sees very close to one octave of colour, but not quite. To have a huge angle that covered exactly one octave per 360 degrees you would need to include some frequencies we can’t see. (Octarine perhaps?)
This is a very interesting point that you raise: pitch frequencies rise logarithmically, while you are proposing to divide the ‘hue octave’ into 12 equal spaces. Is there a reason why the color divisions should be linear and not logarithmic?
Part of my thinking behind a direct mathematical mapping was that although sound waves and visual light waves are physically very disparate, they are both taken in through a human sensing apparatus, and then processed by the same brain. Moreover, any form of qualia seems like it should have the characteristic of creating a maximum amount of qualia variance within its domain to optimize perceptual efficiency.
Therefore, is it possible that there might be some sort of a shared essence between a sound frequency (in hundreds of hertz) doubled all the way up to its visual color frequency (in hundred-trillions of hertz)?
If this direct pitch-to-hue multiplicative correspondence is completely offbase, is there still a more general correspondence between pitch octave and hue octave?
The first step of the process is to produce an accurate mapping of pitch-to-hue, and to understand how this mapping should be produced. The task seems a bit nontrivial at this juncture for me, either because of an inapt metaphor, or (hopefully) because of my lack of expertise in visual color.
Thanks for the replies so far…I’m still digesting them
It would be kind of cool if you could transpose a simple tune or even more complicated harmonies into the visual spectrum. Is that where you’re ultimately going with this? It sounds like RGB isn’t the best colour space for your needs though.
On my laptop in AdobeRGB, 185, 30, 30 was the most intense red i could get that’s in-gamut. Increased R values as well as decreased B & G levels both pushed the color out of gamut. You may well be getting a different color that you just can’t distinguish.
How do I convert THz frequency to CIE color?
So you’re saying to move ‘G’ a little bit towards crimson. Good idea, and it might be the only available simple compromise, but I’d rather not stray from the exact mappings if possible.
You can use an on-line table. Convert frequency to wavelength to use the tables. And remember to apply
x = X / (X+Y+Z)
and
y = Y / (X+Y+Z)
As others have suggested, this will be, at best, but a first step in a solution to your underlying problem. Converting to RGB and getting points outside a (0,255) range is avoidable: Just apply a linear function to dictate a (0,255) maximum range.
But as you’ve seen, CIE values don’t vary equally across the spectrum.
How do you plan to render the difference between C and high C?
The easy way is to simply look them up on the colour chart.
Wavelength = velocity/frequency, then look around the curved edge of the CIE chart. Find your wavelength, get the coordinates off the chart axes. This site is a good place to start CIE Color System
If you want a computational formula, it is somewhat messy. The definition of the space uses a standard set of sensitivity values for the eye, at 5nm intervals. For a spectral colour it is easier as you only need to consider one interval. The contribution of each of the three channels is then convolved to produce a cartesian pair, which is the location in the space. You can find the various tables of numbers needed on the CIE website here: http://files.cie.co.at/204.xls
I am not entirely sure I understand what you are getting at here, but I think it is probably misconceived. The way the eyes senses color and the way the ear senses pitch are very different, and although the data is processed by the same brain, the initial processing, at least, happens in quite different areas of that brain.
Color perception depends on just three cone types, each with different spectral sensitivity curves, and the colors we subjectively see (and can discriminate) depend (to simplify quite a bit) upon the differential responses of the different cone types. Outside the laboratory, pure spectral colors are rare to non-existent: most of the colors that we actually see consist of mixtures of various wavelengths, even when they look like pure “primary” colors or are indistinguishable from some pure spectral color. Also, quite frequently, quite different mixtures of wavelengths can give rise to the exact same subjective color (a phenomenon known as “metamerism”).You are thus quite mistaken in thinking that color perception achieves, or even aims at, anything like “a maximum amount of qualia variance within its domain”. On the other hand, we can see, and distinguish, many colors that are not in the spectrum at all. Brown is the most obvious example, but another, surprisingly, is subjectively pure red. The seems to be no single, pure, monochromatic wavelength of light that most people will accept as a pure red that does not look either a little bit orangey or a little bit purplish, but by mixing wavelengths appropriately a pure looking red can be produced.
Pitch perception, by contrast, seems to arise from a process that is a lot closer to a direct measurement of frequency. The inner hair cells of the cochlea, which are the receptor cells of the ear, are arranged so that their frequency response (which, I believe, depends mainly simply upon their length) varies continuously along the length of the organ. There are complications here too however. In particular, the cochlea also contains what are known as outer hair cells (larger and closer to the entrance to the cochlea than the inner ones). These are not thought to be sensory receptors at all. Instead, they are motoric, and beat spontaneously producing acoustic waves within the fluid that fills the organ. Thus, the acoustic waves that actually stimulate the inner hair cells, which signal to the brain, are the product of the interference between the frequencies of the incoming sounds and the waves produced by the outer hair cells. What actually stimulates the inner cells may be the beat frequencies arising from this interference. It is thought that this allows for selective tuning of the cochlea, so that certain frequencies are amplified and others suppressed, and, probably, the frequency at which the outer hair cells beat can be actively varied (efferent neurons from the brain do connect to then) so as to be able to better detect different frequencies and frequency combinations according to the needs of the moment.
Neither color perception nor, especially, pitch perception are fully understood, but I think it is clear that they work very differently, and cannot really be brought into direct correspondence in the way that you suggest. It may be possible to find psychological correspondences between pitches and colors (basically by asking people about it, and statistically analyzing their answers, which may or may not turn out to have some consistency and pattern), but it does not seem that they could be based in any direct way on the underlying sensory physiology.