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

@@ -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',