partially-done (but compile-friendly) move of instrument info into a new backend object

git-svn-id: svn://localhost/ardour2/branches/3.0@12652 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2012-06-11 12:07:17 +00:00
parent 80afb6e08b
commit 960de7306f
9 changed files with 192 additions and 60 deletions

View File

@ -115,10 +115,6 @@ MidiRegionView::MidiRegionView (ArdourCanvas::Group *parent, RouteTimeAxisView &
_note_group->raise_to_top();
PublicEditor::DropDownKeys.connect (sigc::mem_fun (*this, &MidiRegionView::drop_down_keys));
/* Look up MIDNAM details from our MidiTimeAxisView */
MidiTimeAxisView& mtv = dynamic_cast<MidiTimeAxisView&> (tv);
midi_patch_settings_changed (mtv.midi_patch_model (), mtv.midi_patch_custom_device_mode ());
Config->ParameterChanged.connect (*this, invalidator (*this), boost::bind (&MidiRegionView::parameter_changed, this, _1), gui_context());
connect_to_diskstream ();
@ -156,10 +152,6 @@ MidiRegionView::MidiRegionView (ArdourCanvas::Group *parent, RouteTimeAxisView &
_note_group->raise_to_top();
PublicEditor::DropDownKeys.connect (sigc::mem_fun (*this, &MidiRegionView::drop_down_keys));
/* Look up MIDNAM details from our MidiTimeAxisView */
MidiTimeAxisView& mtv = dynamic_cast<MidiTimeAxisView&> (tv);
midi_patch_settings_changed (mtv.midi_patch_model (), mtv.midi_patch_custom_device_mode ());
connect_to_diskstream ();
SelectionCleared.connect (_selection_cleared_connection, invalidator (*this), boost::bind (&MidiRegionView::selection_cleared, this, _1), gui_context ());
@ -291,8 +283,11 @@ MidiRegionView::init (Gdk::Color const & basic_color, bool wfd)
midi_view()->signal_channel_mode_changed().connect(
sigc::mem_fun(this, &MidiRegionView::midi_channel_mode_changed));
midi_view()->signal_midi_patch_settings_changed().connect(
sigc::mem_fun(this, &MidiRegionView::midi_patch_settings_changed));
RouteUI* route_ui = dynamic_cast<RouteUI*> (&trackview);
if (route_ui) {
route_ui->route()->instrument_info().Changed.connect (_instrument_changed_connection, invalidator (*this),
boost::bind (&MidiRegionView::instrument_settings_changed, this), gui_context());
}
trackview.editor().SnapChanged.connect(snap_changed_connection, invalidator(*this),
boost::bind (&MidiRegionView::snap_changed, this),
@ -1209,10 +1204,10 @@ MidiRegionView::display_patch_changes_on_channel (uint8_t channel, bool active_c
continue;
}
MidiTimeAxisView* const mtv = dynamic_cast<MidiTimeAxisView*>(&trackview);
string patch_name = mtv->get_patch_name ((*i)->bank(), (*i)->program(), channel);
// MidiTimeAxisView* const mtv = dynamic_cast<MidiTimeAxisView*>(&trackview);
//string patch_name = mtv->get_patch_name ((*i)->bank(), (*i)->program(), channel);
add_canvas_patch_change (*i, patch_name, active_channel);
// add_canvas_patch_change (*i, patch_name, active_channel);
}
}
@ -3207,10 +3202,8 @@ MidiRegionView::midi_channel_mode_changed(ChannelMode mode, uint16_t mask)
}
void
MidiRegionView::midi_patch_settings_changed(std::string model, std::string custom_device_mode)
MidiRegionView::instrument_settings_changed ()
{
_model_name = model;
_custom_device_mode = custom_device_mode;
redisplay_model();
}

View File

@ -356,7 +356,8 @@ private:
bool note_canvas_event(GdkEvent* ev);
void midi_channel_mode_changed(ARDOUR::ChannelMode mode, uint16_t mask);
void midi_patch_settings_changed(std::string model, std::string custom_device_mode);
void instrument_settings_changed ();
PBD::ScopedConnection _instrument_changed_connection;
void change_note_channel (ArdourCanvas::CanvasNoteEvent *, int8_t, bool relative=false);
void change_note_velocity(ArdourCanvas::CanvasNoteEvent* ev, int8_t vel, bool relative=false);

