Data AcQuisition And Real-Time AnalysisScope - Spectrum - Spectrogram - Signal Generator
Software for Windows
Science with your Sound Card!
Contact us about
Blocking Generator Update Clicks
When Generator controls other than Volume or dB are changed, sound output is restarted to insure that the new settings take immediate effect, and that the waveform is as indicated by the settings.
For example, if you manually change Tone Frequency during ongoing sound output, the existing Phase setting would be in error (relative to other streams, or to the trace start for Gen Sync) if the sound was not restarted using that Phase value.
Each time the sound is restarted, there is a discontinuity in the output, which is usually quite audible. Listen to the sound while you scroll Tone Frequency, and you will hear a click on each step.
But when changes are made via macros, it is easy to change many different controls in rapid succession. In this case it is pointless to restart after each individual control change, since it just slows down the time needed to change all the controls, and it creates a longer discontinuity.
Instead, you can use the GenUpdate macro to insure that there is only one restart, after all the changes. Before the first Generator control change macro, use GenUpdate=0 to block restarts. Then just before the last change command, use GenUpdate=1 so that the change will cause a restart. (GenUpdate=1 doesn't perform a restart, it just enables restarts on control changes.)
Alternatively, you can use GenUpdate=3 to both unblock restarts and immediately restart. This is used at the end of the lengthy _Miss_Fund_Update subroutine of the Missing Fundamental macro mini-app, since the multiple execution paths allow different "last change" commands.
Sometimes you may want to deliberately block restarts that are not necessary for proper operation, even when changes are made at a slower pace. For example, changes to Stream Level don't invalidate the Phase setting, nor cause the trace to lose Gen Sync, like changes to Tone Frequency do. Usually the only thing that is invalidated is the Level itself: It takes a fraction of a second before the sound output reflects the new setting.
You could thus use macros to slowly fade Level up or down without producing audible clicks. (Note: This method is for use when you want to change only certain output levels, or all levels but only by a certain amount; if you want to fade the entire output from full-on to full-off or the reverse, the Generator On/Off Fade option or its macros are much better.)
Level=>1 will scroll Level up by 1 step (1%) each time it is invoked. You could create a macro (here called _UpLevel) that delays by a small amount, then scrolls Level:
WaitSecs=100m ;Wait 0.10 second L.0.Level=>1 ;Raise Level 1%
Then call that in a loop with GenUpdate=0 (assuming Level starts at 0):
GenUpdate=0 ;No Generator restarts @_UpLevel=100 ;Level = 0 to 100 in 10 secs GenUpdate=1 ;Normal restarts
You may find that this is not a perfectly smooth fade, depending on the exact WaitSecs time. The reason is that the Generator must create the waveform samples in advance of when the sound card actually uses them to create sound.
The default Wave Block setting in the Start Preferences dialog is 32 KB, which for one channel of 16-bit sound at 48000 Hz sample rate means that Daqarta builds the waveform in blocks of about a third of a second each before sending them to the sound card. So the above macro could make 3 or 4 changes to Level during the time Daqarta is waiting to fill the next block, and then it uses the current Level value... 3 or 4 steps louder than the prior block.
To insure evenly spaced changes, GenUpdate=2 causes macro processing to wait until Daqarta has just filled a block before running the next command. So instead of WaitSecs, the _UpLevel macro could use:
GenUpdate=2 ;Wait for block update L.0.Level=>1 ;Raise Level 1%
With the default Wave Block size, this will slow down the fade-up rate to about 3 steps per second, but they will be evenly spaced in time. The calling macro no longer needs GenUpdate=0 before the _UpLevel loop, but it still needs GenUpdate=1 afterward.
Note that if you don't use GenUpdate=1 or GenUpdate=3 after GenUpdate=0 or GenUpdate=2, the Generator will not be restarted automatically even for manual control changes. This condition will persist until a subsequent GenUpdate=1 or GenUpdate=3 command, or until the next Daqarta session.
You may find this click-avoidance method useful for certain manual changes to controls like Level, or even for controls like Tone Frequency if you are not using Gen Sync. (Typically, Spectrum and Sgram/PT displays don't need any sync or triggering.)
You can read the current GenUpdate state via UX=GenUpdate, where UX (or whatever variable you use) will be 0 after either GenUpdate=0 or GenUpdate=2, and will be 1 after GenUpdate=1 or GenUpdate=3.
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 - 2021 by Interstellar Research
All rights reserved