From 48e1cedf4a8d78c6dab002ccb730dc5444463775 Mon Sep 17 00:00:00 2001 From: Keith OHara Date: Fri, 15 Jul 2011 17:09:51 -0700 Subject: [PATCH] MIDI: reset channel counters when done; issue 1678 --- lily/staff-performer.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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 -- 2.39.5