View File

@ -317,15 +317,14 @@ MidiTimeAxisView::model_changed()
}
_custom_device_mode_selector.set_active(0);
set_gui_property (X_("midnam-model-name"), midi_patch_model ());
_route->instrument_info().set_external_instrument (_model_selector.get_active_text(), _custom_device_mode_selector.get_active_text());
}
void
MidiTimeAxisView::custom_device_mode_changed()
{
_midi_patch_settings_changed.emit (midi_patch_model (), midi_patch_custom_device_mode ());
set_gui_property (X_("midnam-custom-device-mode"), midi_patch_custom_device_mode ());
_route->instrument_info().set_external_instrument (_model_selector.get_active_text(), _custom_device_mode_selector.get_active_text());
}
MidiStreamView*
@ -1207,33 +1206,3 @@ MidiTimeAxisView::note_range_changed ()
set_gui_property ("note-range-max", (int) midi_view()->highest_note ());
}
string
MidiTimeAxisView::midi_patch_model () const
{
return _model_selector.get_active_text ();
}
string
MidiTimeAxisView::midi_patch_custom_device_mode () const
{
return _custom_device_mode_selector.get_active_text ();
}
string
MidiTimeAxisView::get_patch_name (uint16_t bank, uint8_t program, uint8_t channel) const
{
MIDI::Name::PatchPrimaryKey patch_key (bank, program);
boost::shared_ptr<MIDI::Name::Patch> patch =
MIDI::Name::MidiPatchManager::instance().find_patch (midi_patch_model(), midi_patch_custom_device_mode(), channel, patch_key);
if (patch) {
return patch->name();
} else {
/* program and bank numbers are zero-based: convert to one-based: MIDI_BP_ZERO */
#define MIDI_BP_ZERO ((Config->get_first_midi_bank_is_zero())?0:1)
return string_compose ("%1 %2",program + MIDI_BP_ZERO , bank + MIDI_BP_ZERO);
}
}

View File

@ -86,11 +86,6 @@ class MidiTimeAxisView : public RouteTimeAxisView
return _channel_selector.mode_changed;
}
sigc::signal<void, std::string, std::string>& signal_midi_patch_settings_changed() {
return _midi_patch_settings_changed;
}
const MidiMultipleChannelSelector& channel_selector() { return _channel_selector; }
Gtk::CheckMenuItem* automation_child_menu_item (Evoral::Parameter);
@ -102,10 +97,6 @@ class MidiTimeAxisView : public RouteTimeAxisView
uint8_t get_channel_for_add () const;
std::string midi_patch_model () const;
std::string midi_patch_custom_device_mode () const;
std::string get_patch_name (uint16_t bank, uint8_t program, uint8_t channel) const;
protected:
void start_step_editing ();
void stop_step_editing ();

View File

@ -0,0 +1,56 @@
/*
Copyright (C) 2012 Paul 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.
*/
#ifndef __ardour_instrument_info_h__
#define __ardour_instrument_info_h__
#include <string>
#include <stdint.h>
#include "pbd/signals.h"
#include <boost/weak_ptr.hpp>
namespace ARDOUR {
class Processor;
class InstrumentInfo {
public:
InstrumentInfo();
~InstrumentInfo ();
void set_external_instrument (const std::string& model, const std::string& mode);
void set_internal_instrument (boost::shared_ptr<ARDOUR::Processor>);
std::string get_patch_name (uint16_t bank, uint8_t program, uint8_t channel) const;
std::string get_instrument_name () const;
PBD::Signal0<void> Changed;
private:
std::string external_instrument_model;
std::string external_instrument_mode;
boost::weak_ptr<ARDOUR::Processor> internal_instrument;
};
} /* namespace ARDOUR */
#endif /* __ardour_instrument_info_h__ */

View File

