Ruby
Sonic PI: live music, live coding

Summarized using AI

Sonic PI: live music, live coding

Ju Liu • November 13, 2015 • Turin, Italy

In Ju Liu's talk at RubyDay 2015 in Turin, he presented "Sonic Pi: live music, live coding," emphasizing the intersection of music and programming using Sonic Pi, a unique tool designed for creating music through code. Throughout the talk, he engaged the audience by encouraging Ruby and music lovers to embrace their dual passions. Here are the key points discussed:

  • Introduction of Sonic Pi: Ju introduced Sonic Pi, created by Sam Aaron at the University of Cambridge, as a tool designed to teach programming to children by making music creation accessible and engaging.

  • Personal Background: Ju shared his journey as a software engineer who fell in love with Ruby, discussing his professional experiences and love for programming.

  • Cultural Context of Turin: He provided interesting facts about Turin, including its historical significance as the first capital of Italy, renowned local foods and drinks, and its contributions to computing, particularly the Turing Test and Turing machines.

  • Live Coding Demonstrations: Ju showcased live coding with Sonic Pi, illustrating how to write simple melodies, use loops, and adjust parameters within the audio synthesizer while coding in Ruby.

  • Creativity Through Coding: He highlighted the creative potential within Sonic Pi, demonstrating how users can manipulate sounds, create samples, and explore 'live loops' to develop music on the fly.

  • Encouragement to Experiment: Ju encouraged the audience to embrace experimentation with Sonic Pi, illustrating that sound creation is both a technical and artistic endeavor that can yield unexpected and beautiful results.

  • Conclusion and Call to Action: In closing, he invited the audience to explore Sonic Pi and share their experiences, emphasizing that sound and music are unique forms of expression that connect us all. He also mentioned that code examples from his talk would be available on his GitHub, facilitating further exploration of Sonic Pi.

Ju's talk served as an inspiring invitation for programmers and music lovers alike to merge their passions using Sonic Pi, fostering creativity in both coding and music production.

Sonic PI: live music, live coding
Ju Liu • November 13, 2015 • Turin, Italy

Ju Liu's talk from RubyDay 2015 in Turin.

rubyday 2015

