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!

MIDI Changes Script IF Statements

Changes: [condition ... | ... ]

IF statements allow MIDI Changes scripts to execute commands or groups of commands conditionally, as in conventional programming languages.

A simple IF statement begins with [ followed immediately by the conditional statement such as UA=1. Any number of commands may follow, on any number of lines, that will be executed if the conditional statement is true. The IF statement can then end with ].

An IF...ELSE statement is just like the above, except that after all the commands that are to be executed if the condition is true, you use | (SHIFT+Backslash) to indicate ELSE, followed by all the commands to be executed if the condition is false. Note that the | should be preceded by a space to prevent confusion with the bitwise or logical OR operators in an expression. As above, the IF...ELSE statement ends with ].

The conditional statement can have any valid expressions (including current MIDI control values, random values, current computer keyboard states or mouse position, input or buffered notes, oscillators, and User Variables) on the left and right sides of the condition operator. The condition operator may be =, != (not equal), > (greater than), < (less than), >= (greater or equal), or <= (less or equal).

Note that this is unlike the Daqarta macro IF, which always requires an initial =:

  Macro   MIDI
    =      =      Equal
    =!     !=     Not equal
    =>     >      Greater than
    =<     <      Less than
    =>=    >=     Greater than or equal to
    =<=    <=     Less than or equal to

There must be no spaces in conditional statements. This can make them hard to read. For example, to set Instrument number for Voice 2 to 43 based upon a complex conditional statement:

[UA*?(10,20)/5>=UB-2+$1(100,200) I2=43]

Complex statements can be made more legible by assigning the left and right sides to User Variables ahead of time, so that the statement itself has the form [UX>=UY I2=43]

IF statements normally test only numeric values. You can't test multi-character strings directly, but you can test if a variable is equal to a single character as in [UK="?". This approach is used in GlossyFish (and related) Percussion scripts to test for user keyboard entry.

You can test Fields (or Labels) for strings up to 4 characters long by treating the ASCII characters as a hex value, as in [F1=h41424344 to test if Field1 holds "ABCD".

IF and IF...ELSE statements can be nested up to 8 levels deep, though you can have as many as you want at each level. If you attempt to go beyond 8 levels, the Changes debugger will report "Too many nested IF levels" for that script and will prevent it from running.

See also Changes Script Overview, Changes Script Editor, MIDI Voice Setup Dialogs, Pitch-to-MIDI dialog, Pitch Track Toolbox - 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