X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fmidi%2B%2B2%2Fmidi%2B%2B%2Fchannel.h;h=6bd08073b371c9518a5d21e715ae2d2abf2535bd;hb=e9752ff93ea44098fd8c02b21a3a787ef1cbf3ab;hp=e1ffb954a51b862b24121ebbe1fcae587ae56dec;hpb=8277d134b9733aee344782891c99f07114384d9e;p=ardour.git diff --git a/libs/midi++2/midi++/channel.h b/libs/midi++2/midi++/channel.h index e1ffb954a5..6bd08073b3 100644 --- a/libs/midi++2/midi++/channel.h +++ b/libs/midi++2/midi++/channel.h @@ -1,5 +1,5 @@ /* - Copyright (C) 1998-99 Paul Barton-Davis + Copyright (C) 1998-99 Paul Barton-Davis This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -15,18 +15,16 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id$ */ #ifndef __midichannel_h__ #define __midichannel_h__ #include +#include -#include - -#include -#include +#include "pbd/signals.h" +#include "midi++/parser.h" namespace MIDI { @@ -37,36 +35,36 @@ class Port; * This remembers various useful information about the current 'state' of a * MIDI channel (eg current pitch bend value). */ -class Channel : public sigc::trackable { +class LIBMIDIPP_API Channel : public PBD::ScopedConnectionList { public: Channel (byte channel_number, Port &); - Port &midi_port() { return _port; } + Port &midi_port() { return _port; } byte channel() { return _channel_number; } byte program() { return _program_number; } - byte bank() { return _bank_number; } + unsigned short bank() { return _bank_number; } byte pressure () { return _chanpress; } byte poly_pressure (byte n) { return _polypress[n]; } - byte last_note_on () { + byte last_note_on () { return _last_note_on; } - byte last_on_velocity () { + byte last_on_velocity () { return _last_on_velocity; } - byte last_note_off () { + byte last_note_off () { return _last_note_off; } - byte last_off_velocity () { + byte last_off_velocity () { return _last_off_velocity; } - pitchbend_t pitchbend () { + pitchbend_t pitchbend () { return _pitch_bend; } - controller_value_t controller_value (byte n) { + controller_value_t controller_value (byte n) { return _controller_val[n%128]; } @@ -78,23 +76,26 @@ class Channel : public sigc::trackable { _controller_val[n%128] = val; } + controller_value_t rpn_value (uint16_t rpn_id); + controller_value_t nrpn_value (uint16_t rpn_id); + bool channel_msg (byte id, byte val1, byte val2, timestamp_t timestamp); bool all_notes_off (timestamp_t timestamp) { return channel_msg (MIDI::controller, 123, 0, timestamp); } - + bool control (byte id, byte value, timestamp_t timestamp) { return channel_msg (MIDI::controller, id, value, timestamp); } - + bool note_on (byte note, byte velocity, timestamp_t timestamp) { return channel_msg (MIDI::on, note, velocity, timestamp); } - + bool note_off (byte note, byte velocity, timestamp_t timestamp) { return channel_msg (MIDI::off, note, velocity, timestamp); } - + bool aftertouch (byte value, timestamp_t timestamp) { return channel_msg (MIDI::chanpress, value, 0, timestamp); } @@ -111,22 +112,38 @@ class Channel : public sigc::trackable { return channel_msg (MIDI::pitchbend, lsb, msb, timestamp); } + float rpn_value (uint16_t rpn) const; + float nrpn_value (uint16_t nrpn) const; + float rpn_value_absolute (uint16_t rpn) const; + float nrpn_value_absolute (uint16_t nrpn) const; + protected: friend class Port; - void connect_input_signals (); - void connect_output_signals (); + void connect_signals (); private: - Port & _port; + Port& _port; + + enum RPNState { + HaveLSB = 0x1, + HaveMSB = 0x2, + HaveValue = 0x4 + }; /* Current channel values */ byte _channel_number; - byte _bank_number; + unsigned short _bank_number; byte _program_number; byte _rpn_msb; byte _rpn_lsb; + byte _rpn_val_msb; + byte _rpn_val_lsb; byte _nrpn_msb; byte _nrpn_lsb; + byte _nrpn_val_lsb; + byte _nrpn_val_msb; + RPNState _rpn_state; + RPNState _nrpn_state; byte _chanpress; byte _polypress[128]; bool _controller_14bit[128]; @@ -143,8 +160,13 @@ class Channel : public sigc::trackable { bool _mono; size_t _notes_on; - void reset (timestamp_t timestamp, nframes_t nframes, bool notes_off = true); - + typedef std::map RPNList; + + RPNList rpns; + RPNList nrpns; + + void reset (timestamp_t timestamp, framecnt_t nframes, bool notes_off = true); + void process_note_off (Parser &, EventTwoBytes *); void process_note_on (Parser &, EventTwoBytes *); void process_controller (Parser &, EventTwoBytes *); @@ -153,6 +175,14 @@ class Channel : public sigc::trackable { void process_chanpress (Parser &, byte); void process_pitchbend (Parser &, pitchbend_t); void process_reset (Parser &); + bool maybe_process_rpns (Parser&, EventTwoBytes *); + + void rpn_reset (); + void nrpn_reset (); + + static const RPNState RPN_READY_FOR_VALUE; + static const RPNState RPN_VALUE_READY; + }; } // namespace MIDI