diff options
author | David Robillard <d@drobilla.net> | 2008-01-19 05:06:33 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2008-01-19 05:06:33 +0000 |
commit | 7295d8e9f675f4441ab626c0655b2d2e6663e47e (patch) | |
tree | 50a1bf7d6b736c02591de3904909dda5cdd625d4 /libs/ardour | |
parent | 4ca1fe7993adf63ea3f35958f63dd20ee546e7ae (diff) |
Merge with 2.0-ongoing R2943.
git-svn-id: svn://localhost/ardour2/branches/3.0@2944 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour')
-rw-r--r-- | libs/ardour/ardour/io.h | 5 | ||||
-rw-r--r-- | libs/ardour/audio_unit.cc | 2 | ||||
-rw-r--r-- | libs/ardour/audioengine.cc | 3 | ||||
-rw-r--r-- | libs/ardour/io.cc | 151 | ||||
-rw-r--r-- | libs/ardour/rb_effect.cc | 22 |
5 files changed, 103 insertions, 80 deletions
diff --git a/libs/ardour/ardour/io.h b/libs/ardour/ardour/io.h index bd3cfcc30e..0b82844f61 100644 --- a/libs/ardour/ardour/io.h +++ b/libs/ardour/ardour/io.h @@ -375,8 +375,9 @@ class IO : public Automatable, public Latent bool ensure_inputs_locked (ChanCount, bool clear, void *src); bool ensure_outputs_locked (ChanCount, bool clear, void *src); - int32_t find_input_port_hole (); - int32_t find_output_port_hole (); + std::string build_legal_port_name (DataType type, bool for_input); + int32_t find_input_port_hole (const char* base); + int32_t find_output_port_hole (const char* base); void create_bundles_for_inputs_and_outputs (); void setup_bundles_for_inputs_and_outputs (); diff --git a/libs/ardour/audio_unit.cc b/libs/ardour/audio_unit.cc index 9f19a21865..387c7f1238 100644 --- a/libs/ardour/audio_unit.cc +++ b/libs/ardour/audio_unit.cc @@ -516,7 +516,7 @@ PluginInfoList AUPluginInfo::discover () { PluginInfoList plugs; - + discover_fx (plugs); discover_music (plugs); diff --git a/libs/ardour/audioengine.cc b/libs/ardour/audioengine.cc index 8ec97debd4..69502f9922 100644 --- a/libs/ardour/audioengine.cc +++ b/libs/ardour/audioengine.cc @@ -1119,9 +1119,8 @@ AudioEngine::connect_to_jack (string client_name) const char *server_name = NULL; jack_client_name = client_name; /* might be reset below */ - _jack = jack_client_open (jack_client_name.c_str(), options, &status, server_name); - + if (_jack == NULL) { if (status & JackServerFailed) { diff --git a/libs/ardour/io.cc b/libs/ardour/io.cc index 8231218e63..babf1e451f 100644 --- a/libs/ardour/io.cc +++ b/libs/ardour/io.cc @@ -28,6 +28,7 @@ #include <pbd/xml++.h> #include <pbd/replace_all.h> +#include <pbd/unknown_type.h> #include <ardour/audioengine.h> #include <ardour/io.h> @@ -612,7 +613,6 @@ int IO::add_output_port (string destination, void* src, DataType type) { Port* our_port; - char name[64]; if (type == DataType::NIL) type = _default_type; @@ -630,15 +630,10 @@ IO::add_output_port (string destination, void* src, DataType type) /* Create a new output port */ - // FIXME: naming scheme for differently typed ports? - if (_output_maximum.get(type) == 1) { - snprintf (name, sizeof (name), _("%s/out"), _name.c_str()); - } else { - snprintf (name, sizeof (name), _("%s/out %u"), _name.c_str(), find_output_port_hole()); - } + string portname = build_legal_port_name (type, false); - if ((our_port = _session.engine().register_output_port (type, name, _public_ports)) == 0) { - error << string_compose(_("IO: cannot register output port %1"), name) << endmsg; + if ((our_port = _session.engine().register_output_port (type, portname, _public_ports)) == 0) { + error << string_compose(_("IO: cannot register output port %1"), portname) << endmsg; return -1; } @@ -723,7 +718,6 @@ int IO::add_input_port (string source, void* src, DataType type) { Port* our_port; - char name[64]; if (type == DataType::NIL) type = _default_type; @@ -740,15 +734,10 @@ IO::add_input_port (string source, void* src, DataType type) /* Create a new input port */ - // FIXME: naming scheme for differently typed ports? - if (_input_maximum.get(type) == 1) { - snprintf (name, sizeof (name), _("%s/in"), _name.c_str()); - } else { - snprintf (name, sizeof (name), _("%s/in %u"), _name.c_str(), find_input_port_hole()); - } + string portname = build_legal_port_name (type, true); - if ((our_port = _session.engine().register_input_port (type, name, _public_ports)) == 0) { - error << string_compose(_("IO: cannot register input port %1"), name) << endmsg; + if ((our_port = _session.engine().register_input_port (type, portname, _public_ports)) == 0) { + error << string_compose(_("IO: cannot register input port %1"), portname) << endmsg; return -1; } @@ -845,18 +834,12 @@ IO::ensure_inputs_locked (ChanCount count, bool clear, void* src) /* create any necessary new ports */ while (n_inputs().get(*t) < n) { - char buf[64]; - - if (_input_maximum.get(*t) == 1) { - snprintf (buf, sizeof (buf), _("%s/in"), _name.c_str()); - } else { - snprintf (buf, sizeof (buf), _("%s/in %u"), _name.c_str(), find_input_port_hole()); - } + string portname = build_legal_port_name (*t, true); try { - if ((input_port = _session.engine().register_input_port (*t, buf, _public_ports)) == 0) { - error << string_compose(_("IO: cannot register input port %1"), buf) << endmsg; + if ((input_port = _session.engine().register_input_port (*t, portname, _public_ports)) == 0) { + error << string_compose(_("IO: cannot register input port %1"), portname) << endmsg; return -1; } } @@ -960,19 +943,11 @@ IO::ensure_io (ChanCount in, ChanCount out, bool clear, void* src) while (n_inputs().get(*t) < nin) { - char buf[64]; - - /* Create a new input port */ - - if (_input_maximum.get(*t) == 1) { - snprintf (buf, sizeof (buf), _("%s/in"), _name.c_str()); - } else { - snprintf (buf, sizeof (buf), _("%s/in %u"), _name.c_str(), find_input_port_hole()); - } + string portname = build_legal_port_name (*t, true); try { - if ((port = _session.engine().register_input_port (*t, buf, _public_ports)) == 0) { - error << string_compose(_("IO: cannot register input port %1"), buf) << endmsg; + if ((port = _session.engine().register_input_port (*t, portname, _public_ports)) == 0) { + error << string_compose(_("IO: cannot register input port %1"), portname) << endmsg; return -1; } } @@ -992,19 +967,11 @@ IO::ensure_io (ChanCount in, ChanCount out, bool clear, void* src) while (n_outputs().get(*t) < nout) { - char buf[64]; - - /* Create a new output port */ - - if (_output_maximum.get(*t) == 1) { - snprintf (buf, sizeof (buf), _("%s/out"), _name.c_str()); - } else { - snprintf (buf, sizeof (buf), _("%s/out %u"), _name.c_str(), find_output_port_hole()); - } - + string portname = build_legal_port_name (*t, false); + try { - if ((port = _session.engine().register_output_port (*t, buf, _public_ports)) == 0) { - error << string_compose(_("IO: cannot register output port %1"), buf) << endmsg; + if ((port = _session.engine().register_output_port (*t, portname, _public_ports)) == 0) { + error << string_compose(_("IO: cannot register output port %1"), portname) << endmsg; return -1; } } @@ -1115,16 +1082,10 @@ IO::ensure_outputs_locked (ChanCount count, bool clear, void* src) /* create any necessary new ports */ while (n_outputs().get(*t) < n) { - char buf[64]; + string portname = build_legal_port_name (*t, false); - if (_output_maximum.get(*t) == 1) { - snprintf (buf, sizeof (buf), _("%s/out"), _name.c_str()); - } else { - snprintf (buf, sizeof (buf), _("%s/out %u"), _name.c_str(), find_output_port_hole()); - } - - if ((output_port = _session.engine().register_output_port (*t, buf, _public_ports)) == 0) { - error << string_compose(_("IO: cannot register output port %1"), buf) << endmsg; + if ((output_port = _session.engine().register_output_port (*t, portname, _public_ports)) == 0) { + error << string_compose(_("IO: cannot register output port %1"), portname) << endmsg; return -1; } @@ -2290,8 +2251,62 @@ IO::transport_stopped (nframes_t frame) _panner->transport_stopped (frame); } +string +IO::build_legal_port_name (DataType type, bool in) +{ + const int name_size = jack_port_name_size(); + int limit; + string suffix; + int maxports; + + if (type == DataType::AUDIO) { + suffix = _("audio"); + } else if (type == DataType::MIDI) { + suffix = _("midi"); + } else { + throw unknown_type(); + } + + if (in) { + suffix += _("_in"); + maxports = _input_maximum.get(type); + } else { + suffix += _("_out"); + maxports = _output_maximum.get(type); + } + + if (maxports == 1) { + // allow space for the slash + the suffix + limit = name_size - _session.engine().client_name().length() - (suffix.length() + 1); + char buf[name_size+1]; + snprintf (buf, name_size+1, ("%.*s/%s"), limit, _name.c_str(), suffix.c_str()); + return string (buf); + } + + // allow up to 4 digits for the output port number, plus the slash, suffix and extra space + + limit = name_size - _session.engine().client_name().length() - (suffix.length() + 5); + + char buf1[name_size+1]; + char buf2[name_size+1]; + + snprintf (buf1, name_size+1, ("%.*s/%s"), limit, _name.c_str(), suffix.c_str()); + + int port_number; + + if (in) { + port_number = find_input_port_hole (buf1); + } else { + port_number = find_output_port_hole (buf1); + } + + snprintf (buf2, name_size+1, "%s %d", buf1, port_number); + + return string (buf2); +} + int32_t -IO::find_input_port_hole () +IO::find_input_port_hole (const char* base) { /* CALLER MUST HOLD IO LOCK */ @@ -2301,11 +2316,14 @@ IO::find_input_port_hole () return 1; } - for (n = 1; n < UINT_MAX; ++n) { + /* we only allow up to 4 characters for the port number + */ + + for (n = 1; n < 9999; ++n) { char buf[jack_port_name_size()]; PortSet::iterator i = _inputs.begin(); - snprintf (buf, jack_port_name_size(), _("%s/in %u"), _name.c_str(), n); + snprintf (buf, jack_port_name_size(), _("%s %u"), base, n); for ( ; i != _inputs.end(); ++i) { if (i->short_name() == buf) { @@ -2321,7 +2339,7 @@ IO::find_input_port_hole () } int32_t -IO::find_output_port_hole () +IO::find_output_port_hole (const char* base) { /* CALLER MUST HOLD IO LOCK */ @@ -2331,11 +2349,14 @@ IO::find_output_port_hole () return 1; } - for (n = 1; n < UINT_MAX; ++n) { + /* we only allow up to 4 characters for the port number + */ + + for (n = 1; n < 9999; ++n) { char buf[jack_port_name_size()]; PortSet::iterator i = _outputs.begin(); - snprintf (buf, jack_port_name_size(), _("%s/out %u"), _name.c_str(), n); + snprintf (buf, jack_port_name_size(), _("%s %u"), base, n); for ( ; i != _outputs.end(); ++i) { if (i->short_name() == buf) { diff --git a/libs/ardour/rb_effect.cc b/libs/ardour/rb_effect.cc index 7a948f6004..9711e5e4dc 100644 --- a/libs/ardour/rb_effect.cc +++ b/libs/ardour/rb_effect.cc @@ -74,9 +74,12 @@ RBEffect::run (boost::shared_ptr<AudioRegion> region) nframes_t pos = 0; int avail = 0; + double this_time_fraction = tsr.time_fraction * region->stretch (); + double this_pitch_fraction = tsr.pitch_fraction * region->shift (); + RubberBandStretcher stretcher (session.frame_rate(), region->n_channels(), (RubberBandStretcher::Options) tsr.opts, - tsr.time_fraction, tsr.pitch_fraction); + this_time_fraction, this_pitch_fraction); stretcher.setExpectedInputDuration(region->length()); stretcher.setDebugLevel(1); @@ -91,14 +94,14 @@ RBEffect::run (boost::shared_ptr<AudioRegion> region) digits just to disambiguate close but not identical FX */ - if (tsr.time_fraction == 1.0) { - snprintf (suffix, sizeof (suffix), "@%d", (int) floor (tsr.pitch_fraction * 100.0f)); - } else if (tsr.pitch_fraction == 1.0) { - snprintf (suffix, sizeof (suffix), "@%d", (int) floor (tsr.time_fraction * 100.0f)); + if (this_time_fraction == 1.0) { + snprintf (suffix, sizeof (suffix), "@%d", (int) floor (this_pitch_fraction * 100.0f)); + } else if (this_pitch_fraction == 1.0) { + snprintf (suffix, sizeof (suffix), "@%d", (int) floor (this_time_fraction * 100.0f)); } else { snprintf (suffix, sizeof (suffix), "@%d-%d", - (int) floor (tsr.time_fraction * 100.0f), - (int) floor (tsr.pitch_fraction * 100.0f)); + (int) floor (this_time_fraction * 100.0f), + (int) floor (this_pitch_fraction * 100.0f)); } /* create new sources */ @@ -259,9 +262,8 @@ RBEffect::run (boost::shared_ptr<AudioRegion> region) nframes_t start; nframes_t length; - // note: tsr.time_fraction is a percentage of original length. 100 = no change, - // 50 is half as long, 200 is twice as long, etc. - + // note: this_time_fraction is a ratio of original length. 1.0 = no change, + // 0.5 is half as long, 2.0 is twice as long, etc. float stretch = (*x)->stretch() * (tsr.time_fraction/100.0); float shift = (*x)->shift() * tsr.pitch_fraction; |