namespace ARDOUR {
-/** A mapping from one set of channels to another
- * (e.g. how to 'connect' two BufferSets).
+/** A mapping from one set of channels to another.
+ * The general form is 1 source (from), many sinks (to).
+ * numeric IDs are used to identify sources and sinks.
*
- * for plugins the form is "pin" -> "buffer"
+ * for plugins this is used to map "plugin-pin" to "audio-buffer"
*/
class LIBARDOUR_API ChanMapping {
public:
uint32_t get(DataType t, uint32_t from, bool* valid) const;
+ /** reverse lookup
+ * @param type data type
+ * @param to pin
+ * @param valid pointer to a boolean. If not NULL it is set to true if the mapping is found, and false otherwise.
+ * @returns first "from" that matches given "to"
+ */
+ uint32_t get_src(DataType t, uint32_t to, bool* valid) const;
+
/** get buffer mapping for given data type and pin
* @param type data type
- * @param from pin
+ * @param from numeric source id
* @returns mapped buffer number (or ChanMapping::Invalid)
*/
- uint32_t get(DataType t, uint32_t from) const { return get (t, from, NULL); }
+ uint32_t get (DataType t, uint32_t from) const { return get (t, from, NULL); }
+
/** set buffer mapping for given data type
* @param type data type
- * @param from pin
+ * @param from numeric source id
* @param to buffer
*/
void set(DataType t, uint32_t from, uint32_t to);
/** remove mapping
* @param type data type
- * @param from source to remove from mapping
+ * @param from numeric source to remove from mapping
*/
void unset(DataType t, uint32_t from);
*/
bool is_monotonic () const;
-
/** Test if this mapping is a subset
* @param superset to test against
* @returns true if all mapping are also present in the superset
return ! (*this == other);
}
- ChanMapping operator+=(const ChanMapping& other) {
- const ChanMapping::Mappings& mp (other.mappings());
- for (Mappings::const_iterator tm = mp.begin(); tm != mp.end(); ++tm) {
- for (TypeMapping::const_iterator i = tm->second.begin(); i != tm->second.end(); ++i) {
-#if 0
- bool valid; uint32_t x = get (tm->first, i->first, &valid);
- assert (!valid || x == i->second);
-#endif
- set (tm->first, i->first, i->second);
- }
- }
- return *this;
- }
-
private:
Mappings _mappings;
};
/* all instances have completed, now clear outputs that have not been written to.
* (except midi bypass)
*/
- if (bufs.count().n_midi() == 1 && natural_output_streams().get(DataType::MIDI) == 0) {
+ if (has_midi_bypass ()) {
used_outputs.set (DataType::MIDI, 0, 1); // Midi bypass.
}
for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) {
for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) {
for (uint32_t out = 0; out < bufs.count().get (*t); ++out) {
bool mapped = false;
+ if (*t == DataType::MIDI && out == 0 && has_midi_bypass ()) {
+ mapped = true; // in-place Midi bypass
+ }
for (uint32_t pc = 0; pc < get_count() && !mapped; ++pc) {
for (uint32_t o = 0; o < natural_output_streams().get (*t); ++o) {
bool valid;
}
}
+ChanMapping
+PluginInsert::input_map () const
+{
+ ChanMapping rv;
+ uint32_t pc = 0;
+ for (PinMappings::const_iterator i = _in_map.begin (); i != _in_map.end (); ++i, ++pc) {
+ ChanMapping m (i->second);
+ const ChanMapping::Mappings& mp ((*i).second.mappings());
+ for (ChanMapping::Mappings::const_iterator tm = mp.begin(); tm != mp.end(); ++tm) {
+ for (ChanMapping::TypeMapping::const_iterator i = tm->second.begin(); i != tm->second.end(); ++i) {
+ rv.set (tm->first, i->first + pc * natural_input_streams().get(tm->first), i->second);
+ }
+ }
+ }
+ return rv;
+}
+
+ChanMapping
+PluginInsert::output_map () const
+{
+ ChanMapping rv;
+ uint32_t pc = 0;
+ for (PinMappings::const_iterator i = _out_map.begin (); i != _out_map.end (); ++i, ++pc) {
+ ChanMapping m (i->second);
+ const ChanMapping::Mappings& mp ((*i).second.mappings());
+ for (ChanMapping::Mappings::const_iterator tm = mp.begin(); tm != mp.end(); ++tm) {
+ for (ChanMapping::TypeMapping::const_iterator i = tm->second.begin(); i != tm->second.end(); ++i) {
+ rv.set (tm->first, i->first + pc * natural_output_streams().get(tm->first), i->second);
+ }
+ }
+ }
+ if (has_midi_bypass ()) {
+ rv.set (DataType::MIDI, 0, 0);
+ }
+
+ return rv;
+}
+
+bool
+PluginInsert::has_midi_bypass () const
+{
+ if (_configured_in.n_midi () == 1 && _configured_out.n_midi () == 1 && natural_output_streams ().n_midi () == 0) {
+ return true;
+ }
+ return false;
+}
+
bool
PluginInsert::configure_io (ChanCount in, ChanCount out)
{
return Match (ExactMatch, get_count(), false, true); // XXX
}
- /* try automatic configuration next */
+ /* try automatic configuration */
Match m = PluginInsert::automatic_can_support_io_configuration (inx, out);
-
PluginInfoPtr info = _plugins.front()->get_info();
ChanCount inputs = info->n_inputs;
ChanCount outputs = info->n_outputs;
ChanCount midi_bypass;
+ if (inx.get(DataType::MIDI) == 1 && outputs.get(DataType::MIDI) == 0) {
+ midi_bypass.set (DataType::MIDI, 1);
+ }
/* handle case strict-i/o */
if (_strict_io && m.method != Impossible) {
switch (m.method) {
case NoInputs:
- if (inx != out) {
+ if (inx.n_audio () != out.n_audio ()) { // ignore midi bypass
/* replicate processor to match output count (generators and such)
* at least enough to feed every output port. */
uint32_t f = 1; // at least one. e.g. control data filters, no in, no out.
if (nin == 0 || inx.get(*t) == 0) { continue; }
f = max (f, (uint32_t) ceil (inx.get(*t) / (float)nin));
}
- out = inx;
+ out = inx + midi_bypass;
return Match (Replicate, f);
}
break;
default:
break;
}
- if (inx == out) { return m; }
- out = inx;
+ out = inx + midi_bypass;
if (inx.get(DataType::MIDI) == 1
&& out.get (DataType::MIDI) == 0
&& outputs.get(DataType::MIDI) == 0) {
f = max (f, (uint32_t) floor (inx.get(*t) / (float)nout));
}
if (f > 0 && outputs * f >= _configured_out) {
- out = outputs * f;
+ out = outputs * f + midi_bypass;
return Match (Replicate, f);
}
if (nin == 0 || inx.get(*t) == 0) { continue; }
f = max (f, (uint32_t) ceil (inx.get(*t) / (float)nin));
}
- out = outputs * f;
+ out = outputs * f + midi_bypass;
return Match (Replicate, f);
}
if (in.get(DataType::MIDI) == 1 && outputs.get(DataType::MIDI) == 0) {
DEBUG_TRACE ( DEBUG::Processors, string_compose ("bypassing midi-data around %1\n", name()));
- midi_bypass.set(DataType::MIDI, 1);
+ midi_bypass.set (DataType::MIDI, 1);
}
if (in.get(DataType::MIDI) == 1 && inputs.get(DataType::MIDI) == 0) {
DEBUG_TRACE ( DEBUG::Processors, string_compose ("hiding midi-port from plugin %1\n", name()));
}
}
- if (can_replicate) {
+ if (can_replicate && f > 0) {
for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) {
out.set (*t, outputs.get(*t) * f);
}
return Match (Hide, 1, false, false, hide_channels);
}
- midi_bypass.reset();
return Match (Impossible, 0);
}