00:00:00.030 I guess for the first 10 seconds, you can just look at this. It took me hours to do; I had to find the right font and fit it just right. Yeah, okay, so hi!
00:00:16.139 I'm so happy to be here! I would like every Ruby lover to stand up. No, no one? Come on, guys! I see you in the back; you're still sitting. All right, that's good. How about any music lovers? Please stand up. I know it's a lot to ask to be dessert in the morning, right? Good! So, everybody who loves Ruby and music at the same time, you know what you should do? Stand up! Please stay standing for a while. You guys are the absolute rock stars of this talk! You both know Ruby and really love music; you're the elite. So, when I started and discovered Sonic Pi, everybody involved in Sonic Pi and the project were absolute rock stars, and I knew nothing about music. I felt like I sucked, but apparently, the program is so cool that even if you don't know music, you can still create pretty cool things with it. So, yeah, I'm sure everybody else can still have some fun. Now you can sit down; sorry for taking a lot of time.
00:01:01.200 I have to warn you that I have prepared some slides for this talk, but none of them are serious, so I'm just going to quickly go through them and then get straight to the real deal, hopefully. So, I'm Ju, and you can find me online as our camp—it's a bit weird because the second 'a' is missing, but someone took my nickname. I managed to secure it on GitHub and some other platforms. A couple of things about me: I'm a software engineer. I discovered Ruby five years ago in this same city; it was the first language I used professionally, and I absolutely fell in love with it. I've never stopped using it, and yes, I'm doing a bit of JavaScript on the side—because you can't avoid JavaScript nowadays. This year, I got addicted to rock climbing; that's me there. I live in London, having moved there two years ago.
00:01:55.390 Here's a lovely picture of our beloved King. I work for a company called Alpha Sites, which kindly sponsored me to be here today, and we build amazing products using Ruby, Amber, Jazz, and Elixir. I have some t-shirts, and I really like that this is being recorded because the guy in the yellow Teletubby costume is the technical lead of the company. Yes, hi, Tor! As you might have realized, we love Ruby as a language. I think it's fantastic; it is so expressive that you can pretty much do whatever you want with it. My favorite part is also the terrain; I lived here for about ten years. I went to university here and worked here for the first time. It's beautiful, especially in the winter when you can see all the snowy mountains. When I heard that this year's Ruby Day was going to be in Turin, I was super excited. This morning, I was happy to see a lot of friends; it just feels great!
00:02:30.390 Since I know this is a very international gathering, I thought some of you might not know a lot about Turin. Instead of spending a lot of time on my talk, I actually prepared some slides about the city. I asked some English friends of mine; they said, 'Yeah, this sounds good,' so blame them! Turin is famous for many things. In 1861, it was declared the capital of the newly founded Kingdom of Italy, which was more than 150 years ago. We have one very famous football team, and I haven't heard of any others. I don’t know; maybe some of you might not know. James Bond owes us something! You know the famous James Bond drink—the medium vodka dry martini with a slice of lemon peel, shaken, not stirred? Half of this drink is actually made in Turin; there's this company called Martini Rossi, founded two years after Turin was declared the capital.
00:03:13.560 So, even this company is over 150 years old, and they make the vermouth that's used in martinis today. We also have some pretty good food—and I know every region thinks they have the best food, so I don't think that's really fair. But anyhow, we have this dish called 'bagna cauda,' which is a dip made of anchovies, garlic, olive oil, and a little bit of milk and butter, depending on how heretic you are. Basically, you mash it all up, put a candle beneath it to keep it warm, and then you use either raw or cooked vegetables to dip it in. The only downside is that you may end up sweating garlic for three days, so if you have an interview or something, you might want to avoid it! It's called 'bagna cauda.' Additionally, there’s a very special type of chocolate called 'gianduiotto' that's made of sugar, cocoa, and hazelnut.
00:04:05.950 It’s quite interesting because if you’ve never tried it, please do! When you put it in your mouth, you don’t even have to chew it; it instantly melts. It’s called 'gianduiotto,’ too. The last treat I want to mention is 'bicerin,' a drink made with chocolate, coffee, and cream, served in beautiful glasses. It's absolutely fantastic! Fun fact: 'bicerin' actually means 'small glass,' and I guess that's why they choose really pretty glasses to serve it. Now, this is the most controversial part about Turin, and I’m sure you have your opinions, but here’s the truth: Some of you might not know that Turin contributes a lot to computing. Computing as we know it wouldn’t be where it is today without Turin.
00:04:53.250 For instance, we invented the Turing Test, which is crucial in artificial intelligence, and it was developed in Turin. We also made the Turing machine, which is like the predecessor of all modern computers, and using Turing machines, you can solve problems that are known as Turing-complete. I know this might be controversial, but that's the truth! Now, let's get back to Sonic Pi. I need to set it up in a specific way. The variant is called Sonic Pi, built by someone who worked on it. I've never seen such a small screen since 1990. The program is designed for this purpose. This program was built by Sam Aaron, an incredibly smart guy who works as a researcher at the University of Cambridge. He is one of the rockstars I referred to before, really good at computer science and music.
00:05:44.840 He created Sonic Pi to teach programming to kids. Kids have such short attention spans, and you can say, 'Hey, we’re going to learn about loops and functional programming,' and they’re like, 'Gone!' However, with this tool, you can actually play music using code, and hopefully this will work. Writting a number is the media representation of the note. So, you can play symbols as well. Instead of playing with numbers, you can use Ruby symbols; you know the keyboard notation of notes. For instance, you can use C to represent what is called 'Do' in Italian. The cool thing is, you can modify the notes, and you can also use other functions in Sonic Pi.
00:06:48.670 Let’s say I want to play more music—it's never enough! That sounds good! It feels a bit slow for modern times, so maybe you can use BPM to set the beats per minute. That’s better! But what if I told you that everything you see here is just Ruby? I ran it with Ruby version 2.2.2. Everything you’ve seen and everything you will see in this whole talk is simply Ruby. Someone has written their scheduler and their own timer because you can’t always trust the operating system to measure exactly one second. If they wrote their versions of all the OS internals to ensure when you say 'sleep for one second,' it actually sleeps for that exact amount of time.
00:08:01.400 Everything here is Ruby! I was thinking I could show how to write a simple song, so I’ll just do this and that. So, here we have a construct called 'times' to repeat playing music. You can run the block twice, but oh no, we need to add sleep here! Because we’re all really good programmers, we can see that there’s so much duplication in this block. This is where we create an abstraction over it: play a note and add sleep. Let's play 'C' twice and have fun with the tempo.
00:09:02.400 Now we can adjust our tempo. To speed things up, let’s play the sequence faster. If you know the song, you might think this sounds familiar. This song is 'Frère Jacques,' also known as 'Brother John' in Britain. We can play E next and follow it with F and G, repeating twice. Then we can tweak the parameters for duration to make it sound just right! The note should last longer, and we can control that by passing a parameter called 'release' that tells the synthesizer how long the note should last. Using Ruby's keyword arguments, we can also have defaults.
00:09:48.760 For instance, we could have a C note length and specify the release time. We can keep playing the notes and adjust the length using the same conventions. Now, while writing 'E' and 'C' notes, it’s always a pleasure to reflect on the first time you wrote a program, saying 'printf Hello World!' and how satisfying it felt. It's such a joy to write music this way; coding and music blend into something magnificent.
00:10:50.440 Now, we can reinstate our final note by adjusting its release. I should have used my beautiful abstraction again. That's better! I think we’re ready to hear the whole song now. This should be played as 'Frère Jacques,' and since all this is Ruby code, you can simply call it, and it works. The sounds you hear are from the synthesizer called 'pretty bell.' Let’s experiment with other synths and bring some unique layers to the song.
00:11:30.500 We can use different synthesizers and manipulate the sound dynamics as well. We'll create some captivating variations. I’ve seen how people around the world use Sonic Pi to build amazing sounds because when you combine both programming and music, you can achieve something incredible. This tool is just the beginning of what creatives can do.
00:12:59.800 Let’s get ready for something else. There are many samples provided with the program; they are a lot of fun to explore. The cool thing is that you can manipulate samples as well, turning even simple sounds into hip-hop beats or electronic rhythms. The creativity is endless, and you can truly adjust samples to your liking.
00:13:35.700 Now, the coolest part of this tool is called 'live loop' which allows you to swap code on the fly while keeping the beat intact. Let’s use a little sleep command so you can hear how it all works together. If we want to tweak the synthesizer settings, we can add various parameters, such as cutoff and enhance the overall experience.
00:14:06.800 This brings us to how sonic magic happens with Sonic Pi! You can play with the synth settings, adjust the filters, and even play with the volume parameters to create something completely unique. Imagine the endless possibilities—every tweak leads to an entirely new sound and feeling! It’s a wonderful playground for anyone interested in combining technology with art.
00:14:48.500 As you dive deeper into this world, you might feel overwhelmed with all the options you have available. But trust me, every moment spent experimenting is worth it. You can create sounds that resonate with everyone’s nostalgia, even reaching back into your childhood.
00:15:37.200 Ultimately, the key to enjoying sonic creation is not just mastering the techniques but embracing the whimsical chaos of experimentation. I encourage you all to try out Sonic Pi, as it's a platform where you can express your love for music and programming simultaneously. Let your creativity run wild!
00:16:20.760 Before I conclude, if anyone is curious about the code I used during this talk, you can find that on my GitHub. I also host a few projects related to Sonic Pi, encouraging collaboration and learning. Sound can be more than just music; it’s an art form that connects us all in unique ways!
00:17:01.560 Feel free to reach out to me; I’d love to hear your thoughts and see what you all create with Sonic Pi. Let’s embrace this journey of discovery together and craft unique compositions that tell our stories. Thank you all for being here and enjoying this exploration into the world of Sonic Pi.
00:17:39.600 I hope you enjoyed my talk and feel inspired to experiment with music and programming through Sonic Pi. Thank you for your time, and I look forward to seeing what you all come up with!
Explore all talks recorded at rubyday 2015
+6