@ -41,6 +41,7 @@
#include "pbd/destructible.h"
#include "ardour/ardour.h"
#include "ardour/instrument_info.h"
#include "ardour/io.h"
#include "ardour/types.h"
#include "ardour/mute_master.h"
@ -405,6 +406,7 @@ class Route : public SessionObject, public Automatable, public RouteGroupMember,
special case not covered by this utility function.
*/
boost::shared_ptr<Processor> the_instrument() const;
InstrumentInfo& instrument_info() { return _instrument_info; }
void automation_snapshot (framepos_t now, bool force=false);
void protect_automation ();
@ -500,6 +502,8 @@ class Route : public SessionObject, public Automatable, public RouteGroupMember,
DataType _default_type;
FedBy _fed_by;
InstrumentInfo _instrument_info;
virtual ChanCount input_streams () const;
protected:

View File

@ -0,0 +1,100 @@
/*
Copyright (C) 2012 Paul 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.
*/
#include "pbd/compose.h"
#include "midi++/midnam_patch.h"
#include "ardour/instrument_info.h"
#include "ardour/midi_patch_manager.h"
#include "ardour/processor.h"
#include "ardour/rc_configuration.h"
#include "i18n.h"
using namespace ARDOUR;
using std::string;
InstrumentInfo::InstrumentInfo ()
: external_instrument_model (_("Unknown"))
{
}
InstrumentInfo::~InstrumentInfo ()
{
}
void
InstrumentInfo::set_external_instrument (const string& model, const string& mode)
{
external_instrument_model = model;
external_instrument_mode = mode;
internal_instrument.reset ();
Changed(); /* EMIT SIGNAL */
}
void
InstrumentInfo::set_internal_instrument (boost::shared_ptr<Processor> p)
{
internal_instrument = p;
external_instrument_model = (_("Unknown"));
external_instrument_mode = "";
Changed(); /* EMIT SIGNAL */
}
string
InstrumentInfo::get_instrument_name () const
{
boost::shared_ptr<Processor> p = internal_instrument.lock();
if (p) {
return p->name();
}
if (external_instrument_mode.empty()) {
return external_instrument_model;
} else {
return string_compose ("%1 (%2)", external_instrument_model, external_instrument_mode);
}
}
string
InstrumentInfo::get_patch_name (uint16_t bank, uint8_t program, uint8_t channel) const
{
boost::shared_ptr<Processor> p = internal_instrument.lock();
if (p) {
return "some plugin program";
}
MIDI::Name::PatchPrimaryKey patch_key (bank, program);
boost::shared_ptr<MIDI::Name::Patch> patch =
MIDI::Name::MidiPatchManager::instance().find_patch (external_instrument_model,
external_instrument_mode, channel, patch_key);
if (patch) {
return patch->name();
} else {
/* program and bank numbers are zero-based: convert to one-based: MIDI_BP_ZERO */
#define MIDI_BP_ZERO ((Config->get_first_midi_bank_is_zero())?0:1)
return string_compose ("%1 %2",program + MIDI_BP_ZERO , bank + MIDI_BP_ZERO);
}
}

View File

@ -1014,6 +1014,11 @@ Route::add_processor (boost::shared_ptr<Processor> processor, boost::shared_ptr<
_output->set_user_latency (0);
}
boost::shared_ptr<Processor> instr = the_instrument();
if (instr) {
_instrument_info.set_internal_instrument (instr);
}
processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
set_processor_positions ();
@ -1162,6 +1167,11 @@ Route::add_processors (const ProcessorList& others, boost::shared_ptr<Processor>
_output->set_user_latency (0);
}
boost::shared_ptr<Processor> instr = the_instrument();
if (instr) {
_instrument_info.set_internal_instrument (instr);
}
processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
set_processor_positions ();
@ -1368,6 +1378,8 @@ Route::clear_processors (Placement p)
processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
set_processor_positions ();
_instrument_info.set_internal_instrument (boost::shared_ptr<Processor>());
if (!already_deleting) {
_session.clear_deletion_in_progress();
}
@ -1466,6 +1478,11 @@ Route::remove_processor (boost::shared_ptr<Processor> processor, ProcessorStream
}
}
boost::shared_ptr<Processor> instr = the_instrument();
if (instr) {
_instrument_info.set_internal_instrument (instr);
}
processor->drop_references ();
processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
set_processor_positions ();

View File

@ -105,6 +105,7 @@ libardour_sources = [
'graph.cc',
'graphnode.cc',
'import.cc',
'instrument_info.cc',
'internal_return.cc',
'internal_send.cc',
'interpolation.cc',