Data AcQuisition And Real-Time AnalysisScope - Spectrum - Spectrogram - Signal Generator
Software for Windows
Science with your Sound Card!
Contact us about
Macro Array Copy/Swap Operations
You can copy main Daqarta 1024-sample waveform, Spectrum, or Averager data into macro array buffers for manipulation. In addition, you can copy any 1024 samples of raw data directly from any sound card input or output channel buffer, starting at any arbitrary time point up to 65535 samples before the current time.
You can copy or swap between array buffers, or fill a buffer with a constant, random values, a list of values from Notes, or fill each element with its index. Buffers can also be "uploaded" back to replace main Daqarta data for further processing, display, or saving.
You can also copy to buffers from MemArb or Arb memory, or from Play memory. You can likewise upload to these, either to create dynamic Generator waveforms, or just to use this memory as extra workspace.
Buf0= Clear Buffer (fill with 0s) Buf0="<=(K)" Fill With Constant Buf0="<c=(A,B)" Fill With Complex Constant Buf0="<=#" Fill With Indexes Buf0="<r(A,B)" Fill With Uniform Random Values Buf0="<rt(A,B)" Fill With Triangular Random Values Buf0="<xB1" Exchange Buffers Buf0="<=B1" Copy Another Buffer Buf0="<=W1" Copy Waveform Channel Buf0="<=S1" Copy Spectrum Channel Buf0="<=A1" Copy Averager Channel Buf0="<=C1" Copy Calibration Curve Buf0="<=V1" Copy Spectrum Curve Buf0="<=D1(U1)" Copy Raw Waveform Data At Sample U1 Buf0="<=M1" Copy MemArb or Arb Waveform Buf0="<=P1" Copy Play Waveform Buf0="<Notes" Copy List From Notes Buf0="<NoteS" Copy String From Notes Buf0="<NotesF" Copy List From File Notes Buf0="<NoteSF" Copy String From File Notes Buf0="<NotesFR" Raw Bulk Copy from File Notes Buf0="<NotesR" Raw Bulk Copy from Notes Buf0="<uN" Upload to Notes Buf0="<uW1" Upload To Waveform Channel 1 Buf0="<uS1" Upload To Spectrum Channel 1 Buf0="<uA1" Upload To Averager Channel 1 Buf0="<uM1" Upload To MemArb or Arb Waveform 1 Buf0="<uP1" Upload To Play Waveform 1 Buf0="<uV1" Upload To Spectrum Curve 1 as Memory Curve Buf0#Bs=N Save Variables To Buffer Block N Buf0#Br=N Restore Variables From Block N Buf0#Bz=N Zero Variables In Block N Buf0#P=N Copy Spectrogram Palette To Block N Buf0#Pr=N As above but with reversed color order Buf0#Ps=N Set Block N As Spectrogram Palette Buf0="<Port" Copy port Device Control Block (DCB) to Buf0- Buf0#A=Port?A Copy 1280 port bytes as 1024 10-bit ADC samples Buf0#A2=Port?A Copy 1280 bytes as 2 x 512-sample 10-bit ADC channels Buf0#A4=Port?A Copy 1280 bytes as 4 x 256-sample 10-bit ADC channels Buf0#b=Port?a Copy 1024 port bytes as 1024 8-bit ADC samples Buf0#b2=Port?a Copy 1024 bytes as 2 * 512-sample 8-bit ADC channels Buf0#b4=Port?a Copy 1024 bytes as 4 * 256-sample 8-bit ADC channels Buf0#Dn=Port?D Copy bit n of 1024 port bytes to Buf0 Buf1#D1=Port?C Continued copy of bit 1 (etc) to Buf1, etc
Buf0="<=(K)" sets (copies) the value of K to each element of Buf0. K can be any constant, value, or expression; parentheses around it are mandatory.
Buf0= (nothing on right side) is a shortcut that fills Buf0 with 0s, equivalent to Buf0="<=(0)".
Buf0="<c=(A,B)" sets (copies) the complex value A + jB to each pair of elements of Buf0, such that real value A goes into even elements 0, 2, 4... 1022 and imaginary value B goes into odd elements 1, 3, 5... 1023. See the Complex Number Array Math subtopic under Macro Array Math Operations for more information.
A and B can be any constants, values, or expressions; parentheses around the pair are mandatory.
Buf0="<=#" replaces each element of Buf0 with its index, from 0 to 1023. This is useful for generating slope functions. See the discussion on generating linear or exponential slopes under Macro Array Math Operations.
Buf0="<r(A,B)" fills all elements of Buf0 with random values uniformly distributed between limits A and B. The limits can be either (Max,Min) or (Min,Max).
This operation uses a 32-bit linear congruential generator whose current seed can be read via Posn?r or set via Posn#r. It is effectively the same as sequentially using the rnd(A,B) math function to fill each of the 1024 elements in the array.
See Repeatable Random Values section under Random Macro Values for a discussion of the linear congruential generator, and how to make custom modifications to its operation.
Buf0="<rt(A,B)" is similar to the above, except the random values have a triangular distribution. This is obtained by adding two uniform random values together and dividing by two before entering each value into the array. See the Triangular Distributions section under Changes Script Random Values for a detailed explanation with numerical examples. (That topic is for MIDI Changes script commands, but the principles are the same.)
Triangular distributions are commonly used for dither sources in digital audio.
Buf0="<xB1" exchanges (swaps) the contents of Buf1 and Buf0.
Buf0="<=B1" copies each element of Buf1 to the corresponding element of Buf0. You can use B0 to B7 here.
Alternatively, in this and any buffer command that requires a source (right side) buffer number, you may use an expression to specify the source by enclosing it in parentheses, as in Buf0="<=B(X+Y)".
Since this command copies each element in turn, it works equally well when applied to an array of 512 complex values. (See the Complex Number Array Math subtopic under Macro Array Math Operations for more information.)
However, you can use Buf0="<c=B1" as a reminder that an array holds complex values.
Buf0="<=W1" copies each element of waveform channel 1 to Buf0. Valid waveform channels are 0 to 3:
0 = Left In 1 = Right In 2 = Left Out 3 = Right Out
As for buffer number, in any buffer command that requires a channel number you can use an expression for the channel by enclosing it in parentheses, as in Buf0="<=W(A-B)".
Buf0="<=S1" copies raw FFT output data from spectrum channel 1 to Buf0. Valid spectrum channels are 0 to 3, as above. This command will only return valid results if Spectrum or Spectrogram display mode is active.
Note that the main averager data actually consists of an array of summed values, each of which is automatically divided by the current Frames total so that the buffer "copy" holds true averaged values.
If a Linear, Exponential, or PSTH waveform average is active or done, the 1024 averaged values are copied to Buf0 elements 0-1023. Histogram averages have only 512 values, which are copied to Buf0 elements 0-511; elements 512-1023 are unchanged.
Spectrum averages contain only average magnitude data for each of 512 spectrum lines... there are no separate Real and Imaginary components. These 512 values are copied to BufN elements 0-511; elements 512-1023 are unchanged.
If a waveform average is active or done, and Spectrum display mode is active, the FFT of the averaged waveform data is taken and the raw (Re,Im) values are copied to BufN elements 0-1023. This is similar to Buf0="<=S1", but with higher resolution due to the averaging.
Alternatively, if the waveform average is active or done, you can use Buf0="<=a1" to copy the waveform average of the Right Input regardless of Spectrum display mode.
The copied values for the above W, S, and A or a operations are scaled such that +/-32767 represents a full-scale signal. To convert to volts or User Units, see Macro Data Unit Conversions. Exceptions: For Histogram and PSTH averages, the copied values are the percentage of "hits" in each histogram bin, scaled such that 32768 is 100%.
Buf0="<=C1" copies any User Units calibration curve that has been loaded for channel 1 to Buf0 elements 0-511. Valid channels are 0-3, as above. The data points are interpolated from the loaded .CAL or .FRD file to match the spectral lines at the current sample rate, and they are normalized such that the peak value is stored as 0 dB, and all other values are negative. (You can read the original peak dB for channel 1 from UserSPL?1.)
The sensitivity (Sens: value) from the .CAL or .FRD file is ignored.
You would typically use this together with array display commands such as Buf7="<dC0" followed by Buf7="<dSU" to specify that Buf0 be applied when displaying Buf7 in Spectrum Unipolar mode.
Alternatively, you can use U3R.Buf0="<=CU" to specify the User Units CAL file loaded for Right Input Line 3 (in this example) even if that line is not the current Right Input channel. See the User Line Enable topic for a complete description of other User Units prefixes that can be used instead of the U3R shown here.
Buf0="<=V1" copies Spectrum Curve 1 (not channel 1) to Buf0 elements 0-511. Valid Curve files are designated 0-3. As for the above User Units calibration files, the data points are interpolated from the loaded Curve file to match the spectral lines at the current sample rate. However, the dB values are not normalized. The Curve file (.CRV, .CAL, or .FRD) must be loaded in the Spectrum Curves Dialog, but it need not be currently selected.
You would typically use this with array display operations as discussed above for Buf0="<=C1".
Buf0="<=D1(U1)" copies 1024 samples of raw waveform data from sound card channel 1 (Right In). Valid channel numbers are 0-3, as shown in Copy Waveform Channel, above. The copy starts from absolute sample number U1.
As an example, Buf0="<=D1(Posn?D)" copies from the start position of the Right In data currently displayed, which is equivalent to Buf0="<=W1". Buf0="<=D1(Posn?D - 100)" would start 100 samples earlier than that, equivalent to a Trigger Delay of -100 samples.
Note that this command requires an explicit channel number, unlike Buf0="<=W(UC)", which gets the channel number from variable UC.
Buf0="<=M1" copies 1024 samples of waveform data from MemArb1 or Arb1, starting at the beginning of the waveform. There must be a waveform at the designated Arb 1 location, even if not in active use, or this command does nothing. No error message is given. Valid numbers after the 'M' are 0-7.
Buf0="<=M(UC)" behaves as above, but allows the MemArb or Arb number to be specified by an expression or variable such as UC.
Buf0="<=M1(U1)" copies from MemArb1 or Arb1, starting at sample U1. If U1 is too close to the end of the waveform, less than 1024 samples will be copied and the remainder of Buf0 will be filled with zeros.
You can determine the size of the waveform ahead of time via UN=MemArb1?N or UN=Arb1. (Either will work for either situation.)
Note that you must explicitly specify the MemArb/Arb number if you specify a starting sample.
Buf0="<=P1" copies 1024 samples of waveform data from Play1, starting at the beginning of the waveform. There must be a waveform at the designated Play 1 location, even if not in active use, or this command does nothing. No error message is given. Valid numbers after the 'P' are 0-7.
Buf0="<=P(UC)" behaves as above, but allows the Play number to be specified by an expression or variable such as UC.
Buf0="<=P1(U1)" copies from Play1, starting at sample U1. If U1 is too close to the end of the waveform, less than 1024 samples will be copied and the remainder of Buf0 will be filled with zeros.
You can determine the size of the waveform ahead of time via UN=Play1.
Note that you must explicitly specify the Play number if you specify a starting sample.
Buf0="<Notes" copies a list of values from the Daqarta Notes area into Buf0, filling as many elements as there are values. (But see below.) The values may be separated using commas or spaces, or using one value per line. You can use Windows standard Copy (CTRL+C) and Paste (CTRL+V) to import values from elsewhere. The text may include comments: when a semicolon (;) is encountered, the rest of that line will be ignored.
You may use Buf0#N=n to set the number of buffer "channels" n to fill, just as for File Operations. n can be 1, 2, or 4, with 1 being the default. For example, if you use Buf0#N=2 ahead of the copy command, the first Notes value will go to Buf0, the next to Buf1, then Buf0, Buf1, etc, with all even values going to Buf0 and all odd values to Buf1. Typically, you would use this with two values per line. Similarly, with Buf0#N=4 you would use 4 values per line to fill Buf0-Buf3.
If you use higher buffers than Buf0, the maximum n value is decreased. For example, Buf6#N=2 is allowed, indicating that Buf6 and Buf7 will be used, but not Buf6#N=3 or greater since that would require buffers beyond Buf7. Likewise, Buf4 is the highest that allows n = 4.
Although the Buf0 array can hold up to 1024 values, the Notes area can hold only 2047 characters (including commas, spaces, and carriage returns). At 8 characters per value (say -72.25, -81.52, etc) you can fit up to 256 values into Notes. If you have more or longer values you may want to read them from a file instead.
Alternatively, it's possible to fill a buffer or buffers by accepting some text, then advancing the Start Offset into the destination buffer using Buf0#SO=n, then accepting some more until you have what you need. Note that for multi-buffer copies using Buf0#N=2 or Buf0#N=4, the Buf0#SO command sets the start offset of all buffers in the subsequent copy.
You might want to use this approach to accept a list of values entered manually into Notes, one line at a time.
As mentioned, the Buf0="<Notes" operation normally copies all the values present. If needed, you can limit the copy to n samples (per buffer, for multi-buffer operations) via Buf0#S=n.
Immediately after any Buf0="<Notes" operation you can obtain the number of values copied via Buf0?L, as in UL=Buf0?L. (This is the same as for obtaining the number of points read from a file.) You can use this number as a WHILE loop count-down or limit in a macro that operates on the list. See the dB_Sum macro listing in the RMS "Sum" of dB Values topic for an example. For a multi-buffer copy, just as for file load or save, the Buf0?L value is the number of index positions on any one of the buffers.
Buf0="<NoteS" (note uppercase 'S') copies a string of characters from the Daqarta Notes area into Buf0, one character per element, filling as many elements as there are characters. All normal keyboard characters are copied, including spaces, but not including Tab or Enter or other control characters. Unlike the above Buf0="<Notes" command, there is no provision for ignoring comments.
Also unlike the above Buf0="<Notes" command, this only fills the designated buffer; the Buf0#N=n command has no effect. Likewise, the Buf0#SO=n command to set Start Offset and the Buf0#S=n command to limit the number of Samples are both ignored.
Immediately after any Buf0="<NoteS" operation you can obtain the number of characters copied via Buf0?L, as in UL=Buf0?L. (This is the same as for obtaining the number of points read from a file.) You can use this number as a WHILE loop count-down or limit in a macro that operates on the string.
You can use Windows standard Copy (CTRL+C) and Paste (CTRL+V) to import text from elsewhere.
When you save a file with a .DQA extension, either a short single-screen file or a longer DDisk file, the current Daqarta Notes area is saved along with the file. When the file is subsequently opened to be viewed, its Notes are copied into a File Notes memory area which is used to temporarily replace the current Notes display. If the file is instead loaded into the Generator as an Arb or Play file, its Notes are still copied to the File Notes memory area but are not displayed. In either case, the File Notes are retained until overwritten by loading another .DQA file.
You can read the current File Notes by appending an 'F' to get Buf0="<NotesF" to read a list or Buf0="<NoteSF" to read a string, one character per index, as discussed above.
You can also do a raw bulk copy from File Notes via Buf0="<NotesFR"... see the next topic for details.
You can do all of the above copy operations on the same File Notes using different Buf numbers on the left side.
This is a handy way for macros to save and retrieve special data that pertains to the file. For Arb or Play files the operation is invisible to the user since the data is not displayed (unless you do it explicitly... see below).
The Engine_Sim Engine Crank and Cam Sensor Simulator mini-app uses Buf0="<NotesF" and Buf2="<NotesFR" to retrieve values as well as any user Notes from the Arb file of a previously created engine design.
Buf0="<NotesR" copies everything in the Daqarta Notes area into Buf0, including valid control characters. After the operation you can obtain the number of characters copied via Buf0?L, as in UL=Buf0?L.
Unlike the previously-discussed Buf0="<NoteS" operation, the characters are stored contiguously, 8 per array element. They can be accessed as String Storage elements, for example by using Msg=Buf0(a) to show the first 8 characters in a Custom Macro Message.
Since the Daqarta Notes area only holds 2047 characters, at most only the first 256 elements will be used. The remainder will be filled with nulls. You may then use the rest of the array for other purposes, if desired.
Alternatively, you can specify which of four 256-element blocks (numbered 0-3) should receive the Notes contents, via Buf0="<NotesR0" through Buf0="<NotesR3". In this case, only the specified block will be affected; if the Notes content is less than 2047 characters, only the remainder of that block will be nulled.
You can use this raw bulk copy method to store the Notes contents temporarily while you use that area for other purposes. For example, you can enter special data to Notes just before saving a .DQA file, and that data will be included with the file and be shown in the Notes area whenever that file is opened for viewing. See Copy String, List, Or Raw Bulk File Notes, above, for more information.
You can also do a raw bulk copy from File Notes via Buf0="<NotesFR", using the same block selection options.
After the file save, you can restore the original Notes by "uploading" them using the Buf0="<uN" command. You can specify which block to upload via Buf0="<uN0" to Buf0="<uN3", otherwise block 0 is assumed.
Buf0="<uW1" uploads each element of Buf0 to waveform channel 1. Valid waveform channels are 0 to 3, as noted earlier for copying from these channels. Note that uploaded values are limited to +/-32767, the normal 16-bit sound card range, to avoid overflow in subsequent processing operations.
Uploaded data replaces a 1024-sample frame of raw sound card Input or Generator data that would otherwise be processed and displayed. The uploaded data will thus receive the same processing and display treatment, and can be read by the cursor readouts. If you toggle to Spectrum mode, you'll see the spectrum of the uploaded data, and you can apply Window functions, Curves, Limits, and use Spectrum Peak Track as usual. You can use the File menu to save single traces as DQA, WAV, DAT, or TXT files, or as Memory Array traces, just as for sound card data.
What you can not do is save uploaded data as Direct-To-Disk (DDisk) files, since those really do read raw sound card data, before any processing.
The upload commands are also used to process data obtained from a source other than a sound card, such as an Arduino or Numato device that uses Port Access. See the Direct Display vs. Uploaded Data subtopic under Macro Array Display Operations for details.
(Note that when a Generator stream is replaced by uploaded data, the raw Generator output still goes to the sound card output as usual... you just don't see it on the screen.)
Buf0="<uS1" uploads each element of Buf0 as raw FFT output data to spectrum channel 1. Valid spectrum channels are 0 to 3, as above.
Buf0="<uA1" uploads data from Buf0 to the Waveform or Spectrum Averager, whichever is active. Valid channels are 0-3, as above. The data is assumed to be appropriate for the current averager mode (Linear or Exponential Waveform, Histogram, PSTH, Linear or Exponential Spectrum, or Spectrum Peak.)
Although the buffer data is assumed to consist of averaged values, note that the main Averager arrays actually hold summed values. During upload, each buffer value is thus automatically multiplied by the current Frames total to give an equivalent summed value.
You should avoid uploading to ongoing averages, since additional incoming raw data will be summed into the uploaded array... usually with unwanted results.
A more typical application would be to subtract a previously-obtained background average from the finished average in order to view or save an after-the-fact equivalent to Average Subtract. You'd copy the finished average to a buffer, subtract the background buffer, and upload the result. Then the corrected average can be analyzed, or saved to Juxt trace memory or to a .DQA file.
Buf0="<uM1" uploads all 1024 samples of Buf0 to replace the first 1024 samples of the MemArb1 or Arb1 waveform buffer. There must be a waveform at the designated Arb 1 location, even if not in active use, or this command does nothing. No error message is given. Valid numbers after the 'M' are 0-7. This command is equivalent to MemArb1="<=B0".
If used with an Arb that has been loaded from a file, this command only replaces the samples in Daqarta's working memory; the original file is unchanged.
Note that MemArbs and Arbs use the same 16-bit signed integer format as raw sound card waveform data. Since Buf0-Buf7 use a 64-bit fixed-point with 32 integer bits and 32 fraction bits, this command only uploads the integer portion (without rounding the fraction), and limits the uploaded values to +/-32767.
Buf0="<uM(UC)" uploads Buf0 to the MemArb or Arb specified by an expression or variable such as UC. This command is equivalent to MemArb1="<=B(UC)".
Buf0="<uM1(U1)" uploads Buf0 to MemArb1 or Arb1, starting at target sample U1 (or any valid expression). If U1 is too close to the end of the waveform, less than 1024 samples will be copied to just fill the MemArb or Arb waveform buffer.
You can determine the size of the waveform ahead of time via UN=MemArb1?N or UN=Arb1. (Either will work for either situation.)
Note that you must explicitly specify the MemArb/Arb number if you specify a starting sample.
This command is equivalent to MemArb1="<=B0", after a prior MemArb1#SO=U1 command to set the Start Offset to U1.
Buf0="<uP1" uploads all 1024 samples of Buf0 to replace the first 1024 samples of the Play1 waveform buffer. There must be a Play waveform file loaded at the designated location (uP0 to uP7) even if not in active use, or this command does nothing. No error message is given.
This command only replaces the samples in Daqarta's working memory; the original Play file is unchanged.
Note that Play files use the same 16-bit signed integer format as raw sound card waveform data. Since Buf0-Buf7 use a 64-bit fixed-point with 32 integer bits and 32 fraction bits, this command only uploads the integer portion (without rounding the fraction), and limits the uploaded values to +/-32767.
Buf0="<uP(UC)" uploads Buf0 to the Play waveform specified by an expression or variable such as UC.
Buf0="<uP1(U1)" uploads Buf0 to Play1, starting at target sample U1 (or any valid expression). If U1 is too close to the end of the waveform, less than 1024 samples will be copied to just fill the Play waveform buffer.
In those rare cases where the overall Play waveform holds less than 1024 samples, the first two command types Buf0="<uP1" and Buf0="<uP(UC)" will likewise be limited to copying only the Buf0 samples needed to replace the Play waveform.
You can determine the size of the Play waveform ahead of time via UN=Play1.
Note that you must explicitly specify the Play number if you specify a starting sample.
Buf0="<=uV1" uploads the first 512 elements of Buf0 to the "Weighting Curve 1" button and labels it "Memory Curve 1". If there was already a file loaded at this position, it is automatically unloaded first.
The values are assumed to be dB, and they are assumed to apply to spectral lines 0-511 at whatever sample rate is in use. If the sample rate is changed, the Memory Curve does not get interpolated or extrapolated... the same dB values will be applied to the same spectral lines, even though their frequencies have changed. Note that this is unlike a Curve file, which contains a list of frequencies and corresponding dB values to enable automatic updating to maintain them when the sample rate changes.
Also note that a Memory Curve is not saved when Daqarta is closed, unlike a Curve file whose name is automatically saved and reloaded at the next start.
Buf0#Bs=N saves all floating-point variables A-Z plus all macro/MIDI variables to Block N of Buf0. Each buffer can hold up to 10 such blocks, numbered 0-9. Macro/MIDI variables include integers U0-9, UA-Z, Q0-9, and QA-Z as well as 32-bit fixed point values Ua-z and Qa-z.
(Note that cross-session 64-bit fixed-point macro variables Var0-Z are not included, nor Special Macro-MIDI integer variables Posn#0-9, nor special fixed-point variables Posn#i to Posn#o, nor are any Daqarta control settings like SmplRate or ToneFreq.)
Buf0#Br=N restores all variables from Block N of Buf0, reversing the above process.
Buf0#Bz=N zeros all the variables in Block N of Buf0.
These commands allow multitasking macros to have free use of all variables for their own purposes, without worry about corrupting other simultaneous-running macros. A task would typically save all variables when it is awakened, then replace them with its own local variable set. When the task is done with its calculations it would save these local values back to its own block, and restore the main variables from their block just before exiting.
Before launching the task you can use Buf0#Bz=N to clear the block that will be used for local variables, so that when the task runs it will start with all zeros in its local variables. If you want the task to start with most variables set to zero, but some pre-set to certain values (such as a countdown counter), your setup code could clear the block, then "restore" it to get all variables set to zero. Then set any needed values and save it again.
Another use for Block commands is with macros that invoke MIDI performances. Macro/MIDI variables are shared between main macros and MIDI scripts. They are handy as integers in macros, but they are cleared when a MIDI setup runs. Use of the above commands allows a macro mini-app like Missing_Fundamental to save all variables, run the MissFundamental.DQM MIDI setup by toggling the Play Music button in its Custom Controls dialog, and restore the variables after the button is toggled off.
The Block N designated in the command packs all variables into 95 elements of the specified buffer. Each block is 100 elements long, with 5 unused elements at the end of the block.
There are 10 possible blocks, numbered 0-9, such that Block 0 consists of elements  to , Block 1 is  to , and so on up to Block 9 at  to .
Note that these buffer Block numbers and sizes are not the same as those in Copy Spectrogram Palette To/From Buffer Block, below.
The remainder of the buffer, elements  to , is unaffected and available for other uses, as are any blocks not used for saving variables. You can even use the 5 elements at the end of an active block. (Note that these 5 elements are not zeroed via the Buf0#Bz=N command.)
This flexibility allows you to, for example, dedicate one buffer to storing working variables for multiple concurrent tasks, as well as storing variables for the main (non-multitasking) macro. Alternatively, you can use one buffer to store macro string arrays for, say, main Labels, Custom Control button labels, and miscellaneous working values that you access by index, and still include a Block to save normal variables when invoking MIDI scripts.
Please note that due to the way variables are packed by these commands, they can not be read or written as normal indexed buffer values.
Besides multitasking, you can use the Block commands to provide local variables for normal non-multitasking subroutines (those that are invoked via the @_MySubroutine format). Note, however, that most subroutines need to pass input and output values back and forth, which would be overwritten by Block restore commands. Local Block variables are thus most appropriate for large subroutines that use lots of working variables, but require only a few input/output values that can be passed in non-Block portions of a buffer.
Buf0#P=n copies the full 256-color Spectrogram palette to block n of Buf0. For palette use, blocks are numbered 0-3. If you store the palette in block 0, the array element at index 0 will be the lowest (usually darkest) color in the palette, while index 255 will hold the highest.
Note that palette buffer block numbers and sizes are not the same as those in Save/Restore Variables To/From Buffer Block, above.
Each palette color is composed of three 8-bit values, one each for red (R), green (G), and blue (B). These form an unsigned 24-bit value that is low-justified in the buffer's 32-bit integer portion. The format is h00RRGGBB. The fractional part of each array element is set to zero.
To read the RGB colors from any given index UI, use:
UC=Buf0[UI] ;Get 24-bit RGB color value R=int(UC >> 16) & 255 ;Red G=int(UC >> 8) & 255 ;Green B=UC & 255 ;Blue
Buf0#Pr=n also copies the Spectrogram palette, except that it reverses the color order to h00BBGGRR. You can read these color values with:
UC=Buf0[UI] ;Get 24-bit RGB color value B=int(UC >> 16) & 255 ;Blue G=int(UC >> 8) & 255 ;Green R=UC & 255 ;Red
To set block n as the new Spectrogram palette, use Buf0#Ps=n. Note that this assumes you used Buf0#P=n to copy, which preserves the original Spectrogram color format.
Buf0="<Port" copies the open port's complete DCB (Device Control Block) to a buffer for subsequent examination. The DCB will always be copied to elements  to , regardless of whether an index is used. Element  will hold the return value from Windows' BuildCommDCB command. See Port Setup Commands under USB / Serial Communications Port Access.
The following commands pertain to special functions of the DaqPort sketch for Arduino used by the DaquinOscope mini-app. They are used after a command of the form Port=$(hF1) + $(UM) has requested that the Arduino acquire a burst of 1024 samples of data and store it in its memory, and a subsequent command of the form Port#D1=hF2 has requested that the data be sent from memory to the port. See Special Bulk Data Read Commands under USB / Serial Communications Port Access for more details:
Buf0#An=Port?A Copies 1280 bytes from the port as 1024 10-bit ADC samples, where n is the number of channels and must be 1 (or omitted), 2, or 4. If n is 1 or omitted, all samples are assumed to come from a single ADC channel. If n is 2, 512 samples of the first channel go to Buf0 and 512 alternating samples go to Buf1. If n is 4, 256 samples of the first channel go to Buf0, the next channel to Buf1, then Buf2 and Buf3 in rotation.
Buf0#bn=Port?a is similar to the above but copies 1024 bytes as 8-bit ADC samples.
Buf0#Dn=Port?D copies 1024 bytes of digital input data from the port to Daqarta memory. The n specifies the bit number that will be scaled such that if set it becomes 16384 (half of screen full scale for display use), else 0. Here n may be a digit 0-7, or a literal n to use the special bit channel select set via Ch#n=UA.
Buf0#Dn=Port?C is identical, except that the Port?C indicates that it is a Continued read following an initial Port?D form. No new data comes from the port, but the stored initial data is queried with a different n value, usually with a different Buf number by using BufV after setting the number in Ch. Note that this may be different than the Ch#n value, so you can send any of the 8 bits to any Buf0 - Buf7.
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