Sonic Pi: Live Programming Language To ‘Make Music’ With Simple Code

Tweet
Share
WhatsApp

Are you a programmer who wants to be a musician and perform live on a stage? Or are you a musician who doesn’t have instruments or teams to set the stage on fire?

Here I introduce a new kind of instrument for you to be a programmer and musician at the same time. You can turn live performances from ambient sets to dance music nightclubs using simple computer code.

Sonic Pi: Code live to make music

Learning programming sometimes turns into a rigorous and dull process for students that need excitement and fun at every stage to keep up the pace. And the most preferred instance chosen by a programmer is listening to music to refresh their mood.

But what if I say that you can correlate both the task of coding and musical sound to get joy from every line of code?

If you’re a programmer, you can now learn looping, conditional, function, thread, data structure, and algorithm not just by printing the text output but by creating the type of music you like the most.

Or, if you’re a musician, you can create any style of music and learn to program alongside. It may sound unrealistic, but it’s possible.

Sam Aaron is the person who released the essence of learning without losing enthusiasm by expanding the scope of programming beyond the code, by producing numbers and alphabets.

Sonic Pi is a sophisticated software tool developed by Sam Aaron to create sound or music by writing computer code in real-time. You can use it for learning how to code, exploring new notations for music and improvising electronic music, or even collaborating on musical ideas via text.

sam aaron live performance at thinkingdigital conference
Sam Aaron live performance at ThinkDigital Conference

While working as a researcher at Cambridge University, he started an open-source project for building a teaching platform for the children in a very fresh and exciting way. Subsequently, He developed an instrument, Sonic Pi, to engage a new generation of a coder.

Sonic Pi is the icing on the cake for the programmer who wants to be a live performer.  It does not matter whether you have equipment or teammates; you only require a laptop and installed software tool — Sonic Pi — to refill the tedious environment with dancing beats.

Sonic Pi is a live coding language to create music for a range of styles from Classical and Jazz to Grime and EDM. The best thing about it is that you can write and modify the code live to change the tone of music with high or low beats and different melodies.

Note: Live coding is a new form of programming method where code is written live on stage in front of the audience that produces visuals or musical art.

How does Sonic Pi code play music?

Sonic Pi follows a simple block-like, text-based syntactic structure built upon the Ruby programming language.

Two extremely important commands play and sleep is the starting point to play different notes and choose how long to wait before playing the next note.

play 72
sleep 1
play 75
sleep 1
play 79

By sequencing a few lines of code, you create a simple melody with a western touch. Along with the ideas of your notes and song, you can use a sample command that extends the ability to play any pre-recorded sound.

Sonic Pi includes tons of built-in recordings to use, such as drums, guitars and atmospheric noises as a sample.

Furthermore, if you want to repeat or play random notes, there are also other commands like do, end, and loop that allow you to iterate or select accordingly.

Last but not least, the most interesting aspect that Sonic Pi offers is live coding. You can use the live_loop command to tweak and modify the program as it runs continually.

live_loop :beats do
 sample :bd_haus
 sleep 0.5
end

A live loop is a kind of loop that can be changed while it’s running. It provides the concurrency to play multiple instruments sound at once, just like members of the band—one playing drums, the other bass, and another on guitar.

These commands are processed through a synthesizer backend called SuperCollider.

Future of music

With the advancement in technology, the music industry is also booming alongside as artists now use various tools or software for music production.

Hence, Sonic Pi comes in the picture that widens the aspects of software tools by allowing them to add their ideas of music with few lines of code. It also broadens the limit of programming, which is restricted to the software for remixing the pre-recorded sounds.

From all over the world, programmers or musicians participate in adding their innovative ideas to develop music. For example, Japan making music in VR spaces with Sonic Pi; Algorave event was organized by an Indian woman for live-coding workshops with small groups of coders to revive the live music performance.

Algorave India Workshop
Algorave India Workshop

Sam Aaron is currently preparing for the v3.2 release at the end of Feb to enhance the scope of Sonic Pi so that it can be used by local musicians to produce folk songs easily.

Sonic Pi is available for Raspberry Pi, Windows, and macOS platform. You can download the software directly from the official site here and also follow the tutorial written on the page.

Keep reading Fossbytes to get the latest bytes of all the technology and innovation.

Sarvottam Kumar

Sarvottam Kumar

Sarvottam Kumar is a software engineer by profession with interest and experience in Blockchain, Angular, React and Flutter. He loves to explore the nuts and bolts of Linux and share his experience and insights of Linux and open source on the web/various prestigious portals.
More From Fossbytes

Latest On Fossbytes