Notes for loop play graphical bug - CCS-1L-F19/MuseScore GitHub Wiki

Looking for where code that moves cursor while in play mode.

The only line of code that seems to do anything audio/cursor related when a "play" event is recieved is seq->start() in ScoreView::changeState.

MuseScore::setPos is probably called where play loop is.

There is a process thread, a gui thread, and a real-time thread (I'm thinking this is what I need to find).

There are two timers in Seq: heartbeatTimer and noteTimer. heartBeatTimer is connected to heartBeatTimeout and that function emits the heartBeat signal. I got rid of heartBeatTimeout and the GUI didn't update but the audio was still bugged. Somewhere in heartBeatTimeout the pos is being read and is causing the bug.

Seq has two iterators, playPos and guiPos, which are called in the real-time and gui threads respectively.

audio driver _driver in Seq is started with startTransport and stopped with stopTransport. Also runs on its own thread. Could be another lead.

Seq::process is called by a PortAudio callback specified in PortAudio's OpenStream. Maybe this is the magic function?

TempoMap inherits from std::map<int, TEvent>. I think the keys are ticks and the events are tempo change events.

Seems like a lot of Seq is done with events in EventMap events. Try to figure out how this thing works.

MidiRenderer::renderChunk calls score->createPlayEvents. LEAD?

Answered questions:

What is a utick vs tick?

utick means unrolled tick (like after taking repeats and stuff into account). Same for utime.

What is the gui thread?

The main thread. It is what is started by qapp->exex()