Contents



Going Beyond the Basics

Next
 

Text Output and Formatting

The fact that GUI pins and connections are bidirectional adds a new capability to SynthEdit projects: the ability to output dynamic text.

Using this new capability to full advantage was one of my main motivations for creating the DH_Sub-ControlPak. Its modules enable you to:

  • insert numeric values into a string of text

  • select text strings from an array or list

  • create custom lists

  • combine text strings from different sources

  • display text in a variety of fonts, sizes, and colors that can be changed on the fly

Detailed descriptions of the modules are included in the DH_Sub-ControlPak User's Guide, and won't be covered here. Instead, we'll focus on simple examples that demonstrate how various text formatting and output tasks can be accomplished.


Inserting Numbers into Text

Let's say we'd like to display units of measure with a control's readout in the same display. This requires combining a variable numeric value with a text abbreviation.

The key to this trick is a little module called DH_Format.

It takes as input a text Format string, and one or more numeric (voltage) variables. The Format string includes placeholders that indicate where the numeric values are to be inserted. The placeholders are called format specifications, because they allow you to specify things like how many decimal places to display.

All format specifications start with a percent sign (%), and end with the letter f.

A format specification of the following form will do what you need in most cases:

%[number].[number]f

  • The first number is the minimum field width to use. You can leave it blank if you don't care.

  • The second number, after the decimal point, is the number of decimal places to display.

So, %6.2f will display a numeric value with 2 decimal places in a field at least 6 characters wide (right-justified, padded with spaces).

Except for the format specifications, the characters in the Format string are just copied as they are to Text Out.

If I use a Format string of "Center Freq. = %5.0f Hz" and the value of the Var input is 500, the Text Out will be "Center Freq. = 500 Hz".
Center Freq. = %5.0f Hz------> ------>Center Freq. = 500 Hz
500------>

To the right are the structure and panel views of a cutoff knob that displays a filter cutoff frequency in Hz. The simple Format string has been entered directly into the DH_Format's Properties:

Here's the structure inside the Knob container:

top

Next