X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fmidi%2B%2B2%2Fmidi%2B%2B%2Fparser.h;h=e4126b210bac34db57ae7ee4b8bdcc897679a2b3;hb=b9185d2c07c77eccf3679ac99f6b69f8fdd79c48;hp=73c7c75f614732dbce9ac36e9afb4939243d7aee;hpb=6edccc3070b813157ffcd4014ec8dd7fa6ed9ce7;p=ardour.git diff --git a/libs/midi++2/midi++/parser.h b/libs/midi++2/midi++/parser.h index 73c7c75f61..e4126b210b 100644 --- a/libs/midi++2/midi++/parser.h +++ b/libs/midi++2/midi++/parser.h @@ -23,25 +23,36 @@ #include #include -#include +#include "pbd/signals.h" -#include +#include "midi++/libmidi_visibility.h" +#include "midi++/types.h" namespace MIDI { class Port; class Parser; -typedef sigc::signal OneByteSignal; -typedef sigc::signal TwoByteSignal; -typedef sigc::signal PitchBendSignal; -typedef sigc::signal Signal; +typedef PBD::Signal1 ZeroByteSignal; +typedef PBD::Signal2 TimestampedSignal; +typedef PBD::Signal2 OneByteSignal; +typedef PBD::Signal2 TwoByteSignal; +typedef PBD::Signal2 PitchBendSignal; +typedef PBD::Signal3 Signal; -class Parser : public sigc::trackable { +class LIBMIDIPP_API Parser { public: - Parser (Port &p); + Parser (); ~Parser (); + + /* sets the time that will be reported for any MTC or MIDI Clock + message the next time ::scanner() parses such a message. It should + therefore be set before every byte passed into ::scanner(). + */ + framecnt_t get_timestamp() const { return _timestamp; } + void set_timestamp (const framecnt_t timestamp) { _timestamp = timestamp; } + /* signals that anyone can connect to */ OneByteSignal bank_change; @@ -61,11 +72,11 @@ class Parser : public sigc::trackable { OneByteSignal channel_program_change[16]; PitchBendSignal channel_pitchbend[16]; TwoByteSignal channel_controller[16]; - sigc::signal channel_active_preparse[16]; - sigc::signal channel_active_postparse[16]; - - OneByteSignal mtc_quarter_frame; + ZeroByteSignal channel_active_preparse[16]; + ZeroByteSignal channel_active_postparse[16]; + OneByteSignal mtc_quarter_frame; /* see below for more useful signals */ + Signal mtc; Signal raw_preparse; Signal raw_postparse; Signal any; @@ -74,18 +85,16 @@ class Parser : public sigc::trackable { Signal position; Signal song; - Signal mtc; - sigc::signal mtc_qtr; + ZeroByteSignal all_notes_off; + ZeroByteSignal tune; + ZeroByteSignal active_sense; + ZeroByteSignal reset; + ZeroByteSignal eox; - sigc::signal all_notes_off; - sigc::signal tune; - sigc::signal timing; - sigc::signal start; - sigc::signal stop; - sigc::signal contineu; /* note spelling */ - sigc::signal active_sense; - sigc::signal reset; - sigc::signal eox; + TimestampedSignal timing; + TimestampedSignal start; + TimestampedSignal stop; + TimestampedSignal contineu; /* note spelling */ /* This should really be protected, but then derivatives of Port can't access it. @@ -97,13 +106,12 @@ class Parser : public sigc::trackable { const char *midi_event_type_name (MIDI::eventType); void trace (bool onoff, std::ostream *o, const std::string &prefix = ""); bool tracing() { return trace_stream != 0; } - Port &port() { return _port; } void set_offline (bool); bool offline() const { return _offline; } - sigc::signal OfflineStatusChanged; + PBD::Signal0 OfflineStatusChanged; - sigc::signal edit; + PBD::Signal2 edit; void set_mmc_forwarding (bool yn) { _mmc_forward = yn; @@ -111,20 +119,15 @@ class Parser : public sigc::trackable { /* MTC */ - enum MTC_Status { - MTC_Stopped = 0, - MTC_Forward, - MTC_Backward - }; - MTC_FPS mtc_fps() const { return _mtc_fps; } MTC_Status mtc_running() const { return _mtc_running; } const byte *mtc_current() const { return _mtc_time; } bool mtc_locked() const { return _mtc_locked; } - - sigc::signal mtc_status; - sigc::signal mtc_skipped; - sigc::signal mtc_time; + + PBD::Signal3 mtc_qtr; + PBD::Signal3 mtc_time; + PBD::Signal1 mtc_status; + PBD::Signal0 mtc_skipped; void set_mtc_forwarding (bool yn) { _mtc_forward = yn; @@ -133,13 +136,12 @@ class Parser : public sigc::trackable { void reset_mtc_state (); private: - Port &_port; /* tracing */ - + std::ostream *trace_stream; std::string trace_prefix; void trace_event (Parser &p, byte *msg, size_t len); - sigc::connection trace_connection; + PBD::ScopedConnection trace_connection; size_t message_counter[256]; @@ -168,6 +170,8 @@ class Parser : public sigc::trackable { MTC_Status _mtc_running; bool _mtc_locked; byte last_qtr_frame; + + framecnt_t _timestamp; ParseState pre_variable_state; MIDI::eventType pre_variable_msgtype;