A Music Context for Teaching Introductory Computing Ananya Misra
Total Page:16
File Type:pdf, Size:1020Kb
Bryn Mawr College Scholarship, Research, and Creative Work at Bryn Mawr College Computer Science Faculty Research and Computer Science Scholarship 2009 A music context for teaching introductory computing Ananya Misra Doug Blank Bryn Mawr College, [email protected] Deepak Kumar Bryn Mawr College, [email protected] Let us know how access to this document benefits ouy . Follow this and additional works at: http://repository.brynmawr.edu/compsci_pubs Part of the Computer Sciences Commons Custom Citation Ananya Misra, Douglas Blank, and Deepak Kumar. A Music Context for Teaching Introductory Computing. ACM SIGCSE Bulletin - ITiCSE '09 41.3 (September 2009): 248-252. This paper is posted at Scholarship, Research, and Creative Work at Bryn Mawr College. http://repository.brynmawr.edu/compsci_pubs/52 For more information, please contact [email protected]. A Music Context for Teaching Introductory Computing Ananya Misra Douglas Blank Deepak Kumar Princeton University Bryn Mawr College Bryn Mawr College 35 Olden St. 101 N. Merion Ave. 101 N. Merion Ave. Princeton, NJ, USA Bryn Mawr, PA, USA Bryn Mawr, PA, USA [email protected] [email protected] [email protected] ABSTRACT programming language supports those goals. Contexts al- We describe myro.chuck, a Python module for controlling ready successfully explored at Bryn Mawr College include music synthesis, and its applications to teaching introduc- robotics as part of the Institute for Personal Robots in Ed- tory computer science. The module was built within the ucation (IPRE) initiative, and games [12, 1, 17]. In these Myro framework using the ChucK programming language, classes, creative tasks such as making the robot dance pro- and was used in an introductory computer science course vided the motivation to learn. Students used the Python- combining robots, graphics and music. The results sup- based Myro library (see Section 2.1) to control robots, cre- ported the value of music in engaging students and broad- ate graphics, and design games. We wanted to retain the ening their view of computer science. advantages of these tools and also present music as yet an- other context, taking a “the more, the merrier” perspective. Existing support for music in Myro included commands to Categories and Subject Descriptors make the robot or computer beep with specified frequencies K.3.2 [Computers and Education]: Computer and Infor- and durations, and to write songs composed of successive mation Science Education—computer science education beeps. However, programming music has wider scope, even at an introductory level. Thus, we sought richer music pro- General Terms gramming tools that would suit first-time programmers and complement and enhance the Myro framework. Design, Experimentation Existing work on teaching CS1 via sound or music includes the use of high-level Java MIDI implementations [11, 5], as Keywords well as sample-level sound synthesis in the Squeak environ- ment [8]. The Princeton Laptop Orchestra (PLOrk) teaches CS1, computer science, education, pedagogy, music, Python students to program music for live performance, exposing some computer science concepts while focusing on the end 1. INTRODUCTION product [15]. Musical composition has also contributed to Computers and music have a long association. Years ago, teaching more advanced topics, such as design patterns [9]. Ada Lovelace had hypothesized that the Analytical Engine Most of the existing pedagogical tools, however, use lan- “might compose elaborate and scientific pieces of music of guages other than Python; we hesitated to confuse novices any degree of complexity or extent” [6]. Although modern by teaching in multiple languages. While introductory ma- computers have realized this hypothesis in many ways, this terial based on media computing offer Python APIs to ma- aspect of computing is often invisible to introductory stu- nipulate sound [7], we also hoped to focus on the experience dents. However, given accessible tools, music can serve as of “creating music” rather than “processing sound”. a powerful means to engage students in introductory com- Current Python systems for synthesizing music include puter science courses (CS1), highlighting the creative as well an interface to the music programming language CSound as analytical sides of computing. Our goal was to introduce [2] and SWIG bindings to the music analysis and synthe- music as an application of computers and employ it to teach sis framework MARSYAS [13]. Python scripting to control computer science concepts to new students. sound synthesis is also available in the PySndObj module Many traditional CS1 courses are taught with the pro- [10]. These are excellent tools for computer musicians, but gramming language as the focus. We believe that students have not been designed for pedagogical purposes. CSound, learn better when the focus is a particular context, and the for instance, includes a potentially confusing distinction be- tween the score file and the orchestra file of a piece. PyS- ndObj and MARSYAS offer low-level control over sound synthesis, but do not offer a wide range of readymade instru- Permission to make digital or hard copies of all or part of this work for ments to play, as present in music programming languages personal or classroom use is granted without fee provided that copies are or in the Synthesis ToolKit (STK)[4]. not made or distributed for profit or commercial advantage and that copies Hence, we developed a Myro module for synthesizing mu- bear this notice and the full citation on the first page. To copy otherwise, to sic, offering a simple Python interface coherent with the rest republish, to post on servers or to redistribute to lists, requires prior specific of Myro, and outsourcing the synthesis to the real-time au- permission and/or a fee. ITiCSE’09, July 6–9, 2009, Paris, France. dio programming language ChucK [14]. The module was Copyright 2009 ACM 978-1-60558-381-5/09/07 ...$5.00. 248 deployed in a CS1 course at Bryn Mawr College. The rest myro.chuck of this paper describes the system, presents some code ex- ChucK Python OSC messages server amples and student feedback, and discusses the results. module 2. THE MYRO/CHUCK SYSTEM Synthesized Log The components and architecture of the Myro/ChucK sys- sound statements tem are described below, followed by a brief discussion of the support it provides for teaching computer science concepts. Front-end Terminal / 2.1 Myro Python Speakers command code window Myro is the name of the Python module developed by the Institute for Personal Robots in Education (IPRE). Myro was designed to allow introductory students to quickly and easily begin to explore interesting computational problems Figure 1: A diagram of the Myro/ChucK system. through simple, low-cost robots. Using imperative com- mands, students can explore programs that move a robot, read sensors, take pictures, and perform basic image pro- be further manipulated in specific ways. Thus, program- cessing on the resulting images. Myro supports a variety ming music supports the teaching of imperative program- of interfaces for exploring graphics, games, artificial intelli- ming, introduces the notion of objects and polymorphism, gence, and now music. and familiarizes students with Python object syntax. More abstractly, it continues the mapping between code and real- 2.2 ChucK life actions present in the rest of Myro. ChucK is a specialized audio programming language that Parallelism is another concept well-suited to study through allows precise control over audio synthesis, performance and music. Programmatically, parallelism could be implemented analysis, at any time granularity [14]. For our purposes, one via threads. However, rather than grappling with the tech- of its key strengths is that the audio synthesis takes place nical details of creating and managing threads for CS1 stu- in real-time. Since sound is produced while the ChucK code dents, we introduced a new programming construct: doTo- runs, it is also possible to modify the sound on-the-fly based gether(f1, f2, ...),wheref1, f2 are names of Python on input from external devices or programs, using message functions each individually controlling a single instrument. passing protocols. ChucK includes a set of built-in unit gen- doTogether, provided in the Myro library, takes care of man- erator objects that output different types of sounds. In par- aging and executing all functions in parallel threads. This ticular, it incorporates many of the instruments from STK way, we have managed to introduce the idea of parallelism [4], providing easy access to their parameters and output. to CS1 students as well as the notion of using functions as ChucK has been used extensively in PLOrk [15]. first class arguments. The name “doTogether” comes from a function of the same name, but different usage, in Alice 2.3 Putting them together [3]. We found that students also extended their use of this construct to control graphics and robot dances in parallel Combining Myro and ChucK in a student-friendly way with music synthesis. Myro includes several other similar involves several levels of translation (see Figure 1). A stu- programming constructs that were designed to facilitate be- dent’s Python code invokes functions and objects from a ginners to conceptualize computational ideas in the applica- special myro.chuck Python module. This module uses the tion context without succumbing to the often “dirty” details Open Sound Control (OSC) protocol [16], via the simpleOSC of their underlying implementation. API, to communicate with ChucK. Each function in the One of the greatest strengths of programming music in myro.chuck module sends out an OSC message with a spe- an introductory computer science class is that it provides cific label and value, containing all the information needed a broader perspective, early on, of what we can do with to update the sound synthesis appropriately. computers. The more possibilities offered, the better chance When myro.chuck is initialized, it starts running a sepa- students have to “bond” with computing.