diff options
Diffstat (limited to 'src/engine')
37 files changed, 286 insertions, 286 deletions
diff --git a/src/engine/Action.cpp b/src/engine/Action.cpp index c13e9c8..5504297 100644 --- a/src/engine/Action.cpp +++ b/src/engine/Action.cpp @@ -1,15 +1,15 @@ /* This file is part of Machina. * Copyright (C) 2007 Dave Robillard <http://drobilla.net> - * + * * Machina is free software; you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later * version. - * + * * Machina is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. - * + * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA @@ -25,7 +25,7 @@ void Action::write_state(Redland::Model& model) { using namespace Raul; - + if (!_id) set_id(model.world().blank_id()); diff --git a/src/engine/ActionFactory.cpp b/src/engine/ActionFactory.cpp index 6632b3c..0b926d6 100644 --- a/src/engine/ActionFactory.cpp +++ b/src/engine/ActionFactory.cpp @@ -1,15 +1,15 @@ /* This file is part of Machina. * Copyright (C) 2007 Dave Robillard <http://drobilla.net> - * + * * Machina is free software; you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later * version. - * + * * Machina is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. - * + * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA diff --git a/src/engine/Edge.cpp b/src/engine/Edge.cpp index e380a30..fe8df22 100644 --- a/src/engine/Edge.cpp +++ b/src/engine/Edge.cpp @@ -1,15 +1,15 @@ /* This file is part of Machina. * Copyright (C) 2007 Dave Robillard <http://drobilla.net> - * + * * Machina is free software; you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later * version. - * + * * Machina is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. - * + * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA @@ -52,7 +52,7 @@ Edge::write_state(Redland::Model& model) model.add_statement(_id, "machina:head", head->id()); - + model.add_statement(_id, "machina:probability", AtomRDF::atom_to_node(model.world(), Atom(_probability.get()))); diff --git a/src/engine/Engine.cpp b/src/engine/Engine.cpp index f25c4d4..0cd9e77 100644 --- a/src/engine/Engine.cpp +++ b/src/engine/Engine.cpp @@ -1,15 +1,15 @@ /* This file is part of Machina. * Copyright (C) 2007 Dave Robillard <http://drobilla.net> - * + * * Machina is free software; you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later * version. - * + * * Machina is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. - * + * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA @@ -38,9 +38,9 @@ Engine::load_machine(const Glib::ustring& uri) m->activate(); _driver->set_machine(m); } - + // .. and drop it in this thread (to prevent deallocation in the RT thread) - + return m; } @@ -56,9 +56,9 @@ Engine::import_machine(const Glib::ustring& uri) m->activate(); _driver->machine()->nodes().append(m->nodes()); } - + // Discard m - + return _driver->machine(); } @@ -73,9 +73,9 @@ Engine::import_midi(const Glib::ustring& uri, double q, Raul::TimeDuration durat SharedPtr<Machine> m = file_driver->learn(uri, q, duration); m->activate(); _driver->machine()->nodes().append(m->nodes()); - + // Discard m - + return _driver->machine(); } diff --git a/src/engine/Evolver.cpp b/src/engine/Evolver.cpp index af126d6..0ca4c27 100644 --- a/src/engine/Evolver.cpp +++ b/src/engine/Evolver.cpp @@ -1,15 +1,15 @@ /* This file is part of Machina. * Copyright (C) 2007 Dave Robillard <http://drobilla.net> - * + * * Machina is free software; you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later * version. - * + * * Machina is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. - * + * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA @@ -33,9 +33,9 @@ namespace Machina { 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>()); - + m->append_mutation(1/6.0f, boost::shared_ptr< Eugene::Mutation<Machine> >( new Mutation::Compress())); m->append_mutation(1/6.0f, boost::shared_ptr< Eugene::Mutation<Machine> >( @@ -58,7 +58,7 @@ Evolver::Evolver(TimeUnit unit, const string& target_midi, SharedPtr<Machine> se _ga = SharedPtr<MachinaGA>(new MachinaGA(_problem, s, crossover, m, 20, 20, 2, 1.0, 0.0)); } - + void Evolver::seed(SharedPtr<Machine> parent) @@ -68,7 +68,7 @@ Evolver::seed(SharedPtr<Machine> parent) _problem->seed(parent); _seed_fitness = _problem->fitness(*parent.get()); } - + void Evolver::_run() @@ -85,7 +85,7 @@ Evolver::_run() _ga->iteration(); float new_best = _ga->best_fitness(); - + /*cout << _problem->fitness_less(old_best, *_ga->best().get()) << endl; cout << "best: " << _ga->best().get() << endl; cout << "best fitness: " << _problem->fitness(*_ga->best().get()) << endl; @@ -98,7 +98,7 @@ Evolver::_run() old_best = new_best; cout << "*** NEW BEST: " << new_best << endl; } - + //cout << "}" << endl; } } diff --git a/src/engine/JackDriver.cpp b/src/engine/JackDriver.cpp index 9993866..ef74a61 100644 --- a/src/engine/JackDriver.cpp +++ b/src/engine/JackDriver.cpp @@ -1,15 +1,15 @@ /* This file is part of Machina. * Copyright (C) 2007 Dave Robillard <http://drobilla.net> - * + * * Machina is free software; you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later * version. - * + * * Machina is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. - * + * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA @@ -58,12 +58,12 @@ JackDriver::attach(const std::string& client_name) if (jack_client()) { //_cycle_time.set_tick_rate(1/(double)sample_rate()); - + _input_port = jack_port_register(jack_client(), "in", JACK_DEFAULT_MIDI_TYPE, JackPortIsInput, 0); - + if (!_input_port) std:: cerr << "WARNING: Failed to create MIDI input port." << std::endl; @@ -71,7 +71,7 @@ JackDriver::attach(const std::string& client_name) "out", JACK_DEFAULT_MIDI_TYPE, JackPortIsOutput, 0); - + if (!_output_port) std::cerr << "WARNING: Failed to create MIDI output port." << std::endl; @@ -93,7 +93,7 @@ JackDriver::detach() jack_port_unregister(jack_client(), _input_port); _input_port = NULL; } - + if (_output_port) { jack_port_unregister(jack_client(), _output_port); _output_port = NULL; @@ -109,7 +109,7 @@ JackDriver::set_machine(SharedPtr<Machine> machine) return; cout << "DRIVER MACHINE: " << machine.get() << endl; - SharedPtr<Machine> last_machine = _last_machine; // Keep a reference + SharedPtr<Machine> last_machine = _last_machine; // Keep a reference _machine_changed.reset(0); assert(!last_machine.unique()); _machine = machine; @@ -136,7 +136,7 @@ JackDriver::process_input(SharedPtr<Machine> machine, const TimeSlice& time) for (jack_nframes_t i=0; i < event_count; ++i) { jack_midi_event_t ev; jack_midi_event_get(&ev, jack_buffer, i); - + _recorder->write(_record_time + TimeStamp(_record_time.unit(), ev.time, 0), ev.size, ev.buffer); } @@ -165,9 +165,9 @@ JackDriver::process_input(SharedPtr<Machine> machine, const TimeSlice& time) } } else if (ev.buffer[0] == 0x80) { - + const SharedPtr<LearnRequest> learn = machine->pending_learn(); - + if (learn) { if (learn->started()) { learn->exit_action()->set_event(ev.size, ev.buffer); @@ -193,7 +193,7 @@ JackDriver::write_event(Raul::TimeStamp time, return; if (_cycle_time.beats_to_ticks(time) + _cycle_time.offset_ticks() < _cycle_time.start_ticks()) { - std::cerr << "ERROR: Missed event by " + std::cerr << "ERROR: Missed event by " << _cycle_time.start_ticks() - (_cycle_time.beats_to_ticks(time) + _cycle_time.offset_ticks()) << " ticks" @@ -262,14 +262,14 @@ JackDriver::on_process(jack_nframes_t nframes) } _machine_changed.post(); // Signal we're done with it } - + if (!machine) { _last_machine = machine; return; } - + machine->set_sink(shared_from_this()); - + if (_recording.get()) _record_time += length_beats; @@ -296,13 +296,13 @@ JackDriver::on_process(jack_nframes_t nframes) } else if (machine->is_finished()) { const TimeStamp finish_offset = _cycle_time.offset_ticks() + run_dur_frames; assert(finish_offset < length_ticks); - + machine->reset(machine->time()); _cycle_time.set_slice(TimeStamp(_frames_unit, 0, 0), TimeDuration(_frames_unit, nframes - finish_offset.ticks())); _cycle_time.set_offset(finish_offset); - + // Machine ran for entire cycle } else { if (machine->is_finished()) { @@ -323,7 +323,7 @@ end: /* Remember the last machine run, in case a switch happens and * we need to finalize it next cycle. */ _last_machine = machine; - + if (_stop.pending()) { _cycle_time.set_slice(TimeStamp(_frames_unit, 0, 0), TimeStamp(_frames_unit, 0, 0)); diff --git a/src/engine/LearnRequest.cpp b/src/engine/LearnRequest.cpp index 782cfff..5573fb7 100644 --- a/src/engine/LearnRequest.cpp +++ b/src/engine/LearnRequest.cpp @@ -1,15 +1,15 @@ /* This file is part of Machina. * Copyright (C) 2007 Dave Robillard <http://drobilla.net> - * + * * Machina is free software; you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later * version. - * + * * Machina is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. - * + * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA @@ -29,7 +29,7 @@ LearnRequest::finish(TimeStamp time) _node->set_exit_action(_exit_action); //TimeDuration duration = Raul::Quantizer::quantize(_quantization, time - _start_time); - + //_node->set_duration(duration); } diff --git a/src/engine/Loader.cpp b/src/engine/Loader.cpp index 6d1409d..1f0140c 100644 --- a/src/engine/Loader.cpp +++ b/src/engine/Loader.cpp @@ -1,15 +1,15 @@ /* This file is part of Machina. * Copyright (C) 2007 Dave Robillard <http://drobilla.net> - * + * * Machina is free software; you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later * version. - * + * * Machina is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. - * + * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA @@ -76,7 +76,7 @@ Loader::load(const Glib::ustring& uri) cout << "[Loader] Loading " << machine_uri << " from " << document_uri << endl; machine = SharedPtr<Machine>(new Machine(TimeUnit::beats(MACHINA_PPQN))); - + typedef std::map<string, SharedPtr<Node> > Created; Created created; @@ -85,7 +85,7 @@ Loader::load(const Glib::ustring& uri) /* Get initial nodes */ Query query = Query(_rdf_world, ustring( - "SELECT DISTINCT ?node ?duration WHERE {\n") + + "SELECT DISTINCT ?node ?duration WHERE {\n") + machine_uri + " :initialNode ?node .\n" "?node :duration ?duration .\n" "}\n"); @@ -118,14 +118,14 @@ Loader::load(const Glib::ustring& uri) SharedPtr<Node> node(new Node( TimeStamp(TimeUnit(TimeUnit::BEATS, MACHINA_PPQN), (double)(*i)["duration"]), false)); - machine->add_node(node); + machine->add_node(node); created[node_id] = node; } } /* Find out which nodes are selectors */ - + query = Query(_rdf_world, ustring( "SELECT DISTINCT ?node WHERE {\n") + machine_uri + " :node ?node .\n" @@ -184,7 +184,7 @@ Loader::load(const Glib::ustring& uri) for (Query::Results::iterator i = results.begin(); i != results.end(); ++i) { const char* src_uri = (*i)["src"]; - const char* dst_uri = (*i)["dst"]; + const char* dst_uri = (*i)["dst"]; float prob = (*i)["prob"]; Created::iterator src_i = created.find(src_uri); diff --git a/src/engine/Machine.cpp b/src/engine/Machine.cpp index 7dcac34..fdeb6c6 100644 --- a/src/engine/Machine.cpp +++ b/src/engine/Machine.cpp @@ -1,15 +1,15 @@ /* This file is part of Machina. * Copyright (C) 2007 Dave Robillard <http://drobilla.net> - * + * * Machina is free software; you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later * version. - * + * * Machina is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. - * + * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA @@ -38,7 +38,7 @@ Machine::Machine(TimeUnit unit) { } - + /** Copy a Machine. * * Creates a deep copy which is the 'same' machine, but with @@ -53,13 +53,13 @@ Machine::Machine(const Machine& copy) , _sink(copy._sink) { map< SharedPtr<Node>, SharedPtr<Node> > replacements; - + for (Nodes::const_iterator n = copy._nodes.begin(); n != copy._nodes.end(); ++n) { SharedPtr<Machina::Node> node(new Machina::Node(*n->get())); _nodes.push_back(node); replacements[*n] = node; } - + for (Nodes::const_iterator n = _nodes.begin(); n != _nodes.end(); ++n) { for (Node::Edges::const_iterator e = (*n)->edges().begin(); e != (*n)->edges().end(); ++e) { (*e)->set_tail(*n); @@ -82,13 +82,13 @@ Machine::operator=(const Machine& other) _nodes.clear(); map< SharedPtr<Node>, SharedPtr<Node> > replacements; - + for (Nodes::const_iterator n = other._nodes.begin(); n != other._nodes.end(); ++n) { SharedPtr<Machina::Node> node(new Machina::Node(*n->get())); _nodes.push_back(node); replacements[*n] = node; } - + for (Nodes::const_iterator n = _nodes.begin(); n != _nodes.end(); ++n) { for (Node::Edges::const_iterator e = (*n)->edges().begin(); e != (*n)->edges().end(); ++e) { (*e)->set_tail(*n); @@ -111,7 +111,7 @@ Machine::set_sink(SharedPtr<Raul::MIDISink> sink) { _sink = sink; } - + /** Always returns a node, unless there are none */ SharedPtr<Node> @@ -119,7 +119,7 @@ Machine::random_node() { if (_nodes.empty()) return SharedPtr<Node>(); - + size_t i = rand() % _nodes.size(); // FIXME: O(n) worst case :( @@ -136,7 +136,7 @@ SharedPtr<Edge> Machine::random_edge() { SharedPtr<Node> tail = random_node(); - + for (size_t i = 0; i < _nodes.size() && tail->edges().empty(); ++i) tail = random_node(); @@ -156,7 +156,7 @@ void Machine::remove_node(SharedPtr<Node> node) { _nodes.erase(_nodes.find(node)); - + for (Nodes::const_iterator n = _nodes.begin(); n != _nodes.end(); ++n) (*n)->remove_edges_to(node); } @@ -176,7 +176,7 @@ Machine::reset(Raul::TimeStamp time) assert(! node->is_active()); } - + for (size_t i=0; i < MAX_ACTIVE_NODES; ++i) _active_nodes.at(i).reset(); } @@ -190,12 +190,12 @@ Machine::reset(Raul::TimeStamp time) */ SharedPtr<Node> Machine::earliest_node() const -{ +{ SharedPtr<Node> earliest; - + for (size_t i=0; i < MAX_ACTIVE_NODES; ++i) { SharedPtr<Node> node = _active_nodes.at(i); - + if (node) { assert(node->is_active()); if (!earliest || node->exit_time() < earliest->exit_time()) { @@ -209,7 +209,7 @@ Machine::earliest_node() const /** Enter a state at the current _time. - * + * * Returns true if node was entered, or false if the maximum active nodes has been reached. */ bool @@ -250,7 +250,7 @@ Machine::exit_node(SharedPtr<Raul::MIDISink> sink, SharedPtr<Node> node) // Activate successors to this node // (that aren't aready active right now) - + if (node->is_selector()) { const double rand_normal = rand() / (double)RAND_MAX; // [0, 1] @@ -258,7 +258,7 @@ Machine::exit_node(SharedPtr<Raul::MIDISink> sink, SharedPtr<Node> node) for (Node::Edges::const_iterator s = node->edges().begin(); s != node->edges().end(); ++s) { - + if (!(*s)->head()->is_active() && rand_normal > range_min && rand_normal < range_min + (*s)->probability()) { @@ -293,7 +293,7 @@ Machine::exit_node(SharedPtr<Raul::MIDISink> sink, SharedPtr<Node> node) /** Run the machine for a (real) time slice. * * Returns the duration of time the machine actually ran. - * + * * Caller can check is_finished() to determine if the machine still has any * active states. If not, time() will return the exact time stamp the * machine actually finished on (so it can be restarted immediately @@ -317,10 +317,10 @@ Machine::run(const Raul::TimeSlice& time) bool entered = false; if ( ! _nodes.empty()) { for (Nodes::const_iterator n = _nodes.begin(); n != _nodes.end(); ++n) { - + if ((*n)->is_active()) (*n)->exit(sink, _time); - + if ((*n)->is_initial()) { if (enter_node(sink, (*n))) entered = true; @@ -333,7 +333,7 @@ Machine::run(const Raul::TimeSlice& time) return TimeStamp(_time.unit(), 0, 0); } } - + TimeStamp this_time(_time.unit(), 0, 0); while (true) { @@ -363,7 +363,7 @@ Machine::run(const Raul::TimeSlice& time) } } - + //assert(this_time <= time.length_beats()); return this_time; } @@ -394,7 +394,7 @@ Machine::write_state(Redland::Model& model) size_t count = 0; for (Nodes::const_iterator n = _nodes.begin(); n != _nodes.end(); ++n) { - + (*n)->write_state(model); if ((*n)->is_initial()) { @@ -411,12 +411,12 @@ Machine::write_state(Redland::Model& model) count = 0; for (Nodes::const_iterator n = _nodes.begin(); n != _nodes.end(); ++n) { - + for (Node::Edges::const_iterator e = (*n)->edges().begin(); e != (*n)->edges().end(); ++e) { - + (*e)->write_state(model); - + model.add_statement(model.base_uri(), Redland::Node(model.world(), Redland::Node::RESOURCE, "machina:edge"), (*e)->id()); diff --git a/src/engine/MachineBuilder.cpp b/src/engine/MachineBuilder.cpp index f3d6387..28f7364 100644 --- a/src/engine/MachineBuilder.cpp +++ b/src/engine/MachineBuilder.cpp @@ -1,15 +1,15 @@ /* This file is part of Machina. * Copyright (C) 2007 Dave Robillard <http://drobilla.net> - * + * * Machina is free software; you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later * version. - * + * * Machina is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. - * + * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA @@ -103,7 +103,7 @@ MachineBuilder::connect_nodes(SharedPtr<Machine> m, delay_node->add_edge(SharedPtr<Edge>(new Edge(delay_node, head))); m->add_node(delay_node); } - + return delay_node; } @@ -120,7 +120,7 @@ MachineBuilder::event(Raul::TimeStamp time_offset, return; if ((buf[0] & 0xF0) == MIDI_CMD_NOTE_ON) { - + SharedPtr<Node> node(new Node(TimeStamp(unit))); node->set_enter_action(SharedPtr<Action>(new MidiAction(ev_size, buf))); @@ -159,7 +159,7 @@ MachineBuilder::event(Raul::TimeStamp time_offset, _active_nodes.push_back(node); } else if ((buf[0] & 0xF0) == MIDI_CMD_NOTE_OFF) { - + for (ActiveList::iterator i = _active_nodes.begin(); i != _active_nodes.end(); ++i) { SharedPtr<MidiAction> action = PtrCast<MidiAction>((*i)->enter_action()); if (!action) @@ -202,7 +202,7 @@ MachineBuilder::event(Raul::TimeStamp time_offset, // Just monophonic } else { - + // Trim useless delay node if possible (these appear after poly sections) if (is_delay_node(_connect_node) && _connect_node->duration().is_zero() && _connect_node->edges().size() == 1 @@ -223,7 +223,7 @@ MachineBuilder::event(Raul::TimeStamp time_offset, _connect_node = resolved; _machine->add_node(resolved); } - } + } // Polyphonic, add this state to poly list } else { @@ -231,7 +231,7 @@ MachineBuilder::event(Raul::TimeStamp time_offset, _connect_node = resolved; _connect_node_end_time = t; } - + if (resolved->is_active()) resolved->exit(SharedPtr<Raul::MIDISink>(), t); @@ -240,7 +240,7 @@ MachineBuilder::event(Raul::TimeStamp time_offset, break; } } - + } } @@ -273,7 +273,7 @@ MachineBuilder::resolve() } // Add initial note if necessary - if (_machine->nodes().size() > 0 + if (_machine->nodes().size() > 0 && _machine->nodes().find(_initial_node) == _machine->nodes().end()) _machine->add_node(_initial_node); diff --git a/src/engine/MidiAction.cpp b/src/engine/MidiAction.cpp index c57a9c0..127c931 100644 --- a/src/engine/MidiAction.cpp +++ b/src/engine/MidiAction.cpp @@ -1,15 +1,15 @@ /* This file is part of Machina. * Copyright (C) 2007 Dave Robillard <http://drobilla.net> - * + * * Machina is free software; you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later * version. - * + * * Machina is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. - * + * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA @@ -101,7 +101,7 @@ MidiAction::write_state(Redland::Model& model) model.add_statement(_id, Redland::Node(model.world(), Redland::Node::RESOURCE, "rdf:type"), Redland::Node(model.world(), Redland::Node::RESOURCE, "machina:MidiAction")); - + // FIXME: Assumes note on/note off model.add_statement(_id, Redland::Node(model.world(), Redland::Node::RESOURCE, "machina:midiNote"), diff --git a/src/engine/Mutation.cpp b/src/engine/Mutation.cpp index 62abad5..1d3d794 100644 --- a/src/engine/Mutation.cpp +++ b/src/engine/Mutation.cpp @@ -1,15 +1,15 @@ /* This file is part of Machina. * Copyright (C) 2007 Dave Robillard <http://drobilla.net> - * + * * Machina is free software; you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later * version. - * + * * Machina is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. - * + * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA @@ -37,7 +37,7 @@ Compress::mutate(Machine& machine) for (Machine::Nodes::iterator i = machine.nodes().begin(); i != machine.nodes().end() ;) { Machine::Nodes::iterator next = i; ++next; - + if ((*i)->edges().empty()) machine.remove_node(*i); @@ -54,7 +54,7 @@ AddNode::mutate(Machine& machine) // Create random node SharedPtr<Node> node(new Node(machine.time().unit())); node->set_selector(true); - + SharedPtr<Node> note_node = machine.random_node(); if (!note_node) return; @@ -68,12 +68,12 @@ AddNode::mutate(Machine& machine) node->set_enter_action(ActionFactory::note_on(note)); node->set_exit_action(ActionFactory::note_off(note)); machine.add_node(node); - + // Insert after some node SharedPtr<Node> tail = machine.random_node(); if (tail && tail != node/* && !node->connected_to(tail)*/) tail->add_edge(boost::shared_ptr<Edge>(new Edge(tail, node))); - + // Insert before some other node SharedPtr<Node> head = machine.random_node(); if (head && head != node/* && !head->connected_to(node)*/) @@ -91,7 +91,7 @@ RemoveNode::mutate(Machine& machine) machine.remove_node(node); } - + void AdjustNode::mutate(Machine& machine) { @@ -110,12 +110,12 @@ AdjustNode::mutate(Machine& machine) } } - + void SwapNodes::mutate(Machine& machine) { //cout << "SWAP NODE" << endl; - + if (machine.nodes().size() <= 1) return; @@ -165,7 +165,7 @@ RemoveEdge::mutate(Machine& machine) tail->remove_edge(tail->random_edge()); } - + void AdjustEdge::mutate(Machine& machine) { diff --git a/src/engine/Node.cpp b/src/engine/Node.cpp index 9ca4157..2c3ddda 100644 --- a/src/engine/Node.cpp +++ b/src/engine/Node.cpp @@ -1,15 +1,15 @@ /* This file is part of Machina. * Copyright (C) 2007 Dave Robillard <http://drobilla.net> - * + * * Machina is free software; you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later * version. - * + * * Machina is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. - * + * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA @@ -65,7 +65,7 @@ Node::random_edge() SharedPtr<Edge> ret; if (_edges.empty()) return ret; - + size_t i = rand() % _edges.size(); // FIXME: O(n) worst case :( @@ -88,13 +88,13 @@ Node::edges_changed() // Normalize edge probabilities if we're a selector double prob_sum = 0; - + for (Edges::iterator i = _edges.begin(); i != _edges.end(); ++i) prob_sum += (*i)->probability(); for (Edges::iterator i = _edges.begin(); i != _edges.end(); ++i) (*i)->set_probability((*i)->probability() / prob_sum); - + _changed = true; } @@ -106,7 +106,7 @@ Node::set_selector(bool yn) if (yn) edges_changed(); - + _changed = true; } @@ -131,13 +131,13 @@ void Node::enter(SharedPtr<MIDISink> sink, TimeStamp time) { assert(!_is_active); - + _changed = true; _is_active = true; _enter_time = time; cerr << "ENTERING " << this << endl; - + if (sink && _enter_action) _enter_action->execute(sink, time); } @@ -147,12 +147,12 @@ void Node::exit(SharedPtr<MIDISink> sink, TimeStamp time) { assert(_is_active); - + cerr << "EXITING " << this << endl; - + if (sink && _exit_action) _exit_action->execute(sink, time); - + _changed = true; _is_active = false; _enter_time = 0; @@ -166,7 +166,7 @@ Node::add_edge(SharedPtr<Edge> edge) for (Edges::const_iterator i = _edges.begin(); i != _edges.end(); ++i) if ((*i)->head() == edge->head()) return; - + _edges.push_back(edge); edges_changed(); } @@ -179,7 +179,7 @@ Node::remove_edge(SharedPtr<Edge> edge) edges_changed(); } - + bool Node::connected_to(SharedPtr<Node> node) { @@ -203,7 +203,7 @@ Node::remove_edges_to(SharedPtr<Node> node) i = next; } - + edges_changed(); } @@ -212,7 +212,7 @@ void Node::write_state(Redland::Model& model) { using namespace Raul; - + if (!_id) set_id(model.world().blank_id()); @@ -231,7 +231,7 @@ Node::write_state(Redland::Model& model) if (_enter_action) { _enter_action->write_state(model); - + model.add_statement(_id, "machina:enterAction", _enter_action->id()); diff --git a/src/engine/Problem.cpp b/src/engine/Problem.cpp index 6de61a3..8ecc16d 100644 --- a/src/engine/Problem.cpp +++ b/src/engine/Problem.cpp @@ -1,15 +1,15 @@ /* This file is part of Machina. * Copyright (C) 2007 Dave Robillard <http://drobilla.net> - * + * * Machina is free software; you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later * version. - * + * * Machina is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. - * + * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA @@ -33,7 +33,7 @@ using namespace std; namespace Machina { - + Problem::Problem(TimeUnit unit, const std::string& target_midi, SharedPtr<Machine> seed) : _unit(unit) , _target(*this) @@ -42,9 +42,9 @@ Problem::Problem(TimeUnit unit, const std::string& target_midi, SharedPtr<Machin Raul::SMFReader smf; const bool opened = smf.open(target_midi); assert(opened); - + smf.seek_to_track(2); // FIXME: ? - + uint8_t buf[4]; uint32_t ev_size; uint32_t delta_time; @@ -80,7 +80,7 @@ Problem::fitness(const Machine& const_machine) const map<Machine*, float>::const_iterator cached = _fitness.find(&machine); if (cached != _fitness.end()) return cached->second; - + SharedPtr<Evaluator> eval(new Evaluator(*this)); //machine.reset(); @@ -89,15 +89,15 @@ Problem::fitness(const Machine& const_machine) const machine.set_sink(eval); // FIXME: timing stuff here isn't right at all... - + static const unsigned ppqn = MACHINA_PPQN; Raul::TimeSlice time(ppqn, ppqn, 120.0); time.set_slice(TimeStamp(_unit, 0, 0), TimeDuration(_unit, 2 * ppqn)); - + machine.run(time); if (eval->n_notes() == 0) return 0.0f; // bad dog - + TimeStamp end(_unit, time.start_ticks().ticks() + 2 * ppqn); time.set_slice(end, TimeStamp(_unit, 0, 0)); @@ -109,7 +109,7 @@ Problem::fitness(const Machine& const_machine) const } eval->compute(); - + // count #if 0 float f = 0; @@ -123,12 +123,12 @@ Problem::fitness(const Machine& const_machine) const } #endif //cout << ")"; - + // distance //float f = distance(eval->_notes, _target._notes); - + float f = 0.0; - + for (Evaluator::Patterns::const_iterator i = eval->_patterns.begin(); i != eval->_patterns.end(); ++i) { // Reward for matching patterns if (_target._patterns.find(i->first) != _target._patterns.end()) { @@ -142,7 +142,7 @@ Problem::fitness(const Machine& const_machine) const f -= (i->second / (float)eval->_patterns.size() * (float)(invlen*invlen*invlen)) * 4; } } - + // Punish for missing patterns for (Evaluator::Patterns::const_iterator i = _target._patterns.begin(); i != _target._patterns.end(); ++i) { if (eval->_patterns.find(i->first) == _target._patterns.end()) { @@ -156,7 +156,7 @@ Problem::fitness(const Machine& const_machine) const return f; } - + void Problem::Evaluator::write_event(Raul::TimeStamp time, @@ -166,10 +166,10 @@ Problem::Evaluator::write_event(Raul::TimeStamp time, if ((ev[0] & 0xF0) == MIDI_CMD_NOTE_ON) { const uint8_t note = ev[1]; - + if (_first_note == 0) _first_note = note; - + /*++_note_frequency[note]; ++n_notes();*/ //_notes.push_back(note); @@ -193,7 +193,7 @@ Problem::Evaluator::write_event(Raul::TimeStamp time, ++_counts[note]; ++_n_notes; - + } } @@ -209,7 +209,7 @@ Problem::Evaluator::compute() } }*/ } - + boost::shared_ptr<Problem::Population> Problem::initial_population(size_t gene_size, size_t pop_size) const @@ -262,7 +262,7 @@ Problem::initial_population(size_t gene_size, size_t pop_size) const cur = head; } } - + ret->push_back(m); /*cout << "initial # nodes: " << m.nodes().size(); @@ -279,10 +279,10 @@ Problem::distance(const std::vector<uint8_t>& source, const std::vector<uint8_t>& target) const { // Derived from http://www.merriampark.com/ldcpp.htm - + assert(source.size() < UINT16_MAX); assert(target.size() < UINT16_MAX); - + // Step 1 const uint16_t n = source.size(); diff --git a/src/engine/RaulJackDriver.cpp b/src/engine/RaulJackDriver.cpp index 6c60085..b37a1d4 100644 --- a/src/engine/RaulJackDriver.cpp +++ b/src/engine/RaulJackDriver.cpp @@ -1,15 +1,15 @@ /* This file is part of Raul. * Copyright (C) 2007 Dave Robillard <http://drobilla.net> - * + * * Raul is free software; you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later * version. - * + * * Raul is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. - * + * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA @@ -41,7 +41,7 @@ JackDriver::JackDriver() } -JackDriver::~JackDriver() +JackDriver::~JackDriver() { detach(); } @@ -50,12 +50,12 @@ JackDriver::~JackDriver() /** Connect to Jack. */ void -JackDriver::attach(const string& client_name, string server_name) +JackDriver::attach(const string& client_name, string server_name) { // Already connected if (_client) return; - + jack_set_error_function(error_cb); if (server_name.length() > 0) @@ -75,7 +75,7 @@ JackDriver::attach(const string& client_name, string server_name) jack_set_buffer_size_callback(_client, jack_buffer_size_cb, this); jack_set_xrun_callback(_client, jack_xrun_cb, this); jack_set_process_callback(_client, jack_process_cb, this); - + //_is_dirty = true; _buffer_size = jack_get_buffer_size(_client); } @@ -83,7 +83,7 @@ JackDriver::attach(const string& client_name, string server_name) void -JackDriver::detach() +JackDriver::detach() { if (_client) { deactivate(); @@ -120,17 +120,17 @@ JackDriver::deactivate() void -JackDriver::jack_port_registration_cb(jack_port_id_t /*port_id*/, int /*registered*/, void* /*jack_driver*/) +JackDriver::jack_port_registration_cb(jack_port_id_t /*port_id*/, int /*registered*/, void* /*jack_driver*/) { /* whatever. */ } int -JackDriver::jack_graph_order_cb(void* jack_driver) +JackDriver::jack_graph_order_cb(void* jack_driver) { JackDriver* me = reinterpret_cast<JackDriver*>(jack_driver); - + assert(me); me->on_graph_order_changed(); @@ -142,7 +142,7 @@ int JackDriver::jack_xrun_cb(void* jack_driver) { JackDriver* me = reinterpret_cast<JackDriver*>(jack_driver); - + assert(me); me->_xruns++; @@ -150,16 +150,16 @@ JackDriver::jack_xrun_cb(void* jack_driver) me->reset_delay(); me->on_xrun(); - + return 0; } int -JackDriver::jack_buffer_size_cb(jack_nframes_t buffer_size, void* jack_driver) +JackDriver::jack_buffer_size_cb(jack_nframes_t buffer_size, void* jack_driver) { JackDriver* me = reinterpret_cast<JackDriver*>(jack_driver); - + assert(me); me->reset_xruns(); me->reset_delay(); @@ -169,16 +169,16 @@ JackDriver::jack_buffer_size_cb(jack_nframes_t buffer_size, void* jack_driver) return 0; } - + int JackDriver::jack_process_cb(jack_nframes_t nframes, void* jack_driver) { JackDriver* me = reinterpret_cast<JackDriver*>(jack_driver); - + assert(me); me->on_process(nframes); - + return 0; } @@ -234,7 +234,7 @@ JackDriver::set_buffer_size(jack_nframes_t size) _buffer_size = size; return true; } - + if (jack_set_buffer_size(_client, size)) { //_app->status_message("[JACK] ERROR: Unable to set buffer size"); return false; diff --git a/src/engine/RaulJackDriver.hpp b/src/engine/RaulJackDriver.hpp index f1b92f1..6ab0116 100644 --- a/src/engine/RaulJackDriver.hpp +++ b/src/engine/RaulJackDriver.hpp @@ -1,15 +1,15 @@ /* This file is part of Raul. * Copyright (C) 2007 Dave Robillard <http://drobilla.net> - * + * * Raul is free software; you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later * version. - * + * * Raul is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. - * + * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA @@ -36,7 +36,7 @@ class JackDriver public: JackDriver(); virtual ~JackDriver(); - + void attach(const std::string& client_name, std::string server_name=""); void detach(); @@ -46,17 +46,17 @@ public: bool is_activated() const { return _is_activated; } bool is_attached() const { return (_client != NULL); } bool is_realtime() const { return _client && jack_is_realtime(_client); } - + void start_transport() { jack_transport_start(_client); } void stop_transport() { jack_transport_stop(_client); } - + void rewind_transport() { jack_position_t zero; zero.frame = 0; zero.valid = (jack_position_bits_t)0; jack_transport_reposition(_client, &zero); } - + jack_nframes_t buffer_size(); bool set_buffer_size(jack_nframes_t size); diff --git a/src/engine/Recorder.cpp b/src/engine/Recorder.cpp index 03ea7d0..2ae8b85 100644 --- a/src/engine/Recorder.cpp +++ b/src/engine/Recorder.cpp @@ -1,15 +1,15 @@ /* This file is part of Machina. * Copyright (C) 2007 Dave Robillard <http://drobilla.net> - * + * * Machina is free software; you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later * version. - * + * * Machina is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. - * + * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA @@ -45,7 +45,7 @@ Recorder::_whipped() _builder->set_time(t); _builder->event(TimeStamp(_unit), size, buf); } -} +} SharedPtr<Machine> diff --git a/src/engine/SMFDriver.cpp b/src/engine/SMFDriver.cpp index f482652..3cab320 100644 --- a/src/engine/SMFDriver.cpp +++ b/src/engine/SMFDriver.cpp @@ -1,15 +1,15 @@ /* This file is part of Machina. * Copyright (C) 2007 Dave Robillard <http://drobilla.net> - * + * * Machina is free software; you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later * version. - * + * * Machina is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. - * + * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA @@ -52,7 +52,7 @@ SMFDriver::learn(const string& filename, unsigned track, double q, Raul::TimeDur SharedPtr<Machine> m(new Machine(max_duration.unit())); SharedPtr<MachineBuilder> builder = SharedPtr<MachineBuilder>(new MachineBuilder(m, q)); Raul::SMFReader reader; - + if (!reader.open(filename)) { cerr << "Unable to open MIDI file " << filename << endl; return SharedPtr<Machine>(); @@ -82,7 +82,7 @@ SMFDriver::learn(const string& filename, double q, Raul::TimeStamp max_duration) SharedPtr<Machine> m(new Machine(max_duration.unit())); SharedPtr<MachineBuilder> builder = SharedPtr<MachineBuilder>(new MachineBuilder(m, q)); Raul::SMFReader reader; - + if (!reader.open(filename)) { cerr << "Unable to open MIDI file " << filename << endl; return SharedPtr<Machine>(); @@ -112,11 +112,11 @@ SMFDriver::learn_track(SharedPtr<MachineBuilder> builder, const bool found_track = reader.seek_to_track(track); if (!found_track) return; - + uint8_t buf[4]; uint32_t ev_size; uint32_t ev_delta_time; - + uint64_t t = 0; double unquantized_t = 0; diff --git a/src/engine/machina/Action.hpp b/src/engine/machina/Action.hpp index 09c3878..f7a702f 100644 --- a/src/engine/machina/Action.hpp +++ b/src/engine/machina/Action.hpp @@ -1,15 +1,15 @@ /* This file is part of Machina. * Copyright (C) 2007 Dave Robillard <http://drobilla.net> - * + * * Machina is free software; you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later * version. - * + * * Machina is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. - * + * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA diff --git a/src/engine/machina/ActionFactory.hpp b/src/engine/machina/ActionFactory.hpp index 0cf4154..1e613bb 100644 --- a/src/engine/machina/ActionFactory.hpp +++ b/src/engine/machina/ActionFactory.hpp @@ -1,15 +1,15 @@ /* This file is part of Machina. * Copyright (C) 2007 Dave Robillard <http://drobilla.net> - * + * * Machina is free software; you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later * version. - * + * * Machina is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. - * + * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA diff --git a/src/engine/machina/Driver.hpp b/src/engine/machina/Driver.hpp index f412574..f1f0587 100644 --- a/src/engine/machina/Driver.hpp +++ b/src/engine/machina/Driver.hpp @@ -1,15 +1,15 @@ /* This file is part of Machina. * Copyright (C) 2007 Dave Robillard <http://drobilla.net> - * + * * Machina is free software; you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later * version. - * + * * Machina is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. - * + * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA @@ -32,10 +32,10 @@ public: SharedPtr<Machine> machine() { return _machine; } virtual void set_machine(SharedPtr<Machine> machine) { _machine = machine; } - + virtual void set_bpm(double bpm) = 0; virtual void set_quantization(double q) = 0; - + virtual void activate() {} virtual void deactivate() {} diff --git a/src/engine/machina/Edge.hpp b/src/engine/machina/Edge.hpp index 5851090..41f5d00 100644 --- a/src/engine/machina/Edge.hpp +++ b/src/engine/machina/Edge.hpp @@ -1,15 +1,15 @@ /* This file is part of Machina. * Copyright (C) 2007 Dave Robillard <http://drobilla.net> - * + * * Machina is free software; you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later * version. - * + * * Machina is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. - * + * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA @@ -53,7 +53,7 @@ public: private: Raul::DoubleBuffer<float> _probability; - + WeakPtr<Node> _tail; SharedPtr<Node> _head; }; diff --git a/src/engine/machina/Engine.hpp b/src/engine/machina/Engine.hpp index 92384a8..b77f637 100644 --- a/src/engine/machina/Engine.hpp +++ b/src/engine/machina/Engine.hpp @@ -1,15 +1,15 @@ /* This file is part of Machina. * Copyright (C) 2007 Dave Robillard <http://drobilla.net> - * + * * Machina is free software; you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later * version. - * + * * Machina is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. - * + * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA @@ -36,7 +36,7 @@ public: , _loader(_rdf_world) { } - + Redland::World& rdf_world() { return _rdf_world; } SharedPtr<Driver> driver() { return _driver; } diff --git a/src/engine/machina/Evolver.hpp b/src/engine/machina/Evolver.hpp index 1b847db..d5006f6 100644 --- a/src/engine/machina/Evolver.hpp +++ b/src/engine/machina/Evolver.hpp @@ -1,15 +1,15 @@ /* This file is part of Machina. * Copyright (C) 2007 Dave Robillard <http://drobilla.net> - * + * * Machina is free software; you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later * version. - * + * * Machina is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. - * + * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA @@ -35,14 +35,14 @@ class Problem; class Evolver : public Raul::Thread { public: Evolver(Raul::TimeUnit unit, const string& target_midi, SharedPtr<Machine> seed); - + void seed(SharedPtr<Machine> parent); bool improvement() { return _improvement; } SharedPtr<const Machine> best() { return _ga->best(); } - + typedef Eugene::GAImpl<Machine> MachinaGA; - + private: void _run(); diff --git a/src/engine/machina/JackDriver.hpp b/src/engine/machina/JackDriver.hpp index 5982f87..2a5a695 100644 --- a/src/engine/machina/JackDriver.hpp +++ b/src/engine/machina/JackDriver.hpp @@ -1,15 +1,15 @@ /* This file is part of Machina. * Copyright (C) 2007 Dave Robillard <http://drobilla.net> - * + * * Machina is free software; you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later * version. - * + * * Machina is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. - * + * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA @@ -50,16 +50,16 @@ public: void attach(const std::string& client_name); void detach(); - + void activate() { Raul::JackDriver::activate(); } void deactivate() { Raul::JackDriver::deactivate(); } void set_machine(SharedPtr<Machine> machine); - + void write_event(Raul::TimeStamp time, size_t size, const unsigned char* event) throw (std::logic_error); - + void set_bpm(double bpm) { _bpm.set(bpm); } void set_quantization(double q) { _quantization.set(q); } @@ -80,7 +80,7 @@ private: jack_port_t* _input_port; jack_port_t* _output_port; - + Raul::TimeUnit _frames_unit; Raul::TimeUnit _beats_unit; Raul::TimeSlice _cycle_time; diff --git a/src/engine/machina/LearnRequest.hpp b/src/engine/machina/LearnRequest.hpp index edc76c9..d106395 100644 --- a/src/engine/machina/LearnRequest.hpp +++ b/src/engine/machina/LearnRequest.hpp @@ -1,15 +1,15 @@ /* This file is part of Machina. * Copyright (C) 2007 Dave Robillard <http://drobilla.net> - * + * * Machina is free software; you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later * version. - * + * * Machina is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. - * + * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA @@ -45,9 +45,9 @@ public: void start(double q, Raul::TimeStamp time) { _started = true; _start_time = time; _quantization = q; } - + void finish(TimeStamp time); - + bool started() { return _started; } const SharedPtr<Node>& node() { return _node; } diff --git a/src/engine/machina/Loader.hpp b/src/engine/machina/Loader.hpp index 2c9fa1c..4a6ba38 100644 --- a/src/engine/machina/Loader.hpp +++ b/src/engine/machina/Loader.hpp @@ -1,15 +1,15 @@ /* This file is part of Machina. * Copyright (C) 2007 Dave Robillard <http://drobilla.net> - * + * * Machina is free software; you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later * version. - * + * * Machina is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. - * + * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA diff --git a/src/engine/machina/Machine.hpp b/src/engine/machina/Machine.hpp index 468b9bc..3fd7073 100644 --- a/src/engine/machina/Machine.hpp +++ b/src/engine/machina/Machine.hpp @@ -1,15 +1,15 @@ /* This file is part of Machina. * Copyright (C) 2007 Dave Robillard <http://drobilla.net> - * + * * Machina is free software; you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later * version. - * + * * Machina is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. - * + * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA @@ -24,7 +24,7 @@ #include "raul/WeakPtr.hpp" #include "raul/List.hpp" #include "raul/TimeSlice.hpp" -#include "redlandmm/Model.hpp" +#include "redlandmm/Model.hpp" #include "types.hpp" #include "LearnRequest.hpp" #include "Node.hpp" @@ -43,11 +43,11 @@ public: // Kluge to appease Eugene bool operator==(const Machine& other) { return false; } - + // Main context void activate() { _is_activated = true; } void deactivate() { _is_activated = false; } - + bool is_empty() { return _nodes.empty(); } bool is_finished() { return _is_finished; } bool is_activated() { return _is_activated; } @@ -61,7 +61,7 @@ public: // Audio context void reset(Raul::TimeStamp time); TimeDuration run(const Raul::TimeSlice& time); - + // Any context inline Raul::TimeStamp time() const { return _time; } @@ -76,9 +76,9 @@ public: SharedPtr<Edge> random_edge(); void set_sink(SharedPtr<Raul::MIDISink> sink); - + private: - + // Audio context SharedPtr<Node> earliest_node() const; bool enter_node(SharedPtr<Raul::MIDISink> sink, SharedPtr<Node> node); diff --git a/src/engine/machina/MachineBuilder.hpp b/src/engine/machina/MachineBuilder.hpp index 2c9d0a2..4353797 100644 --- a/src/engine/machina/MachineBuilder.hpp +++ b/src/engine/machina/MachineBuilder.hpp @@ -1,15 +1,15 @@ /* This file is part of Machina. * Copyright (C) 2007 Dave Robillard <http://drobilla.net> - * + * * Machina is free software; you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later * version. - * + * * Machina is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. - * + * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA @@ -35,7 +35,7 @@ public: void set_time(Raul::TimeStamp time) { _time = time; } void event(Raul::TimeStamp time_offset, size_t size, unsigned char* buf); - + void reset(); void resolve(); @@ -49,10 +49,10 @@ private: connect_nodes(SharedPtr<Machine> m, SharedPtr<Node> tail, Raul::TimeStamp tail_end_time, SharedPtr<Node> head, Raul::TimeStamp head_start_time); - + typedef std::list<SharedPtr<Node> > ActiveList; ActiveList _active_nodes; - + typedef std::list<std::pair<Raul::TimeStamp, SharedPtr<Node> > > PolyList; PolyList _poly_nodes; diff --git a/src/engine/machina/MidiAction.hpp b/src/engine/machina/MidiAction.hpp index 5ae507e..96087d6 100644 --- a/src/engine/machina/MidiAction.hpp +++ b/src/engine/machina/MidiAction.hpp @@ -1,15 +1,15 @@ /* This file is part of Machina. * Copyright (C) 2007 Dave Robillard <http://drobilla.net> - * + * * Machina is free software; you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later * version. - * + * * Machina is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. - * + * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA @@ -31,7 +31,7 @@ namespace Machina { class MidiAction : public Action { public: ~MidiAction(); - + MidiAction(size_t size, const unsigned char* event); @@ -41,7 +41,7 @@ public: bool set_event(size_t size, const byte* event); void execute(SharedPtr<Raul::MIDISink> driver, Raul::TimeStamp time); - + virtual void write_state(Redland::Model& model); private: diff --git a/src/engine/machina/Mutation.hpp b/src/engine/machina/Mutation.hpp index de31fc3..7c407c6 100644 --- a/src/engine/machina/Mutation.hpp +++ b/src/engine/machina/Mutation.hpp @@ -1,15 +1,15 @@ /* This file is part of Machina. * Copyright (C) 2007 Dave Robillard <http://drobilla.net> - * + * * Machina is free software; you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later * version. - * + * * Machina is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. - * + * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA diff --git a/src/engine/machina/Node.hpp b/src/engine/machina/Node.hpp index 4258476..535a49d 100644 --- a/src/engine/machina/Node.hpp +++ b/src/engine/machina/Node.hpp @@ -1,15 +1,15 @@ /* This file is part of Machina. * Copyright (C) 2007 Dave Robillard <http://drobilla.net> - * + * * Machina is free software; you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later * version. - * + * * Machina is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. - * + * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA @@ -78,12 +78,12 @@ public: inline bool changed() { return _changed; } inline void set_changed() { _changed = true; } - + typedef Raul::List<SharedPtr<Edge> > Edges; Edges& edges() { return _edges; } - + SharedPtr<Edge> random_edge(); - + private: Node& operator=(const Node& other); // undefined diff --git a/src/engine/machina/Problem.hpp b/src/engine/machina/Problem.hpp index c0c1662..58393e1 100644 --- a/src/engine/machina/Problem.hpp +++ b/src/engine/machina/Problem.hpp @@ -1,15 +1,15 @@ /* This file is part of Machina. * Copyright (C) 2007 Dave Robillard <http://drobilla.net> - * + * * Machina is free software; you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later * version. - * + * * Machina is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. - * + * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA @@ -33,11 +33,11 @@ public: void seed(SharedPtr<Machine> parent) { _seed = parent; } float fitness(const Machine& machine) const; - + bool fitness_less_than(float a, float b) const { return a < b; } void clear_fitness_cache() { _fitness.clear(); } - + boost::shared_ptr<Population> initial_population(size_t gene_size, size_t pop_size) const; @@ -57,9 +57,9 @@ private: const uint8_t* ev) throw (std::logic_error); void compute(); const Problem& _problem; - + size_t n_notes() const { return _n_notes; } - + float _note_frequency[128]; size_t _n_notes; double _length; @@ -75,11 +75,11 @@ private: const Problem& _problem; size_t n_notes() const { return _notes.size(); } - + std::vector<uint8_t> _notes; float _counts[128]; };*/ - + struct Evaluator : public Raul::MIDISink { Evaluator(const Problem& problem) : _problem(problem), _order(4), _n_notes(0), _first_note(0) { for (uint8_t i=0; i < 128; ++i) @@ -93,7 +93,7 @@ private: size_t n_notes() const { return _n_notes; } uint8_t first_note() const { return _first_note; } - + const uint32_t _order; std::string _read; @@ -109,7 +109,7 @@ private: Evaluator _target; SharedPtr<Machine> _seed; - + /// for levenshtein distance mutable std::vector< std::vector<uint16_t> > _matrix; diff --git a/src/engine/machina/Recorder.hpp b/src/engine/machina/Recorder.hpp index 6a91ba6..16c3b73 100644 --- a/src/engine/machina/Recorder.hpp +++ b/src/engine/machina/Recorder.hpp @@ -1,15 +1,15 @@ /* This file is part of Machina. * Copyright (C) 2007 Dave Robillard <http://drobilla.net> - * + * * Machina is free software; you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later * version. - * + * * Machina is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. - * + * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA @@ -40,7 +40,7 @@ public: private: virtual void _whipped(); - + TimeUnit _unit; Raul::EventRingBuffer _record_buffer; SharedPtr<MachineBuilder> _builder; diff --git a/src/engine/machina/SMFDriver.hpp b/src/engine/machina/SMFDriver.hpp index 5e1e9f8..bc814d8 100644 --- a/src/engine/machina/SMFDriver.hpp +++ b/src/engine/machina/SMFDriver.hpp @@ -1,15 +1,15 @@ /* This file is part of Machina. * Copyright (C) 2007 Dave Robillard <http://drobilla.net> - * + * * Machina is free software; you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later * version. - * + * * Machina is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. - * + * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA @@ -48,12 +48,12 @@ public: Raul::TimeDuration max_duration); void run(SharedPtr<Machine> machine, Raul::TimeStamp max_time); - + void write_event(Raul::TimeStamp time, size_t ev_size, const unsigned char* ev) throw (std::logic_error) { _writer->write_event(time, ev_size, ev); } - + void set_bpm(double /*bpm*/) { } void set_quantization(double /*quantization*/) { } @@ -61,7 +61,7 @@ public: private: SharedPtr<Raul::SMFWriter> _writer; - + void learn_track(SharedPtr<MachineBuilder> builder, Raul::SMFReader& reader, unsigned track, diff --git a/src/engine/machina/Schrodinbit.hpp b/src/engine/machina/Schrodinbit.hpp index 6065cfc..c156f09 100644 --- a/src/engine/machina/Schrodinbit.hpp +++ b/src/engine/machina/Schrodinbit.hpp @@ -1,15 +1,15 @@ /* This file is part of Machina. * Copyright (C) 2007 Dave Robillard <http://drobilla.net> - * + * * Machina is free software; you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later * version. - * + * * Machina is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. - * + * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA diff --git a/src/engine/machina/types.hpp b/src/engine/machina/types.hpp index d74fce9..de7d73f 100644 --- a/src/engine/machina/types.hpp +++ b/src/engine/machina/types.hpp @@ -1,15 +1,15 @@ /* This file is part of Machina. * Copyright (C) 2007 Dave Robillard <http://drobilla.net> - * + * * Machina is free software; you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later * version. - * + * * Machina is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. - * + * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA |