Live Coding
Rocking Out In Ruby - A Playful Introduction to Sonic Pi

Summarized using AI

Rocking Out In Ruby - A Playful Introduction to Sonic Pi

Xavier Riley • March 11, 2016 • Bath, UK

Summary of "Rocking Out In Ruby - A Playful Introduction to Sonic Pi"

In this presentation, Xavier Riley introduces Sonic Pi, a programming environment that allows users to create music with code, particularly using the Ruby language. He reflects on the joy of programming and emphasizes the importance of making that experience accessible to everyone, especially children.

Key Points:

  • Initial Experience in Programming: Riley encourages the audience to recall their first joyful experience in programming, highlighting its significance as motivation.
  • Introduction of Sonic Pi:
    • Sonic Pi combines Ruby with music synthesis and is a free, open-source application available on multiple platforms, including pre-installed on Raspberry Pi.
    • Developed with the intention to provide an engaging introduction to coding for children.
  • Overview of Sonic Pi API:
    • The API consists of synths, samples, effects, and sequencing, all of which are simple enough for young learners.
    • Simple commands like play and sleep allow for quick musical experimentation and engagement.
  • Educational Impact:
    • Sonic Pi has been implemented in educational settings, allowing students to create music easily while learning programming concepts.
    • Riley emphasizes the approachable design of Sonic Pi, influenced by the simplicity of the Logo programming language.
  • Hands-on Examples:
    • Riley demonstrates coding commands in Sonic Pi, showing how to manipulate sounds and offer students a creative outlet.
    • He discusses the flexibility of samples and effects and highlights the feature of live coding for real-time musical creation.
  • Integration of Advanced Programming Concepts:
    • The potential to use Ruby’s functionalities for complex projects, such as building a sampler, illustrates how Sonic Pi can bridge music creation and programming skills.
  • Community and Collaboration:
    • Riley encourages collaboration and participation in initiatives that promote coding education, particularly targeting underrepresented groups in tech.

Conclusion:

Riley concludes by reinforcing the idea that coding is becoming essential in various fields and should be a fundamental skill taught to all children. He invites the audience to explore Sonic Pi as a means of fostering creativity in music and coding. This video serves as both a technical introduction to Sonic Pi and an inspirational call to action for broader programming education.

Rocking Out In Ruby - A Playful Introduction to Sonic Pi
Xavier Riley • March 11, 2016 • Bath, UK

Rocking Out In Ruby - A Playful Introduction to Sonic PI by Xavier Riley

Help us caption & translate this video!

http://amara.org/v/IG11/

BathRuby 2016

00:00:17.520 Okay, hello! I’d like you to indulge me for just a second. I'd like you to cast your mind back and think about the first time that you enjoyed programming. I'll give everyone a moment to think. If you're anything like me, it probably was a moment where you were typing in some code you didn't quite understand, thinking, ‘Yeah, this is going to be great!’ and then suddenly, you hit run, and it worked. It’s a feeling of joy, right? In my case, I probably ran around the room with my hands in the air, exclaiming, 'Oh my God, I can't believe it worked!' That's an important feeling, one that everyone encounters at some point in their coding journey, and it's a crucial source of motivation on the path to becoming a programmer.
00:00:58.920 So the question I pose is: how can we ensure that the maximum number of people have that experience at least once? After all, they should have the choice to say, ‘You know what? I do enjoy this! I am going to pursue a career in programming.’ Today, I’m going to discuss an attempt to answer that question through a tool called Sonic Pi. For those of you unfamiliar with it, Sonic Pi is a program that combines Ruby with synthesis to allow you to create music with code.
00:01:44.399 Before we dive into it, let's outline what we are going to cover today. First, I’ll introduce you to the bare bones of Sonic Pi's API, which is a small API—nothing like Rails, so there's no need to worry! It can be covered in about ten minutes. Then, I’ll showcase some examples of what people have been creating with Sonic Pi and share some of my own experiments.
00:02:02.640 Finally, we’ll discuss how Sonic Pi relates to education. To start, it’s important to note that Sonic Pi is a free, open-source project that you can download as an application. It’s cross-platform, working on Windows, OSX, and Linux. Additionally, it’s pre-installed on every Raspberry Pi. The reason for its name is that the Raspberry Pi Foundation sponsored its development to provide children who buy a Raspberry Pi for around 25 quid something tangible to do with it. Having sold 8 million Raspberry Pis, there’s a lot of potential for Sonic Pi to be people's positive first introduction to music making.
00:02:54.920 Now, let's look at the Sonic Pi API, which can be broken down into four parts: synths, samples, effects, and sequencing. We’ll delve into each of these areas. First up, let’s see what we can do. Year five students in a computer science class often start their journey here, and teachers can feel nervous if they're unsure about the material.
00:03:14.879 So, here we have our first program: ‘play 60’. This is written in Ruby. If I type `puts Ruby version`, we have a little console on the right, and you immediately get feedback with a nice beep. The first thing the kids usually do is experiment and see what happens if they try various inputs, leading to a delightful discovery. Even if it sounds a bit chaotic, this simplicity and flexibility mean kids can start making music quickly, which is very important for their engagement.
00:04:12.079 The creator of Sonic Pi, Sam Aaron, was inspired by Logo, aiming for a straightforward paradigm. The rule we follow with the Sonic Pi API is that if a 10-year-old can't use and understand it, then it doesn’t belong in the API. It’s a gold-standard approach that could inspire future web frameworks. We also have the play command, and you can experiment with floating-point numbers and note names like 'C' and 'D'. Fun! Now, let’s perform our first tune. Everyone knows ‘Faka,’ right?
00:05:17.560 So we can figure out the notes to play, but oh no, they all play simultaneously! This is actually intentional—it’s a feature, not a bug. With just two commands, ‘play’ and ‘sleep’, you can create captivating musical outputs. The interesting aspect is that with our flexible pitch and timing systems, you can represent most Western music using just these two commands, which provides a powerful level of abstraction.
00:06:09.400 Right now, it sounds a bit limited since we’re just using beeps. Let’s try playing a classic synthesizer sound. Sonic Pi comes predefined with some synthesizers, but the most exciting part is that you can modify parameters. For example, using a release of two means the sound lasts for two seconds. That's all we need to know about synths; let’s delve into samples.
00:06:57.640 Samples are really flexible in musical situations and can add immense value with minimal code. If you want a well-known sample, the ‘Amen break’ is a classic. Since it’s a loop, we’ll want to sleep for the sample's duration. The Year Five students understand this. They're enthusiastic and instinctively want to turn it into a rave! However, using sample duration might limit creativity, which is why we prefer to use sample BPM. This scales the current tempo to match any sample you provide.
00:08:29.080 With Sonic Pi, samples can be played at various speeds, allowing exploration and fun. You can also specify start and end times for your samples, which can be incredibly engaging as you explore musical creativity. Let's experiment with first snippets to see the results.
00:09:00.160 In addition to samples, effects are crucial in music. Sonic Pi offers built-in effects, allowing users to apply reverb, among others. Applied to our samples, the effects drastically enhance the experience. Live coding is another compelling aspect where the timing system allows users to create real-time music, keeping everything synchronized and engaging.
00:10:16.920 Speaking of live coding, there’s a construct called a ‘live loop’ that makes a significant impact. It allows for threading, so you can redefine parts and have them stay in sync. It's a practical way of making music in real time, and I find it endlessly exciting. You can dynamically tweak your sounds, beat by beat.
00:10:57.720 Once you start working with live loops, the possibilities become endless. With a multi-threaded structure, you can run multiple threads in time, enhancing the musical programming experience. When I began using Sonic Pi, I had a programming background, but I found it so intuitive and exciting to create music through Ruby.
00:11:51.480 The ability to combine my knowledge of programming with music has led to countless experiments. While there’s much more to explore within the Sonic Pi API, it’s crucial to understand there’s built-in documentation available. There’s about 3,000 words of tutorials to guide you through every step if you wish to try it yourself or teach it to your kids.
00:12:36.999 Let’s take a look at an example from the help directory. This showcases how quickly you can create something engaging using the commands you’ve just learned. Many students have successfully used projects like these in their classrooms, and seeing them enjoy it is heartwarming.
00:13:34.960 Now, you might wonder how Ruby ties into all this. You have all the power of Ruby at your disposal, which will be particularly helpful for creating advanced applications. As an example, I wanted to build a sampler that could slice samples—a task that took me months previously using other environments. Now, I can accomplish similar results in Ruby much faster, effectively utilizing Ruby's range, methods, and enumerations.
00:14:28.320 Through this, I've been able to tackle musical challenges using Ruby, which ultimately sharpens programming skills while creating something fun. The concept of working with slices, collecting them, and playing them back allows for endless experimentation.
00:15:47.680 The ability to use any sound file on your system opens up more creative possibilities—like utilizing popular music samples and modifying them to create something new. You can blend sound effects with live coding, which is immensely satisfying. The exciting take here is that you’re not bounded by expensive hardware or complex setups when you can produce amazing results with just a few lines of code.
00:16:47.080 As I delve deeper into the nuances of Sonic Pi, I have enjoyed incorporating authentic sounds from classic gaming, bringing fun elements to my code. This, combined with colorful programming, shows the delightful intersection between music and technology.
00:17:45.320 The creative potential here is vast. You might recall my mention about Markov Chains earlier. With Sonic Pi's API, a community project introduced a Markov Chain generation feature, enabling users to create unique compositions based on simple input. The implementation is simple yet extends the expressive capabilities of music.
00:18:32.160 Hopefully, I've given you clear insights into what you can create with Sonic Pi. The challenging concept of live coding allows you to meld music creation with programming, enabling real-time interaction with your code and dynamic expression.
00:19:35.360 Returning to the aspect of creating compelling musical results without reliance on dedicated hardware highlights how Sonic Pi democratizes musical technology; anyone with basic coding skills can explore and create. I've been using it regularly, refining my skills while having tons of fun.
00:20:28.480 Now, I want to encourage all of you to explore Sonic Pi. It can be an enjoyable, engaging experience for families sharing creative moments together. Imagine explaining your work to your parents and actually sharing your passion with them—it could be a game-changer!
00:21:27.200 Before I wrap up, I want to extend my gratitude for everyone who made today possible, especially BathRuby. Thank you all for being such a wonderful audience! If anyone has questions about Sonic Pi, Ruby, or collaboration, feel free to find me afterward.
00:22:29.320 To conclude, I invite you all to join me in the fun part of the session. We'll dive into some rocking out of the music! Thank you very much. Hi, everybody!
00:23:18.960 As we step into a period of remarkable change impacting how we live and work, it's essential for workers to develop skills to succeed in an evolving economy. We must ensure everyone has a fair shot at succeeding in this new landscape, and that starts with education.
00:24:33.759 The goal is to equip all children with the skills they need for future jobs—fostering analytical and coding abilities for a thriving innovation economy. Today's mechanic isn't just changing oil under cars; they're managing sophisticated machines with potentially hundreds of millions of lines of code. Workers across all fields need to break down major problems into manageable parts and identify effective solutions. Accordingly, computer science is not just an optional skill.
00:25:52.560 I've devised a plan to help ensure that our kids learn computer science, especially targeting girls and minorities by introducing teaching programming support. This collective effort involves each of us doing our part, and that involvement is vital for success.
00:27:12.840 So, as I share this information, I hope you find it enlightening and inspiring. I encourage active participation in such programs and initiatives, and sense the communal effort behind these endeavors.
00:28:05.720 Thank you for your time and attention. I hope you all have a wonderful weekend!
Explore all talks recorded at BathRuby 2016
+12