-
Notifications
You must be signed in to change notification settings - Fork 1
ring mod multithread
senso edited this page Jun 22, 2026
·
2 revisions
#example #audio #threading #query #advanced
Ring modulator with parallel multi-threaded processing.
| Module Name | ring mod multithread |
| Type | mtSimple |
| Color | clAudioModuleColor |
| Source | examples/RingModMultithread/ |
Same ring modulator as RingMod, but processes channels in parallel using two worker threads. Demonstrates real-time multi-threading with sync primitives.
Same as RingMod — N audio ins/outs + mod + mix.
-
onInitModule: Creates a sync object, a critical section, and two worker threads (manual restart mode) -
onProcess: Resets sync, sets counter=2, restarts both threads, waits for completion (500ms timeout) - Workers: Thread 1 processes even channels, thread 2 processes odd channels. Last thread to finish signals the sync object.
onProcess()
├── Reset sync object, counter = 2
├── Restart thread1 → processes channels 0, 2, 4, ...
├── Restart thread2 → processes channels 1, 3, 5, ...
└── Wait on sync object
Each thread:
├── Process assigned channels
├── Lock critical section
├── if (--counter == 0) signal sync
└── Unlock critical section
-
sdkThreadCreatewithUINT32_MAXinterval (manual restart) -
sdkSyncObjectCreate/Reset/Set/Wait— process synchronization -
sdkCriticalSectionCreate/Lock/UnLock— shared counter protection - Channel interleaving for load balancing
onGetModuleInfo · onGetNumberOfParams · onAfterQuery · onInitModule · onGetParamInfo · onCallBack · onProcess
- RingMod — Same effect, single-threaded
- MultiThreading — Thread and critical section basics