aboutsummaryrefslogtreecommitdiffstats
path: root/src/engine
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2008-11-17 03:48:38 +0000
committerDavid Robillard <d@drobilla.net>2008-11-17 03:48:38 +0000
commitcbfd2dafcf8979e177abccf382dadaabdab6a45b (patch)
tree935dbd1117fa89ad280207b6c7722da1a3a5fccf /src/engine
parente091b5eea5f533fe61c5559a10f1388aeca096e2 (diff)
downloadmachina-cbfd2dafcf8979e177abccf382dadaabdab6a45b.tar.gz
machina-cbfd2dafcf8979e177abccf382dadaabdab6a45b.tar.bz2
machina-cbfd2dafcf8979e177abccf382dadaabdab6a45b.zip
Compile.
git-svn-id: http://svn.drobilla.net/lad/trunk/machina@1755 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/engine')
-rw-r--r--src/engine/Engine.cpp2
-rw-r--r--src/engine/Evolver.cpp10
-rw-r--r--src/engine/JackDriver.cpp45
-rw-r--r--src/engine/LearnRequest.cpp4
-rw-r--r--src/engine/MachineBuilder.cpp6
-rw-r--r--src/engine/Problem.cpp30
-rw-r--r--src/engine/Recorder.cpp2
-rw-r--r--src/engine/SMFDriver.cpp27
-rw-r--r--src/engine/machina/Driver.hpp2
-rw-r--r--src/engine/machina/Engine.hpp2
-rw-r--r--src/engine/machina/Evolver.hpp5
-rw-r--r--src/engine/machina/JackDriver.hpp9
-rw-r--r--src/engine/machina/LearnRequest.hpp6
-rw-r--r--src/engine/machina/MachineBuilder.hpp6
-rw-r--r--src/engine/machina/Mutation.hpp2
-rw-r--r--src/engine/machina/Problem.hpp7
-rw-r--r--src/engine/machina/Recorder.hpp2
-rw-r--r--src/engine/machina/SMFDriver.hpp6
-rw-r--r--src/engine/wscript33
19 files changed, 129 insertions, 77 deletions
diff --git a/src/engine/Engine.cpp b/src/engine/Engine.cpp
index 0724018..f25c4d4 100644
--- a/src/engine/Engine.cpp
+++ b/src/engine/Engine.cpp
@@ -67,7 +67,7 @@ Engine::import_machine(const Glib::ustring& uri)
* Safe to call while engine is processing.
*/
SharedPtr<Machine>
-Engine::import_midi(const Glib::ustring& uri, Raul::TimeStamp q, Raul::TimeDuration duration)
+Engine::import_midi(const Glib::ustring& uri, double q, Raul::TimeDuration duration)
{
SharedPtr<SMFDriver> file_driver(new SMFDriver());
SharedPtr<Machine> m = file_driver->learn(uri, q, duration);
diff --git a/src/engine/Evolver.cpp b/src/engine/Evolver.cpp
index 3cb2dd8..af126d6 100644
--- a/src/engine/Evolver.cpp
+++ b/src/engine/Evolver.cpp
@@ -16,9 +16,9 @@
*/
#include <iostream>
-#include "eugene/core/Mutation.hpp"
-#include "eugene/core/HybridMutation.hpp"
-#include "eugene/core/TournamentSelection.hpp"
+#include "eugene/Mutation.hpp"
+#include "eugene/HybridMutation.hpp"
+#include "eugene/TournamentSelection.hpp"
#include "machina/Evolver.hpp"
#include "machina/Mutation.hpp"
#include "machina/Problem.hpp"
@@ -30,8 +30,8 @@ using namespace boost;
namespace Machina {
-Evolver::Evolver(const string& target_midi, SharedPtr<Machine> seed)
- : _problem(new Problem(target_midi, seed))
+Evolver::Evolver(TimeUnit unit, const string& target_midi, SharedPtr<Machine> seed)
+ : _problem(new Problem(unit, target_midi, seed))
, _seed_fitness(-FLT_MAX)
{
SharedPtr<Eugene::HybridMutation<Machine> > m(new HybridMutation<Machine>());
diff --git a/src/engine/JackDriver.cpp b/src/engine/JackDriver.cpp
index 809efb9..5363a5a 100644
--- a/src/engine/JackDriver.cpp
+++ b/src/engine/JackDriver.cpp
@@ -33,9 +33,10 @@ JackDriver::JackDriver(SharedPtr<Machine> machine)
, _machine_changed(0)
, _input_port(NULL)
, _output_port(NULL)
+ , _frames_unit(TimeUnit::FRAMES, 48000.0)
, _cycle_time(1/48000.0, 120.0)
, _bpm(120.0)
- , _quantization(machine->time().unit())
+ , _quantization(0.0f)
, _record_time(machine->time().unit())
, _recording(0)
{
@@ -55,7 +56,7 @@ JackDriver::attach(const std::string& client_name)
if (jack_client()) {
- _cycle_time.set_tick_rate(1/(double)sample_rate());
+ //_cycle_time.set_tick_rate(1/(double)sample_rate());
_input_port = jack_port_register(jack_client(),
"in",
@@ -187,6 +188,7 @@ JackDriver::write_event(Raul::TimeStamp time,
size_t size,
const byte* event) throw (std::logic_error)
{
+#if 0
if (!_output_port)
return;
@@ -225,17 +227,20 @@ JackDriver::write_event(Raul::TimeStamp time,
event, size);
#endif
}
+#endif
}
void
JackDriver::on_process(jack_nframes_t nframes)
{
+#if 0
_cycle_time.set_bpm(_bpm.get());
- // (N.B. start time set at end of previous cycle)
- _cycle_time.set_offset(0);
- _cycle_time.set_length(nframes);
+ TimeStamp start(TimeUnit(TimeUnit::FRAMES, 0));
+ TimeDuration length(TimeUnit(TimeUnit::FRAMES, nframes));
+ _cycle_time.set_offset(start);
+ _cycle_time.set_length(length);
assert(_output_port);
#ifdef JACK_MIDI_NEEDS_NFRAMES
@@ -256,7 +261,7 @@ JackDriver::on_process(jack_nframes_t nframes)
_last_machine->reset(_last_machine->time()); // Exit all active states
_last_machine.reset(); // Cut our reference
}
- _cycle_time.set_start(0);
+ _cycle_time.set_start(start);
_machine_changed.post(); // Signal we're done with it
}
@@ -268,7 +273,7 @@ JackDriver::on_process(jack_nframes_t nframes)
machine->set_sink(shared_from_this());
if (_recording.get())
- _record_time += nframes;
+ _record_time += length;
if (_stop.pending())
machine->reset(_cycle_time.start_beats());
@@ -280,31 +285,31 @@ JackDriver::on_process(jack_nframes_t nframes)
while (true) {
- const BeatCount run_dur_beats = machine->run(_cycle_time);
- const TickCount run_dur_ticks = _cycle_time.beats_to_ticks(run_dur_beats);
+ const TimeDuration run_dur_beats = machine->run(_cycle_time);
+ const TimeDuration run_dur_ticks = _cycle_time.beats_to_ticks(run_dur_beats);
// Machine didn't run at all (empty, or no initial states)
- if (run_dur_beats == 0) {
+ if (run_dur_beats == TimeDuration(_frames_unit, 0, 0)) {
machine->reset(machine->time()); // Try again next cycle
- _cycle_time.set_start(0);
+ _cycle_time.set_start(TimeStamp(_frames_unit, 0, 0));
goto end;
// Machine ran for portion of cycle (finished)
} else if (run_dur_ticks < _cycle_time.length_ticks()) {
- const TickCount finish_offset = _cycle_time.offset_ticks() + run_dur_ticks;
- assert(finish_offset < nframes);
+ const TimeStamp finish_offset = _cycle_time.offset_ticks() + run_dur_ticks;
+ assert(finish_offset < length);
machine->reset(machine->time());
- _cycle_time.set_start(0);
- _cycle_time.set_length(nframes - finish_offset);
+ _cycle_time.set_start(TimeStamp(_frames_unit, 0, 0));
+ _cycle_time.set_length(TimeDuration(_frames_unit, nframes - finish_offset.ticks()));
_cycle_time.set_offset(finish_offset);
// Machine ran for entire cycle
} else {
if (machine->is_finished()) {
machine->reset(machine->time());
- _cycle_time.set_start(0);
+ _cycle_time.set_start(TimeStamp(_frames_unit, 0, 0));
} else {
_cycle_time.set_start(
_cycle_time.start_ticks() + _cycle_time.length_ticks());
@@ -321,9 +326,10 @@ end:
_last_machine = machine;
if (_stop.pending()) {
- _cycle_time.set_start(0);
+ _cycle_time.set_start(TimeStamp(_frames_unit, 0, 0));
_stop.finish();
}
+#endif
}
@@ -342,11 +348,10 @@ void
JackDriver::start_record()
{
// FIXME: Choose an appropriate maximum ringbuffer size
- _recorder = SharedPtr<Recorder>(new Recorder(
- 1024, (1.0/(double)sample_rate()) * (_bpm.get() / 60.0), _quantization.get()));
+ /*_recorder = SharedPtr<Recorder>(new Recorder(1024, _frames_unit, _quantization.get()));
_recorder->start();
_record_time = 0;
- _recording = 1;
+ _recording = 1;*/
}
diff --git a/src/engine/LearnRequest.cpp b/src/engine/LearnRequest.cpp
index 00401dc..782cfff 100644
--- a/src/engine/LearnRequest.cpp
+++ b/src/engine/LearnRequest.cpp
@@ -28,9 +28,9 @@ LearnRequest::finish(TimeStamp time)
_node->set_enter_action(_enter_action);
_node->set_exit_action(_exit_action);
- TimeDuration duration = Raul::Quantizer::quantize(_quantization, time - _start_time);
+ //TimeDuration duration = Raul::Quantizer::quantize(_quantization, time - _start_time);
- _node->set_duration(duration);
+ //_node->set_duration(duration);
}
diff --git a/src/engine/MachineBuilder.cpp b/src/engine/MachineBuilder.cpp
index 21280e0..180d843 100644
--- a/src/engine/MachineBuilder.cpp
+++ b/src/engine/MachineBuilder.cpp
@@ -29,7 +29,7 @@ using namespace Raul;
namespace Machina {
-MachineBuilder::MachineBuilder(SharedPtr<Machine> machine, Raul::TimeStamp q)
+MachineBuilder::MachineBuilder(SharedPtr<Machine> machine, double q)
: _quantization(q)
, _time(machine->time().unit()) // = 0
, _machine(machine)
@@ -63,8 +63,9 @@ MachineBuilder::is_delay_node(SharedPtr<Node> node) const
/** Set the duration of a node, with quantization.
*/
void
-MachineBuilder::set_node_duration(SharedPtr<Node> node, Raul::TimeStamp d) const
+MachineBuilder::set_node_duration(SharedPtr<Node> node, Raul::TimeDuration d) const
{
+#if 0
Raul::TimeStamp q_dur = Quantizer::quantize(_quantization, d);
// Never quantize a note to duration 0
@@ -72,6 +73,7 @@ MachineBuilder::set_node_duration(SharedPtr<Node> node, Raul::TimeStamp d) const
q_dur = _quantization; // Round up
node->set_duration(q_dur);
+#endif
}
diff --git a/src/engine/Problem.cpp b/src/engine/Problem.cpp
index daf3ace..0660d0c 100644
--- a/src/engine/Problem.cpp
+++ b/src/engine/Problem.cpp
@@ -27,15 +27,16 @@
#include "machina/Edge.hpp"
#include "raul/SMFReader.hpp"
#include "raul/midi_events.h"
-#include "eugene/core/Problem.hpp"
+#include "eugene/Problem.hpp"
using namespace std;
namespace Machina {
-Problem::Problem(const std::string& target_midi, SharedPtr<Machine> seed)
- : _target(*this)
+Problem::Problem(TimeUnit unit, const std::string& target_midi, SharedPtr<Machine> seed)
+ : _unit(unit)
+ , _target(*this)
, _seed(new Machine(*seed.get()))
{
Raul::SMFReader smf;
@@ -49,7 +50,7 @@ Problem::Problem(const std::string& target_midi, SharedPtr<Machine> seed)
uint32_t delta_time;
while (smf.read_event(4, buf, &ev_size, &delta_time) >= 0) {
// time ignored
- _target.write_event(0, ev_size, buf);
+// _target.write_event(0, ev_size, buf);
#if 0
//_target._length += delta_time / (double)smf.ppqn();
if ((buf[0] & 0xF0) == MIDI_CMD_NOTE_ON) {
@@ -82,7 +83,7 @@ Problem::fitness(const Machine& const_machine) const
SharedPtr<Evaluator> eval(new Evaluator(*this));
- machine.reset(0.0f);
+ //machine.reset();
machine.deactivate();
machine.activate();
machine.set_sink(eval);
@@ -91,20 +92,21 @@ Problem::fitness(const Machine& const_machine) const
static const unsigned ppqn = 19200;
Raul::TimeSlice time(1.0/(double)ppqn, 120);
- time.set_start(0);
- time.set_length(2*ppqn);
+ time.set_start(TimeStamp(_unit, 0, 0));
+ time.set_length(TimeDuration(_unit, 2*ppqn));
machine.run(time);
if (eval->n_notes() == 0)
return 0.0f; // bad dog
- time.set_start(time.start_ticks() + 2*ppqn);
+ TimeStamp end(_unit, time.start_ticks().ticks() + 2*ppqn);
+ time.set_start(end);
while (eval->n_notes() < _target.n_notes()) {
machine.run(time);
if (machine.is_finished())
machine.reset(time.start_ticks());
- time.set_start(time.start_ticks() + 2*ppqn);
+ time.set_start(end);
}
eval->compute();
@@ -158,9 +160,9 @@ Problem::fitness(const Machine& const_machine) const
void
-Problem::Evaluator::write_event(Raul::BeatTime time,
- size_t ev_size,
- const uint8_t* ev) throw (std::logic_error)
+Problem::Evaluator::write_event(Raul::TimeStamp time,
+ size_t ev_size,
+ const uint8_t* ev) throw (std::logic_error)
{
if ((ev[0] & 0xF0) == MIDI_CMD_NOTE_ON) {
@@ -217,11 +219,11 @@ Problem::initial_population(size_t gene_size, size_t pop_size) const
// FIXME: ignores _seed and builds based on MIDI
// evolution of the visible machine would be nice..
- SharedPtr<Machine> base = SharedPtr<Machine>(new Machine());
+ SharedPtr<Machine> base = SharedPtr<Machine>(new Machine(_unit));
for (uint8_t i=0; i < 128; ++i) {
if (_target._counts[i] > 0) {
//cout << "Initial note: " << (int)i << endl;
- SharedPtr<Node> node(new Node(1/2.0));
+ SharedPtr<Node> node(new Node(TimeDuration(_unit, 1/2.0)));
node->set_enter_action(ActionFactory::note_on(i));
node->set_exit_action(ActionFactory::note_off(i));
node->set_selector(true);
diff --git a/src/engine/Recorder.cpp b/src/engine/Recorder.cpp
index 302a66e..03ea7d0 100644
--- a/src/engine/Recorder.cpp
+++ b/src/engine/Recorder.cpp
@@ -26,7 +26,7 @@ using namespace Raul;
namespace Machina {
-Recorder::Recorder(size_t buffer_size, TimeUnit unit, TimeStamp q)
+Recorder::Recorder(size_t buffer_size, TimeUnit unit, double q)
: _unit(unit)
, _record_buffer(buffer_size)
, _builder(new MachineBuilder(SharedPtr<Machine>(new Machine(unit)), q))
diff --git a/src/engine/SMFDriver.cpp b/src/engine/SMFDriver.cpp
index cf4c9da..6d23368 100644
--- a/src/engine/SMFDriver.cpp
+++ b/src/engine/SMFDriver.cpp
@@ -46,9 +46,9 @@ SMFDriver::SMFDriver(SharedPtr<Machine> machine)
* @return the resulting machine.
*/
SharedPtr<Machine>
-SMFDriver::learn(const string& filename, unsigned track, Raul::TimeStamp q, Raul::TimeDuration max_duration)
+SMFDriver::learn(const string& filename, unsigned track, double q, Raul::TimeDuration max_duration)
{
- assert(q.unit() == max_duration.unit());
+ //assert(q.unit() == max_duration.unit());
SharedPtr<Machine> m(new Machine(max_duration.unit()));
SharedPtr<MachineBuilder> builder = SharedPtr<MachineBuilder>(new MachineBuilder(m, q));
Raul::SMFReader reader;
@@ -77,8 +77,9 @@ SMFDriver::learn(const string& filename, unsigned track, Raul::TimeStamp q, Raul
* This will result in one disjoint subgraph in the machine for each track.
*/
SharedPtr<Machine>
-SMFDriver::learn(const string& filename, Raul::TimeStamp q, Raul::TimeStamp max_duration)
+SMFDriver::learn(const string& filename, double q, Raul::TimeStamp max_duration)
{
+#if 0
SharedPtr<Machine> m(new Machine(q.unit()));
SharedPtr<MachineBuilder> builder = SharedPtr<MachineBuilder>(new MachineBuilder(m, q));
Raul::SMFReader reader;
@@ -98,6 +99,7 @@ SMFDriver::learn(const string& filename, Raul::TimeStamp q, Raul::TimeStamp max_
if (m->nodes().size() > 1)
return m;
else
+#endif
return SharedPtr<Machine>();
}
@@ -106,20 +108,22 @@ void
SMFDriver::learn_track(SharedPtr<MachineBuilder> builder,
Raul::SMFReader& reader,
unsigned track,
- Raul::TimeStamp q,
+ double q,
Raul::TimeDuration max_duration)
{
const bool found_track = reader.seek_to_track(track);
if (!found_track)
return;
+#if 0
+ uint8_5 buf[4];
+ uint32_t ev_size;
+ uint32_t ev_delta_time;
+
+ uint64_t t = 0;
+ uint64_t unquantized_t = 0;
- Raul::TimeStamp unquantized_t(q.unit(), 0, 0);
- Raul::TimeStamp t(q.unit(), 0, 0);
- unsigned char buf[4];
- uint32_t ev_size;
- Raul::TimeStamp ev_time(q.unit());
- while (reader.read_event(4, buf, &ev_size, &ev_time) >= 0) {
- unquantized_t += ev_time;
+ while (reader.read_event(4, buf, &ev_size, &ev_delta_time) >= 0) {
+ unquantized_t += ev_delta_time;
t = Raul::Quantizer::quantize(q, unquantized_t);
builder->set_time(t);
@@ -130,6 +134,7 @@ SMFDriver::learn_track(SharedPtr<MachineBuilder> builder,
if (ev_size > 0)
builder->event(TimeStamp(t.unit(), 0, 0), ev_size, buf);
}
+#endif
builder->resolve();
}
diff --git a/src/engine/machina/Driver.hpp b/src/engine/machina/Driver.hpp
index d087d88..f412574 100644
--- a/src/engine/machina/Driver.hpp
+++ b/src/engine/machina/Driver.hpp
@@ -34,7 +34,7 @@ public:
virtual void set_machine(SharedPtr<Machine> machine) { _machine = machine; }
virtual void set_bpm(double bpm) = 0;
- virtual void set_quantization(Raul::TimeStamp q) = 0;
+ virtual void set_quantization(double q) = 0;
virtual void activate() {}
virtual void deactivate() {}
diff --git a/src/engine/machina/Engine.hpp b/src/engine/machina/Engine.hpp
index 02a9fc6..92384a8 100644
--- a/src/engine/machina/Engine.hpp
+++ b/src/engine/machina/Engine.hpp
@@ -44,7 +44,7 @@ public:
SharedPtr<Machine> load_machine(const Glib::ustring& uri);
SharedPtr<Machine> import_machine(const Glib::ustring& uri);
- SharedPtr<Machine> import_midi(const Glib::ustring& uri, Raul::TimeStamp q, Raul::TimeDuration d);
+ SharedPtr<Machine> import_midi(const Glib::ustring& uri, double q, Raul::TimeDuration d);
void set_bpm(double bpm);
void set_quantization(double beat_fraction);
diff --git a/src/engine/machina/Evolver.hpp b/src/engine/machina/Evolver.hpp
index edf68db..1b847db 100644
--- a/src/engine/machina/Evolver.hpp
+++ b/src/engine/machina/Evolver.hpp
@@ -20,7 +20,8 @@
#include "raul/SharedPtr.hpp"
#include "raul/Thread.hpp"
-#include "eugene/core/GAImpl.hpp"
+#include "raul/TimeStamp.hpp"
+#include "eugene/GAImpl.hpp"
#include "Schrodinbit.hpp"
namespace Eugene { template <typename G> class HybridMutation; }
@@ -33,7 +34,7 @@ class Problem;
class Evolver : public Raul::Thread {
public:
- Evolver(const string& target_midi, SharedPtr<Machine> seed);
+ Evolver(Raul::TimeUnit unit, const string& target_midi, SharedPtr<Machine> seed);
void seed(SharedPtr<Machine> parent);
bool improvement() { return _improvement; }
diff --git a/src/engine/machina/JackDriver.hpp b/src/engine/machina/JackDriver.hpp
index 54c7b1a..40c2868 100644
--- a/src/engine/machina/JackDriver.hpp
+++ b/src/engine/machina/JackDriver.hpp
@@ -60,8 +60,8 @@ public:
size_t size,
const unsigned char* event) throw (std::logic_error);
- void set_bpm(double bpm) { _bpm.set(bpm); }
- void set_quantization(Raul::TimeStamp q) { _quantization.set(q); }
+ void set_bpm(double bpm) { _bpm.set(bpm); }
+ void set_quantization(double q) { _quantization.set(q); }
void stop();
@@ -81,10 +81,11 @@ private:
jack_port_t* _input_port;
jack_port_t* _output_port;
+ Raul::TimeUnit _frames_unit;
Raul::TimeSlice _cycle_time;
- Raul::DoubleBuffer<double> _bpm;
- Raul::DoubleBuffer<Raul::TimeStamp> _quantization;
+ Raul::DoubleBuffer<double> _bpm;
+ Raul::DoubleBuffer<double> _quantization;
Raul::Command _stop;
diff --git a/src/engine/machina/LearnRequest.hpp b/src/engine/machina/LearnRequest.hpp
index 4a65675..edc76c9 100644
--- a/src/engine/machina/LearnRequest.hpp
+++ b/src/engine/machina/LearnRequest.hpp
@@ -43,7 +43,7 @@ public:
return ret;
}
- void start(TimeStamp q, Raul::TimeStamp time)
+ void start(double q, Raul::TimeStamp time)
{ _started = true; _start_time = time; _quantization = q; }
void finish(TimeStamp time);
@@ -58,7 +58,7 @@ private:
LearnRequest(SharedPtr<Raul::Maid> maid, SharedPtr<Node> node)
: _started(false)
, _start_time(TimeUnit(TimeUnit::BEATS, 19200), 0, 0) // irrelevant
- , _quantization(TimeUnit(TimeUnit::BEATS, 19200), 1, 0) // irrelevant
+ , _quantization(0) // irrelevant
, _node(node)
, _enter_action(new MidiAction(4, NULL))
, _exit_action(new MidiAction(4, NULL))
@@ -69,7 +69,7 @@ private:
bool _started;
TimeStamp _start_time;
- TimeStamp _quantization;
+ double _quantization;
SharedPtr<Node> _node;
SharedPtr<MidiAction> _enter_action;
SharedPtr<MidiAction> _exit_action;
diff --git a/src/engine/machina/MachineBuilder.hpp b/src/engine/machina/MachineBuilder.hpp
index 4e0e28d..2c9d0a2 100644
--- a/src/engine/machina/MachineBuilder.hpp
+++ b/src/engine/machina/MachineBuilder.hpp
@@ -30,7 +30,7 @@ class Node;
class MachineBuilder {
public:
MachineBuilder(SharedPtr<Machine> machine,
- Raul::TimeStamp quantization);
+ double quantization);
void set_time(Raul::TimeStamp time) { _time = time; }
@@ -43,7 +43,7 @@ public:
private:
bool is_delay_node(SharedPtr<Node> node) const;
- void set_node_duration(SharedPtr<Node> node, Raul::TimeStamp d) const;
+ void set_node_duration(SharedPtr<Node> node, Raul::TimeDuration d) const;
SharedPtr<Node>
connect_nodes(SharedPtr<Machine> m,
@@ -56,7 +56,7 @@ private:
typedef std::list<std::pair<Raul::TimeStamp, SharedPtr<Node> > > PolyList;
PolyList _poly_nodes;
- Raul::TimeStamp _quantization;
+ double _quantization;
Raul::TimeStamp _time;
SharedPtr<Machine> _machine;
diff --git a/src/engine/machina/Mutation.hpp b/src/engine/machina/Mutation.hpp
index 628222b..6d97d29 100644
--- a/src/engine/machina/Mutation.hpp
+++ b/src/engine/machina/Mutation.hpp
@@ -21,7 +21,7 @@
#include "config.h"
#if HAVE_EUGENE
- #include "eugene/core/Mutation.hpp"
+ #include "eugene/Mutation.hpp"
#define SUPER : public Eugene::Mutation<Machine>
#else
#define SUPER
diff --git a/src/engine/machina/Problem.hpp b/src/engine/machina/Problem.hpp
index d487f46..9f15e09 100644
--- a/src/engine/machina/Problem.hpp
+++ b/src/engine/machina/Problem.hpp
@@ -23,13 +23,14 @@
#include <map>
#include "raul/MIDISink.hpp"
#include "machina/Machine.hpp"
+#include "eugene/Problem.hpp"
namespace Machina {
class Problem : public Eugene::Problem<Machine> {
public:
- Problem(const std::string& target_midi, SharedPtr<Machine> seed = SharedPtr<Machine>());
+ Problem(TimeUnit unit, const std::string& target_midi, SharedPtr<Machine> seed = SharedPtr<Machine>());
void seed(SharedPtr<Machine> parent) { _seed = parent; }
@@ -86,7 +87,7 @@ private:
for (uint8_t i=0; i < 128; ++i)
_counts[i] = 0;
}
- void write_event(Raul::BeatTime time,
+ void write_event(TimeStamp time,
size_t ev_size,
const uint8_t* ev) throw (std::logic_error);
void compute();
@@ -106,6 +107,8 @@ private:
uint8_t _first_note;
};
+ TimeUnit _unit;
+
Evaluator _target;
SharedPtr<Machine> _seed;
diff --git a/src/engine/machina/Recorder.hpp b/src/engine/machina/Recorder.hpp
index aa5040a..6a91ba6 100644
--- a/src/engine/machina/Recorder.hpp
+++ b/src/engine/machina/Recorder.hpp
@@ -30,7 +30,7 @@ class MachineBuilder;
class Recorder : public Raul::Slave {
public:
- Recorder(size_t buffer_size, TimeUnit unit, TimeStamp q);
+ Recorder(size_t buffer_size, TimeUnit unit, double q);
inline void write(Raul::TimeStamp time, size_t size, const unsigned char* buf) {
_record_buffer.write(time, size, buf);
diff --git a/src/engine/machina/SMFDriver.hpp b/src/engine/machina/SMFDriver.hpp
index 9cbef26..5e1e9f8 100644
--- a/src/engine/machina/SMFDriver.hpp
+++ b/src/engine/machina/SMFDriver.hpp
@@ -39,12 +39,12 @@ public:
SMFDriver(SharedPtr<Machine> machine = SharedPtr<Machine>());
SharedPtr<Machine> learn(const std::string& filename,
- Raul::TimeStamp q,
+ double q,
Raul::TimeDuration max_duration);
SharedPtr<Machine> learn(const std::string& filename,
unsigned track,
- Raul::TimeStamp q,
+ double q,
Raul::TimeDuration max_duration);
void run(SharedPtr<Machine> machine, Raul::TimeStamp max_time);
@@ -65,7 +65,7 @@ private:
void learn_track(SharedPtr<MachineBuilder> builder,
Raul::SMFReader& reader,
unsigned track,
- Raul::TimeStamp q,
+ double q,
Raul::TimeDuration max_duration);
};
diff --git a/src/engine/wscript b/src/engine/wscript
new file mode 100644
index 0000000..be489de
--- /dev/null
+++ b/src/engine/wscript
@@ -0,0 +1,33 @@
+#!/usr/bin/env python
+import Params
+import autowaf
+
+def build(bld):
+ core_source = '''
+ Action.cpp
+ ActionFactory.cpp
+ Edge.cpp
+ Engine.cpp
+ Evolver.cpp
+ JackDriver.cpp
+ LearnRequest.cpp
+ Loader.cpp
+ Machine.cpp
+ MachineBuilder.cpp
+ MidiAction.cpp
+ Mutation.cpp
+ Node.cpp
+ Problem.cpp
+ RaulJackDriver.cpp
+ Recorder.cpp
+ SMFDriver.cpp
+ '''
+
+ obj = bld.create_obj('cpp', 'shlib')
+ obj.source = core_source
+ obj.includes = ['.', '..']
+ obj.name = 'libmachina_engine'
+ obj.target = 'machina_engine'
+ core_libs = 'GLIBMM GTHREAD RAUL REDLANDMM JACK EUGENE'
+ autowaf.use_lib(bld, obj, core_libs)
+