Thread


#1

what is the best way to implement a thread to play a midi sequence ?
i explain my question :
i have done a basic juce application with a top component
in this component i create a juce thread to play the midi sequence
it works but the problem is when there is a lot of graphic work on the top component my midisequence stops few milliseconds
i tried to change the thread priority but it didn’t change a lot the performance
maybe there is a best way to implement my thread ?


#2

If you crank up the thread priority to about 8 it should be fine - that’s all I did in tracktion and it works well. Maybe it’s something else interrupting the playback, like a critical section?

One other thing you might want to look at is Process::setPriority() - setting this to high makes the whole app run more steadily.


#3

yes i think it’s a computer problem

this computer is windows 2000 sp4 P4 2Ghz
with a thread priority > 7 my computer locks
with a process with HighPriority my computer become very slow
with a process with RealtimePriority my computer locks

on my top component i have a TabbedComponent and a lot of Sliders
in release mode when i select a tab the midisequence stops during 100ms

i tried my application with another computer with windows xp and on this one the midisequence is really perfect


#4

Check your algorithm though, because it should still run ok on that machine. If you’re using high-priority threads you have to be very careful to allow it to sleep occasionally and avoid spinning the cpu for too long.


#5

bravo ! you are right !
to use high priority settings the algo needed some sleep :smiley:
it works perfect now

thanks for your help !


#6