Data AcQuisition And Real-Time AnalysisScope - Spectrum - Spectrogram - Signal Generator
Software for Windows
Science with your Sound Card!
Contact us about
Spectrogram (Sgram) Color Palette Dialog
This dialog allows you to create, modify, save, or load Spectrogram color palettes. (Note that you can also do these things via macro operations on arrays; see Copy Spectrogram Palette To/From Buffer Block under Macro Array Copy/Swap Operations.) Additionally, the dialog allows control over the White and Black key colors in Pitch Track mode.
A color palette is a sequence of 256 colors that will be assigned to a specified range of spectrum levels. The palette is only the set of colors, independent of any dB range that they may represent. (You can change the dB range via PgUp/PgDn keys, or by dragging the values of the color bar on the right end of the Spectrogram display, or by direct entry into the upper and lower controls to the right of the color bar.)
The Spectrogram can resolve 256 discrete spectrum levels. The actual dB range covered by these levels is divided up into 256 equal dB steps, each assigned a color index number from 0 (softest level) to 255 (loudest). For each index number there is an associated color that will be shown wherever the spectrum level falls within that step's boundaries.
Each color index has a triplet of Red, Green, and Blue (RGB) color component values associated with it to describe the color, with each component able to range from 0 to 255. If all three are set to 0, the color is black. If all are set to 255, the color is bright white. If all three are set to any other value, but all equal, the color will be some shade of gray.
All other colors can be formed by changing the contributions of the individual RGB components. Note that this is additive (light) color mixing, not the subtractive (pigment) color mixing that you learned in grade school. Note that you do not need to open this dialog to change its controls directly via macro commands.
Here are a few examples:
255,0,0 = Red 0,255,0 = Green 0,0,255 = Blue 0,255,255 = Cyan 255,0,255 = Magenta 255,255,0 = Yellow
The above colors are the brightest (most saturated) forms; as you reduce all the initial 255-value components proportionally toward zero, the colors become dimmer and closer to black. Conversely, if you raise all the initial 0-value components toward 255, the colors become paler and wash out toward white.
Daqarta allows any color index to be set to any RGB triplet. However, the most useful color palettes are those where the colors change smoothly with index, such as brightest or lightest at 255, down to darkest or black at 0. More commonly you will want the colors to change hue, not just brightness, as the index changes. As a simple example, you might have index 255 set to bright red (255,0,0), smoothly changing to deep blue (0,0,255) at an index of 0.
Daqarta can create the smooth color changes automatically. You specify the top index and RGB values, and the bottom index and RGB values, and Daqarta fills in all the colors between. For example, to get the Red-to-Blue palette mentioned above, you first make sure the palette is unlocked (more on this later), set Top Index to 255 and its RGB values to 255,0,0, then set Bottom Index to 0 and its RGB values to 0,0,255. That's it!
The palette is shown as a color bar at the left side of the dialog. If a Spectrogram is currently displayed, the palette is also shown with the current dB steps at the right end of the Spectrogram.
But what if you want several intermediate hue changes, such as Red-to-Yellow-to-Green-to-Cyan-to-Blue? Then you use a piecewise approach: First set Top Index to 255 with RGB at 255,0,0 and Bottom Index to 192 with 255,255,0. The top quarter of the palette will run from Red to Yellow.
Now set Top Index to 192. Setting the index causes the current RGB values for that index to be shown, and since we just set those to Yellow, no further change is needed there. Set Bottom Index to 128 and set its RGB values to 0,255,0 and that quarter of the palette will run from Yellow to Green.
Use the same approach to set the 128-64 range to run from Green to Cyan, then set the 64-0 range to run from Cyan to Blue.
When the Top or Bottom Index limits change, the color gradient fades between whatever RGB values happen to be set from the prior palette. When you set new RGB values, the gradient adjusts to match.
In this example, everything worked fine because we always moved in the same direction. When we went to create the next lower index range, we first set the Top index to equal the Bottom, so of course there was no gradient change. Then we changed the Bottom index and the gradient changed to match whatever old RGB was there, until we adjusted the Bottom RGB to the desired target.
But suppose we look at the new palette we've just created and decide that the yellow portion is too narrow, and the green portion too wide. We'd like to split the present Yellow-to-Green range into two unequal ranges; the shade of Yellow-Green that now falls at midpoint index 160 will instead be at 144. The upper range will thus be from the present Yellow at 192 down to Yellow-Green at 144, and the lower range will be from that Yellow-Green to full Green at 128, where it is at present.
But the current Top Index was left at 64 and the Bottom at 0 from the prior change. If we now change Top to 192, we will suddenly overwrite the gradient we just created with one that runs from Yellow at 192 to Blue at 0. Similar problems would result if we instead tried to set Bottom to 144. (Note that it's OK to have Bottom greater than Top, however.)
We need a way to tell Daqarta to not automatically create a gradient when we simply change index values. To do that, simply activate the Lock Palette button at the top of the dialog before you change indices. The RGB components will be disabled and grayed out, though changing indices will still update the respective RGB values... there just won't be any palette changes.
After both indices are correct for the 192 to 144 range, unlock the palette and change the RGB values as desired. Repeat for the 144 to 128 range and you're done.
Besides showing the current palette, the color bar at the left side of the dialog has another use. You can click anywhere on it, then click the color square for the Top or Bottom Index and it will match the clicked color. This can be useful in cases like the above example, where you want to pick a particular shade of Yellow-Green to use at the 144 index.
With Palette Lock active, you click on the shade you prefer, then click on the color square for either Top or Bottom Index just to read the RGB values. Remember those values, but ignore the actual index. Now set Top and Bottom to 192 and 144, unlock the palette, and enter the new RGB values to Bottom.
When the Spectrogram / Pitch Track dialog is open, SgColorDlg=1 opens the Spectrogram Color Palette dialog, SgColorDlg=0 closes it, and SgColorDlg=x toggles between open and closed.
When the Color Edit dialog is open, ColorSgDlg=1 opens the Spectrogram Color Palette dialog, ColorSgDlg=0 closes it, and ColorSgDlg=x toggles between open and closed.
Note that you do not need to open the Spectrogram Color Palette dialog to change its controls directly via macro commands.
Questions? Comments? Contact us!We respond to ALL inquiries, typically within 24 hrs.
Over 30 Years of Innovative Instrumentation
© Copyright 2007 - 2017 by Interstellar Research
All rights reserved