I said timers were the easiest way, not the safest way.
Reid
Control rate
-
- Posts: 599
- Joined: Mon Nov 15, 2021 9:23 pm
Re: Control rate
Cyberwerks Heavy Industries -- viewforum.php?f=76
Re: Control rate
<Chuckles>UrbanCyborg wrote: ↑Thu May 12, 2022 4:43 pm I said timers were the easiest way, not the safest way.
Reid
Multi-threading is probably the most difficult aspect of programming.
Even in the old days of direct-to-the-metal programming where one had total control of a processor and there was no invisible code it was still a nightmare.
One colorful anecdote that might amuse...
Back in the mists of time I was presenting the so-called final version of a game called Eco that simulated aspects of evolution to the head of the big publisher. It had run without any problems for "an eternity" but crashed half way through the presentation. He was very understanding but I was mortified.
It took about three or four days of intense effort before I discovered that the bug was caused by the 3D graphics pipeline interrupting another thread during a tiny critical segment of code that was simulating two creatures having sex.
-
- Posts: 599
- Joined: Mon Nov 15, 2021 9:23 pm
Re: Control rate
Ah, games. I recall one I was on as sound coder/designer. Another team member kept complaining that there was something wrong with my sound code. Took a few days for me (of course) to find out where the bug actually was. His code was walking on whatever happened to be active at the time, which, naturally enough, was frequently the sound code. Didn't even get an acknowledgement from the guy for making me waste the better part of a week tracking his obscure bug.
Reid
Reid
Cyberwerks Heavy Industries -- viewforum.php?f=76
Re: Control rate
I put together a module for playing about with dividing the ProcessSample() method by an integer amount.
The 'audio' code segment is executed on every pass.
The 'control' code segment is only executed once every N passes. A panel switch allows you to select different values of N in real time.
I placed a chuck of CPU-intensive operations within the 'control' segment such that it would overload my Core i7 processor at N=1.
When you select '1' on the divider switch, audible distorion occurs. Even changing the divider switch back to '4' (on my machine, at least) gives the processor enough time to spread the load of the intensive operations over time, bringing the CPU load back under 25% and restoring a clean audio signal.
YouTube video of module in operation
Source code is available on my Google Drive.
The 'audio' code segment is executed on every pass.
The 'control' code segment is only executed once every N passes. A panel switch allows you to select different values of N in real time.
I placed a chuck of CPU-intensive operations within the 'control' segment such that it would overload my Core i7 processor at N=1.
When you select '1' on the divider switch, audible distorion occurs. Even changing the divider switch back to '4' (on my machine, at least) gives the processor enough time to spread the load of the intensive operations over time, bringing the CPU load back under 25% and restoring a clean audio signal.
YouTube video of module in operation
Source code is available on my Google Drive.
______________________
Dome Music Technologies
Dome Music Technologies
Re: Control rate
Reid, very bad form from that colleague. Of course such sh*t happens but it shouldn't.
Grant, coitus interruptus were exactly the words that came to mind but this old atheist was taught Latin while attending a Catholic school. What's your excuse?
In your little experiment did you look at different buffer sizes? I'd expect things would get skewed if you were dividing by anything where the buffer size was larger than the divisor. If not that would be very curious.
Grant, coitus interruptus were exactly the words that came to mind but this old atheist was taught Latin while attending a Catholic school. What's your excuse?
In your little experiment did you look at different buffer sizes? I'd expect things would get skewed if you were dividing by anything where the buffer size was larger than the divisor. If not that would be very curious.
Re: Control rate
This old atheist was brought up as a Glaswegian Protestant, but one of my greatest joys in life is puns.
That's my excuse, and I'm sticking to it!
______________________
Dome Music Technologies
Dome Music Technologies
-
- Posts: 599
- Joined: Mon Nov 15, 2021 9:23 pm
Re: Control rate
Okay, nun of that, now!
Latin humor, eh? Way back in Bruce Reich's Third-year Music Theory class we were given the assignment to write a motet in period style. Casting about for an appropriate text, I settled on translating the opening chant of the Doors' The Soft Parade into Latin. Actually spent more time on that than on writing the motet itself.
Latin humor, eh? Way back in Bruce Reich's Third-year Music Theory class we were given the assignment to write a motet in period style. Casting about for an appropriate text, I settled on translating the opening chant of the Doors' The Soft Parade into Latin. Actually spent more time on that than on writing the motet itself.
Cyberwerks Heavy Industries -- viewforum.php?f=76
Re: Control rate
Ah, reading back, I may very well have misled you. My bad.
The "audio phase" of ProcessSample() is executed every sample period.
The "control phase" of ProcessSample() is executed every N sample periods, where N is the divider setting.
I put my "BATSH*T CRAZY BONKERS (tm)" lump of heavy-duty code (1,000 double-precision log(x) and 1,000 double-precision exp(x)) within the "control phase".
This means that where N is 1, you max out the processor because you're executing the BCB code 100% of the time.
With N set to 4, you are only executing the BCB code 1 out of every 4 cycles, i.e. 25% of the time. If you set N to 256 and your buffer size was only 64 samples, then you would get 1 execution of the BCB code segment every four BUFFERS.
______________________
Dome Music Technologies
Dome Music Technologies