(1) silence non-process FIFO message (2) move MIDI state tracking down to the MidiPor...
[ardour.git] / libs / ardour / ardour / midi_state_tracker.h
1 /*
2     Copyright (C) 2008 Paul Davis
3     Author: Torben Hohn
4
5     This program is free software; you can redistribute it and/or modify it
6     under the terms of the GNU General Public License as published by the Free
7     Software Foundation; either version 2 of the License, or (at your option)
8     any later version.
9
10     This program is distributed in the hope that it will be useful, but WITHOUT
11     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
13     for more details.
14
15     You should have received a copy of the GNU General Public License along
16     with this program; if not, write to the Free Software Foundation, Inc.,
17     675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20 #ifndef __ardour_midi_state_tracker_h__
21 #define __ardour_midi_state_tracker_h__
22
23 #include <bitset>
24
25 #include "ardour/midi_buffer.h"
26
27 namespace ARDOUR {
28
29
30 /** Tracks played notes, so they can be resolved in potential stuck note
31  * situations (e.g. looping, transport stop, etc).
32  */
33 class MidiStateTracker
34 {
35 public:
36         MidiStateTracker();
37
38         void track (const MidiBuffer::iterator& from, const MidiBuffer::iterator& to, bool& looped);
39         void resolve_notes (MidiBuffer& buffer, nframes64_t time);
40         void dump (std::ostream&);
41         void reset ();
42
43 private:
44         void track_note_onoffs(const Evoral::MIDIEvent<MidiBuffer::TimeType>& event);
45
46         uint8_t _active_notes[128*16];
47 };
48
49
50 } // namespace ARDOUR
51
52 #endif // __ardour_midi_state_tracker_h__