Webenabled Audiosynthesis Development Environment Rory Walsh Conor Dempsey Dundalk Institute of Technology, Dundalk Institute of Technology, Dundalk, Co. Louth Dundalk, Co. Louth Ireland Ireland [email protected] [email protected] Abstract Platform[2], Equinox OSGi[3], Java Servlets, HTML[4] and javaScript[5]. Collaboration and education in the world of digital audio synthesis has been facilitated in many ways 1.1 Web-enabled Audio Synthesis by the internet and its World Wide Web. In 1995 Ossenbruggen and Elıens proposed the use Numerous projects have endeavoured to progress of clientside sound synthesis techniques in order beyond textbased applications to facilitate wider to reduce the amount of resources needed for high modes of collaborative activity such as, network quality music on the web[6]. Their project wrapped musical performance and composition. When developing a software application one is faced Csound for use with a Tcl/TK (scripting language with technology decisions which limit the scope and its graphical widget library) based browser or for future development. Similarly, the choice of Tcl browser plugin. This allowed Csound to be one audio synthesis language or engine over used as a synthesis engine on the client side, thus another can limit the potential user base of the removing the amount of data being transferred application. This paper will describe how, through from client to server and moving the more the WADE system architecture it is possible to processor intensive task, of synthesising a Csound integrate existing software in a highly scalable and Score file, to the client. deployable way. The current incarnation of the This work was closely followed by a network WADE system, as depicted in the WADE enabled sound synthesis system created by James Examples section below, uses the Csound McCartney, (1996) in the guise of his synthesis engine and audio synthesis language as Supercollider synthesis project. More recent work its audio server. done on web enabling existing sound synthesis engines has been carried out by Jim Hearon[7] and Keywords Victor Lazzarini[8] (independently), using Csound Audiosynthesis, collaboration, education, web and Alonso, et al. in their creation of a Pure Data based, OSGi browser plugin [9]. The need for webenabled audio synthesis as a pedagogical tool or as a means 1 Introduction of offering high quality audio across low bandwidth networks can now be answered in new The Webenabled Audiosynthesis Development and interesting ways which can lead to unforeseen Environment, WADE, is a proof of concept future development projects. application designed to facilitate collaboration and education in audio synthesis development. While 1.2 Open Service Gateway Initiative (OSGi) the initial goal of this project was to investigate the The OSGi component architecture is a creation of a browser based user interface for the framework which sits on top of the Java virtual Csound[1] synthesis engine, research and machine. It is specifically designed to deal with technology decisions lead to the outlining of a many of the pitfalls of OOP and the way in which possible software architecture which was not tied software applications have historically been to any specific synthesis engine, or even to audio constructed. synthesis development itself. The application was developed using the Eclipse Rich Client 1.4 HTML + JavaScript Hyper Text Markup Language is the language used by web developers and web browsers to layout webpage content. While book publishing houses have been using markup annotations for many years, they do not have to contend with dynamic content changes such as those seen in web pages. JavaScript or ECMAScript is a scripting language supported by most web (fig.1 OSGi Model) At the heart of the OSGi (fig.1) ideology is the browsers that allows web developers to create bundle; a bundle provides a specific piece of more dynamic and interactive web pages. This functionality and advertises this functionality as a project extends the CodeMirror JavaScript code service to other bundles through a well defined editor[10] to enable parsing and syntax interface. As well as specifying the services they highlighting of Csound CSD files within the web provide, bundles must specify their dependencies browser. The JQuery [11] library and JQueryUI on other services/ bundles. This allows the OSGi JavaScript libraries were used to create the web service registry to determine whether a particular page user interface. bundle can be started. In the same vein, a bundle 1.5 Java Servlets can specify what functionality it can provide in circumstances when only some of its dependencies Java Servlets are Java classes which can be used are satisfied. It is also possible for bundles to to create and extend web based applications. They provide extension points, points at which one have access to a range of http calls and also the bundle can extend or override the functionality of Java APIs. In this particular application they are another bundle. used to provide the web facing interface for the This tolerance for dynamic service availability Csound synthesis engine. makes OSGi well suited for developing 2 WADE Architecture applications seeking to utilise web services and diverse hardware. In this specific project one of the underlying requirements is the reuse of existing software applications i.e. Csound and the Jetty http server; the ability to register these as separate services within the OSGi framework means that they can be implemented independently of the overall system, e.g. if future implementations wish to use a different audio synthesis engine they would simply have to provide an OSGi bundle for that synthesis engine, its complementary web interface bundle, and choose to use that engine over any preexisting one. 1.3 Eclipse RCP The Eclipse Rich Client Platform is a collection of OSGi bundles called a target platform. The RCP (fig.2 WADE Architecture) specific bundles allow developers to make In explanation of the fig. 2 above; the program contributions to an Eclipse GUI through extension runs within the JVM, on top of this runs the OSGi points, advertised by the Eclipse runtime’s framework which manages the bundle extension registry. configuration that provides functionality for both the frontend and the backend of the system. As all bundles are registered with the OSGi service registry it is possible for any bundle to request the functionality of another bundle. As such, the The code shown below is from the Csound API frontend and backend sections of the diagram are service bundle; it creates the aforementioned simply logical compartmentalisations for the objects, passing the CppSound object to the purposes of design thinking. CsoundPerformanceThread object and setting up The frontend contains the specific bundles the callback object for channel input and retrieving required to manage the GUI features of the console output messages. application and the backend contains the functionality desired by the project, e.g. the csoundObj= new CppSound(); synthesis engine, its servlet interface and the chanCaller = new CsChansetCB(csoundObj); chanCaller.SetOutputValueCallback(); servlet container which will serve the servlets chanCaller.SetMessageCallback(); when requested by the web browser. A benefit of csndSingleThread = new Thread(this); this configuration is that the applications csndSingleThread.start(); functionality can be extended independently of the user interface. When the servlet retrieves the csdElement OSGi enables dynamic service composition parameter from the HttpServletRequest object it through a number of mechanisms. One of these is passes this string value to the csnd object via the Declarative Services, which can be seen in the setCSDString function. Ultimately the PlayServlet class, where there is no Equinox createCSDFile function is called to create the specific code required. The component.xml file temporary .orc and .sco files from the csd string and the ServletComponent class are used by the and prepares the Csound object to run these. Equinox DS bundle to weave the services together at runtime. private void createCSDFile(String csdString){ if(csoundObj!=null && (!csdString.equalsIgnoreCase(""))) public class PlayServlet extends HttpServlet{... { CsoundFile csFile = csoundObj.getCsoundFile(); csFile.setCSD(csdString); The HTTP POST method needs to be csFile.setCommand(csOptionsString); implemented in order to accept the incoming csoundObj.PreCompile(); Csound file from the web editor. csFile.exportForPerformance(); csoundObj.compile(); public void doPost( csdFileString=""; HttpServletRequest req, csdFileCreated = true; HttpServletResponse resp){ } String csdString = (String) else{ req.getParameter("csdElement"); csdFileCreated = false; try { } if((csnd!=null)&&(!csdString.equalsIgnoreCase(""))){ } csnd.setCSDString(csdString); } While this prototype uses Csound as it's synthesis else{ engine, it is entirely possible to add OSC to allow resp.getWriter().write(csnd.getPlaying()?"true":"false"); } control of any OSC aware synthesis engine such } as, Pure Data or SuperCollider. catch(IOException e){ e.printStackTrace(); } } 2.1 Csound API As can be seen in the code excerpt above, the csnd object is used by the servlet. This object is created using the CppCsound interface and uses the CsoundPerformanceThread and CsoundCallbackWrapper classes to control real time operation of Csound. 3 WADE Examples made available to the sound synthesising community. The current version of this application is being tested with the Ubuntu 10.10 Linux distribution and the Google Chrome web browser. (fig.3 WADE Application window) (fig.5 WADE browserbased editor in Csound manual) Once the desktop application has started, the Above is an example of the oscil opcode reference “Welcome” view will be displayed, providing page from the Csound manual in HTML format. links to a number of pages informing you about the WADE application. Along the top of the 4 Future Developments application window you will see the obligatory Current refactoring efforts are underway to main toolbar, from which you can access the resolve issues in line with a first public release of preferences and console view. the system. Due to the integration of different open source technologies, the completed system and source code will likely be made available under the LGP licence, with the obvious caveat when integrating other technologies; that their respective licences are adhered to and that the use of these projects is acknowledged. The project releases and source code will be available from the WADE project page on Sourceforge: http://wadesys.sourceforge.net/. The features being assessed are as follows, the dynamic generation of a RESTful OSC [12] API on a per instrument basis, using Apache CXF [13]; dynamic GUI (fig. 4 WADE Browserbased Interface) slider bank generation; the inclusion of a HyperSQL database which could be used to store Next, access the webbased code editor with OSC packets for replaying a live performance; slider bank in your web browser (as you would any XMPP [14] chat client for realtime web page). Once the page has loaded, click the communication with other developers; XML “Csound Editor” and “Slider Bank” buttons to specification for instruments, including what show the editor and associated faders. You will graphical widgets should be used to display the note that Instrument 2 in the CSD file has two instrument. channels “volChan” and “pitchChan”; these are The provision for extensibility and deployment controlled by the faders in the slider bank window. options afforded by OSGi and the Eclipse Rich Press the “Play / Pause” button to send the CSD Client Platform could lead to the incorporation of file to the WADE desktop application for features in the areas of: networked musical rendering. It is possible to send live control performance, sound installation frameworks, information to the WADE desktop application via visual art development, cloud based audio the faders in the slider bank. synthesis and even pseudoembedded synthesis A pedagogical application of this system, could systems. In short, it is possible that future see an interactive Csound manual created, or a iterations of this project will be deployed on small large database of interactive Csound instruments form factor devices such as the BeagleBoard[15] Conference, The Web Revolution, pages 309– or PandaBoard[16], to create a Csound based 314. O’Reilly and Associates, Inc effects pedal, or across a number of large servers [7] Hearon J. 2009. Processing and csnd.jar. to provide a cloud synthesis solution. Csound Journal. 11 (5) -no page numbers. http://www.csounds.com/journal/issue11/Process 5 Conclusion ing.html The question of how to integrate these diverse [8] Lazzarini, V. 2006, 27-30 April. Scripting technologies lead to the identification of the OSGi Csound 5. Proceedings of the 4th Linux Audio framework, which in turn lead to a much greater Conference. consideration of the software architecture of the http://lac.zkm.de/2006/papers/lac2006_victor_la project. While it can be shown that systems zzarini.pdf designed for a specific task are more likely to be [9] Alonso, Marcos and Geiger, Gunter and Jorda, less bloated and in many cases better suited to that Sergi. “An Internet Browser Plug-in for Real- task than larger programs designed to address time Sound Synthesis using Pure Data.” In numerous concerns[17] it was concluded that by Proceedings, International Computer Music designing a system which facilitated future Conference, Miami, USA. International expansion and development, the long term goal of Computer Music Association. 2004 creating a system capable of delivering a complete http://www.dtic.upf.edu/~malonso/pdplugin/pdpl collaborative environment for audio synthesis uginICMC.pdf development, learning and performance would be [10] CodeMirror. 2010. http://codemirror.net/ best satisfied. [11] JQuery JavaScript Library. 2010. 6 Acknowledgements http://jquery.com/ [12] Freed, Schmeder and Zbyszynski. 2007. Open I would like to acknowledge the help I received Sound Control: A flexible protocol for sensor from the Csound mailing list, in particular I would networking. Presented at Maker Faire, San like to thank Jacob Joaquin, Michael Goggins, Mateo, CA, USA, 20th October 2007 Steven Yi and Victor Lazarini(Csound Mailing http://opensoundcontrol.org/files/OSC-Demo.pdf List); Dundalk Institute of Technology for their support of my research and finally, I wish to thank [13] Apache CXF. 2010. CXF User’s Guide the contributors of the Eclipse help wiki and Lars http://cxf.apache.org/docs/index.html Vogel for his Eclipse RCP programming tutorials. [14] Ignite Realtime. 2008. Smack API. http://www.igniterealtime.org/projects/smack/ References [15] BeagleBoard.org. 2010 [1] Vercoe B. et al. 2005. The Csound Reference http://beagleboard.org/ Manual. [16] PandaBoard.org. 2010 http://pandaboard.org/ http://www.csounds.com/manual/html/index.html [17] Samaai S. and Barnes J. 2007. Investigating [2] Eclipsepedia. 2010. Rich Client Platform. the effect of software bloat on users. http://wiki.eclipse.org/index.php/Rich_Client_Pl http://dk.cput.ac.za/cgi/viewcontent.cgi? atform filename=17&article=1004&context=inf_papers &type=additional [3] OSGi Alliance. 2010. Benefits of Using OSGi http://www.osgi.org/About/WhyOSGi [4]W3C. 1999. HTML4.01 Specification. http://www.w3.org/TR/html401/ [5] ECMAScript: The language of the web. 2010. http://www.ecmascript.org/index.php [6] van Ossenbruggen, J. and Eliens, A. 1995. Bringing music to the web. In Proceedings of the Fourth International World Wide Web