JunctionBox for Android: An Interaction Toolkit for Android-based Mobile Devices Lawrence FYFE Adam TINDALE Sheelagh CARPENDALE InnoVis Group Alberta College of InnoVis Group University of Calgary Art + Design University of Calgary 2500 University Drive NW 1407 14 Avenue NW 2500 University Drive NW Calgary, AB T2N 1N4 Calgary, AB T2N 4R3 Calgary, AB T2N 1N4 Canada Canada Canada [email protected] [email protected] [email protected] Abstract computers, can be made easier by a toolkit that putscommonlyusedorrepetitivelycodedfeatures JunctionBox is an interaction toolkit specifically de- signed for building multi-touch sound control inter- into a single place for reuse. faces. The toolkit allows developers to build inter- JunctionBox is an interaction toolkit for build- facesforAndroidmobiledevices,includingphonesand ing sound control interfaces that addresses this tablets. Those devices can then be used to remotely scenario. The toolkit is written in Java and is de- control any sound engine via OSC messaging. While signedasalibraryfortheProcessingdevelopment the toolkit makes many aspects of interface develop- menteasy, thetoolkitisdesignedtoofferconsiderable environment [Reas and Fry, 2006]. JunctionBox power to developers looking to build novel interfaces. bridgestheinteractiongapbetweenthevisualde- sign possibilities offered by Processing and the Keywords sound control possibilities afforded by the Open Android, OSC, mobile, interaction, toolkit. Sound Control (OSC) protocol [Wright, 2005]. Figure1showshowJunctionBoxrelatesthesetwo 1 Introduction functions. It does this by handling touch inter- The Android operating system [Google, 2012a], actions and by making it easy for developers to developed by Google Inc., runs on a wide variety map those interactions to OSC messages (via the of mobile devices, including phones and tablets. JavaOSC library [Ramakrishnan, 2003]). Junc- With the easy availability of these devices, it be- tionBox has mapping features that are described comes desirable to develop sound and music ap- indetailinanearlierpaperbythecurrentauthors plications for them. ([Fyfe et al., 2011]). One application scenario involves using inter- faces to control sound in which the interface is onecomputerandthesoundgeneratorisanother. The advantage of this scenario is that the quality oftheaudioonmobiledeviceswilllikelynotbeas good as with combinations of audio interface and speakersinwhichbotharedesignedtoprovidethe highestqualityaudioexperience. Anotherrelated advantage is the possibility of multi-channel sce- narios that go beyond the two channels available on portable devices. For example, an Android device would handle input by a performer, with the option of project- ing the interface, while another computer handles all sound processing. This is not a hypothetical scenario but is the current musical practice of the Figure 1: How JunctionBox serves as a hub for first author. With this kind of scenario, certain both sound and visuals. aspects of development, like messaging between 2 Background Other toolkits exist that have features similar to that of JunctionBox. The MT4J toolkit [Laufs et al., 2010] has many features for multi-touch in- teraction building and is available for use with Android. However, MT4J, lacks the OSC map- ping capabilities that make JunctionBox a toolkit forbuildingsoundandmusiccontrolapplications. TouchOSC [hexler.net, 2012] offers functionality Figure 2: JunctionBox/Android internals with that is similar to what is offered by JunctionBox classes shown as boxes with solid lines. in which widgets can be mapped to custom OSC messages. Widgets include faders, push buttons DifferencesinusingtheDispatcherincodehave androtarycontrolsandothersthat areareskeuo- beenminimizedwithbothversionsusingthesame morphs of controls for physical hardware devices code for construction. A new Dispatcher will like mixers. take four arguments: the width and height of the Insteadofsimplyofferingwidgets,JunctionBox screen/touch interface and a socket destination isafull-fledgeddevelopmenttoolkitthatismeant for OSC messages. The following code constructs to be used by developers who are not necessar- a new Dispatcher object: ily interested in skeuomorphs. The JunctionBox Dispatcher dispatcher = new Dispatcher( approach to interaction design can be summed screenWidth, up as BYOW, for build your own widgets. The screenHeight, focus of JunctionBox is to provide functionality "192.168.1.1", 7000); like OSC message mapping while offering the full range of visual design options available via Pro- All code written for the standard version of cessing. This approach to toolkit design is meant JunctionBox will work with Android with the to encourage greater creativity in the design of addition of a single method made available in both interactions and interfaces. the Android Dispatcher class. The additional method, handleMotionEvent(), gets touch infor- 3 JunctionBox for Android mation from the MotionEvent class. The Dis- The original version of the JunctionBox toolkit patcher’shandleMotionEvent()methodisutilized was not developed for Android. However, since it by creating a dispatchTouchEvent() method in was written in Java, porting to Android did not the code for the Processing sketch: require a complete rewrite of the existing code. boolean dispatchTouchEvent(MotionEvent ev) { The main difference between the standard Java dispatcher.handleMotionEvent(ev); version and the Android version of JunctionBox return true; } is that TUIO [Kaltenbrunner et al., 2005] is not needed on the Android version since Android de- While only a single additional method is re- vices have a separate system for handling touch quiredfortheAndroidversionofJunctionBox,in- interactions. Android-basedsystemsgettouchin- ternally an important difference in touch location formation via handling the data contained in the handlingisthatTUIOtouchtrackingdataisnor- MotionEvent class [Google, 2012b]. malized relative to the size of the interface while Both versions of JunctionBox contain a Dis- for Android devices, touch position is absolute. patcher class that is responsible for handling This difference is made transparent to the devel- touch interactions that ultimately get mapped to oper and the same code will work in both systems OSC messages for controlling audio. Figure 2 with only one minor change, the addition of the shows the relationship of the MotionEvent class new handleMotionEvent() method. Making dif- to JunctionBox classes including the Dispatcher. ferences like this transparent is part of the Junc- The mapping process is exactly the same for both tionBox approach of making development easier the standard version of JunctionBox and the An- without taking away the ability to build highly droid version. customized interfaces. 4 Interfaces The first author of this paper wrote the code for JunctionBox not only to provide the community with a toolkit for creating networked instruments but for his own performance practice. That prac- tice currently consists of the building of touch in- terfacesforAndroiddevicesthatruntheinterface to handle touch input. That interface then com- municates with another computer running audio viaOSC.Theaudiocomputerusedtodevelopthe following interfaces runs Ubuntu Linux, JACK and Pd. Figure 3: The Orrerator interface with the first 4.1 Orrerator and third planets active and playing. The Orrerator interface has widget-like controls but with a much more stylized appearance. It is white and half black. The black tiles feature re- designed both as a general instrument that could versed numbers 1-5. Each of the tiles can be be used for a variety of pieces but also specifically moved anywhere in the interface with a single for the composition by the first author entitled touch. When the tiles are moved into the tar- Sol Aur. get in the center of the interface and the touch The metaphor for the Orrerator is the Orrery is released, a sound file corresponding to that tile oramodelofthesolarsystem, asshowninFigure number is played. Reversed tiles play the same 3. The sound engine controlled by the Orrerator sound reversed. Figure 4 shows the tiles and the is written in Pd and features four FM oscillators. target. Sound files play until either they have Theinterfacehasfourplanetbuttonsthatlightup reached the end of the file or if a touch is ap- when toggled by simply touching the particular plied while playing. This allows the sounds to be planet. Each planet button turns a single FM paused and moved across the target. oscillator on or off. In addition to on or off controls, each planet button can be rotated around its orbit by touch- ing the orbit area and rotating it around the cen- ter. Orbit areas look increasingly lighter towards the inner planet. This change of rotation will de- tune that particular FM oscillator from its base frequencybyafactorofbetweenoneandtwowith the starting vertical position being one and a full rotation back to that same position being two. Orbital rotations are limited to 360 degrees from the starting position. On the left and right edges of the interface are two sliders: the left slider changes the index of modulation and the modulation frequency and Figure 4: The Distance 2 interface with tile 2 in the right slider changes the gain of all four os- the center set to play at normal rate. cillators. Tiles placed in the very center of the target are 4.2 Distance2 played back at normal playback rate. Tiles in the The Distance2 interface is designed specifically next circle out play at half that rate. The next for a composition entitled Distance 2 (Toshi circle plays at one-third rate and the outermost Ichiyanagi) by the first author. It features ten circle plays at one-quarter rate. If a tile is paused tiles numbered 1-5 with half of the tiles being by touch and moved from one target circle to an- other,thesoundwillpauseandresumeatthenew References playback rate. Lawrence Fyfe, Adam Tindale, and Sheelagh Tiles placed in the circle but on the left of the Carpendale. 2011. Junctionbox: A toolkit for verticaldividinglineplayintheleftchannelwhile creating multi-touch sound control interfaces. tiles on the right side play in the right channel. In Proceedings of the Conference on New Inter- Tiles placed in the center (normal rate) play in faces for Musical Expression, pages 276–279. the center of the stereo field. Google. 2012a. Android. http://developer. The sound engine for this piece is written in Pd android.com/index.html. withacustomfileplaybackcontrolmechanismde- signedbythefirstauthor. The5soundfilesareall Google. 2012b. Motionevent. http: various recorded clips from an interview with ex- //developer.android.com/reference/ perimental composer Toshi Ichiyanagi. Distance android/view/MotionEvent.html. 2, the piece, is based on a piece by Ichiyanagi hexler.net. 2012. Touchosc. http://hexler. called Distance [Ichiyanagi, 1961] in which the net/software/touchosc. performer must be at least three meters away from his or her instrument while playing. In a Toshi Ichiyanagi. 1961. Distance. time of computer music in which wireless net- Martin Kaltenbrunner, Till Bovermann, Ross working makes this kind of setup trivial, the no- Bencina, and Enrico Costanza. 2005. Tuio - a tion of distance can be explored in other ways. In protocol for table-top tangible user interfaces. the context of the piece, distance from the center In Proceedings of the 6th International Work- of the target represents the recognizbility of the shop on Gesture in Human-Computer Interac- recorded clips with the clips getting further away tion and Simulation. fromtheoriginalasthetilesgetfurtherawayfrom the center. Uwe Laufs, Christopher Ruff, and Jan Zibuschka. 2010. Mt4j-across-platformmulti- 5 Summary touch development. In Proceedings of the 2nd ACM SIGCHI symposium on Engineering in- Bringing the JunctionBox toolkit to the Android teractive computing systems, EICS ’10, New operatingsystemallowsdeveloperstobuildsound York, NY, USA. ACM. and music control interfaces on an increasing ar- Chandrasekhar Ramakrishnan. 2003. Javaosc. ray of touch devices. With a focus on inter- http://www.illposed.com/software/ face coding rather than providing pre-built wid- javaoscdoc/. gets,JunctionBoxprovidesdeveloperswithanop- portunity to create new touch-based interactions CaseyReasandBenFry.2006.Processing: pro- with highly customized visuals. Two example in- gramming for the media arts. AI & Society, terfaces, the Orrerator and Distance2, show some 20(4):526–538. of the creative interfaces that can be built using Matthew Wright. 2005. Open sound control: the toolkit. an enabling technology for musical networking. Organised Sound, 10(3):193–200. 6 Acknowledgements WewouldliketothanktheAlbertaCollegeofArt + Design, the Canada Council for the Arts, the Natural Science and Engineering Research Coun- cil of Canada, SMART Technologies, the Cana- dian Foundation for Innovation, and the Alberta Association of Colleges and Technical Institutes for research support. We would also like to thank the members of the Interactions Lab at the Uni- versityofCalgaryforfeedbackandsupportduring the development of this project.