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!

Channel Select Macro

Macros: Ch, Ch#n

Channel Select:

Certain macro functions require that a channel number be specified. Data Point Functions (Wv(), Sp(), and Av()) allow the channel to be specified as an explicit parameter preceding the index parameter, or it may be optionally set ahead of time with the Ch command so that only an index parameter is specified by the function.

Sigma (Summation) Functions (wSig(), BwSig(), sSig(), and BsSig()) must always have the channel set ahead of time; these functions take two index parameters only.

Wv(), Sp(), Av(), wSig(), and sSig() require that the Ch value be in the range of 0-3:

  • 0 = Left In
  • 1 = Right In
  • 2 = Left Out
  • 3 = Right Out

You can use Ch with Range?V, RangeDlg?V, GainDlg?V, and Atten_G?V to query the range value for the indicated channel.

Buffer sigma functions BwSig() and BsSig() use the Ch value to select macro arrays Buf0 to Buf7.

Ch can also be used with BufV instead the explicit digit in Buf0 to Buf7 to select an array. This same approach works with ArbV, MemArbV, PlayV, and StrV.

Similarly, Ch can be used with the Button Select macro as WaitBtns#V to specify a button for setting or labeling, or as UA=WaitBtns?V to query a button state.

(Please note that other commands have #V and/or ?V forms that have nothing to do with Ch, including Buf0#V to set Vertical range, LogName#V to specify .CRV file, Enable#V to enable or disable the {\b Vol / dB} button, Port?V to read a Port value, and Posn?V to read Pitch Track peak magnitude.)

Commands that allow specific channel selection via two-letter prefixes LI., RI., LO., or RO. can alternatively use the Ch. prefix to allow programmable control. Examples are Ch.Disp=1 to set a display channel, Ch.Curve0=1 to apply a Spectrum Curve, or Ch.TiltdB=3.01 to set dB/Octave for a Spectrum Tilt.

You can use Ch to select the Stream of the Generator that a macro command will apply to. For example, instead of the specific L.0.ToneFreq=F, you can use Ch.ToneFreq=F. That allows a WHILE loop to set multiple streams by stepping through Ch values. In this use, the streams are numbered 0-7:

    0  =  L.0.   Left Stream 0
    1  =  L.1.   Left Stream 1
    2  =  L.2.   Left Stream 2
    3  =  L.3.   Left Stream 3
    4  =  R.0.   Right Stream 0
    5  =  R.1.   Right Stream 1
    6  =  R.2.   Right Stream 2
    7  =  R.3.   Right Stream 3

Note that there is only one global Ch value, which must be shared by the above functions. See Multitasking Variable Usage under Multitasking Macros for methods to allow different tasks to use different Ch values.

You can read Ch just like any other variable to get the value that has been previously set.

For input and output channels (but not buffer numbers), you can also query Ch to see if a particular channel is active. For example, Ch?2 returns 1 (True) if channel 2 (Left Out) is active, or 0 (False) if not. You might want to do this to limit your use of data point or sigma functions to active channels only. (Applying one of these functions to an inactive channel returns 0, which could be confused with valid data.)

Queries only apply to input and output channels, not buffer numbers. Ch?4 to Ch?7 always return 0.

Alternatively, instead of a Ch?N query, you can use the chan() function (see Channel Status Function under Macro Math Functions), which allows you to use a variable or expression to specify the channel to be validated. This simplifies a Custom Control to select the channel to be set (say, for a Custom Meter).

A string expression can use the Channel Name format option (c) or (C) to specify that any variable in the 0-3 range be shown as a channel name instead of as a value. For example, if Ch has been set to 1, then Mtr0=Ch(c) would be displayed as "Right In", while Mtr0=Ch(C) would show the short form "R.I.".

You may also use a special query to determine the lowest visible channel number (active, and selected via its Display Channel button at the lower left of the display area). Ch?c returns the lowest of any (input or output) channel 0-3, Ch?i returns the lowest input 0-1, and Ch?o returns the lowest output 2-3. These queries allow a macro to specify a channel to use, without hard-coding a specific number. In operation, the channel can be changed just by toggling the relevant Display Channels.

Special Bit Channel Select:

The special Bulk Read Port commands BufV#Dn=Port?D and BufV#Dn=Port?C allow the DaquinOscope macro mini-app to read 1024 bytes of digital input data, and plot each bit as a different screen trace. The V in BufV allows the above Ch to select Buf0 to Buf7 instead of using explicit numerals. In order to allow independent selection of which bit will be sent to the buffer, the n in #Dn allows it to be set via a prior Ch#n=UA operation, where UA is limited to the 0-7 range.

You can read the current value at any time via UA=Ch?n.

See also Macro Overview


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