-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
update the slowly changing parameters faster and more consistently #401
Comments
A somewhat specific example is the recordsignal module in a live recording situation where it starts/stops-writes according to a Redis value ; due to it's polling of changes to Redis values (when to record), and the use of a blocksize, the resultant duration of recordings are variable with multiples of blocksize, depending when a changing Redis value is noticed. Except for a complicated with multiple threads which I can't fully oversee, perhaps the easiest would be to create another module ft2file that writes the content of the ft buffer to file at button-press (with |
With EDF requires the block size to be specified in the header (see https://www.edfplus.info/specs/edf.html), hence it cannot change on the fly. WAV writes the data in a multiplexed format (one sample for all channels, and that repeated for all samples) which is technically independent of the specified block size. The only consideration there is that you don't want to read/write the data in too short (e.g., 1-sample) blocks, as that puts more overhead on the network (getting data) and on the disk (writing data). Given the topic of this issue, I suggest that further discussions that are specific to writing signals to disk are continued in another issue. |
I suggest we also move the discussion about switching on and off certain behaviour of a module (such as saving to disk) to another thread. Note that with Edit: see also #393. |
I have been thinking about this: the EEGsynth Getting the value repeatedly is resource (cpu) intensive and updates to the value are always a bit too late. Implementing pub/sub in each module is code-wise complex, as it requires a thread. Imagine that the It would look like this:
and at the end there should be a The advantage is that the code in the modules need fewer global variables, that the modules become more resource efficient (since no polling of Redis with |
This allows to demonstrate the changes to the patch object as suggested in #401
Initially we implemented many modules with
get/set
, but later switched topatch.setvalue
which does simultaneouspub/sub
andget/set
. As a consequence, when the value in one module changes and is sent to Redis, another module can in principle be notified of this immediately. However, we have many modules that only once or infrequently check the value of parameters that can be hardcoded in the ini, but that can also come from Redis.For example
delaytrigger
only checks the delay and output value upon startupeegsynth/module/delaytrigger/delaytrigger.py
Line 137 in 32a3fa7
and in the
outputmidi
module theUpdateParameters
function is called upon each iteration (typically every 50 ms)eegsynth/module/outputmidi/outputmidi.py
Line 317 in 32a3fa7
whereas in the
synthesizer
module theControlThread
thread runs constantly without delays (that must be hard on the CPU)eegsynth/module/synthesizer/synthesizer.py
Line 101 in 32a3fa7
It would be good to make this more consistent and to come up with a generic implementation that does not make the code of individual modules more complex, but that does take care of more consistent, faster, and more efficient updating of Redis values between modules.
The text was updated successfully, but these errors were encountered: