summaryrefslogtreecommitdiff
path: root/libs/ardour/io.cc
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2006-06-26 16:01:34 +0000
committerDavid Robillard <d@drobilla.net>2006-06-26 16:01:34 +0000
commitfe13d08874f08b723df53116e5655c3d229a657e (patch)
tree21dcf9d03415864b685c1e23cb553dcf18a3ab07 /libs/ardour/io.cc
parent13532c8500dce5f7a4525bcdfc3b44936fbaa5e6 (diff)
Large nasty commit in the form of a 5000 line patch chock-full of completely
unecessary changes. (Sorry, doing a "sprint" based thing, this is the end of the first one) Achieved MIDI track and bus creation, associated Jack port and diskstream creation, and minimal GUI stuff for creating them. Should be set to start work on actually recording and playing midi to/from disk now. Relevant (significant) changes: - Creation of a Buffer class. Base class is type agnostic so things can point to a buffer but not care what kind it is (otherwise it'd be a template). Derived into AudioBuffer and MidiBuffer, with a type tag because checking type is necessary in parts of the code where dynamic_cast wouldn't be wise. Originally I considered this a hack, but passing around a type proved to be a very good solution to all the other problems (below). There is a 1:1 mapping between jack port data types and ardour Buffer types (with a conversion function), but that's easily removed if it ever becomes necessary. Having the type scoped in the Buffer class is maybe not the best spot for it, but whatever (this is proof of concept kinda stuff right now...) - IO now has a "default" port type (passed to the constructor and stored as a member), used by ensure_io (and similar) to create n ports. IO::register_***_port has a type argument that defaults to the default type if not passed. Rationale: previous IO API is identical, no changes needed to existing code, but path is paved for multiple port types in one IO, which we will need for eg synth plugin inserts, among other things. This is not quite ideal (best would be to only have the two port register functions and have them take a type), but the alternative is a lot of work (namely destroying the 'ensure' functions and everything that uses them) for very little gain. (I am convinced after quite a few tries at the whiteboard that subclassing IO in any way is not a feasible option, look at it's inheritance diagram in Doxygen and you can see why) - AudioEngine::register_audio_input_port is now register_input_port and takes a type argument. Ditto for output. - (Most significant change) AudioDiskstream abstracted into Distream, and sibling MidiDiskstream created. Very much still a work in progress, but Diskstream is there to switch references over to (most already are), which is the important part. It is still unclear what the MIDI diskstream's relation to channels is, but I'm pretty sure they will be single channel only (so SMF Type 0) since noone can come up with a reason otherwise. - MidiTrack creation. Same thing as AudioTrack but with a different default type basically. No big deal here. - Random cleanups and variable renamings etc. because I have OCD and can't help myself. :) Known broken: Loading of sessions containing MIDI tracks. git-svn-id: svn://localhost/ardour2/branches/midi@641 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/io.cc')
-rw-r--r--libs/ardour/io.cc71
1 files changed, 52 insertions, 19 deletions
diff --git a/libs/ardour/io.cc b/libs/ardour/io.cc
index 2f04b7eaca..8225396486 100644
--- a/libs/ardour/io.cc
+++ b/libs/ardour/io.cc
@@ -55,7 +55,8 @@ extern "C" int isinf (double);
using namespace std;
using namespace ARDOUR;
-//using namespace sigc;
+using namespace PBD;
+
static float current_automation_version_number = 1.0;
@@ -96,11 +97,18 @@ static bool sort_ports_by_name (Port* a, Port* b)
}
+/** The 'default_type' argument here isn't very good, but port creation is too
+ * brufty and all over the place to make anything else feasible without massive
+ * changes. The default typed passed is the type of port that will be created
+ * by ensure_io and friends. This is a temporary compatibility hack to get
+ * multiple data types off the gound and should be removed.
+ */
IO::IO (Session& s, string name,
-
- int input_min, int input_max, int output_min, int output_max)
+ int input_min, int input_max, int output_min, int output_max,
+ Buffer::Type default_type)
: _session (s),
_name (name),
+ _default_type(default_type),
_midi_gain_control (*this, _session.midi_port()),
_gain_automation_curve (0.0, 2.0, 1.0),
_input_minimum (input_min),
@@ -784,11 +792,20 @@ IO::remove_output_port (Port* port, void* src)
return -1;
}
+/** Add an output port.
+ *
+ * @param destination Name of input port to connect new port to.
+ * @param src Source for emitted ConfigurationChanged signal.
+ * @param type Data type of port. Default value (Buffer::NIL) will use this IO's default type.
+ */
int
-IO::add_output_port (string destination, void* src)
+IO::add_output_port (string destination, void* src, Buffer::Type type)
{
Port* our_port;
- char buf[64];
+ char name[64];
+
+ if (type == Buffer::NIL)
+ type = _default_type;
{
Glib::Mutex::Lock em(_session.engine().process_lock());
@@ -802,14 +819,15 @@ IO::add_output_port (string destination, void* src)
/* Create a new output port */
+ // FIXME: naming scheme for differently typed ports?
if (_output_maximum == 1) {
- snprintf (buf, sizeof (buf), _("%s/out"), _name.c_str());
+ snprintf (name, sizeof (name), _("%s/out"), _name.c_str());
} else {
- snprintf (buf, sizeof (buf), _("%s/out %u"), _name.c_str(), find_output_port_hole());
+ snprintf (name, sizeof (name), _("%s/out %u"), _name.c_str(), find_output_port_hole());
}
- if ((our_port = _session.engine().register_audio_output_port (buf)) == 0) {
- error << string_compose(_("IO: cannot register output port %1"), buf) << endmsg;
+ if ((our_port = _session.engine().register_output_port (type, name)) == 0) {
+ error << string_compose(_("IO: cannot register output port %1"), name) << endmsg;
return -1;
}
@@ -885,11 +903,21 @@ IO::remove_input_port (Port* port, void* src)
return -1;
}
+
+/** Add an input port.
+ *
+ * @param type Data type of port. The appropriate Jack port type, and @ref Port will be created.
+ * @param destination Name of input port to connect new port to.
+ * @param src Source for emitted ConfigurationChanged signal.
+ */
int
-IO::add_input_port (string source, void* src)
+IO::add_input_port (string source, void* src, Buffer::Type type)
{
Port* our_port;
- char buf[64];
+ char name[64];
+
+ if (type == Buffer::NIL)
+ type = _default_type;
{
Glib::Mutex::Lock em (_session.engine().process_lock());
@@ -903,14 +931,15 @@ IO::add_input_port (string source, void* src)
/* Create a new input port */
+ // FIXME: naming scheme for differently typed ports?
if (_input_maximum == 1) {
- snprintf (buf, sizeof (buf), _("%s/in"), _name.c_str());
+ snprintf (name, sizeof (name), _("%s/in"), _name.c_str());
} else {
- snprintf (buf, sizeof (buf), _("%s/in %u"), _name.c_str(), find_input_port_hole());
+ snprintf (name, sizeof (name), _("%s/in %u"), _name.c_str(), find_input_port_hole());
}
- if ((our_port = _session.engine().register_audio_input_port (buf)) == 0) {
- error << string_compose(_("IO: cannot register input port %1"), buf) << endmsg;
+ if ((our_port = _session.engine().register_input_port (type, name)) == 0) {
+ error << string_compose(_("IO: cannot register input port %1"), name) << endmsg;
return -1;
}
@@ -1006,6 +1035,8 @@ IO::ensure_inputs_locked (uint32_t n, bool clear, void* src)
/* Create a new input port */
+ // FIXME: of what type?
+
if (_input_maximum == 1) {
snprintf (buf, sizeof (buf), _("%s/in"), _name.c_str());
}
@@ -1015,7 +1046,7 @@ IO::ensure_inputs_locked (uint32_t n, bool clear, void* src)
try {
- if ((input_port = _session.engine().register_audio_input_port (buf)) == 0) {
+ if ((input_port = _session.engine().register_input_port (_default_type, buf)) == 0) {
error << string_compose(_("IO: cannot register input port %1"), buf) << endmsg;
return -1;
}
@@ -1106,6 +1137,8 @@ IO::ensure_io (uint32_t nin, uint32_t nout, bool clear, void* src)
/* create any necessary new ports */
+ // FIXME: of what type?
+
while (_ninputs < nin) {
char buf[64];
@@ -1120,7 +1153,7 @@ IO::ensure_io (uint32_t nin, uint32_t nout, bool clear, void* src)
}
try {
- if ((port = _session.engine().register_audio_input_port (buf)) == 0) {
+ if ((port = _session.engine().register_input_port (_default_type, buf)) == 0) {
error << string_compose(_("IO: cannot register input port %1"), buf) << endmsg;
return -1;
}
@@ -1153,7 +1186,7 @@ IO::ensure_io (uint32_t nin, uint32_t nout, bool clear, void* src)
}
try {
- if ((port = _session.engine().register_audio_output_port (buf)) == 0) {
+ if ((port = _session.engine().register_output_port (_default_type, buf)) == 0) {
error << string_compose(_("IO: cannot register output port %1"), buf) << endmsg;
return -1;
}
@@ -1278,7 +1311,7 @@ IO::ensure_outputs_locked (uint32_t n, bool clear, void* src)
snprintf (buf, sizeof (buf), _("%s/out %u"), _name.c_str(), find_output_port_hole());
}
- if ((output_port = _session.engine().register_audio_output_port (buf)) == 0) {
+ if ((output_port = _session.engine().register_output_port (_default_type, buf)) == 0) {
error << string_compose(_("IO: cannot register output port %1"), buf) << endmsg;
return -1;
}