aboutsummaryrefslogtreecommitdiffstats
path: root/src/engine/SMFDriver.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2013-01-12 23:38:03 +0000
committerDavid Robillard <d@drobilla.net>2013-01-12 23:38:03 +0000
commit1dad5b5aaa139993fe19e266d08dfc55844e6804 (patch)
treefd2bed5971853b429f1b74369a778a4d608e6925 /src/engine/SMFDriver.cpp
parent8f048287d06afd7d3c2e90f4a503d7666a9cb6fa (diff)
downloadmachina-1dad5b5aaa139993fe19e266d08dfc55844e6804.tar.gz
machina-1dad5b5aaa139993fe19e266d08dfc55844e6804.tar.bz2
machina-1dad5b5aaa139993fe19e266d08dfc55844e6804.zip
Remove Raul::SharedPtr and switch to std::shared_ptr.
Use project local short type aliases for shared_ptr and friends. Move Raul::Disposable and Raul::Manageable into Raul::Maid. Use sets to store machina nodes and edges to avoid O(n) searches. git-svn-id: http://svn.drobilla.net/lad/trunk/machina@4939 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/engine/SMFDriver.cpp')
-rw-r--r--src/engine/SMFDriver.cpp47
1 files changed, 24 insertions, 23 deletions
diff --git a/src/engine/SMFDriver.cpp b/src/engine/SMFDriver.cpp
index da7fecb..7401755 100644
--- a/src/engine/SMFDriver.cpp
+++ b/src/engine/SMFDriver.cpp
@@ -20,10 +20,9 @@
#include <glibmm/convert.h>
-#include "raul/SharedPtr.hpp"
-
#include "machina/Context.hpp"
#include "machina/Machine.hpp"
+#include "machina/types.hpp"
#include "Edge.hpp"
#include "SMFDriver.hpp"
@@ -36,9 +35,9 @@ using namespace std;
namespace Machina {
SMFDriver::SMFDriver(Raul::Forge& forge, Raul::TimeUnit unit)
- : Driver(forge, SharedPtr<Machine>())
+ : Driver(forge, SPtr<Machine>())
{
- _writer = SharedPtr<SMFWriter>(new SMFWriter(unit));
+ _writer = SPtr<SMFWriter>(new SMFWriter(unit));
}
/** Learn a single track from the MIDI file at @a uri
@@ -48,23 +47,25 @@ SMFDriver::SMFDriver(Raul::Forge& forge, Raul::TimeUnit unit)
* Currently only file:// URIs are supported.
* @return the resulting machine.
*/
-SharedPtr<Machine>
-SMFDriver::learn(const string& filename, unsigned track, double q,
+SPtr<Machine>
+SMFDriver::learn(const string& filename,
+ unsigned track,
+ double q,
Raul::TimeDuration max_duration)
{
//assert(q.unit() == max_duration.unit());
- SharedPtr<Machine> m(new Machine(max_duration.unit()));
- SharedPtr<MachineBuilder> builder = SharedPtr<MachineBuilder>(
+ SPtr<Machine> m(new Machine(max_duration.unit()));
+ SPtr<MachineBuilder> builder = SPtr<MachineBuilder>(
new MachineBuilder(m, q, false));
SMFReader reader;
if (!reader.open(filename)) {
cerr << "Unable to open MIDI file " << filename << endl;
- return SharedPtr<Machine>();
+ return SPtr<Machine>();
}
if (track > reader.num_tracks()) {
- return SharedPtr<Machine>();
+ return SPtr<Machine>();
} else {
learn_track(builder, reader, track, q, max_duration);
}
@@ -74,7 +75,7 @@ SMFDriver::learn(const string& filename, unsigned track, double q,
if (m->nodes().size() > 1) {
return m;
} else {
- return SharedPtr<Machine>();
+ return SPtr<Machine>();
}
}
@@ -82,17 +83,17 @@ SMFDriver::learn(const string& filename, unsigned track, double q,
*
* This will result in one disjoint subgraph in the machine for each track.
*/
-SharedPtr<Machine>
+SPtr<Machine>
SMFDriver::learn(const string& filename, double q, Raul::TimeStamp max_duration)
{
- SharedPtr<Machine> m(new Machine(max_duration.unit()));
- SharedPtr<MachineBuilder> builder = SharedPtr<MachineBuilder>(
+ SPtr<Machine> m(new Machine(max_duration.unit()));
+ SPtr<MachineBuilder> builder = SPtr<MachineBuilder>(
new MachineBuilder(m, q, false));
SMFReader reader;
if (!reader.open(filename)) {
cerr << "Unable to open MIDI file " << filename << endl;
- return SharedPtr<Machine>();
+ return SPtr<Machine>();
}
for (unsigned t = 1; t <= reader.num_tracks(); ++t) {
@@ -105,16 +106,16 @@ SMFDriver::learn(const string& filename, double q, Raul::TimeStamp max_duration)
if (m->nodes().size() > 1) {
return m;
} else {
- return SharedPtr<Machine>();
+ return SPtr<Machine>();
}
}
void
-SMFDriver::learn_track(SharedPtr<MachineBuilder> builder,
- SMFReader& reader,
- unsigned track,
- double q,
- Raul::TimeDuration max_duration)
+SMFDriver::learn_track(SPtr<MachineBuilder> builder,
+ SMFReader& reader,
+ unsigned track,
+ double q,
+ Raul::TimeDuration max_duration)
{
const bool found_track = reader.seek_to_track(track);
if (!found_track) {
@@ -153,7 +154,7 @@ SMFDriver::learn_track(SharedPtr<MachineBuilder> builder,
}
void
-SMFDriver::run(SharedPtr<Machine> machine, Raul::TimeStamp max_time)
+SMFDriver::run(SPtr<Machine> machine, Raul::TimeStamp max_time)
{
// FIXME: unit kludge (tempo only)
Context context(_forge, machine->time().unit().ppt(),
@@ -161,7 +162,7 @@ SMFDriver::run(SharedPtr<Machine> machine, Raul::TimeStamp max_time)
context.set_sink(this);
context.time().set_slice(TimeStamp(max_time.unit(), 0, 0),
context.time().beats_to_ticks(max_time));
- machine->run(context, SharedPtr<UpdateBuffer>());
+ machine->run(context, SPtr<UpdateBuffer>());
}
} // namespace Machina