Data AcQuisition And Real-Time AnalysisScope - Spectrum - Spectrogram - Signal Generator
Software for Windows
Science with your Sound Card!
Contact us about
MIDI Changes Script Mouse and Miscellaneous Position
Changes: mX, mY, mW, mH, mM, mB, mT, etc.
A MIDI Changes script can read the current mouse X and Y positions and use them for "live" user control of a performance. It can also obtain the screen width and height to allow scaling the position proportional to the screen boundaries.
The mouse position is a "read-only" variable. It can only appear on the right side of an expression. The general format is m followed by a single character:
mX = X-position mY = Y-position mW = Screen Width mH = Screen Height
The above X and Y positions are in pixels, relative to 0,0 at the upper left screen corner.
To match the screen size to Changes control ranges, you can use the Width and Height to scale the X and Y values. For example, I2=127*mX/mW will set the Instrument number for Voice 2 to 0 (Acoustic Grand Piano) when the mouse is at the left edge of the screen, and to 127 (Gunshot) when it is at the right edge. Use I3=127*mY/mH to get the same control range for vertical mouse positions. These will work for any screen size.
Although less likely to be useful, you can use "dialog units" instead of screen pixels by substituting lowercase letters mx, my, mw, and mh. In this case mx and my will be in units relative to 0,0 at the upper left corner of the Averager button on the main Daqarta toolbar. mw and mh will give the dialog units at the bottom right corner of the Daqarta client area.
Note that if the mouse is above or to the left of the Averager button, the mx and my position values may be negative. If the mouse is below or to the right of the Daqarta client area, the position values may exceed the mw and mh limits.
The letter that follows the m to select these functions is the same as the letter that follows Posn? in the main Mouse and Miscellaneous Position read-only macros. You may obtain additional functions using other letters as discussed there.
Functions relevant to MIDI scripts are:
m0 to m9 Special Integers mi to mo Special Fixed-Point mF Pitch Track Frequency, Hz mN Pitch Track MIDI Note number mV Pitch Track peak magnitude mv Pitch Track velocity mP Pitch Track threshold event count mM Pitch-to-MIDI acquired note count mB Pitch-to-MIDI elapsed beats mT Pitch-to-MIDI elapsed time mt MIDI Record elapsed time ms MIDI random generator seed mR Get alternative random generator value mr Alternative random generator seed
The "special" integer variables that can be read via m0 to m9 can be set via ?0 to ?9. They are useful for main Daqarta macros to communicate with Changes scripts. They can be read by Posn?0 to Posn?9 macros, and written by Posn#0 to Posn#9. Unlike MIDI User Variable integers UA to UZ (which can also be read and written by main macros), these "special" variables are not cleared at the start of a performance.
Similarly, special fixed-point variables can be read via mi through mo and set via ?i to ?o. They can be read in main Daqarta macros via Posn?i to Posn?o and written by Posn#i to Posn#o. They allow signed values with full 32-bit integer and 32-bit fraction resolution when used in macros, but are converted to unsigned 16-bit integer and 16-bit fraction resolution when used in MIDI scripts. As with the above special integers, they are not cleared at the start of a performance.
mF returns Pitch Track Frequency in Hz, including any fractional portion.
mN returns the same Pitch Track frequency after conversion to a MIDI Note number 0-127.
mV returns Pitch Track peak magnitude, scaled such that 100% of full scale is 2^30. To set unsigned fixed-point user variable Ua to percent of full scale for use in a calculation, use Ua=mV>>30*100.
mv returns the equivalent Pitch Track peak magnitude as a MIDI velocity scale factor 0-255.
mM is a very useful function which reads the count of MIDI notes that Pitch-to-MIDI has accepted from the Pitch Tracker since Pitch-to-MIDI was activated. This only counts "new notes"; if an input tone is sustained, that is only counted as a single note. There is also a separate mP function that returns the count of "above-threshold events" found by Pitch Track, which would be incremented for each beat a sustained input tone is held.
Alternatively, mT reads the elapsed time in milliseconds for the current Pitch-to-MIDI performance, and mt reads the milliseconds since MIDI Record was toggled on.
These functions could be used to modify a performance based upon beats, time, or cumulative note inputs, or, especially for KaleidoSynth, based on current note activity. For the latter, you could set a variable with the number of notes acquired since the prior pass through the Changes script. For example, let UP hold the prior-pass total note count, and UN hold the notes acquired since:
UN=mM-UP ;New total - prior = notes per pass UP=mM ;Update prior total for next pass
Questions? Comments? Contact us!We respond to ALL inquiries, typically within 24 hrs.
Over 35 Years of Innovative Instrumentation
© Copyright 2007 - 2021 by Interstellar Research
All rights reserved