From: Tim E. R. <ter...@ro...> - 2011-04-11 02:47:20
|
On April 10, 2011 06:02:42 pm Tim E. Real wrote: > I wrote: > > > And speaking of dummy audio: I fixed lock-ups and crashes by > > > replacing the dummy audio thread's infinite loop code with the > > > code found in muse_qt4_evolution. > > > > I agree, timing of usleep is not guaranteed which is why I originally > > used an external timer, but as you say we should be able to fix this > > by keeping time ourselves and adding/substracting. > > With the timer, my Global Setting's "Actual rate used now" said 46080Hz, > with 44100Hz/512 preferred. > A difference of nearly 2000Hz (500us). > > I assumed usleep would be at least a few magnitudes better. > The manpage says expect maybe 4~5 us minimum resolution. > But upon further reading I see can be much worse: > http://defectivecompass.wordpress.com/2006/09/01/high-precision-sleep > The author mentions getTimeOfDay is supposed to be accurate to about 5us, > and gives code for a hybrid high-precision sleep function :) > > The problem with the prvious code was the crash at dummy loop line: > while (drvPtr->cmdQueue.size()) > I think things were trying to put commands into the queue at the > same time as the loop was reading the queue - a painfully familiar > situation I've fixed in places before. Must fix that if we stick with > timer. > > > Although I have to admit I don't know if it matters in a dummy audio > > situation, > > Been pondering that. Obviously not for listening. > Something in the back of my mind tells me we may need this accuracy, > now or later, for certain processing such as files or bouncing. > > > the midi timer will still function at the right interval?! > > Yes. It occurred to me that with this new code, for fun we could give the dummy audio a freewheel mode - simply bypass the sleep and let it go at fullest possible speed - whee! We already have an empty setFreewheel() method, so it'd be real simple. (It's conceivable someone might process their songs using dummy.) So in that respect, if something did depend on that rate, freewheel wouldn't work. Yet MusE audio seems OK so far with such a mode. Of course cursor speed, meter animation etc. are affected. Ah, neat. It's just about increments, and sample rate. Tim. |