diff options
author | David Robillard <d@drobilla.net> | 2007-04-05 17:06:53 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2007-04-05 17:06:53 +0000 |
commit | 4541e87aa843dd97c542f7c66fcbc0a16ffbcee5 (patch) | |
tree | b78b2bc374e62401df6e6e5d3d250d1845053ec4 /src/engine | |
parent | 0123cdeacc9acc7ca16fa8b0a9dee7a5d916b7df (diff) | |
download | machina-4541e87aa843dd97c542f7c66fcbc0a16ffbcee5.tar.gz machina-4541e87aa843dd97c542f7c66fcbc0a16ffbcee5.tar.bz2 machina-4541e87aa843dd97c542f7c66fcbc0a16ffbcee5.zip |
Code cleanups.
git-svn-id: http://svn.drobilla.net/lad/machina@399 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/engine')
-rw-r--r-- | src/engine/ActionFactory.cpp | 2 | ||||
-rw-r--r-- | src/engine/Engine.cpp | 19 | ||||
-rw-r--r-- | src/engine/JackDriver.cpp | 30 | ||||
-rw-r--r-- | src/engine/LearnRequest.cpp | 3 | ||||
-rw-r--r-- | src/engine/Loader.cpp | 15 | ||||
-rw-r--r-- | src/engine/Machine.cpp | 23 | ||||
-rw-r--r-- | src/engine/MachineBuilder.cpp | 73 | ||||
-rw-r--r-- | src/engine/MidiAction.cpp | 2 | ||||
-rw-r--r-- | src/engine/Node.cpp | 8 | ||||
-rw-r--r-- | src/engine/Recorder.cpp | 8 | ||||
-rw-r--r-- | src/engine/SMFDriver.cpp | 2 | ||||
-rw-r--r-- | src/engine/machina/ActionFactory.hpp | 2 | ||||
-rw-r--r-- | src/engine/machina/Driver.hpp | 3 | ||||
-rw-r--r-- | src/engine/machina/Engine.hpp | 3 | ||||
-rw-r--r-- | src/engine/machina/JackDriver.hpp | 7 | ||||
-rw-r--r-- | src/engine/machina/LearnRequest.hpp | 8 | ||||
-rw-r--r-- | src/engine/machina/Loader.hpp | 2 | ||||
-rw-r--r-- | src/engine/machina/Machine.hpp | 6 | ||||
-rw-r--r-- | src/engine/machina/MachineBuilder.hpp | 2 | ||||
-rw-r--r-- | src/engine/machina/MidiAction.hpp | 2 | ||||
-rw-r--r-- | src/engine/machina/Recorder.hpp | 2 | ||||
-rw-r--r-- | src/engine/machina/SMFDriver.hpp | 2 | ||||
-rw-r--r-- | src/engine/machina/types.hpp | 6 |
23 files changed, 48 insertions, 182 deletions
diff --git a/src/engine/ActionFactory.cpp b/src/engine/ActionFactory.cpp index 4b63e92..2e87cbc 100644 --- a/src/engine/ActionFactory.cpp +++ b/src/engine/ActionFactory.cpp @@ -12,7 +12,7 @@ * * 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 + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "machina/ActionFactory.hpp" diff --git a/src/engine/Engine.cpp b/src/engine/Engine.cpp index 69402a3..5af50b9 100644 --- a/src/engine/Engine.cpp +++ b/src/engine/Engine.cpp @@ -36,7 +36,6 @@ Engine::load_machine(const Glib::ustring& uri) if (m) { m->activate(); _driver->set_machine(m); - //_driver->machine()->nodes().append(m->nodes()); } // .. and drop it in this thread (to prevent deallocation in the RT thread) @@ -51,38 +50,32 @@ Engine::load_machine(const Glib::ustring& uri) SharedPtr<Machine> Engine::import_machine(const Glib::ustring& uri) { - SharedPtr<Machine> old_machine = _driver->machine(); // Hold a reference to current machine.. - SharedPtr<Machine> m = Loader().load(uri); if (m) { m->activate(); _driver->machine()->nodes().append(m->nodes()); } - // .. and drop it in this thread (to prevent deallocation in the RT thread) + // Discard m return _driver->machine(); } -/** Learn the SMF (MIDI) file at @a uri, and run the resulting machine - * (replacing current machine). +/** Learn the SMF (MIDI) file at @a uri, add it to the current machine. * Safe to call while engine is processing. */ SharedPtr<Machine> -Engine::learn_midi(const Glib::ustring& uri) +Engine::import_midi(const Glib::ustring& uri, Raul::BeatTime duration) { - SharedPtr<Machine> old_machine = _driver->machine(); // Hold a reference to current machine.. - SharedPtr<SMFDriver> file_driver(new SMFDriver()); - SharedPtr<Machine> m = file_driver->learn(uri, 32.0); // FIXME: hardcoded + SharedPtr<Machine> m = file_driver->learn(uri, duration); m->activate(); - //_driver->set_machine(m); _driver->machine()->nodes().append(m->nodes()); - // .. and drop it in this thread (to prevent deallocation in the RT thread) + // Discard m - return m; + return _driver->machine(); } diff --git a/src/engine/JackDriver.cpp b/src/engine/JackDriver.cpp index 25ff496..d2c131d 100644 --- a/src/engine/JackDriver.cpp +++ b/src/engine/JackDriver.cpp @@ -12,7 +12,7 @@ * * 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 + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include <iostream> @@ -118,6 +118,7 @@ JackDriver::process_input(SharedPtr<Machine> machine, const TimeSlice& time) using namespace std; if (_recording.get()) { + const jack_nframes_t nframes = time.length_ticks(); void* jack_buffer = jack_port_get_buffer(_input_port, nframes); const jack_nframes_t event_count = jack_midi_get_event_count(jack_buffer, nframes); @@ -133,6 +134,7 @@ JackDriver::process_input(SharedPtr<Machine> machine, const TimeSlice& time) _recorder->whip(); } else { + const jack_nframes_t nframes = time.length_ticks(); void* jack_buffer = jack_port_get_buffer(_input_port, nframes); const jack_nframes_t event_count = jack_midi_get_event_count(jack_buffer, nframes); @@ -146,10 +148,8 @@ JackDriver::process_input(SharedPtr<Machine> machine, const TimeSlice& time) const SharedPtr<LearnRequest> learn = machine->pending_learn(); if (learn) { learn->enter_action()->set_event(ev.size, ev.buffer); - cerr << "LEARN START\n"; learn->start(_quantization.get(), time.ticks_to_beats(jack_last_frame_time(_client) + ev.time)); - //LearnRecord learn = machine->pop_learn(); } } else if (ev.buffer[0] == 0x80) { @@ -162,14 +162,11 @@ JackDriver::process_input(SharedPtr<Machine> machine, const TimeSlice& time) learn->finish( time.ticks_to_beats(jack_last_frame_time(_client) + ev.time)); machine->clear_pending_learn(); - cerr << "LEARNED!\n"; } } } - - //std::cerr << "EVENT: " << std::hex << (int)ev.buffer[0] << "\n"; - } + } } @@ -179,9 +176,13 @@ JackDriver::write_event(Raul::BeatTime time, size_t size, const byte* event) throw (std::logic_error) { + if (!_output_port) + return; + if (_cycle_time.beats_to_ticks(time) + _cycle_time.offset_ticks() < _cycle_time.start_ticks()) { std::cerr << "ERROR: Missed event by " - << _cycle_time.start_ticks() - (_cycle_time.beats_to_ticks(time) + _cycle_time.offset_ticks()) + << _cycle_time.start_ticks() + - (_cycle_time.beats_to_ticks(time) + _cycle_time.offset_ticks()) << " ticks" << "\n\tbpm: " << _cycle_time.bpm() << "\n\tev time: " << _cycle_time.beats_to_ticks(time) @@ -195,8 +196,6 @@ JackDriver::write_event(Raul::BeatTime time, const TickCount offset = _cycle_time.beats_to_ticks(time) + _cycle_time.offset_ticks() - _cycle_time.start_ticks(); - assert(_output_port); - if ( ! (offset < _cycle_time.offset_ticks() + nframes)) { std::cerr << "ERROR: Event offset " << offset << " outside cycle " << "\n\tbpm: " << _cycle_time.bpm() @@ -297,7 +296,8 @@ JackDriver::on_process(jack_nframes_t nframes) void JackDriver::reset() { - // FIXME: Flag audio thread and end active notes, etc + /* FIXME: This should signal the audio thread and wait for it + * to exit all active states to resolve stuck notes, then reset. */ _machine->deactivate(); _machine->reset(); _cycle_time.set_start(0); @@ -307,9 +307,9 @@ JackDriver::reset() void JackDriver::start_record() { - std::cerr << "START RECORD" << std::endl; - // FIXME: hardcoded size - _recorder = SharedPtr<Recorder>(new Recorder(1024, (1.0/(double)sample_rate()) * (_bpm.get() / 60.0), _quantization.get())); + // 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->start(); _record_time = 0; _recording = 1; @@ -321,10 +321,8 @@ JackDriver::finish_record() { _recording = 0; SharedPtr<Machine> machine = _recorder->finish(); - std::cout << "Learned machine! " << machine->nodes().size() << " nodes." << std::endl; _recorder.reset(); machine->activate(); - //set_machine(machine); _machine->nodes().append(machine->nodes()); } diff --git a/src/engine/LearnRequest.cpp b/src/engine/LearnRequest.cpp index 019f7a2..70420e2 100644 --- a/src/engine/LearnRequest.cpp +++ b/src/engine/LearnRequest.cpp @@ -31,9 +31,6 @@ LearnRequest::finish(BeatTime time) double duration = Raul::Quantizer::quantize(_quantization, time - _start_time); _node->set_duration(duration); - using namespace std; - cerr << "Q=" << _quantization << ", T=" << time << ", ST=" << _start_time << endl; - std::cerr << "LEARN DURATION: " << duration << std::endl; } diff --git a/src/engine/Loader.cpp b/src/engine/Loader.cpp index 57905ba..f9145c9 100644 --- a/src/engine/Loader.cpp +++ b/src/engine/Loader.cpp @@ -12,7 +12,7 @@ * * 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 + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include <iostream> @@ -77,8 +77,6 @@ Loader::load(const Glib::ustring& uri) const Glib::ustring machine_uri = "<>"; - cout << "USER URI: " << uri << endl; - cout << "[Loader] Loading " << machine_uri << " from " << document_uri << endl; machine = SharedPtr<Machine>(new Machine()); @@ -102,8 +100,6 @@ Loader::load(const Glib::ustring& uri) const Glib::ustring& node_id = (*i)["initialNode"]; const Glib::ustring& duration = (*i)["duration"]; - cout << "Initial: " << node_id << " - " << duration << endl; - SharedPtr<Node> node(new Node(strtod(duration.c_str(), NULL), true)); machine->add_node(node); created.insert(std::make_pair(node_id.collate_key(), node)); @@ -125,8 +121,6 @@ Loader::load(const Glib::ustring& uri) const Glib::ustring& node_id = (*i)["node"]; const Glib::ustring& duration = (*i)["duration"]; - //cout << "Node: " << node_id << " - " << duration << endl; - if (created.find(node_id.collate_key()) == created.end()) { SharedPtr<Node> node(new Node(strtod(duration.c_str(), NULL), false)); machine->add_node(node); @@ -137,11 +131,6 @@ Loader::load(const Glib::ustring& uri) } - /*for (Created::iterator n = created.begin(); n != created.end(); ++n) { - cout << "NODE: " << n->first << endl; - }*/ - - /* Get note actions */ query = Raul::RDFQuery(*_namespaces, Glib::ustring( @@ -157,8 +146,6 @@ Loader::load(const Glib::ustring& uri) const Glib::ustring& node_id = (*i)["node"]; const Glib::ustring& note = (*i)["note"]; - //cerr << "NOTE: " << node_id << " = " << note << endl; - Created::iterator node_i = created.find(node_id); if (node_i != created.end()) { SharedPtr<Node> node = node_i->second; diff --git a/src/engine/Machine.cpp b/src/engine/Machine.cpp index 38e6e11..5879243 100644 --- a/src/engine/Machine.cpp +++ b/src/engine/Machine.cpp @@ -55,7 +55,6 @@ Machine::set_sink(SharedPtr<Raul::MIDISink> sink) void Machine::add_node(SharedPtr<Node> node) { - //cerr << "ADDING NODE " << node.get() << endl; assert(_nodes.find(node) == _nodes.end()); _nodes.push_back(node); } @@ -113,13 +112,6 @@ Machine::earliest_node() const } } } - /*for (Nodes::const_iterator n = _nodes.begin(); n != _nodes.end(); ++n) { - const SharedPtr<Node> node = (*n); - - if (node->is_active()) - if (!earliest || node->exit_time() < earliest->exit_time()) - earliest = node; - }*/ return earliest; } @@ -294,13 +286,6 @@ Machine::run(const Raul::TimeSlice& time) void Machine::learn(SharedPtr<LearnRequest> learn) { - std::cerr << "Learn" << std::endl; - - /*LearnRequest request(node, - SharedPtr<MidiAction>(new MidiAction(4, NULL)), - SharedPtr<MidiAction>(new MidiAction(4, NULL)));*/ - - //_pending_learns.push_back(learn); _pending_learn = learn; } @@ -320,8 +305,6 @@ Machine::write_state(Raul::RDFWriter& writer) for (Nodes::const_iterator n = _nodes.begin(); n != _nodes.end(); ++n) { - //cerr << "Writing node " << count++ << " state." << endl; - (*n)->write_state(writer); if ((*n)->is_initial()) { @@ -339,13 +322,9 @@ Machine::write_state(Raul::RDFWriter& writer) for (Nodes::const_iterator n = _nodes.begin(); n != _nodes.end(); ++n) { - //cerr << "Writing node " << count++ << " edges: "; - for (Node::Edges::const_iterator e = (*n)->outgoing_edges().begin(); e != (*n)->outgoing_edges().end(); ++e) { - //cerr << "."; - (*e)->write_state(writer); writer.write(RdfId(RdfId::RESOURCE, ""), @@ -353,8 +332,6 @@ Machine::write_state(Raul::RDFWriter& writer) (*e)->id()); } - //cerr << endl; - } } diff --git a/src/engine/MachineBuilder.cpp b/src/engine/MachineBuilder.cpp index b62e90e..8be9148 100644 --- a/src/engine/MachineBuilder.cpp +++ b/src/engine/MachineBuilder.cpp @@ -12,7 +12,7 @@ * * 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 + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include <algorithm> @@ -91,22 +91,15 @@ MachineBuilder::connect_nodes(SharedPtr<Machine> m, SharedPtr<Node> delay_node; - /*cerr << "******" << endl; - cerr << "Connect nodes durations: " << tail->duration() << " .. " << head->duration() << endl; - cerr << "Connect nodes times: " << tail_end_time << " .. " << head_start_time << endl;*/ - if (is_delay_node(tail) && tail->outgoing_edges().size() == 0) { // Tail is a delay node, just accumulate the time difference into it - //cerr << "Accumulating delay " << tail_end_time << " .. " << head_start_time << endl; set_node_duration(tail, tail->duration() + head_start_time - tail_end_time); tail->add_outgoing_edge(SharedPtr<Edge>(new Edge(tail, head))); } else if (head_start_time == tail_end_time) { // Connect directly - //cerr << "Connnecting directly " << tail_end_time << " .. " << head_start_time << endl; tail->add_outgoing_edge(SharedPtr<Edge>(new Edge(tail, head))); } else { // Need to actually create a delay node - //cerr << "Adding delay node for " << tail_end_time << " .. " << head_start_time << endl; delay_node = SharedPtr<Node>(new Node()); set_node_duration(delay_node, head_start_time - tail_end_time); tail->add_outgoing_edge(SharedPtr<Edge>(new Edge(tail, delay_node))); @@ -114,8 +107,6 @@ MachineBuilder::connect_nodes(SharedPtr<Machine> m, m->add_node(delay_node); } - /*cerr << "******" << endl << endl;*/ - return delay_node; } @@ -130,10 +121,7 @@ MachineBuilder::event(Raul::BeatTime time_offset, if (ev_size == 0) return; - //cerr << "t = " << t << endl; - if ((buf[0] & 0xF0) == MIDI_CMD_NOTE_ON) { - //cerr << "NOTE ON: " << (int)buf[1] << ", channel = " << (int)(buf[0] & 0x0F) << endl; SharedPtr<Node> node(new Node()); node->set_enter_action(SharedPtr<Action>(new MidiAction(ev_size, buf))); @@ -148,7 +136,6 @@ MachineBuilder::event(Raul::BeatTime time_offset, if (j->second->outgoing_edges().empty()) { this_connect_node = j->second; this_connect_node_end_time = j->first + j->second->duration(); - cerr << "POLY CONNECT!\n"; break; } } @@ -157,7 +144,6 @@ MachineBuilder::event(Raul::BeatTime time_offset, // Currently monophonic, or didn't find a poly node, so use _connect_node // which is maintained below on note off events. if ( ! this_connect_node) { - cerr << "NO POLY CONNECT\n"; this_connect_node = _connect_node; this_connect_node_end_time = _connect_node_end_time; } @@ -166,9 +152,6 @@ MachineBuilder::event(Raul::BeatTime time_offset, SharedPtr<Node> delay_node = connect_nodes(_machine, this_connect_node, this_connect_node_end_time, node, t); - if (delay_node) - cerr << "XXXXXXXXXXXXXX NOTE ON DELAY NODE\n"; - if (delay_node) { _connect_node = delay_node; _connect_node_end_time = t; @@ -178,7 +161,7 @@ MachineBuilder::event(Raul::BeatTime time_offset, _active_nodes.push_back(node); } else if ((buf[0] & 0xF0) == MIDI_CMD_NOTE_OFF) { - //cerr << "NOTE OFF: " << (int)buf[1] << endl; + for (ActiveList::iterator i = _active_nodes.begin(); i != _active_nodes.end(); ++i) { SharedPtr<MidiAction> action = PtrCast<MidiAction>((*i)->enter_action()); if (!action) @@ -191,8 +174,6 @@ MachineBuilder::event(Raul::BeatTime time_offset, && (ev[0] & 0x0F) == (buf[0] & 0x0F) // same channel && ev[1] == buf[1]) // same note { - //cerr << "FOUND MATCHING NOTE OFF!\n"; - SharedPtr<Node> resolved = *i; resolved->set_exit_action(SharedPtr<Action>(new MidiAction(ev_size, buf))); @@ -201,15 +182,11 @@ MachineBuilder::event(Raul::BeatTime time_offset, // Last active note if (_active_nodes.size() == 1) { - cerr << "{ RESOLVING, t= " << t << "\n"; - _connect_node_end_time = t; // Finish a polyphonic section if (_poly_nodes.size() > 0) { - cerr << "POLY\n"; - _connect_node = SharedPtr<Node>(new Node()); _machine->add_node(_connect_node); @@ -228,14 +205,11 @@ MachineBuilder::event(Raul::BeatTime time_offset, // Just monophonic } else { - cerr << "NO POLY\n"; - // Trim useless delay node if possible (these appear after poly sections) if (is_delay_node(_connect_node) && _connect_node->duration() == 0 && _connect_node->outgoing_edges().size() == 1 && (*_connect_node->outgoing_edges().begin())->head() == resolved) { - cerr << "TRIMMING\n"; _connect_node->outgoing_edges().clear(); assert(_connect_node->outgoing_edges().empty()); _connect_node->set_enter_action(resolved->enter_action()); @@ -248,18 +222,13 @@ MachineBuilder::event(Raul::BeatTime time_offset, _machine->add_node(_connect_node); } else { - - cerr << "RESOLVED\n"; _connect_node = resolved; _machine->add_node(resolved); } } - cerr << "}"; - // Polyphonic, add this state to poly list } else { - cerr << "ADDING POLY\n"; _poly_nodes.push_back(make_pair(resolved->enter_time(), resolved)); _connect_node = resolved; _connect_node_end_time = t; @@ -273,6 +242,7 @@ MachineBuilder::event(Raul::BeatTime time_offset, break; } } + } } @@ -309,43 +279,6 @@ MachineBuilder::resolve() && _machine->nodes().find(_initial_node) == _machine->nodes().end()) _machine->add_node(_initial_node); -#if 0 - // Quantize - if (_quantization > 0) { - for (Machine::Nodes::iterator i = _machine->nodes().begin(); - i != _machine->nodes().end(); ++i) { - Raul::BeatTime q_dur = Quantizer::quantize(_quantization, (*i)->duration()); - - // Never quantize a note to duration 0 - if (q_dur > 0 || ( !(*i)->enter_action() && !(*i)->exit_action() )) - (*i)->set_duration(q_dur); - } - } - - // Remove any useless states - for (Machine::Nodes::iterator i = _machine->nodes().begin(); - i != _machine->nodes().end() ; ) { - - if (!(*i)->enter_action() && !(*i)->exit_action() && (*i)->duration() == 0 - && (*i)->outgoing_edges().size() <= 1) { - - // Connect any predecessors to the successor - if ((*i)->outgoing_edges().size() == 1) { - SharedPtr<Node> successor = *((*i)->outgoing_edges().begin())->head(); - - for (Machine::Nodes::iterator i = _machine->nodes().begin(); - i != _machine->nodes().end() ; ) { - - - Machine::Nodes::iterator next = i; - ++next; - - _machine->remove_node(*i); - - i = next; - } - } -#endif } diff --git a/src/engine/MidiAction.cpp b/src/engine/MidiAction.cpp index 969e53a..9609bb6 100644 --- a/src/engine/MidiAction.cpp +++ b/src/engine/MidiAction.cpp @@ -12,7 +12,7 @@ * * 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 + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include <iostream> diff --git a/src/engine/Node.cpp b/src/engine/Node.cpp index b55619d..b03fa1c 100644 --- a/src/engine/Node.cpp +++ b/src/engine/Node.cpp @@ -77,13 +77,11 @@ Node::remove_exit_action() _exit_action.reset(); } -//using namespace std; void Node::enter(SharedPtr<Raul::MIDISink> sink, BeatTime time) { assert(!_is_active); - //std::cerr << "ENTER " << time << std::endl; _is_active = true; _enter_time = time; @@ -96,7 +94,6 @@ void Node::exit(SharedPtr<Raul::MIDISink> sink, BeatTime time) { assert(_is_active); - //std::cerr << "EXIT " << time << std::endl; if (sink && _exit_action) _exit_action->execute(sink, time); @@ -172,13 +169,8 @@ Node::write_state(Raul::RDFWriter& writer) RdfId(RdfId::RESOURCE, "machina:exitAction"), _exit_action->id()); } - - /*for (Node::Edges::const_iterator e = _outgoing_edges.begin(); - e != _outgoing_edges.end(); ++e) - (*e)->write_state(writer);*/ } - } // namespace Machina diff --git a/src/engine/Recorder.cpp b/src/engine/Recorder.cpp index c6130ab..615cd97 100644 --- a/src/engine/Recorder.cpp +++ b/src/engine/Recorder.cpp @@ -12,7 +12,7 @@ * * 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 + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include <iostream> @@ -31,23 +31,17 @@ Recorder::Recorder(size_t buffer_size, double tick_rate, double q) , _record_buffer(buffer_size) , _builder(new MachineBuilder(SharedPtr<Machine>(new Machine()), q)) { - cerr << "XXXXXXXXXXXX new recorder, q=" << q << endl; } void Recorder::_whipped() { - cerr << "Whipped" << endl; - TickTime t; size_t size; unsigned char buf[4]; while (_record_buffer.read(&t, &size, buf)) { - //cout << "RECORD EVENT: t=" << t * _tick_rate << ", size=" << size << ", buf=0x" - // << std::hex << (int)((unsigned char)buf[0]) << std::dec << endl; - _builder->set_time(t * _tick_rate); _builder->event(0, size, buf); } diff --git a/src/engine/SMFDriver.cpp b/src/engine/SMFDriver.cpp index 0283288..b936143 100644 --- a/src/engine/SMFDriver.cpp +++ b/src/engine/SMFDriver.cpp @@ -12,7 +12,7 @@ * * 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 + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include <list> diff --git a/src/engine/machina/ActionFactory.hpp b/src/engine/machina/ActionFactory.hpp index c43bf72..72303ee 100644 --- a/src/engine/machina/ActionFactory.hpp +++ b/src/engine/machina/ActionFactory.hpp @@ -12,7 +12,7 @@ * * 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 + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef MACHINA_ACTIONFACTORY_HPP diff --git a/src/engine/machina/Driver.hpp b/src/engine/machina/Driver.hpp index acc4278..c28bfcf 100644 --- a/src/engine/machina/Driver.hpp +++ b/src/engine/machina/Driver.hpp @@ -1,5 +1,4 @@ /* This file is part of Machina. - * _engine->driver()->reset_time(); * Copyright (C) 2007 Dave Robillard <http://drobilla.net> * * Machina is free software; you can redistribute it and/or modify it under the @@ -13,7 +12,7 @@ * * 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 + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef MACHINA_DRIVER_HPP diff --git a/src/engine/machina/Engine.hpp b/src/engine/machina/Engine.hpp index dc47b2a..a7d0ed7 100644 --- a/src/engine/machina/Engine.hpp +++ b/src/engine/machina/Engine.hpp @@ -20,6 +20,7 @@ #include <glibmm/ustring.h> #include <raul/SharedPtr.h> +#include <raul/types.h> #include "machina/Driver.hpp" namespace Machina { @@ -38,7 +39,7 @@ public: SharedPtr<Machine> load_machine(const Glib::ustring& uri); SharedPtr<Machine> import_machine(const Glib::ustring& uri); - SharedPtr<Machine> learn_midi(const Glib::ustring& uri); + SharedPtr<Machine> import_midi(const Glib::ustring& uri, Raul::BeatTime d); void set_bpm(double bpm); void set_quantization(double beat_fraction); diff --git a/src/engine/machina/JackDriver.hpp b/src/engine/machina/JackDriver.hpp index 1ab6643..ce95462 100644 --- a/src/engine/machina/JackDriver.hpp +++ b/src/engine/machina/JackDriver.hpp @@ -12,7 +12,7 @@ * * 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 + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef MACHINA_JACKDRIVER_HPP @@ -69,8 +69,9 @@ public: void finish_record(); private: - void process_input(SharedPtr<Machine> machine, - const Raul::TimeSlice& time); + void process_input(SharedPtr<Machine> machine, + const Raul::TimeSlice& time); + virtual void on_process(jack_nframes_t nframes); Raul::Semaphore _machine_changed; diff --git a/src/engine/machina/LearnRequest.hpp b/src/engine/machina/LearnRequest.hpp index 9284e90..20c02e5 100644 --- a/src/engine/machina/LearnRequest.hpp +++ b/src/engine/machina/LearnRequest.hpp @@ -43,10 +43,12 @@ public: return ret; } + void start(double q, BeatTime time) + { _started = true; _start_time = time; _quantization = q; } + void finish(BeatTime time); - - void start(double q, BeatTime time) { _started = true; _start_time = time; _quantization = q; } - bool started() { return _started; } + + bool started() { return _started; } const SharedPtr<Node>& node() { return _node; } const SharedPtr<MidiAction>& enter_action() { return _enter_action; } diff --git a/src/engine/machina/Loader.hpp b/src/engine/machina/Loader.hpp index af35c56..7e296c0 100644 --- a/src/engine/machina/Loader.hpp +++ b/src/engine/machina/Loader.hpp @@ -12,7 +12,7 @@ * * 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 + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef MACHINA_LOADER_HPP diff --git a/src/engine/machina/Machine.hpp b/src/engine/machina/Machine.hpp index 14632f0..9504217 100644 --- a/src/engine/machina/Machine.hpp +++ b/src/engine/machina/Machine.hpp @@ -56,10 +56,8 @@ public: // Any context Raul::BeatTime time() { return _time; } - //LearnRequest pop_learn() { return _pending_learns.pop_front(); } - //SharedPtr<LearnRequest> first_learn() { return *_pending_learns.begin(); } - SharedPtr<LearnRequest> pending_learn() { return _pending_learn; } - void clear_pending_learn() { _pending_learn.reset(); } + SharedPtr<LearnRequest> pending_learn() { return _pending_learn; } + void clear_pending_learn() { _pending_learn.reset(); } typedef Raul::List<SharedPtr<Node> > Nodes; Nodes& nodes() { return _nodes; } diff --git a/src/engine/machina/MachineBuilder.hpp b/src/engine/machina/MachineBuilder.hpp index 25104e8..ddb3e02 100644 --- a/src/engine/machina/MachineBuilder.hpp +++ b/src/engine/machina/MachineBuilder.hpp @@ -12,7 +12,7 @@ * * 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 + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef MACHINA_MACHINEBUILDER_HPP diff --git a/src/engine/machina/MidiAction.hpp b/src/engine/machina/MidiAction.hpp index 510c0d0..6541f0e 100644 --- a/src/engine/machina/MidiAction.hpp +++ b/src/engine/machina/MidiAction.hpp @@ -12,7 +12,7 @@ * * 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 + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef MACHINA_MIDIACTION_HPP diff --git a/src/engine/machina/Recorder.hpp b/src/engine/machina/Recorder.hpp index 1bc07c3..d03f6fc 100644 --- a/src/engine/machina/Recorder.hpp +++ b/src/engine/machina/Recorder.hpp @@ -12,7 +12,7 @@ * * 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 + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef MACHINA_RECORDER_HPP diff --git a/src/engine/machina/SMFDriver.hpp b/src/engine/machina/SMFDriver.hpp index 7b22a26..af6e1bb 100644 --- a/src/engine/machina/SMFDriver.hpp +++ b/src/engine/machina/SMFDriver.hpp @@ -12,7 +12,7 @@ * * 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 + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef MACHINA_SMFDRIVER_HPP diff --git a/src/engine/machina/types.hpp b/src/engine/machina/types.hpp index 70eae7d..6e661ef 100644 --- a/src/engine/machina/types.hpp +++ b/src/engine/machina/types.hpp @@ -18,14 +18,8 @@ #ifndef MACHINA_TYPES_HPP #define MACHINA_TYPES_HPP -#include <jack/types.h> - namespace Machina { - -//typedef jack_nframes_t FrameCount; -//typedef jack_nframes_t Timestamp; - typedef unsigned char byte; } // namespace Machina |