Igevorse Otonnoleare

Fixing bugs is also important

10 August 2014 | 07:06 pm

Overview of work this week

In short:

  • Fixed bugs with assigning and syncing midi channels

My mentor found a few bugs in my implementation of midi channels, I was fixing them this week.

The first "bug" is actually an unimplemented feature: instruments are still visible in mixer after deleting. I didn't tested it and forgot about implementation. Actually this bug is more serious and leads to another bugs.

Here's some info for developers:

Every instrument has a pointer to the instance of class Channel. We have an integer there that shows our channel number. So, instr->channel->channel may have a value 0, 1, 2, etc. But it is not a midi channel (remember, we have to keep midi port too). We have a midi mapping (Score::_midiMapping[]) to save midi ports and channels. Our instr->channel->channel is an index in this array.

The main function here is Score::rebuildMidiMapping(). This function clears midi mapping and fills it with new values for each instrument: [port 0, channel 0], [port 0, channel 1], etc.

In my implementation I can't just clear it and assign channels because user can change midi channels. When user changes midi port or channel, we change the port and channel directly in _midiMapping. But when user creates or deletes an instrument we should add or remove a midi mapping. It's not easy to find all places where I should change midi mapping directly. Also it might be too difficult to a new developers. So, I avoided direct changing of _midiMapping. Also, since we don't clear our midi mappings, the order of items in mixer wouldn't be changed if we change it in the Add->Instrument window. I fixed it too. The new implementation of rebuildMidiMapping() works like this:

1. We pass through the _midiMapping array and search for the mapping to instrument that does not exists, then delete it.

2. We pass through the Instruments and search for the instrument that does no have a midi mapping (then it's a new instrument) and create a midi mapping for it.

3. Reorder mappings to the order in Add->Instruments.

Now it works pretty well.

The second bug was related to syncing channels in mixer. Since now we can have 2 or more instruments mapped to one midi port/channel, these instruments can't have different program, volume, pan, etc. When you change the volume of one of these instruments, volume of another instrument with the same channel would be changed too. There were some bugs but now they're fixed.

Also I accidentally fixed a few bugs with mixer and midi export.

Key tasks that stalled

Fixing bugs slows the development process :(.

Upcoming tasks this week


Check JACK implementation for possible bugs.

Finish improving Instrument Change element.

Implement import ports and channels from gtp*, mgu and ove formats (not sure last two support it).

As usual, you can find me on IRC #musescore as igevorse.

Feel free to write me about implementing some JACK-related features that you need and want.

« Let's improve Instrument Change and… · Fixing bugs is also important · 'Assigning midi channels' feature… »

Leave your response!

Style `onWall HashCode` by Lited & Sayori
Get your own blog immediately for free with Lited!