View Issue Details

IDProjectCategoryView StatusLast Update
0002071ardourfeaturespublic2009-08-20 19:36
Reporterryan_scott Assigned Topaul  
PrioritynormalSeverityfeatureReproducibilityN/A
Status acknowledgedResolutionopen 
Product VersionSVN/2.0-ongoing 
Summary0002071: [PATCH] Sending OSC messages to an external program for specific Ardour behaviors
DescriptionThis patch provides a mechanism whereby OSC can be used to provide IPC for basic events within Ardour, such as session load, file export, temp change, etc.

This allows for non-critical tasks, such as loading an accompanying midi file in an external program or encoding to mp3 on export, to be performed externally by a simple helper script.

This patch and corresponding script are setup to load a similarly located/named file in Rosegarden on session load and encode to mp3 on session export via lame.
Additional Information#! /usr/bin/python

from liblo import *
import pcop, pydcop
import os, threading

class ArdourHelper( Server ):

    def run( self ):
        while True:
            self.recv()

    # Handlers
    @make_method( '/session/loaded', 'ss' )
    def sessionLoaded( self, oscPath, args ):
        ( path, name ) = args[:2]

        rose = pydcop.anyAppCalled( "rosegarden" )
        rose.RosegardenIface.openFile( '%s/%s.rg' % ( path, name ) )

    @make_method( '/session/exported', 'ss' )
    def sessionExported( self, oscPath, args ):
        ( path, title ) = args[:2]

        artist = album = ''

        # Call lame
        print 'Encoding %s' % title
        self.mp3Encode( path, artist, album, title )

    def mp3Encode( self, path, artist='', album='', title='' ):
        filename = os.path.dirname( path )
        if artist:
            filename += '%s - ' % artist
        filename = '%s/%s.mp3' % ( filename, title )

        print 'lame --ta "%s" --tl "%s" --tt "%s" "%s" "%s"' % ( artist, album, title, path, filename )
        
        print os.system( 'lame --ta "%s" --tl "%s" --tt "%s" "%s" "%s"' % ( artist, album, title, path, filename ) )

#############################
helper = ArdourHelper( 7770 )
helper.run()
TagsNo tags attached.

Relationships

related to 0001352 acknowledged Run script on export 

Activities

2008-02-12 02:31

 

ardour2-ongoing-osc-external-hooks.patch (3,162 bytes)   
=== libs/ardour/ardour/osc.h
==================================================================
--- libs/ardour/ardour/osc.h	(revision 1269)
+++ libs/ardour/ardour/osc.h	(local)
@@ -54,12 +54,13 @@
 	lo_server _osc_server;
 	lo_server _osc_unix_server;
 	std::string _osc_unix_socket_path;
-   std::string _osc_url_file;
+	std::string _osc_url_file;
 	pthread_t _osc_thread;
 	int _request_pipe[2];
 
 	static void * _osc_receiver(void * arg);
 	void osc_receiver();
+	void send(); // This should accept an OSC payload
 
 	bool init_osc_thread ();
 	void terminate_osc_thread ();
@@ -69,6 +70,11 @@
 
 	void session_going_away ();
 
+	// Handlers for "Application Hook" signals
+	void session_loaded( ARDOUR::Session& );
+	void session_exported( std::string, std::string );
+	// end "Application Hook" handles
+
 	std::string get_server_url ();
 	std::string get_unix_server_url ();
 
=== libs/ardour/ardour/session.h
==================================================================
--- libs/ardour/ardour/session.h	(revision 1269)
+++ libs/ardour/ardour/session.h	(local)
@@ -594,6 +594,7 @@
 	int start_audio_export (ARDOUR::AudioExportSpecification&);
 	int stop_audio_export (ARDOUR::AudioExportSpecification&);
 	void finalize_audio_export ();
+	static sigc::signal<void, std::string, std::string> Exported;
 
 	void add_source (boost::shared_ptr<Source>);
 	void remove_source (boost::weak_ptr<Source>);
=== libs/ardour/osc.cc
==================================================================
--- libs/ardour/osc.cc	(revision 1269)
+++ libs/ardour/osc.cc	(local)
@@ -401,6 +401,10 @@
 {
 	session = &s;
 	session->GoingAway.connect (mem_fun (*this, &OSC::session_going_away));
+
+	// "Application Hooks"
+	session_loaded( s );
+	session->Exported.connect( mem_fun( *this, &OSC::session_exported ) );
 }
 
 void
@@ -409,6 +413,21 @@
 	session = 0;
 }
 
+// "Application Hook" Handlers //
+void
+OSC::session_loaded( Session& s ) {
+	lo_address listener = lo_address_new( NULL, "7770" );
+	lo_send( listener, "/session/loaded", "ss", s.path().c_str(), s.name().c_str() );
+}
+
+void
+OSC::session_exported( std::string path, std::string name ) {
+	lo_address listener = lo_address_new( NULL, "7770" );
+	lo_send( listener, "/session/exported", "ss", path.c_str(), name.c_str() );
+}
+
+// end "Application Hook" Handlers //
+
 /* path callbacks */
 
 int 
