mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-09 16:24:57 +01:00
MCP: the return of the master fader
git-svn-id: svn://localhost/ardour2/branches/3.0@11973 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
2ed2b61224
commit
24377e9fb2
4 changed files with 58 additions and 11 deletions
|
|
@ -17,6 +17,8 @@
|
||||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
#include "fader.h"
|
#include "fader.h"
|
||||||
#include "surface.h"
|
#include "surface.h"
|
||||||
#include "control_group.h"
|
#include "control_group.h"
|
||||||
|
|
@ -50,6 +52,6 @@ Fader::update_message ()
|
||||||
return MidiByteArray();
|
return MidiByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
int posi = int (0x3fff * position);
|
int posi = lrintf (0x3fff * position);
|
||||||
return MidiByteArray (3, 0xe0 | id(), posi & 0x7f, posi >> 7);
|
return MidiByteArray (3, 0xe0 + id(), posi & 0x7f, posi >> 7);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ namespace Mackie {
|
||||||
class Fader : public Control
|
class Fader : public Control
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Fader (int id, std::string name, Group & group)
|
Fader (int id, std::string name, Group & group)
|
||||||
: Control (id, name, group)
|
: Control (id, name, group)
|
||||||
, position (0.0)
|
, position (0.0)
|
||||||
|
|
|
||||||
|
|
@ -7,11 +7,13 @@
|
||||||
#include "midi++/port.h"
|
#include "midi++/port.h"
|
||||||
#include "midi++/manager.h"
|
#include "midi++/manager.h"
|
||||||
|
|
||||||
|
#include "ardour/automation_control.h"
|
||||||
#include "ardour/debug.h"
|
#include "ardour/debug.h"
|
||||||
#include "ardour/route.h"
|
#include "ardour/route.h"
|
||||||
#include "ardour/panner.h"
|
#include "ardour/panner.h"
|
||||||
#include "ardour/panner_shell.h"
|
#include "ardour/panner_shell.h"
|
||||||
#include "ardour/rc_configuration.h"
|
#include "ardour/rc_configuration.h"
|
||||||
|
#include "ardour/session.h"
|
||||||
|
|
||||||
#include "control_group.h"
|
#include "control_group.h"
|
||||||
#include "surface_port.h"
|
#include "surface_port.h"
|
||||||
|
|
@ -36,7 +38,12 @@ using namespace Mackie;
|
||||||
using ARDOUR::Route;
|
using ARDOUR::Route;
|
||||||
using ARDOUR::Panner;
|
using ARDOUR::Panner;
|
||||||
using ARDOUR::Pannable;
|
using ARDOUR::Pannable;
|
||||||
using ARDOUR::PannerShell;
|
using ARDOUR::AutomationControl;
|
||||||
|
|
||||||
|
#define ui_context() MackieControlProtocol::instance() /* a UICallback-derived object that specifies the event loop for signal handling */
|
||||||
|
#define ui_bind(f, ...) boost::protect (boost::bind (f, __VA_ARGS__))
|
||||||
|
extern PBD::EventLoop::InvalidationRecord* __invalidator (sigc::trackable& trackable, const char*, int);
|
||||||
|
#define invalidator() __invalidator (*(MackieControlProtocol::instance()), __FILE__, __LINE__)
|
||||||
|
|
||||||
// The MCU sysex header.4th byte Will be overwritten
|
// The MCU sysex header.4th byte Will be overwritten
|
||||||
// when we get an incoming sysex that identifies
|
// when we get an incoming sysex that identifies
|
||||||
|
|
@ -69,6 +76,10 @@ Surface::Surface (MackieControlProtocol& mcp, const std::string& device_name, ui
|
||||||
if (_mcp.device_info().has_global_controls()) {
|
if (_mcp.device_info().has_global_controls()) {
|
||||||
init_controls ();
|
init_controls ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_mcp.device_info().has_master_fader()) {
|
||||||
|
setup_master ();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t n = _mcp.device_info().strip_cnt();
|
uint32_t n = _mcp.device_info().strip_cnt();
|
||||||
|
|
@ -194,6 +205,33 @@ Surface::init_strips (uint32_t n)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Surface::setup_master ()
|
||||||
|
{
|
||||||
|
_master_fader = dynamic_cast<Fader*> (Fader::factory (*this, 8, "master", *groups["master"]));
|
||||||
|
|
||||||
|
boost::shared_ptr<Route> m;
|
||||||
|
|
||||||
|
if ((m = _mcp.get_session().monitor_out()) == 0) {
|
||||||
|
m = _mcp.get_session().master_out();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!m) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_master_fader->set_normal_control (m->gain_control());
|
||||||
|
m->gain_control()->Changed.connect (*this, invalidator(), ui_bind (&Surface::master_gain_changed, this), ui_context());
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Surface::master_gain_changed ()
|
||||||
|
{
|
||||||
|
boost::shared_ptr<AutomationControl> ac = _master_fader->control(false);
|
||||||
|
float pos = ac->internal_to_interface (ac->get_value());
|
||||||
|
_port->write (_master_fader->set_position (pos));
|
||||||
|
}
|
||||||
|
|
||||||
float
|
float
|
||||||
Surface::scaled_delta (float delta, float current_speed)
|
Surface::scaled_delta (float delta, float current_speed)
|
||||||
{
|
{
|
||||||
|
|
@ -289,11 +327,13 @@ Surface::handle_midi_pitchbend_message (MIDI::Parser&, MIDI::pitchbend_t pb, uin
|
||||||
|
|
||||||
if (fader) {
|
if (fader) {
|
||||||
Strip* strip = dynamic_cast<Strip*> (&fader->group());
|
Strip* strip = dynamic_cast<Strip*> (&fader->group());
|
||||||
|
float pos = (pb >> 4)/1023.0; // only the top 10 bytes are used
|
||||||
if (strip) {
|
if (strip) {
|
||||||
float midi_pos = pb >> 4; // only the top 10 bytes are used
|
strip->handle_fader (*fader, pos);
|
||||||
strip->handle_fader (*fader, midi_pos/1023.0);
|
|
||||||
} else {
|
} else {
|
||||||
/* master fader */
|
/* master fader */
|
||||||
|
fader->set_value (pos, false); // alter master gain
|
||||||
|
_port->write (fader->set_position (pos)); // write back value (required for servo)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
DEBUG_TRACE (DEBUG::MackieControl, "fader not found\n");
|
DEBUG_TRACE (DEBUG::MackieControl, "fader not found\n");
|
||||||
|
|
|
||||||
|
|
@ -59,9 +59,9 @@ public:
|
||||||
std::map<int,Control*> controls_by_device_independent_id;
|
std::map<int,Control*> controls_by_device_independent_id;
|
||||||
|
|
||||||
Mackie::JogWheel* jog_wheel() const { return _jog_wheel; }
|
Mackie::JogWheel* jog_wheel() const { return _jog_wheel; }
|
||||||
|
Fader* master_fader() const { return _master_fader; }
|
||||||
|
|
||||||
/// The collection of all numbered strips. No master
|
/// The collection of all numbered strips.
|
||||||
/// strip in here.
|
|
||||||
typedef std::vector<Strip*> Strips;
|
typedef std::vector<Strip*> Strips;
|
||||||
Strips strips;
|
Strips strips;
|
||||||
|
|
||||||
|
|
@ -147,8 +147,6 @@ public:
|
||||||
MackieControlProtocol& mcp() const { return _mcp; }
|
MackieControlProtocol& mcp() const { return _mcp; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void init_controls();
|
|
||||||
void init_strips (uint32_t n);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MackieControlProtocol& _mcp;
|
MackieControlProtocol& _mcp;
|
||||||
|
|
@ -159,11 +157,17 @@ public:
|
||||||
bool _active;
|
bool _active;
|
||||||
bool _connected;
|
bool _connected;
|
||||||
Mackie::JogWheel* _jog_wheel;
|
Mackie::JogWheel* _jog_wheel;
|
||||||
|
Fader* _master_fader;
|
||||||
|
|
||||||
void jog_wheel_state_display (Mackie::JogWheel::State state);
|
void jog_wheel_state_display (Mackie::JogWheel::State state);
|
||||||
void handle_midi_sysex (MIDI::Parser&, MIDI::byte *, size_t count);
|
void handle_midi_sysex (MIDI::Parser&, MIDI::byte *, size_t count);
|
||||||
MidiByteArray host_connection_query (MidiByteArray& bytes);
|
MidiByteArray host_connection_query (MidiByteArray& bytes);
|
||||||
MidiByteArray host_connection_confirmation (const MidiByteArray& bytes);
|
MidiByteArray host_connection_confirmation (const MidiByteArray& bytes);
|
||||||
|
|
||||||
|
void init_controls();
|
||||||
|
void init_strips (uint32_t n);
|
||||||
|
void setup_master ();
|
||||||
|
void master_gain_changed ();
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue