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
This commit is contained in:
Taybin Rutkin 2006-07-19 16:47:04 +00:00
parent 50a4504e48
commit 433d9a5fc3
46 changed files with 57 additions and 477 deletions

View File

@ -26,7 +26,7 @@
namespace ARDOUR {
class Session;
};
}
/*
* This virtual parent class is so that each dialog box uses the
@ -55,3 +55,4 @@ class ArdourDialog : public Gtk::Dialog
};
#endif // __ardour_dialog_h__

View File

@ -79,7 +79,7 @@ class ColorManager;
namespace Gtkmm2ext {
class TearOff;
};
}
namespace ARDOUR {
class AudioEngine;
@ -87,11 +87,11 @@ namespace ARDOUR {
class Port;
class IO;
class ControlProtocolInfo;
};
}
namespace ALSA {
class MultiChannelDevice;
};
}
#define FRAME_NAME "BaseFrame"
@ -707,5 +707,5 @@ class ARDOUR_UI : public Gtkmm2ext::UI
void toggle_control_protocol (ARDOUR::ControlProtocolInfo*);
};
#endif /* __ardour_gui_h__ */

View File

@ -30,7 +30,7 @@
namespace ARDOUR {
class Session;
};
}
class AudioClock : public Gtk::HBox
{
@ -40,7 +40,7 @@ class AudioClock : public Gtk::HBox
BBT,
MinSec,
Frames,
Off,
Off
};
AudioClock (const string& name, bool editable, bool is_duration = false, bool with_tempo_meter = false);
@ -87,7 +87,7 @@ class AudioClock : public Gtk::HBox
Bars,
Beats,
Ticks,
AudioFrames,
AudioFrames
};
Gtk::EventBox audio_frames_ebox;

View File

@ -74,7 +74,7 @@ namespace ARDOUR {
const char* old;
};
};
}
/* how do we make these be within the Ardour namespace? */

View File

@ -443,6 +443,6 @@ class AudioDiskstream : public Stateful, public sigc::trackable
void disengage_record_enable (void* src);
};
}; /* namespace ARDOUR */
} // namespace ARDOUR
#endif /* __ardour_diskstream_h__ */

View File

@ -162,6 +162,6 @@ class AudioTrack : public Route
bool _destructive;
};
}; /* namespace ARDOUR*/
} // namespace ARDOUR
#endif /* __ardour_audio_track_h__ */

View File

@ -243,6 +243,6 @@ class AudioEngine : public sigc::trackable
mutable gint m_meter_exit;
};
}; /* namespace ARDOUR */
} // namespace ARDOUR
#endif /* __ardour_audioengine_h__ */

View File

@ -150,7 +150,7 @@ class AudioFileSource : public AudioSource {
bool writable() const { return _flags & Writable; }
};
}; /* namespace ARDOUR */
} // namespace ARDOUR
#endif /* __ardour_audiofilesource_h__ */

View File

@ -127,8 +127,7 @@ class AudioRegion : public Region
Fast,
Slow,
LogA,
LogB,
LogB
};
void set_fade_in_active (bool yn);

View File

@ -99,6 +99,6 @@ class Configuration : public Stateful
extern Configuration *Config;
extern gain_t speed_quietning; /* see comment in configuration.cc */
}; /* namespace ARDOUR */
} // namespace ARDOUR
#endif /* __ardour_configuration_h__ */

View File

@ -76,7 +76,7 @@ class Curve : public AutomationList
};
}; /* namespace ARDOUR */
} // namespace ARDOUR
extern "C" {
void curve_get_vector_from_c (void *arg, double, double, float*, int32_t);

View File

@ -83,6 +83,6 @@ namespace ARDOUR
int status;
};
};
} // namespace ARDOUR
#endif /* __ardour_export_h__ */

View File

@ -175,6 +175,6 @@ class PluginInsert : public Insert
Plugin* plugin_factory (Plugin&);
};
}; /* namespace ARDOUR */
} // namespace ARDOUR
#endif /* __ardour_insert_h__ */

View File

@ -381,6 +381,6 @@ public:
int32_t find_output_port_hole ();
};
}; /* namespace ARDOUR */
} // namespace ARDOUR
#endif /*__ardour_io_h__ */

View File

@ -199,6 +199,6 @@ class Locations : public Stateful, public StateManager
StateManager::State* state_factory (std::string why) const;
};
}; /* namespace ARDOUR */
} // namespace ARDOUR
#endif /* __ardour_location_h__ */

View File

@ -126,7 +126,7 @@ class LogCurveOut : public LogCurve
};
}; /* namespace ARDOUR */
} // namespace ARDOUR
#endif /* __ardour_logcurve_h__ */

View File

@ -312,6 +312,6 @@ class Panner : public std::vector<StreamPanner*>, public Stateful, public sigc::
static float current_automation_version_number;
};
}; /* namespace ARDOUR */
} // namespace ARDOUR
#endif /*__ardour_panner_h__ */

View File

@ -208,6 +208,6 @@ class Port : public sigc::trackable {
static jack_nframes_t short_over_length;
};
}; /* namespace ARDOUR */
} // namespace ARDOUR
#endif /* __ardour_port_h__ */

View File

@ -148,6 +148,6 @@ class Redirect : public IO
void* _gui; /* generic, we don't know or care what this is */
};
}; /* namespace ARDOUR */
} // namespace ARDOUR
#endif /* __ardour_redirect_h__ */

View File

@ -62,7 +62,7 @@ class Route : public IO
enum Flag {
Hidden = 0x1,
MasterOut = 0x2,
ControlOut = 0x4,
ControlOut = 0x4
};
@ -352,6 +352,6 @@ class Route : public IO
void redirect_active_proxy (Redirect*, void*);
};
}; /* namespace ARDOUR*/
} // namespace ARDOUR
#endif /* __ardour_route_h__ */

