Currently, Rosegarden sends a MIDI patch change event for each channel
in use, and it does this just before sending the music events in the
piece, in response to clicking the Play icon. The problem here is that a
patch change event may be fairly expensive to process, so there is a
risk of an audio glitch at the start of playing a piece.
I came across this problem with a software synth that I am developing.
In an early version, a patch change event would cause the synth to load
an instrument definition from a file, and this caused a severe audio
glitch at the start of playing a piece, due to the time taken doing I/O,
interpretation, and memory allocation. At all other times, the synth
only used a few percent CPU time. I subsequently fixed this by
pre-loading a set of instrument definitions at synth start time, but the
fact remains that patch changes can be expensive to process, when
compared to handling typical real time MIDI events such as Note On, Note
Off, and Control Change.
Would it be possible to send initial patch change events to the synth
when the Rosegarden file is loaded, i.e well before actually playing the
file? It would also be necessary to send the initial patch changes when
Rosegarden connects to a new synth while it has a music file open.
I would be interested to know how other sequencers behave in this respect.
I am presuming here that patch change events would not normally be sent
while a piece is being played. I have only ever done that while playing
around with different sounds, and I do not mind some audio glitching
when I do that.
As far as I can see, sending initial events at file load time instead of
at the start of playing the file would be completely transparent in
respect of synths that do not suffer from expensive patch loading, and
would be more friendly in respect of synths that do suffer from this
By the way, I am still working on ways to make patch loading less
expensive in my synth, so I am not suggesting that Rosegarden should be
changed just to solve my particular problems.
Sorry for the long post. I have been puzzling over this for some time.