diff options
author | Taybin Rutkin <taybin@taybin.com> | 2006-07-19 16:47:04 +0000 |
---|---|---|
committer | Taybin Rutkin <taybin@taybin.com> | 2006-07-19 16:47:04 +0000 |
commit | 433d9a5fc3538aa170d3ad1cb11929c0e5e94567 (patch) | |
tree | ce4cb929e91bb94ef0d410f2824ca1623440d696 /libs/midi++2 | |
parent | 50a4504e488227182374b39c7ea50a1147f3557d (diff) |
Removed unused midicontrollable.cc
Enum and namespace syntax fixes to satisfy -pedantic
Resolved a couple "code never reached" areas to satisfy -Wextra
git-svn-id: svn://localhost/ardour2/trunk@688 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/midi++2')
-rw-r--r-- | libs/midi++2/SConscript | 1 | ||||
-rw-r--r-- | libs/midi++2/midi++/channel.h | 2 | ||||
-rw-r--r-- | libs/midi++2/midi++/controllable.h | 92 | ||||
-rw-r--r-- | libs/midi++2/midi++/coremidi_midiport.h | 2 | ||||
-rw-r--r-- | libs/midi++2/midi++/factory.h | 2 | ||||
-rw-r--r-- | libs/midi++2/midi++/fd_midiport.h | 2 | ||||
-rw-r--r-- | libs/midi++2/midi++/fifomidi.h | 2 | ||||
-rw-r--r-- | libs/midi++2/midi++/manager.h | 2 | ||||
-rw-r--r-- | libs/midi++2/midi++/mmc.h | 4 | ||||
-rw-r--r-- | libs/midi++2/midi++/nullmidi.h | 2 | ||||
-rw-r--r-- | libs/midi++2/midi++/parser.h | 2 | ||||
-rw-r--r-- | libs/midi++2/midi++/port.h | 5 | ||||
-rw-r--r-- | libs/midi++2/midi++/port_request.h | 2 | ||||
-rw-r--r-- | libs/midi++2/midi++/types.h | 4 | ||||
-rw-r--r-- | libs/midi++2/midicontrollable.cc | 326 | ||||
-rw-r--r-- | libs/midi++2/midiparser.cc | 2 |
16 files changed, 16 insertions, 436 deletions
diff --git a/libs/midi++2/SConscript b/libs/midi++2/SConscript index 63a3b04f8d..696fed6b5b 100644 --- a/libs/midi++2/SConscript +++ b/libs/midi++2/SConscript @@ -18,7 +18,6 @@ fd_midiport.cc fifomidi.cc midi.cc midichannel.cc -midicontrollable.cc midifactory.cc midimanager.cc midiparser.cc diff --git a/libs/midi++2/midi++/channel.h b/libs/midi++2/midi++/channel.h index 1efde3cb93..f8dbb6e194 100644 --- a/libs/midi++2/midi++/channel.h +++ b/libs/midi++2/midi++/channel.h @@ -152,7 +152,7 @@ class Channel : public sigc::trackable { void process_reset (Parser &); }; -}; /* namespace MIDI */ +} // namespace MIDI #endif // __midichannel_h__ diff --git a/libs/midi++2/midi++/controllable.h b/libs/midi++2/midi++/controllable.h deleted file mode 100644 index 3fa108bb46..0000000000 --- a/libs/midi++2/midi++/controllable.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - 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 - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - - $Id$ -*/ - -#ifndef __qm_midicontrollable_h__ -#define __qm_midicontrollable_h__ - -#include <string> - -#include <sigc++/sigc++.h> - -#include <midi++/types.h> - -namespace MIDI { - -class Channel; -class Port; -class Parser; - -class Controllable : public sigc::trackable -{ - public: - Controllable (Port *, bool bistate = false); - virtual ~Controllable (); - - void midi_rebind (Port *, channel_t channel=-1); - void midi_forget (); - void learn_about_external_control (); - void stop_learning (); - void drop_external_control (); - - virtual void set_value (float) = 0; - - sigc::signal<void> learning_started; - sigc::signal<void> learning_stopped; - - bool get_control_info (channel_t&, eventType&, byte&); - void set_control_type (channel_t, eventType, byte); - - bool get_midi_feedback () { return feedback; } - void set_midi_feedback (bool val) { feedback = val; } - - Port * get_port() { return port; } - - std::string control_description() const { return _control_description; } - - void send_midi_feedback (float); - - private: - bool bistate; - int midi_msg_id; /* controller ID or note number */ - sigc::connection midi_sense_connection[2]; - sigc::connection midi_learn_connection; - size_t connections; - Port* port; - eventType control_type; - byte control_additional; - channel_t control_channel; - std::string _control_description; - bool feedback; - - void midi_receiver (Parser &p, byte *, size_t); - void midi_sense_note (Parser &, EventTwoBytes *, bool is_on); - void midi_sense_note_on (Parser &p, EventTwoBytes *tb); - void midi_sense_note_off (Parser &p, EventTwoBytes *tb); - void midi_sense_controller (Parser &, EventTwoBytes *); - void midi_sense_program_change (Parser &, byte); - void midi_sense_pitchbend (Parser &, pitchbend_t); - - void bind_midi (channel_t, eventType, byte); -}; - -}; /* namespace MIDI */ - -#endif // __qm_midicontrollable_h__ - diff --git a/libs/midi++2/midi++/coremidi_midiport.h b/libs/midi++2/midi++/coremidi_midiport.h index e02a225784..d7df23aa04 100644 --- a/libs/midi++2/midi++/coremidi_midiport.h +++ b/libs/midi++2/midi++/coremidi_midiport.h @@ -62,6 +62,6 @@ namespace MIDI { bool firstrecv; }; -}; /* namespace MIDI */ +} // namespace MIDI #endif // __coremidi_midiport_h__ diff --git a/libs/midi++2/midi++/factory.h b/libs/midi++2/midi++/factory.h index 1543f68cdc..7b4122d791 100644 --- a/libs/midi++2/midi++/factory.h +++ b/libs/midi++2/midi++/factory.h @@ -35,6 +35,6 @@ class PortFactory { const std::string &reqstr); }; -}; /* namespace MIDI */ +} // namespace MIDI #endif // __midi_factory_h__ diff --git a/libs/midi++2/midi++/fd_midiport.h b/libs/midi++2/midi++/fd_midiport.h index 853af9d7b4..6a9b8f74d1 100644 --- a/libs/midi++2/midi++/fd_midiport.h +++ b/libs/midi++2/midi++/fd_midiport.h @@ -89,6 +89,6 @@ class FD_MidiPort : public Port int do_slow_write (byte *msg, unsigned int msglen); }; -}; /*namespace MIDI */ +} // namespace MIDI #endif // __fd_midiport_h__ diff --git a/libs/midi++2/midi++/fifomidi.h b/libs/midi++2/midi++/fifomidi.h index eb8778d4d5..200d90eda8 100644 --- a/libs/midi++2/midi++/fifomidi.h +++ b/libs/midi++2/midi++/fifomidi.h @@ -42,6 +42,6 @@ class FIFO_MidiPort : public MIDI::FD_MidiPort void open (PortRequest &req); }; -}; /* namespace MIDI */ +} // namespace MIDI #endif // __fifomidi_h__ diff --git a/libs/midi++2/midi++/manager.h b/libs/midi++2/midi++/manager.h index 4889aad8c9..1bf8dc7cbd 100644 --- a/libs/midi++2/midi++/manager.h +++ b/libs/midi++2/midi++/manager.h @@ -83,6 +83,6 @@ class Manager { void close_ports (); }; -}; /* namespace MIDI */ +} // namespace MIDI #endif // __midi_manager_h__ diff --git a/libs/midi++2/midi++/mmc.h b/libs/midi++2/midi++/mmc.h index 7b51b33a72..2d569f122c 100644 --- a/libs/midi++2/midi++/mmc.h +++ b/libs/midi++2/midi++/mmc.h @@ -82,7 +82,7 @@ class MachineControl : public sigc::trackable cmdRecordStrobeVariable = 0x55, cmdWait = 0x7C, - cmdResume = 0x7F, + cmdResume = 0x7F }; MachineControl (Port &port, @@ -256,6 +256,6 @@ class MachineControl : public sigc::trackable void write_track_record_ready (byte *, size_t len); }; -}; /* namespace MIDI */ +} // namespace MIDI #endif /* __midipp_mmc_h_h__ */ diff --git a/libs/midi++2/midi++/nullmidi.h b/libs/midi++2/midi++/nullmidi.h index a94b1015b0..a74e5e3d9b 100644 --- a/libs/midi++2/midi++/nullmidi.h +++ b/libs/midi++2/midi++/nullmidi.h @@ -57,6 +57,6 @@ class Null_MidiPort : public Port virtual int selectable() const { return -1; } }; -}; /* namespace MIDI */ +} // namespace MIDI #endif // __nullmidi_h__ diff --git a/libs/midi++2/midi++/parser.h b/libs/midi++2/midi++/parser.h index 4ac07cc15d..36d19f3da9 100644 --- a/libs/midi++2/midi++/parser.h +++ b/libs/midi++2/midi++/parser.h @@ -183,7 +183,7 @@ class Parser : public sigc::trackable { void process_mtc_quarter_frame (byte *msg); }; -}; /* namespace MIDI */ +} // namespace MIDI #endif // __midi_parse_h__ diff --git a/libs/midi++2/midi++/port.h b/libs/midi++2/midi++/port.h index a186f1fd5f..4a5319b120 100644 --- a/libs/midi++2/midi++/port.h +++ b/libs/midi++2/midi++/port.h @@ -40,7 +40,7 @@ class Port : public sigc::trackable { ALSA_Sequencer, CoreMidi_MidiPort, Null, - FIFO, + FIFO }; @@ -140,7 +140,6 @@ class Port : public sigc::trackable { static size_t nports; }; -}; /* namespace MIDI */ +} // namespace MIDI #endif // __libmidi_port_h__ - diff --git a/libs/midi++2/midi++/port_request.h b/libs/midi++2/midi++/port_request.h index 28a0d1d70b..86838dd04d 100644 --- a/libs/midi++2/midi++/port_request.h +++ b/libs/midi++2/midi++/port_request.h @@ -54,7 +54,7 @@ struct PortRequest { const std::string &xtype); }; -}; /* namespace MIDI */ +} // namespace MIDI #endif // __midi_port_request_h__ diff --git a/libs/midi++2/midi++/types.h b/libs/midi++2/midi++/types.h index b9d9bf33e7..218416d213 100644 --- a/libs/midi++2/midi++/types.h +++ b/libs/midi++2/midi++/types.h @@ -57,10 +57,10 @@ namespace MIDI { enum MTC_Status { MTC_Stopped = 0, MTC_Forward, - MTC_Backward, + MTC_Backward }; -}; /* namespace MIDI */ +} // namespace MIDI #endif // __midi_types_h__ diff --git a/libs/midi++2/midicontrollable.cc b/libs/midi++2/midicontrollable.cc deleted file mode 100644 index f0dbd9cb77..0000000000 --- a/libs/midi++2/midicontrollable.cc +++ /dev/null @@ -1,326 +0,0 @@ -/* - 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 - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - - $Id$ -*/ - -#include <cstdio> /* for sprintf, sigh */ -#include <pbd/error.h> -#include <midi++/port.h> -#include <midi++/channel.h> -#include <midi++/controllable.h> - -using namespace sigc; -using namespace MIDI; -using namespace PBD; - -Controllable::Controllable (Port *p, bool is_bistate) -{ - control_type = none; - _control_description = "MIDI Control: none"; - control_additional = (byte) -1; - bistate = is_bistate; - connections = 0; - feedback = true; // for now - - /* use channel 0 ("1") as the initial channel */ - - midi_rebind (p, 0); -} - -Controllable::~Controllable () -{ - drop_external_control (); -} - -void -Controllable::midi_forget () -{ - /* stop listening for incoming messages, but retain - our existing event + type information. - */ - - if (connections > 0) { - midi_sense_connection[0].disconnect (); - } - - if (connections > 1) { - midi_sense_connection[1].disconnect (); - } - - connections = 0; - midi_learn_connection.disconnect (); - -} - -void -Controllable::midi_rebind (Port *p, channel_t c) -{ - if ((port = p) == 0) { - midi_forget (); - } else { - if (c >= 0) { - bind_midi (c, control_type, control_additional); - } else { - midi_forget (); - } - } -} - -void -Controllable::learn_about_external_control () -{ - drop_external_control (); - - if (port) { - midi_learn_connection = port->input()->any.connect (mem_fun (*this, &Controllable::midi_receiver)); - learning_started (); - - } else { - info << "No MIDI port specified - external control disabled" << endmsg; - } -} - -void -Controllable::stop_learning () -{ - midi_learn_connection.disconnect (); -} - -void -Controllable::drop_external_control () -{ - if (connections > 0) { - midi_sense_connection[0].disconnect (); - } - if (connections > 1) { - midi_sense_connection[1].disconnect (); - } - - connections = 0; - midi_learn_connection.disconnect (); - - control_type = none; - control_additional = (byte) -1; -} - -void -Controllable::midi_sense_note_on (Parser &p, EventTwoBytes *tb) -{ - midi_sense_note (p, tb, true); -} - -void -Controllable::midi_sense_note_off (Parser &p, EventTwoBytes *tb) -{ - midi_sense_note (p, tb, false); -} - -void -Controllable::midi_sense_note (Parser &p, EventTwoBytes *msg, bool is_on) -{ - if (!bistate) { - set_value (msg->note_number/127.0); - } else { - - /* Note: parser handles the use of zero velocity to - mean note off. if we get called with is_on=true, then we - got a *real* note on. - */ - - if (msg->note_number == control_additional) { - set_value (is_on ? 1 : 0); - } - } -} - -void -Controllable::midi_sense_controller (Parser &, EventTwoBytes *msg) -{ - if (control_additional == msg->controller_number) { - if (!bistate) { - set_value (msg->value/127.0); - } else { - if (msg->value > 64.0) { - set_value (1); - } else { - set_value (0); - } - } - } -} - -void -Controllable::midi_sense_program_change (Parser &p, byte msg) -{ - /* XXX program change messages make no sense for bistates */ - - if (!bistate) { - set_value (msg/127.0); - } -} - -void -Controllable::midi_sense_pitchbend (Parser &p, pitchbend_t pb) -{ - /* pitchbend messages make no sense for bistates */ - - /* XXX gack - get rid of assumption about typeof pitchbend_t */ - - set_value ((pb/(float) SHRT_MAX)); -} - -void -Controllable::midi_receiver (Parser &p, byte *msg, size_t len) -{ - /* we only respond to channel messages */ - - if ((msg[0] & 0xF0) < 0x80 || (msg[0] & 0xF0) > 0xE0) { - return; - } - - /* if the our port doesn't do input anymore, forget it ... */ - - if (!port->input()) { - return; - } - - bind_midi ((channel_t) (msg[0] & 0xf), eventType (msg[0] & 0xF0), msg[1]); - - learning_stopped (); -} - -void -Controllable::bind_midi (channel_t chn, eventType ev, MIDI::byte additional) -{ - char buf[64]; - - drop_external_control (); - - control_type = ev; - control_channel = chn; - control_additional = additional; - - if (port == 0 || port->input() == 0) { - return; - } - - Parser& p = *port->input(); - - int chn_i = chn; - switch (ev) { - case MIDI::off: - midi_sense_connection[0] = p.channel_note_off[chn_i].connect - (mem_fun (*this, &Controllable::midi_sense_note_off)); - - /* if this is a bistate, connect to noteOn as well, - and we'll toggle back and forth between the two. - */ - - if (bistate) { - midi_sense_connection[1] = p.channel_note_on[chn_i].connect - (mem_fun (*this, &Controllable::midi_sense_note_on)); - connections = 2; - } else { - connections = 1; - } - _control_description = "MIDI control: NoteOff"; - break; - - case MIDI::on: - midi_sense_connection[0] = p.channel_note_on[chn_i].connect - (mem_fun (*this, &Controllable::midi_sense_note_on)); - if (bistate) { - midi_sense_connection[1] = p.channel_note_off[chn_i].connect - (mem_fun (*this, &Controllable::midi_sense_note_off)); - connections = 2; - } else { - connections = 1; - } - _control_description = "MIDI control: NoteOn"; - break; - - case MIDI::controller: - midi_sense_connection[0] = p.channel_controller[chn_i].connect - (mem_fun (*this, &Controllable::midi_sense_controller)); - connections = 1; - snprintf (buf, sizeof (buf), "MIDI control: Controller %d", control_additional); - _control_description = buf; - break; - - case MIDI::program: - if (!bistate) { - midi_sense_connection[0] = p.channel_program_change[chn_i].connect - (mem_fun (*this, - &Controllable::midi_sense_program_change)); - connections = 1; - _control_description = "MIDI control: ProgramChange"; - } - break; - - case MIDI::pitchbend: - if (!bistate) { - midi_sense_connection[0] = p.channel_pitchbend[chn_i].connect - (mem_fun (*this, &Controllable::midi_sense_pitchbend)); - connections = 1; - _control_description = "MIDI control: Pitchbend"; - } - break; - - default: - break; - } -} - -void -Controllable::set_control_type (channel_t chn, eventType ev, MIDI::byte additional) -{ - bind_midi (chn, ev, additional); -} - -bool -Controllable::get_control_info (channel_t& chn, eventType& ev, byte& additional) -{ - if (control_type == none) { - chn = -1; - return false; - } - - ev = control_type; - chn = control_channel; - additional = control_additional; - - return true; -} - - -void -Controllable::send_midi_feedback (float val) -{ - byte msg[3]; - - if (port == 0 || control_type == none) { - return; - } - - msg[0] = (control_type & 0xF0) | (control_channel & 0xF); - msg[1] = control_additional; - msg[2] = (byte) (val * 127.0f); - - port->write (msg, 3); -} - diff --git a/libs/midi++2/midiparser.cc b/libs/midi++2/midiparser.cc index 04ac2728f1..424bfa04f8 100644 --- a/libs/midi++2/midiparser.cc +++ b/libs/midi++2/midiparser.cc @@ -101,7 +101,7 @@ Parser::midi_event_type_name (eventType t) default: return "unknow MIDI event type"; } -}; +} Parser::Parser (Port &p) : _port (p) |