View File

@ -43,7 +43,7 @@ class RouteGroup : public Stateful, public sigc::trackable {
enum Flag {
Relative = 0x1,
Active = 0x2,
Hidden = 0x4,
Hidden = 0x4
};
RouteGroup (Session& s, const string &n, Flag f = Flag(0));

View File

@ -58,6 +58,6 @@ class Send : public Redirect {
uint32_t expected_inputs;
};
}; /* namespace ARDOUR */
} // namespace ARDOUR
#endif /* __ardour_send_h__ */

View File

@ -115,7 +115,7 @@ class Session : public sigc::trackable, public Stateful
enum SlaveSource {
None = 0,
MTC,
JACK,
JACK
};
enum AutoConnectOption {
@ -146,7 +146,7 @@ class Session : public sigc::trackable, public Stateful
*/
StopOnce,
AutoLoop,
AutoLoop
};
enum Action {
@ -1760,6 +1760,6 @@ class Session : public sigc::trackable, public Stateful
void remove_controllable (PBD::Controllable*);
};
}; /* namespace ARDOUR */
} // namespace ARDOUR
#endif /* __ardour_session_h__ */

View File

@ -75,7 +75,7 @@ class SndFileSource : public AudioFileSource {
int setup_broadcast_info (jack_nframes_t when, struct tm&, time_t);
};
}; /* namespace ARDOUR */
} // namespace ARDOUR
#endif /* __sndfile_source_h__ */

View File

@ -71,7 +71,7 @@ namespace ARDOUR {
PanAutomation = 0x2,
PluginAutomation = 0x4,
SoloAutomation = 0x8,
MuteAutomation = 0x10,
MuteAutomation = 0x10
};
enum AutoState {
@ -190,7 +190,7 @@ namespace ARDOUR {
enum EditMode {
Slide,
Splice,
Splice
};
enum RegionPoint {
@ -243,7 +243,7 @@ namespace ARDOUR {
PeakDatum min;
PeakDatum max;
};
};
}
std::istream& operator>>(std::istream& o, ARDOUR::SampleFormat& sf);
std::istream& operator>>(std::istream& o, ARDOUR::HeaderFormat& sf);

View File

@ -1179,7 +1179,7 @@ struct PanPlugins {
PanPlugins pan_plugins[] = {
{ EqualPowerStereoPanner::name, 2, EqualPowerStereoPanner::factory },
{ Multi2dPanner::name, 3, Multi2dPanner::factory },
{ string (""), 0 }
{ string (""), 0, 0 }
};
XMLNode&

View File

@ -2463,7 +2463,7 @@ remove_end(string* state)
statename = statename.substr (start+1);
}
if ((end = statename.rfind(".ardour")) < 0) {
if ((end = statename.rfind(".ardour")) == string::npos) {
end = statename.length();
}

View File

@ -18,7 +18,6 @@ fd_midiport.cc
fifomidi.cc
midi.cc
midichannel.cc
midicontrollable.cc
midifactory.cc
midimanager.cc
midiparser.cc

View File

@ -152,7 +152,7 @@ class Channel : public sigc::trackable {
void process_reset (Parser &);
};
}; /* namespace MIDI */
} // namespace MIDI
#endif // __midichannel_h__

View File

@ -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__

View File

@ -62,6 +62,6 @@ namespace MIDI {
bool firstrecv;
};
}; /* namespace MIDI */
} // namespace MIDI
#endif // __coremidi_midiport_h__

View File

@ -35,6 +35,6 @@ class PortFactory {
const std::string &reqstr);
};
}; /* namespace MIDI */
} // namespace MIDI
#endif // __midi_factory_h__

View File

@ -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__

View File

@ -42,6 +42,6 @@ class FIFO_MidiPort : public MIDI::FD_MidiPort
void open (PortRequest &req);
};
}; /* namespace MIDI */
} // namespace MIDI
#endif // __fifomidi_h__

View File

@ -83,6 +83,6 @@ class Manager {
void close_ports ();
};
}; /* namespace MIDI */
} // namespace MIDI
#endif // __midi_manager_h__

View File

@ -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__ */

View File

@ -57,6 +57,6 @@ class Null_MidiPort : public Port
virtual int selectable() const { return -1; }
};
}; /* namespace MIDI */
} // namespace MIDI
#endif // __nullmidi_h__

View File

@ -183,7 +183,7 @@ class Parser : public sigc::trackable {
void process_mtc_quarter_frame (byte *msg);
};
}; /* namespace MIDI */
} // namespace MIDI
#endif // __midi_parse_h__

View File

@ -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__

View File

@ -54,7 +54,7 @@ struct PortRequest {
const std::string &xtype);
};
}; /* namespace MIDI */
} // namespace MIDI
#endif // __midi_port_request_h__

View File

@ -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__

View File

@ -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);
}

View File

@ -101,7 +101,7 @@ Parser::midi_event_type_name (eventType t)
default:
return "unknow MIDI event type";
}
};
}
Parser::Parser (Port &p)
: _port (p)

View File

@ -8,6 +8,6 @@ namespace PBD
extern std::string basename_nosuffix (const std::string&);
};
} // namespace PBD
#endif // __stupid_basename_h__

View File

@ -70,7 +70,7 @@ Pool::alloc ()
} else {
return ptr;
}
};
}
void
Pool::release (void *ptr)

View File

@ -105,6 +105,6 @@ namespace soundtouch
#endif
#endif // INTEGER_SAMPLES
};
}
#endif