Data AcQuisition And Real-Time Analysis
Scope - Spectrum - Spectrogram - Signal Generator
Software for Windows
Science with your Sound Card!
The following is from the Daqarta Help system:



Spectrum Analyzer

Signal Generator

(Absolutely FREE!)


Pitch Tracker


DaqMusiq Generator
(Free Music... Forever!)

Engine Simulator

LCR Meter

Remote Operation

DC Measurements

True RMS Voltmeter

Sound Level Meter

Frequency Counter
    Spectral Event

    MHz Frequencies

Data Logger

Waveform Averager


Post-Stimulus Time
Histogram (PSTH)

THD Meter

IMD Meter

Precision Phase Meter

Pulse Meter

Macro System

Multi-Trace Arrays

Trigger Controls


Spectral Peak Track

Spectrum Limit Testing

Direct-to-Disk Recording



Frequency response

Distortion measurement

Speech and music

Microphone calibration

Loudspeaker test

Auditory phenomena

Musical instrument tuning

Animal sound

Evoked potentials

Rotating machinery


Product test

Contact us about
your application!

Spectrogram (Sgram) Color Palette Dialog

Controls: Sgram/PT Dialog >> Colors
Macros: SgColorDlg, ColorSgDlg

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.

It can be opened via the Color button at the top of the Spectrogram Control Dialog, or via the Spectrogram button at the top of the Colors & Line Styles (ALT+E, C) dialog.

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.

As a safety precaution, it's a good idea to keep the palette locked when you are not changing it. It's also a good idea to Save palettes you like, so you can return to them later.

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.

Macro Notes:

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 Colors & Line Styles 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.

See also Spectrogram / Pitch Track (Sgram/PT), Spectrogram / Pitch Track Controls


Questions? Comments? Contact us!

We respond to ALL inquiries, typically within 24 hrs.
Over 35 Years of Innovative Instrumentation
© Copyright 2007 - 2023 by Interstellar Research
All rights reserved