=== libs/ardour/session.cc
==================================================================
--- libs/ardour/session.cc	(revision 1269)
+++ libs/ardour/session.cc	(local)
@@ -113,6 +113,8 @@
 sigc::signal<void> Session::StartTimeChanged;
 sigc::signal<void> Session::EndTimeChanged;
 
+sigc::signal<void, std::string, std::string> Session::Exported;
+
 int
 Session::find_session (string str, string& path, string& snapshot, bool& isnew)
 {
=== libs/ardour/session_export.cc
==================================================================
--- libs/ardour/session_export.cc	(revision 1269)
+++ libs/ardour/session_export.cc	(local)
@@ -454,6 +454,8 @@
 	spec.freewheel_connection.disconnect ();
 	spec.clear (); /* resets running/stop etc */
 
+	Exported( spec.path, name() );
+
 	return 0;
 }
 

2008-02-12 02:34

 

ardour-osc-helper.py (1,237 bytes)   
#! /usr/bin/python

from liblo import *

import pcop, pydcop

import os, threading

class ArdourHelper( Server ):

    def run( self ):
        while True:
            self.recv()

    # Handlers
    @make_method( '/session/loaded', 'ss' )
    def sessionLoaded( self, oscPath, args ):
        ( path, name ) = args[:2]

        rose = pydcop.anyAppCalled( "rosegarden" )
        rose.RosegardenIface.openFile( '%s/%s.rg' % ( path, name ) )

    @make_method( '/session/exported', 'ss' )
    def sessionExported( self, oscPath, args ):
        ( path, title ) = args[:2]

        artist = album = ''

        # Call lame
        print 'Encoding %s' % title
        self.mp3Encode( path, artist, album, title )

    def mp3Encode( self, path, artist='', album='', title='' ):
        filename = os.path.dirname( path )
        if artist:
            filename += '%s - ' % artist
        filename = '%s/%s.mp3' % ( filename, title )

        print 'lame --ta "%s" --tl "%s" --tt "%s" "%s" "%s"' % ( artist, album, title, path, filename )
        
        print os.system( 'lame --ta "%s" --tl "%s" --tt "%s" "%s" "%s"' % ( artist, album, title, path, filename ) )

#############################

helper = ArdourHelper( 7770 )
helper.run()
ardour-osc-helper.py (1,237 bytes)   

nettings

2009-08-17 19:08

manager   ~0006567

does not apply to r5499 - looks like parts of it are in already:

nettings@kleineronkel:/build/ardour2> patch -p0 < ardour2-ongoing-osc-external-hooks.patch
patching file libs/ardour/ardour/osc.h
Reversed (or previously applied) patch detected! Assume -R? [n] n
Apply anyway? [n] n
Skipping patch.
2 out of 2 hunks ignored -- saving rejects to file libs/ardour/ardour/osc.h.rej
patching file libs/ardour/ardour/session.h
Reversed (or previously applied) patch detected! Assume -R? [n] n
Apply anyway? [n] n
Skipping patch.
1 out of 1 hunk ignored -- saving rejects to file libs/ardour/ardour/session.h.rej
patching file libs/ardour/osc.cc
Reversed (or previously applied) patch detected! Assume -R? [n] n
Apply anyway? [n] n
Skipping patch.
2 out of 2 hunks ignored -- saving rejects to file libs/ardour/osc.cc.rej
patching file libs/ardour/session.cc
Hunk 0000001 succeeded at 120 with fuzz 2 (offset 7 lines).
patching file libs/ardour/session_export.cc
Hunk 0000001 succeeded at 469 with fuzz 2 (offset 15 lines).

paul, this looks unintrusive and might be useful to people with streamlined workflows - any interest? if so, maybe ryan could update his patch.

cth103

2009-08-20 19:36

administrator   ~0006577

This has been applied to 3.0.

Issue History

Date Modified Username Field Change
2008-02-12 02:31 ryan_scott New Issue
2008-02-12 02:31 ryan_scott File Added: ardour2-ongoing-osc-external-hooks.patch
2008-02-12 02:34 ryan_scott File Added: ardour-osc-helper.py
2009-08-17 19:04 nettings Relationship added related to 0001352
2009-08-17 19:08 nettings Note Added: 0006567
2009-08-17 19:09 nettings cost => 0.00
2009-08-17 19:09 nettings Assigned To => paul
2009-08-17 19:09 nettings Status new => acknowledged
2009-08-17 19:09 nettings Summary Sending OSC messages to an external program for specific Ardour behaviors => [PATCH] Sending OSC messages to an external program for specific Ardour behaviors
2009-08-20 19:36 cth103 Note Added: 0006577