mirror of
https://github.com/Ardour/ardour.git
synced 2026-01-06 05:35:47 +01:00
Loading/Saving of sessions containing MIDI tracks and/or busses
git-svn-id: svn://localhost/ardour2/branches/midi@667 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
22c20ab6f2
commit
edd841895b
9 changed files with 87 additions and 13 deletions
|
|
@ -29,6 +29,10 @@
|
|||
namespace ARDOUR {
|
||||
|
||||
|
||||
/* Yes, this is a bit of a mess right now. I'll clean it up when everything
|
||||
* using it works out.. */
|
||||
|
||||
|
||||
/** A buffer of recordable/playable data.
|
||||
*
|
||||
* This is a datatype-agnostic base class for all buffers (there are no
|
||||
|
|
@ -60,13 +64,17 @@ public:
|
|||
size_t size() const { return _size; }
|
||||
|
||||
/** Type of this buffer.
|
||||
* Based on this you can cast a Buffer* to the desired type. */
|
||||
* Based on this you can static cast a Buffer* to the desired type. */
|
||||
virtual Type type() const { return _type; }
|
||||
|
||||
/** Jack type (eg JACK_DEFAULT_AUDIO_TYPE) */
|
||||
const char* jack_type() const { return type_to_jack_type(type()); }
|
||||
|
||||
/** Separate for creating ports (before a buffer exists to call jack_type on) */
|
||||
/** String type as saved in session XML files (eg "audio" or "midi") */
|
||||
const char* type_string() const { return type_to_string(type()); }
|
||||
|
||||
/* The below static methods need to be separate from the above methods
|
||||
* because the conversion is needed in places where there's no Buffer */
|
||||
static const char* type_to_jack_type(Type t) {
|
||||
switch (t) {
|
||||
case AUDIO: return JACK_DEFAULT_AUDIO_TYPE;
|
||||
|
|
@ -74,6 +82,24 @@ public:
|
|||
default: return "";
|
||||
}
|
||||
}
|
||||
|
||||
static const char* type_to_string(Type t) {
|
||||
switch (t) {
|
||||
case AUDIO: return "audio";
|
||||
case MIDI: return "midi";
|
||||
default: return "unknown"; // reeeally shouldn't ever happen
|
||||
}
|
||||
}
|
||||
|
||||
/** Used for loading from XML (route default types etc) */
|
||||
static Type type_from_string(const string& str) {
|
||||
if (str == "audio")
|
||||
return AUDIO;
|
||||
else if (str == "midi")
|
||||
return MIDI;
|
||||
else
|
||||
return NIL;
|
||||
}
|
||||
|
||||
protected:
|
||||
Type _type;
|
||||
|
|
@ -82,7 +108,7 @@ protected:
|
|||
};
|
||||
|
||||
|
||||
/* Since we only have two types, templates aren't worth it, yet.. */
|
||||
/* Inside every class with a type in it's name is a template waiting to get out... */
|
||||
|
||||
|
||||
/** Buffer containing 32-bit floating point (audio) data. */
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include <cmath>
|
||||
#include <fstream>
|
||||
#include <cassert>
|
||||
|
||||
#include <sigc++/bind.h>
|
||||
#include <pbd/xml++.h>
|
||||
|
|
@ -1346,6 +1347,10 @@ Route::state(bool full_state)
|
|||
snprintf (buf, sizeof (buf), "0x%x", _flags);
|
||||
node->add_property("flags", buf);
|
||||
}
|
||||
|
||||
// FIXME: assumes there's only audio and MIDI types
|
||||
node->add_property("default-type", Buffer::type_to_string(_default_type));
|
||||
|
||||
node->add_property("active", _active?"yes":"no");
|
||||
node->add_property("muted", _muted?"yes":"no");
|
||||
node->add_property("soloed", _soloed?"yes":"no");
|
||||
|
|
@ -1541,6 +1546,11 @@ Route::set_state (const XMLNode& node)
|
|||
} else {
|
||||
_flags = Flag (0);
|
||||
}
|
||||
|
||||
if ((prop = node.property ("default-type")) != 0) {
|
||||
_default_type = Buffer::type_from_string(prop->value());
|
||||
assert(_default_type != Buffer::NIL);
|
||||
}
|
||||
|
||||
if ((prop = node.property ("phase-invert")) != 0) {
|
||||
set_phase_invert(prop->value()=="yes"?true:false, this);
|
||||
|
|
|
|||
|
|
@ -74,6 +74,7 @@
|
|||
#include <ardour/slave.h>
|
||||
#include <ardour/tempo.h>
|
||||
#include <ardour/audio_track.h>
|
||||
#include <ardour/midi_track.h>
|
||||
#include <ardour/cycle_timer.h>
|
||||
#include <ardour/utils.h>
|
||||
#include <ardour/named_selection.h>
|
||||
|
|
@ -1716,8 +1717,20 @@ Session::XMLRouteFactory (const XMLNode& node)
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (node.property ("diskstream") != 0 || node.property ("diskstream-id") != 0) {
|
||||
return new AudioTrack (*this, node);
|
||||
bool has_diskstream = (node.property ("diskstream") != 0 || node.property ("diskstream-id") != 0);
|
||||
|
||||
Buffer::Type type = Buffer::AUDIO;
|
||||
const XMLProperty* prop = node.property("default-type");
|
||||
if (prop)
|
||||
type = Buffer::type_from_string(prop->value());
|
||||
|
||||
assert(type != Buffer::NIL);
|
||||
|
||||
if (has_diskstream) {
|
||||
if (type == Buffer::AUDIO)
|
||||
return new AudioTrack (*this, node);
|
||||
else
|
||||
return new MidiTrack (*this, node);
|
||||
} else {
|
||||
return new Route (*this, node);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue