Teaching Sound Synthesis in C/C ++ on the Raspberry Pi

Teaching Sound Synthesis in C/C ++ on the Raspberry Pi

Teaching Sound Synthesis in C=C++ on the Raspberry Pi Henrik von Coler and David Runge Audio Communication Group, TU Berlin [email protected] [email protected] Abstract added, they are not considered for exploring ap- For a sound synthesis programming class in C/C++, plied sound synthesis algorithms in this class. a Raspberry Pi 3 was used as runtime and develop- In a more application-based context, graphi- ment system. The embedded system was equipped cal programming environments like Pure Data with an Arch Linux ARM, a collection of libraries (Pd), MAX MSP or others would be the first for sound processing and interfacing, as well as with choice. They allow rapid progress and interme- basic examples. All material used in and created diate results. However, they are not the best for the class is freely available in public git reposito- platform to enhance the knowledge of sound ries. After a unit of theory on sound synthesis and Linux system basics, students worked on projects synthesis algorithms on a sample-wise level by in groups. This paper is a progress report, point- nature. ing out benefits and drawbacks after the first run of the seminar. The concept delivered a system with C/C++ delivers a reasonable compromise be- acceptable capabilities and latencies at a low price. tween low level access and the comfort of using Usability and robustness, however, need to be im- available libraries for easy interfacing with hard- proved in future attempts. ware. For using C/C++ in the development of sound synthesis software, a software devel- Keywords opment kit (SDK) or application programming Jack, Raspberry Pi, C/C++ Programming, Educa- interface (API) is needed in order to offer access tion, Sound Synthesis, MIDI, OSC, Arch Linux to the audio hardware. Digital audio workstations (DAW) use plug- 1 Introduction ins programmed with SDKs and APIs like Stein- The goal of the seminar outlined in this pa- berg's VST, Apple's Audio Units, Digidesign's per was to enable students with different back- RTAS, the Linux Audio Developer's Simple grounds and programming skills the develop- Plugin API (LADSPA) and its successor LV2, ment of standalone real-time sound synthesis which offer quick access to developing audio projects. Such a class on the programming synthesis and processing units. A plugin-host of sound synthesis algorithms is, among other is necessary to run the resulting programs and things, defined by the desired level of depth in the structure is predefined by the chosen plat- signal processing. It may convey an application- form. The JUCE framework [34] offers the oriented overview or a closer look at algorithms possibility of developing cross platform applica- on a sample-wise signal processing level, as in tions with many builtin features. Build targets this case. Based on this decision, the choice can be audio-plugins for different systems and of tools, respectively the programming environ- standalone applications, including Jack clients, ment should be made. which would present an alternative to the cho- sen approach. Script languages like Matlab or Python are Another possibility is the programming of widely used among students and offer a comfort- Pd externals in the C programming language able environment, especially for students with- with the advantage of quick merging of the self- out a background in computer science. They programmed components with existing Pd in- are well suited for teaching fundamentals and ternals. FAUST [6] also provides means for cre- theoretical aspects of signal processing due to ating various types of audio plugins and stan- advanced possibilities of debugging and visual- dalone applications. Due to a lack in functional isation. Although real-time capabilities can be programming background it was not chosen. For various reasons we settled for the Jack Unfortunately the on-board audio interface API [18] to develop command line programs on of the Raspberry Pi could not be configured a Linux system. for real-time audio applications. It does not feature an input and the Jack server could • Jack clients are used in the research on bin- only be started with high latencies. After try- aural synthesis and sound field synthesis, ing several interfaces, a Renkforce USB-Audio- for example by the WONDER interface [15] Adapter was chosen, since it delivered an ac- or the SoundScape Renderer [14]. Results ceptable performance at a price of 10 e. The of the projects might thus be potentially Jack server did perform better with other inter- integrated into existing contexts. faces, yet at a higher price and with a larger • Jack clients offer quick connection to other housing. clients, making them as modular as audio- Students were equipped with MIDI interfaces plugins in a DAW. from the stock of the research group and private • The Jack API is easy to use, even for be- devices. The complete cost for one system, in- ginners. Once the main processing func- cluding the Raspberry Pi 3 with housing, SD tion is understood, students can immedi- card, power adapter and the audio interface, ately start inserting their own code. were thus kept at about 70 e(vs. the integrated low-latency platform bela[5], that still ranks at • The omission of a graphical user interface around 120 eper unit). for the application leaves more space for focusing on the audio-related problems. 2.2 Operating System • The proposed environment is independent of proprietary components. First tests on the embedded system involved Raspbian [12], as it is highly integrated and has a graphical environment preinstalled, that A main objective of the seminar was to equip eases the use for beginners. Integration with the students with completely identical systems the libraries used for the course proved to be for development. This avoids troubles in han- more complicated however, as they needed to dling different operating systems and hardware be added to the software repository for the ex- configurations. Since no suitable computer pool amples. was available, we aimed at providing a set of machines as cheap as possible for developing, A more holistic approach, integrating the op- compiling and running the applications. The erating system, was aimed at, in order to leave students were thus provided with a Raspberry as few dependencies on the students' side as pos- Pi 3 in groups of two. Besides being one of the sible and not having to deal with the hosting of cheapest development systems, it offers the ad- a custom repository of packages for Raspbian. vantage of resulting in a highly portable, quasi Due to previous experience with low latency se- embedded synthesizer for the actual use in live tups using Arch Linux [7], Arch Linux ARM applications. [2] was chosen. With its package manager pac- man [9] and the Arch Build System [1] an easy The remainder of this paper is organized as system-wide integration of all used libraries and follows: Section 2 introduces the used hard- and software was achieved by providing them as pre- software, as well as the infrastructure. Section 3 installed packages (with them either being avail- presents the concept of the seminar. Section 4 able in the standard repositories, or the Arch briefly summarizes the experiences and evalu- User Repository[3]). Using Arch Linux ARM, ates the concept. it was also possible to guarantee a systemd [13] 2 Technical Outline based startup of the needed components, which is further described in Section 2.5. At the time 2.1 Hardware of preparation for the course, the 64bit vari- A Raspberry Pi 3 was used as development ant (AArch64) - using the mainline kernel - was and runtime system. The most recent version not available yet. At the time of writing it is at that time was equipped with 1.2GHz 64-bit still considered experimental, as some vendor quad-core ARMv8 CPU, 802.11n Wireless LAN, libraries are not yet available for it. Instead the a Bluetooth adapter, 1GB RAM, 4 USB ports ARMv7 variant of the installation image was 40 GPIO pins and various other features [11]. used, which is the default for Raspberry Pi 2. 2.3 Libraries As these settings were not realizable with the All libraries installed on the system are listed internal audio card, the snd-bcm2835 module - in Tab. 1. For communicating with the au- the driver in use for it - was blacklisted using dio hardware, the Jack API was installed. The /etc/modprobe.d/*, to not use the sound device jackcpp framework adds a C++ interface to at all. Jack. Additional libraries allowed the handling For automatic start of the low-latency au- of audio file formats, ALSA-MIDI interfacing, dio server and its clients, systemd user ser- Open Sound Control, configuration files and vices were introduced, that follow a user session Fast Fourier Transforms. based setup. The session of the main system user is started automatically as per systemd's [email protected]. This is achieved by enabling the Table 1: Libraries installed on the development linger status of said user with the help of loginctl system [8], which activates its session during boot and Library Ref. Purpose starts its enabled services. jack2 [18] Jack audio API A specialized systemd user service [30] allows jackcpp [26] C++ wrapper for jack2 for Jack's startup with an elevated CPU sched- uler without the use of dbus [21]. The stu- sndfile [19] Read and write audio files dents' projects could be automatically started rtmidi [32] Connect to MIDI devices as user services, that rely on the audio server liblo [23] OSC support being started by enabling services such as this example: yaml [20] Configuration files [ Unit ] fftw3 [22] Fourier transform Description=Example project boost [4] Various applications After=jack@rpi-usb-44100.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    5 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us