X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fmidi-walker.cc;h=fdafd91b1d3a6252a13dcc0b6d3644a00ba94688;hb=4b61454c923f6b1c5ec2ccc75e1d5d2b3b281f6c;hp=cef858c92768ebacf1374fb6d8f9bddb418a6536;hpb=5ed10e40db547f70f6f5b3ae2092ab0997d89fa3;p=lilypond.git diff --git a/lily/midi-walker.cc b/lily/midi-walker.cc index cef858c927..fdafd91b1d 100644 --- a/lily/midi-walker.cc +++ b/lily/midi-walker.cc @@ -1,10 +1,21 @@ /* - midi-walker.cc -- implement Midi_walker + This file is part of LilyPond, the GNU music typesetter. - source file of the GNU LilyPond music typesetter - - (c) 1997--2007 Han-Wen Nienhuys + Copyright (C) 1997--2011 Han-Wen Nienhuys Jan Nieuwenhuizen + + LilyPond is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + LilyPond is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with LilyPond. If not, see . */ #include "midi-walker.hh" @@ -41,15 +52,14 @@ audio_item_less (Audio_item * const a, return a->get_column ()->when_ < b->get_column ()->when_; } -Midi_walker::Midi_walker (Audio_staff *audio_staff, Midi_track *track, - int channel) +Midi_walker::Midi_walker (Audio_staff *audio_staff, Midi_track *track) { - channel_ = channel; track_ = track; index_ = 0; items_ = audio_staff->audio_items_; vector_sort (items_, audio_item_less); last_tick_ = 0; + percussion_ = audio_staff->percussion_; } Midi_walker::~Midi_walker () @@ -70,6 +80,7 @@ void Midi_walker::do_start_note (Midi_note *note) { Audio_item *ptr = items_[index_]; + assert (note->audio_ == ptr); int stop_ticks = int (moment_to_real (note->audio_->length_mom_) * Real (384 * 4)) + ptr->audio_column_->ticks (); @@ -114,9 +125,6 @@ Midi_walker::do_start_note (Midi_note *note) } } -/** - Output note events for all notes which end before #max_mom# -*/ void Midi_walker::do_stop_notes (int max_ticks) { @@ -162,9 +170,6 @@ Midi_walker::process () if (Midi_item *midi = get_midi (audio)) { - if (Midi_channel_item *mci = dynamic_cast (midi)) - mci->channel_ = channel_; - if (Midi_note *note = dynamic_cast (midi)) { if (note->audio_->length_mom_.to_bool ()) @@ -179,6 +184,11 @@ Midi_item* Midi_walker::get_midi (Audio_item *i) { Midi_item *mi = Midi_item::get_midi (i); + + if (percussion_) + if (Midi_channel_item *mci = dynamic_cast (mi)) + mci->channel_ = 9; + midi_events_.push_back (mi); return mi; }