From: Keith OHara Date: Sat, 16 Jul 2011 00:09:51 +0000 (-0700) Subject: MIDI: reset channel counters when done; issue 1678 X-Git-Tag: release/2.15.6-1~2^2~8 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=48e1cedf4a8d78c6dab002ccb730dc5444463775;p=lilypond.git MIDI: reset channel counters when done; issue 1678 --- diff --git a/lily/staff-performer.cc b/lily/staff-performer.cc index bab8ae0257..6d621a79a3 100644 --- a/lily/staff-performer.cc +++ b/lily/staff-performer.cc @@ -61,12 +61,18 @@ private: map staff_map_; map channel_map_; map dynamic_map_; + // Would prefer to have the following two items be + // members of the containing class Performance, + // so they can be reset for each new midi file output. static map static_channel_map_; static int channel_count_; + // For now, ask the last Staff_performer clean up during its finalize method + static int staff_performer_count_; }; map Staff_performer::static_channel_map_; int Staff_performer::channel_count_ = 0; +int Staff_performer::staff_performer_count_ = 0; #include "translator.icc" @@ -99,6 +105,7 @@ Staff_performer::~Staff_performer () void Staff_performer::initialize () { + ++staff_performer_count_; } Audio_staff* @@ -192,6 +199,13 @@ Staff_performer::finalize () { staff_map_.clear (); channel_map_.clear (); + if (staff_performer_count_) + --staff_performer_count_; + if (0 == staff_performer_count_) + { + static_channel_map_.clear (); + channel_count_ = 0; + } } string