aboutsummaryrefslogtreecommitdiffstats
path: root/src/engine/Machine.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-03-30 22:32:07 +0000
committerDavid Robillard <d@drobilla.net>2007-03-30 22:32:07 +0000
commitdd6be02a7478225f19f02432919b64b96b733172 (patch)
tree35d3476f6728801ed1e6b8d124fc85d549e91bfd /src/engine/Machine.cpp
parent2124952b855e093d6253bfd763cd9ebfe69e9def (diff)
downloadmachina-dd6be02a7478225f19f02432919b64b96b733172.tar.gz
machina-dd6be02a7478225f19f02432919b64b96b733172.tar.bz2
machina-dd6be02a7478225f19f02432919b64b96b733172.zip
Canvas auto-layout uses durations like graphviz diagrams.
Learning fixes. Added duration spinbutton to MIDI Import dialog. git-svn-id: http://svn.drobilla.net/lad/machina@381 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/engine/Machine.cpp')
-rw-r--r--src/engine/Machine.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/engine/Machine.cpp b/src/engine/Machine.cpp
index 600dd3d..43fd280 100644
--- a/src/engine/Machine.cpp
+++ b/src/engine/Machine.cpp
@@ -56,6 +56,7 @@ void
Machine::add_node(SharedPtr<Node> node)
{
//cerr << "ADDING NODE " << node.get() << endl;
+ assert(_nodes.find(node) == _nodes.end());
_nodes.push_back(node);
}
@@ -78,6 +79,8 @@ Machine::reset()
if (node->is_active())
node->exit(_sink.lock(), _time);
+
+ assert(! node->is_active());
}
}
@@ -150,6 +153,7 @@ Machine::exit_node(SharedPtr<Raul::MIDISink> sink, const SharedPtr<Node> node)
{
node->exit(sink, _time);
assert(!node->is_active());
+
for (size_t i=0; i < MAX_ACTIVE_NODES; ++i) {
if (_active_nodes[i] == node) {
_active_nodes[i].reset();
@@ -161,13 +165,15 @@ Machine::exit_node(SharedPtr<Raul::MIDISink> sink, const SharedPtr<Node> node)
for (Node::Edges::const_iterator s = node->outgoing_edges().begin();
s != node->outgoing_edges().end(); ++s) {
+ assert((*s)->head() != node); // no loops
+
const double rand_normal = rand() / (double)RAND_MAX; // [0, 1]
if (rand_normal <= (*s)->probability()) {
- SharedPtr<Node> dst = (*s)->dst();
+ SharedPtr<Node> head = (*s)->head();
- if (!dst->is_active())
- enter_node(sink, dst);
+ if (!head->is_active())
+ enter_node(sink, head);
}
}
}
@@ -187,7 +193,6 @@ Machine::run(const Raul::TimeSlice& time)
{
using namespace std;
if (_is_finished) {
- cerr << "FINISHED\n";
return 0;
}
@@ -195,8 +200,6 @@ Machine::run(const Raul::TimeSlice& time)
const BeatCount cycle_end = _time + time.length_beats();
- //std::cerr << "Start: " << _time << std::endl;
-
assert(_is_activated);
// Initial run, enter all initial states
@@ -249,8 +252,6 @@ Machine::run(const Raul::TimeSlice& time)
}
- //std::cerr << "Done: " << this_time << std::endl;
-
assert(this_time <= time.length_beats());
return this_time;
}
@@ -263,7 +264,7 @@ Machine::run(const Raul::TimeSlice& time)
void
Machine::learn(SharedPtr<LearnRequest> learn)
{
- std::cerr << "LEARN\n";
+ std::cerr << "Learn" << std::endl;
/*LearnRequest request(node,
SharedPtr<MidiAction>(new MidiAction(4, NULL)),