Csound on the Web
Total Page:16
File Type:pdf, Size:1020Kb
Csound on the Web Victor LAZZARINI and Edward COSTELLO and Steven YI and John FITCH Department of Music National University of Ireland Maynooth, Ireland, [email protected], [email protected], [email protected], jpff@codemist.co.uk g Abstract 2 Audio Technologies for the Web This paper reports on two approaches to provide a The current state of audio systems for world- general-purpose audio programming support for web wide web applications is primarily based upon applications based on Csound. It reviews the cur- three technologies: Java1, Adobe Flash2, and rent state of web audio development, and discusses HTML5 Web Audio3. Of the three, Java is the some previous attempts at this. We then introduce oldest. Applications using Java are deployed via a Javascript version of Csound that has been crea- the web either as Applets4 or via Java Web ted using the Emscripten compiler, and discuss its Start5. Java as a platform for web applications features and limitations. In complement to this, we has lost popularity since its introduction, pri- look at a Native Client implementation of Csound, which is a fully-functional version of Csound running marily due to historically sluggish start-up ti- in Chrome and Chromium browsers. mes as well as concerns over security breaches. Also of concern is that major browser vendors have either completely disabled Applet loading Keywords or disabled them by default, and that NPAPI plugin support, with which the Java plugin for Music Programming Languages; Web Applications; browsers is implemented, is planned to be drop- ped in future browser versions6. While Java sees 1 Introduction strong support on the server-side and desktop, its future as a web-deployed application is te- The web browser has become an increasingly nuous at best and difficult to recommend for viable platform for the creation and distributi- future audio system development. on of various types of media computing appli- Adobe Flash as a platform has seen large- cations[Wyse and Subramanian, 2013]. It is no scale support across platforms and across brow- surprise that audio is an important part of these sers. Numerous large-scale applications have be- developments. For a good while now we have be- en developed such as AudioTool7, Patchwork8, en interested in the possibilities of deployment and Noteflight9. Flash developers can choose to of client-side Csound-based applications, in ad- deploy to the web using the Flash plugin, as dition to the already existing server-side capa- well as use Adobe Air10 to deploy to desktop bilities of the system. Such scenarios would be and mobile devices. While these applications de- ideal for various uses of Csound. For instance, monstrate what can be developed for the web in Education, we could see the easy deployment of Computer Music training software for all le- 1http://java.oracle.com vels, from secondary schools to third-level in- 2http://www.adobe.com/products/flashruntimes. html stitutions. For the researcher, web applications 3 can provide an easy means of creating proto- http://www.w3.org/TR/webaudio/ 4http://docs.oracle.com/javase/tutorial/ types and demonstrations. Composers and me- deployment/applet/index.html dia artists can also benefit from the wide reach 5http://docs.oracle.com/javase/tutorial/ of the internet to create portable works of art. deployment/webstart/index.html In summary, given the right conditions, Csound 6http://blog.chromium.org/2013/09/ can provide a solid and robust general-purpose saying-goodbye-to-our-old-friend-npapi.html 7http://www.audiotool.com/ audio development environment for a variety of 8http://www.patchwork-synth.com uses. In this paper, we report on the progress 9http://www.noteflight.com towards supporting these conditions. 10http://www.adobe.com/products/air.html using Flash, the Flash platform itself has a Csound on the server is Oeyvind Brandtsegg's number of drawbacks. The primary tools for VLBI Music 18, where Csound is running on the Flash development are closed-source, commer- server and publishes its audio output to an au- cial applications that are unavailable on Linux, dio stream that end users can listen to. A simi- though open source Flash compilers and IDEs lar architecture is found in [Johannes and To- do exist11. There has been a backlash against shihiro, 2013]. Since version 6.02, Csound also Flash in browsers, most famously by Steve Jobs includes a built-in server, that can be activa- and Apple12, and the technology stack as a who- ted through an option on start up. The server le has seen limited development with the gro- is able to receive code directly through UDP wing popularity of HTML5. At this time, Flash connections and compile them on the fly. may be a viable platform for building audio ap- Using Csound server-side has both positives plications, but the uncertain future makes it dif- and negatives that should be evaluated for a ficult to recommend. project's requirements. It can be appropriate to Finally, HTML5 Web Audio is the most re- use if the project's design calls for a single audio cent of technologies for web audio applications. stream/Csound instance that is shared by all Examples include the \Recreating the sounds of listeners. In this case, users might interact with the BBC Radiophonic Workshop using the Web the audio system over the web, at the expen- Audio API" site13, Gibberish14, and WebPd15. se of network latency. Using multiple realtime Unlike Java or Flash, which are implemented Csound instances, as would be the case if there as browser plug-ins, the Web Audio API is a was one per user, would certainly be taxing for W3C proposed standard that is implemented by a single server and would require careful resour- the browser itself.16 Having built-in support for ce limiting. For multiple non-realtime Csound Audio removes the security issues and concerns instances, as in the case of NetCsound, multi- over the future of plug-ins that affect Java and ple jobs may be scheduled and batch processed Flash. However, the Web Audio API has limita- with less problems than with realtime systems, tions that will be explored further below in the though resource management is still a concern. section on Emscripten. An early project to employ client-side audio computation by Csound was described in [Casey 3 Csound-based Web Application and Smaragdis, 1996], where a sound and music Design description system was proposed for the rende- Csound is a music synthesis system that has ring of network-supplied data streams. A possi- roots in the very earliest history of computer bly more flexible way to use Csound in client- music. Csound use in Desktop and Mobile app- side applications, however, is to use the web lications has been discussed previously in [Laz- browser as a platform. Two attempts at this ha- zarini et al., 2012b], [Yi and Lazzarini, 2012], ve been made in the past. The first was the now- and [Lazzarini et al., 2012a]. defunct ActiveX Csound (also known as AXC- 19 Prior to the technologies presented this pa- sound) , which allowed embedding Csound into per, Csound-based web applications have em- a webpage as an ActiveX Object. This technolo- ployed Csound mostly on the server-side. For gy is no longer maintained and was only availa- example, NetCsound 17 allows sending a CSD ble for use on Windows with Internet Explo- file to the server, where it would render the rer. A second attempt was made in the Mobile project to disk and email the user a link to Csound Project[Lazzarini et al., 2012b], where a the rendered file when complete. Another use of proof-of-concept Csound-based application was developed with Java and deployed using Java 11http://www.flashdevelop.org/ Web Start, achieving client-side Csound use via 12http://www.apple.com/hotnews/ the browser. However, the technology required thoughts-on-flash/ special permissions to run on the client side and 13 http://webaudio.prototyping.bbc.co.uk/ required Java to be installed. Due to those issu- 14Available at https://github.com/ charlieroberts/Gibberish, discussed in [Roberts es and the unsure future of Java over the web, et al., 2013] 15https://github.com/sebpiq/WebPd 18http://www.researchcatalogue.net/view/55360/ 16http://caniuse.com/audio-api lists current brow- 55361 sers that support the Web Audio API 19We were unable to find a copy of this online, but one 17Available at http://dream.cs.bath.ac.uk/ is available from the CD-ROM included with [Boulanger, netcsound/, discussed in [ffitch et al., 2007] 2000] the solution was not further explored. semantic emulation in order to achieve the best The two systems described in this paper are execution performance [Zakai, 2011]. browser-based solutions that run on the client- Implementations of the C and C++ runti- side. The both share the following benefits: me libraries have been created for applicati- ons compiled with Emscripten. These allow pro- • Csound has a large array of signal proces- grams written in C/C++ to transparently per- sing opcodes made immediately available form common tasks such as using the file sys- to web-based projects. tem, allocating memory and printing to the con- • They are compiled using the same source sole. Emscripten allows a virtual filesystem to code as is used for the desktop and mo- be created using its FS library, which is used 21 bile version of Csound. They only require by Emscripten's libc and libcxx for file I/O . recompiling to keep them in sync with the Files can be added or removed from the virtual latest Csound features and bug fixes. filesystem using Javascript helper functions.