diff options
author | David Robillard <d@drobilla.net> | 2007-08-01 04:42:09 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2007-08-01 04:42:09 +0000 |
commit | 1a77934531b0ddfc4392ccffbdde0058c2dbab68 (patch) | |
tree | 51e628c9b3dc4299d1f5dbb3bd5aad4938b0ae5a | |
parent | 9cd4eddfb41c4573d4acd4f625572c4cdff50497 (diff) | |
download | ingen-1a77934531b0ddfc4392ccffbdde0058c2dbab68.tar.gz ingen-1a77934531b0ddfc4392ccffbdde0058c2dbab68.tar.bz2 ingen-1a77934531b0ddfc4392ccffbdde0058c2dbab68.zip |
Remove PostProcessor thread, post-process in main thread instead (solves scripting threading issues, and saves memory anyway).
Revert saw_lp.ingen.ttl (version written by broken raptor committed by mistake).
Working engine->script responses, nicer Python example.
git-svn-id: http://svn.drobilla.net/lad/ingen@665 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r-- | patches/saw_lp.ingen.ttl | 105 | ||||
-rw-r--r-- | src/bindings/Makefile.am | 5 | ||||
-rw-r--r-- | src/bindings/ingen.i | 5 | ||||
-rwxr-xr-x | src/bindings/test_ingen.py | 35 | ||||
-rw-r--r-- | src/libs/engine/Engine.cpp | 9 | ||||
-rw-r--r-- | src/libs/engine/JackAudioDriver.cpp | 2 | ||||
-rw-r--r-- | src/libs/engine/PostProcessor.cpp | 21 | ||||
-rw-r--r-- | src/libs/engine/PostProcessor.hpp | 18 | ||||
-rw-r--r-- | src/libs/engine/QueuedEventSource.cpp | 4 | ||||
-rw-r--r-- | src/libs/engine/tuning.hpp | 5 | ||||
-rw-r--r-- | src/libs/module/World.hpp | 5 | ||||
-rw-r--r-- | src/libs/module/module.cpp | 2 | ||||
-rw-r--r-- | src/progs/ingen/main.cpp | 1 |
13 files changed, 120 insertions, 97 deletions
diff --git a/patches/saw_lp.ingen.ttl b/patches/saw_lp.ingen.ttl index 2f50b01a..50ddef16 100644 --- a/patches/saw_lp.ingen.ttl +++ b/patches/saw_lp.ingen.ttl @@ -2,14 +2,13 @@ @prefix doap: <http://usefulinc.com/ns/doap#> . @prefix ingen: <http://drobilla.net/ns/ingen#> . @prefix ingenuity: <http://drobilla.net/ns/ingenuity#> . -@prefix lv2: <http://lv2plug.in/ns/lv2core#> . +@prefix lv2: <http://lv2plug.in/ontology#> . @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . <> - ingenuity:canvas-x 1.54E3; ingen:node [ - ingenuity:canvas-x E3; + ingenuity:canvas-x 1495.2; ingen:port _:n29, [ ingen:name "SecondInput"; ingen:dataType "ingen:audio"; @@ -21,13 +20,13 @@ ingen:dataType "ingen:audio"; ingen:name "FirstInput" ]; - ingenuity:canvas-y 1.1725E3; + ingenuity:canvas-y 1172.5; ingen:plugin <ladspa:1668>; ingen:name "voice_amp"; a "ingen:Node" ], [ - ingenuity:canvas-x 1.374E3; - ingenuity:canvas-y 1.0E3; + ingenuity:canvas-x 1374.0; + ingenuity:canvas-y 1044.2; ingen:plugin <ladspa:1641>; ingen:port _:n25, [ ingen:connectedTo _:n19; @@ -42,10 +41,10 @@ ingen:plugin <ingen:note_node>; ingen:port _:n22, _:n21, [ a "ingen:OutputPort"; - ingen:maximum 1.0E0; + ingen:maximum 1.0; ingen:dataType "ingen:audio"; ingen:name "Velocity"; - ingen:minimum 0.0E0 + ingen:minimum 0.0 ], _:n19, [ ingen:connectedTo _:n32; ingen:dataType "ingen:midi"; @@ -53,8 +52,8 @@ a "ingen:InputPort" ]; ingen:name "note_in"; - ingenuity:canvas-x E3; - ingenuity:canvas-y 1.0E3 + ingenuity:canvas-x 1258.2; + ingenuity:canvas-y 1087.2 ], [ ingen:port _:n16, [ a "ingen:InputPort"; @@ -63,52 +62,52 @@ ingen:dataType "ingen:audio" ], [ ingen:connectedTo _:n30; - ingen:minimum 1.1920928955E-7; - ingen:value 2.0000000298E-1; + ingen:minimum 0.0; + ingen:value 0.0; a "ingen:InputPort"; - ingen:maximum 1.0E0; + ingen:maximum 0.0; ingen:name "Gain"; ingen:dataType "ingen:control" ]; ingen:plugin <ladspa:1067>; - ingenuity:canvas-x 1.932E3; + ingenuity:canvas-x 1932.0; a "ingen:Node"; - ingenuity:canvas-y 1.151E3; + ingenuity:canvas-y 1151.0; ingen:name "master_amp" ], [ ingen:plugin <ladspa:1680>; a "ingen:Node"; ingen:name "env"; - ingenuity:canvas-x 1.3645E3; - ingenuity:canvas-y E3; + ingenuity:canvas-x 1364.5; + ingenuity:canvas-y 1154.2; ingen:port _:n12, [ - ingen:minimum 0.0E0; + ingen:minimum 0.0; a "ingen:InputPort"; - ingen:value 2.0E0; + ingen:value 0.0; ingen:name "ReleaseTime(s)"; ingen:dataType "ingen:control"; - ingen:maximum 0.0E0 + ingen:maximum 0.0 ], [ - ingen:value 1.0000000149E-1; - ingen:minimum 0.0E0; + ingen:value 1.0; + ingen:minimum 0.0; a "ingen:InputPort"; - ingen:maximum 1.0E0; + ingen:maximum 1.0; ingen:name "SustainLevel"; ingen:dataType "ingen:control" ], [ ingen:dataType "ingen:control"; ingen:name "DecayTime(s)"; - ingen:minimum 0.0E0; - ingen:value 0.0E0; + ingen:minimum 0.0; + ingen:value 0.0; a "ingen:InputPort"; - ingen:maximum 0.0E0 + ingen:maximum 0.0 ], [ - ingen:value 0.0E0; - ingen:minimum 0.0E0; + ingen:value 0.0; + ingen:minimum 0.0; ingen:dataType "ingen:control"; ingen:name "AttackTime(s)"; a "ingen:InputPort"; - ingen:maximum 0.0E0 + ingen:maximum 0.0 ], [ ingen:connectedTo _:n22; a "ingen:InputPort"; @@ -122,9 +121,9 @@ ] ], [ ingen:plugin <ladspa:1672>; - ingenuity:canvas-y 1.1798E3; + ingenuity:canvas-y 1179.8; ingen:name "4PoleLow-PassFilterWithResonance(FCRCIA)"; - ingenuity:canvas-x 1.617E3; + ingenuity:canvas-x 1617.0; ingen:port _:n4, [ a "ingen:InputPort"; ingen:connectedTo _:n29; @@ -132,44 +131,42 @@ ingen:dataType "ingen:audio" ], [ ingen:name "Resonance"; - ingen:value 5.0E-1; + ingen:value 3.3; ingen:dataType "ingen:control"; - ingen:minimum 0.0E0; + ingen:minimum 0.0; a "ingen:InputPort"; - ingen:maximum 4.0E0 + ingen:maximum 4.0 ], [ - ingen:maximum 2.4E4; + ingen:maximum 24000.0; ingen:dataType "ingen:control"; - ingen:value 1.1313E3; + ingen:value 356.6; ingen:connectedTo _:n31; - ingen:minimum 9.9999994E-1; + ingen:minimum 1.0; a "ingen:InputPort"; ingen:name "CutoffFrequency" ]; a "ingen:Node" ]; - ingen:name "saw_lp"; ingen:port [ - ingenuity:canvas-x 2.0588E3; + ingenuity:canvas-x 2058.8; ingen:connectedTo _:n16; a "ingen:OutputPort"; - ingenuity:canvas-y 1.1738E3; + ingenuity:canvas-y 1173.8; ingen:dataType "ingen:audio"; ingen:name "output" ], _:n32, _:n31, _:n30; ingen:polyphony 1; - a ingen:Patch; - ingenuity:canvas-y 1.167E3 . + a ingen:Patch . _:n31 - ingenuity:canvas-y 1.0805E3; + ingenuity:canvas-y 1080.5; ingen:dataType "ingen:control"; - ingenuity:canvas-x 1.5268E3; - ingen:value 3.29700012207E2, E2; + ingenuity:canvas-x 1526.8; + ingen:value 329.7; ingen:name "cutoff"; - ingen:minimum 1.0E1; + ingen:minimum 10.0; a "ingen:InputPort"; - ingen:maximum 1.0E4 . + ingen:maximum 10000.0 . _:n12 a "ingen:OutputPort"; @@ -178,15 +175,15 @@ _:n12 _:n21 a "ingen:OutputPort"; - ingen:default 0.0E0; + ingen:default 0.0; ingen:name "Gate"; ingen:toggled 1; ingen:dataType "ingen:audio" . _:n32 a "ingen:InputPort"; - ingenuity:canvas-y 1.125E3; - ingenuity:canvas-x E3; + ingenuity:canvas-y 1125.0; + ingenuity:canvas-x 1145.2; ingen:dataType "ingen:midi"; ingen:name "midi_input" . @@ -204,14 +201,14 @@ _:n22 ingen:dataType "ingen:audio"; ingen:toggled 1; ingen:name "Trigger"; - ingen:default 0.0E0; + ingen:default 0.0; a "ingen:OutputPort" . _:n30 a "ingen:InputPort"; - ingen:value 2.0000000298E-1; - ingenuity:canvas-y 1.0E3; - ingenuity:canvas-x 1.833E3; + ingen:value 0.2; + ingenuity:canvas-y 1076.2; + ingenuity:canvas-x 1833.0; ingen:name "amp"; ingen:dataType "ingen:control" . diff --git a/src/bindings/Makefile.am b/src/bindings/Makefile.am index 48a5ad4f..cb86a915 100644 --- a/src/bindings/Makefile.am +++ b/src/bindings/Makefile.am @@ -10,6 +10,11 @@ bindings_LTLIBRARIES = libingen_bindings.la libingen_bindings_la_LDFLAGS = -no-undefined -module -avoid-version libingen_bindings_la_LIBADD = @RAUL_LIBS@ @GLIBMM_LIBS@ #../libs/module/libingen_module.la libingen_bindings_la_SOURCES = ingen_wrap.cxx ingen_bindings.cpp ingen_bindings.hpp +libingen_bindings_la_CXXFLAGS = \ + @SLV2_CFLAGS@ @RAUL_CFLAGS@ @GLIBMM_CFLAGS@ \ + -I$(top_srcdir)/ingen/src/common \ + -I$(top_srcdir)/ingen/src/libs \ + -I/usr/include/python2.4 swig: ingen.i swig -c++ -Wall $(FLAGS) -python ingen.i diff --git a/src/bindings/ingen.i b/src/bindings/ingen.i index 719ece20..5eb942d9 100644 --- a/src/bindings/ingen.i +++ b/src/bindings/ingen.i @@ -42,6 +42,11 @@ namespace Ingen { namespace Shared { return Ingen::Shared::ingen_world; } } + + void iteration() { + Ingen::Shared::script_iteration($self); + } + /*SLV2World slv2() { return $self->me->slv2_world; }*/ }; diff --git a/src/bindings/test_ingen.py b/src/bindings/test_ingen.py index 4109dd21..9b925155 100755 --- a/src/bindings/test_ingen.py +++ b/src/bindings/test_ingen.py @@ -1,40 +1,34 @@ #!/usr/bin/env python + import ingen import time world = ingen.World() class PythonClient(ingen.Client): - #def __init__(self): - # ingen.Client(self) - # print "Client" - - def bundle_begin(): - print "Bundle {" + def error(self, msg): + print "*** Received error:", msg + def bundle_begin(self): + print "*** Receiving Bundle {" + + def bundle_end(self): + print "*** }" def new_port(self, path, data_type, is_output): - print "Port:", path, data_type, is_output + print "*** Received Port:", path, data_type, is_output + + def new_node(self, plugin_uri, path, polyphonic, nports): + print "*** Received Node:", plugin_uri, path, polyphonic, nports c = PythonClient() -c.thisown = 0 -print "C OWN", c.thisown -#print c.__base__ +c.enable() e = world.engine -print "E OWN", e.thisown -e.thisown = 0 -#print e - e.activate() -#e.register_client("foo", c) c.subscribe(e) -c.enable() -#c.new_patch("/foo/bar", 1) - - e.create_port("/I", "ingen:midi", False) e.create_port("/made", "ingen:audio", False) e.create_port("/these", "ingen:audio", False) @@ -43,5 +37,6 @@ e.create_port("/a", "ingen:audio", True) e.create_port("/script", "ingen:audio", True) while True: - time.sleep(1) + world.iteration() + time.sleep(0.1) diff --git a/src/libs/engine/Engine.cpp b/src/libs/engine/Engine.cpp index a77662a3..af4eca27 100644 --- a/src/libs/engine/Engine.cpp +++ b/src/libs/engine/Engine.cpp @@ -54,7 +54,7 @@ Engine::Engine(Ingen::Shared::World* world) _midi_driver(NULL), _osc_driver(NULL), _maid(new Raul::Maid(maid_queue_size)), - _post_processor(new PostProcessor(*_maid, post_processor_queue_size)), + _post_processor(new PostProcessor(/**_maid, */post_processor_queue_size)), _broadcaster(new ClientBroadcaster()), _object_store(new ObjectStore()), _node_factory(new NodeFactory(world)), @@ -142,6 +142,7 @@ Engine::main_iteration() lash_driver->process_events(); #endif*/ // Run the maid (garbage collector) + _post_processor->process(); _maid->cleanup(); return !_quit_flag; @@ -227,7 +228,7 @@ Engine::activate() _audio_driver->activate(); - _post_processor->start(); + //_post_processor->start(); _activated = true; @@ -254,8 +255,8 @@ Engine::deactivate() _audio_driver->root_patch()->deactivate(); // Finalize any lingering events (unlikely) - _post_processor->whip(); - _post_processor->stop(); + //_post_processor->whip(); + //_post_processor->stop(); _audio_driver.reset(); diff --git a/src/libs/engine/JackAudioDriver.cpp b/src/libs/engine/JackAudioDriver.cpp index ebb4708b..b9e89189 100644 --- a/src/libs/engine/JackAudioDriver.cpp +++ b/src/libs/engine/JackAudioDriver.cpp @@ -204,7 +204,7 @@ JackAudioDriver::deactivate() cout << "[JackAudioDriver] Deactivated Jack client." << endl; - _engine.post_processor()->stop(); + //_engine.post_processor()->stop(); } } diff --git a/src/libs/engine/PostProcessor.cpp b/src/libs/engine/PostProcessor.cpp index 64c106d8..109635df 100644 --- a/src/libs/engine/PostProcessor.cpp +++ b/src/libs/engine/PostProcessor.cpp @@ -19,7 +19,7 @@ #include <iostream> #include <pthread.h> #include <raul/SRSWQueue.hpp> -#include <raul/Maid.hpp> +//#include <raul/Maid.hpp> #include "Event.hpp" #include "PostProcessor.hpp" @@ -28,14 +28,14 @@ using std::cerr; using std::cout; using std::endl; namespace Ingen { -PostProcessor::PostProcessor(Raul::Maid& maid, size_t queue_size) -: _maid(maid), - _events(queue_size) +PostProcessor::PostProcessor(/*Raul::Maid& maid, */size_t queue_size) + //: _maid(maid) + : _events(queue_size) { - set_name("PostProcessor"); + //set_name("PostProcessor"); } - +#if 0 /** Post-Process every pending event. * * The PostProcessor should be whipped by the audio thread once every cycle @@ -43,12 +43,19 @@ PostProcessor::PostProcessor(Raul::Maid& maid, size_t queue_size) void PostProcessor::_whipped() { + //process(); +} +#endif + +void +PostProcessor::process() +{ while ( ! _events.empty()) { Event* const ev = _events.front(); _events.pop(); assert(ev); ev->post_process(); - _maid.push(ev); + delete ev; } } diff --git a/src/libs/engine/PostProcessor.hpp b/src/libs/engine/PostProcessor.hpp index b77bda6e..114a8bef 100644 --- a/src/libs/engine/PostProcessor.hpp +++ b/src/libs/engine/PostProcessor.hpp @@ -21,9 +21,9 @@ #include <pthread.h> #include "types.hpp" #include <raul/SRSWQueue.hpp> -#include <raul/Slave.hpp> +//#include <raul/Slave.hpp> -namespace Raul { class Maid; } +//namespace Raul { class Maid; } namespace Ingen { @@ -36,20 +36,26 @@ class Event; * is realtime-safe), which signals the processing thread through a semaphore * to handle the event and pass it on to the Maid. * + * Update: This is all run from main_iteration now to solve scripting + * thread issues. Not sure if this is permanent/ideal or not... + * * \ingroup engine */ -class PostProcessor : public Raul::Slave +class PostProcessor //: public Raul::Slave { public: - PostProcessor(Raul::Maid& maid, size_t queue_size); + PostProcessor(/*Raul::Maid& maid, */size_t queue_size); /** Push an event on to the process queue, realtime-safe, not thread-safe. */ inline void push(Event* const ev) { _events.push(ev); } + /** Post-process and delete all pending events */ + void process(); + private: - Raul::Maid& _maid; + //Raul::Maid& _maid; Raul::SRSWQueue<Event*> _events; - virtual void _whipped(); + //virtual void _whipped(); }; diff --git a/src/libs/engine/QueuedEventSource.cpp b/src/libs/engine/QueuedEventSource.cpp index 6414a6e9..ac03ef16 100644 --- a/src/libs/engine/QueuedEventSource.cpp +++ b/src/libs/engine/QueuedEventSource.cpp @@ -106,8 +106,8 @@ QueuedEventSource::process(PostProcessor& dest, SampleCount nframes, FrameTime c ++num_events_processed; } - if (num_events_processed > 0) - dest.whip(); + /*if (num_events_processed > 0) + dest.whip();*/ //else // cerr << "NO PROC: queued: " << unprepared_events() << ", stamped: " << !_stamped_queue.empty() << endl; } diff --git a/src/libs/engine/tuning.hpp b/src/libs/engine/tuning.hpp index 25aa9eb0..7ec55ae4 100644 --- a/src/libs/engine/tuning.hpp +++ b/src/libs/engine/tuning.hpp @@ -30,9 +30,8 @@ static const size_t pre_processor_queue_size = 1024; static const size_t post_processor_queue_size = 1024; static const size_t maid_queue_size = 1024; -// This controls both the LASH event processing rate and the Maid cleanup rate -// (both of which are driven from the main thread) -static const timespec main_rate = { 0, 500000000 }; // 1/2 second +//static const timespec main_rate = { 0, 500000000 }; // 1/2 second +static const timespec main_rate = { 0, 125000000 }; // 1/8 second } // namespace Ingen diff --git a/src/libs/module/World.hpp b/src/libs/module/World.hpp index f665e6ad..1caa50ac 100644 --- a/src/libs/module/World.hpp +++ b/src/libs/module/World.hpp @@ -30,6 +30,9 @@ #endif namespace Ingen { + +class Engine; + namespace Shared { class EngineInterface; @@ -52,6 +55,8 @@ struct World { Raul::RDF::World* rdf_world; EngineInterface* engine; + + Engine* local_engine; }; diff --git a/src/libs/module/module.cpp b/src/libs/module/module.cpp index d169e546..2914907a 100644 --- a/src/libs/module/module.cpp +++ b/src/libs/module/module.cpp @@ -48,6 +48,8 @@ get_world() world->slv2_world = slv2_world_new_using_rdf_world(world->rdf_world->world()); slv2_world_load_all(world->slv2_world); #endif + world->engine = NULL; + world->local_engine = NULL; } return world; diff --git a/src/progs/ingen/main.cpp b/src/progs/ingen/main.cpp index 22ace336..f424eff0 100644 --- a/src/progs/ingen/main.cpp +++ b/src/progs/ingen/main.cpp @@ -88,6 +88,7 @@ main(int argc, char** argv) Engine* (*new_engine)(Ingen::Shared::World* world) = NULL; if (engine_module->get_symbol("new_engine", (void*&)new_engine)) { engine = SharedPtr<Engine>(new_engine(world)); + world->local_engine = engine.get(); } else { engine_module.reset(); } |