- MCP server with stdio transport for local use - Search episodes, transcripts, hosts, and series - 4,511 episodes with metadata and transcripts - Data loader with in-memory JSON storage 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
108 lines
7.2 KiB
Plaintext
108 lines
7.2 KiB
Plaintext
Episode: 1775
|
|
Title: HPR1775: Sonic Pi
|
|
Source: https://hub.hackerpublicradio.org/ccdn.php?filename=/eps/hpr1775/hpr1775.mp3
|
|
Transcribed: 2025-10-18 09:07:15
|
|
|
|
---
|
|
|
|
This is HPR episode 1775 entitled Sonic Pie.
|
|
It is hosted by Steam Vehicle and is about 11 minutes long.
|
|
The summer is a short-remew on Sonic Pie and programming the HPR theme.
|
|
This episode of HPR is brought to you by an Honesthost.com.
|
|
Get 15% discount on all shared hosting with the offer code HPR15.
|
|
That's HPR15.
|
|
Better web hosting that's Honest and Fair at An Honesthost.com.
|
|
Hi, I'm Steve Vehicle and this is my HPR episode about Sonic Pie.
|
|
I recently bought a Raspberry Pi 2 to play with.
|
|
I installed the Raspberry OS onto an SD card.
|
|
I had a bit of a challenge getting online as the BT router doesn't want to play with
|
|
with the Wi-Fi on the Raspberry Pi.
|
|
It also fails to connect with a friend's MacBook Pro, so I'm sure it's the router that's
|
|
a fault.
|
|
And the Ethernet via the mains gadget didn't work either.
|
|
Unfortunately, there's no HDMI monitor to hand under the stairs where the Ethernet
|
|
is available, so I was limited to offline use for my Raspberry Pi.
|
|
Fortunately, you get the pre-packaged educational programming software, Scratch and Sonic Pie.
|
|
So there are toys to play with without going online.
|
|
I'd seen Scratch before, but I'd never come across Sonic Pie.
|
|
Sonic Pie is a music program, but it's different to any that I've seen before.
|
|
It's a procedural programming language for making a manipulating music.
|
|
Despite its primary purpose, being a simple way to introduce programming concepts to children,
|
|
the underlying capabilities of the Sonic Pie language are really sophisticated.
|
|
It has constructs that allow for looping, manipulation of samples, the ability to build
|
|
sounds from primitive oscillators with attack, decay, sustain, release, envelope shaping,
|
|
and complementary to that, it also allows conventional musical constructs such as sequencing
|
|
of individual notes, chords, scales and arpeggios.
|
|
When you list its capabilities, you might expect learning to use the Sonic Pie would be
|
|
quite a daunting task, but it's not.
|
|
Sonic Pie has been designed to educate children about programming, and it comes with a simple
|
|
tutorial and some inspiring examples, along with relatively comprehensive documentation
|
|
for the language, samples and oscillators.
|
|
On a single screen, there are eight tabbed workspaces where music scripts can be written, a runtime
|
|
viewer showing the actions being taken by your running program or programs, and the information
|
|
pain, where tutorials or documentation can be viewed whilst programming.
|
|
Some Aaron, who wrote Sonic Pie, is one of a community of live performers of music programming.
|
|
Sonic Pie allows for live looping, where the programs changed on the fly and re-envoked
|
|
with new code to move the performance on.
|
|
There are mechanisms to create threads that run separately, but can be synchronised with
|
|
each other.
|
|
There's the ability to use random numbers to add variability into your program.
|
|
A nice touch here is that the random number generator seed is always the same, so a program
|
|
will perform repeatedly in a consistent manner.
|
|
Some has managed to orchestrate, no pun intended, a swath of complex libraries, and optimise
|
|
the coding of Sonic Pie in such a way that it's possible to produce a sophisticated multi-layered
|
|
soundscape with the relatively meager resources of the Raspberry Pi and a few lines of code.
|
|
I've never learned to play, I've never played a musical instrument, but after a couple
|
|
of hours with Sonic Pie, a sheet of music, and a giff image I found listing the names
|
|
of the notes in a treble clef, I have a program to play the tune to Flanders and Swans
|
|
Hippopotamus song, a task I originally achieved back in the early 1980s on an Atari 400.
|
|
This is not a very sophisticated rendition, and sort of misses the point of the looping
|
|
capabilities of Sonic Pie, but it made me smile.
|
|
So I thought I might take things a step further and try something a little bit more ambitious,
|
|
the HPR theme.
|
|
Not being a musician, I can't tell what note is being played by listing alone, all the
|
|
timing for that matter, and there was no sheet music to hand.
|
|
I managed to hack around this by playing the accordion version of the Outtrace theme
|
|
from the HPR website on my laptop with a guitar tuner program on my Android phone displaying
|
|
the pitch.
|
|
To get the basic two note timings down, I used this setup, and listened to it many times
|
|
at half speed, quarter speed, and also listened to the main theme version in VLC as well.
|
|
Finally, I used Audacity to listen to portions of the tune repeatedly by selecting sections
|
|
and hitting the space bar to replay.
|
|
After a few hours of this, I'd hacked out a version of the tune into a program.
|
|
This was still just sequential notes and sounded very flat and mechanical.
|
|
The default sound is a beep, I changed the voice to a sawtooth waveform which sounds
|
|
more like a brass instrument.
|
|
For the last few bars, I changed to an alternate voice to give a richer sound, then changed
|
|
the final notes to chords to build up the sound.
|
|
On the main theme, there's a light, percussive, urgent background beat, so in another workspace,
|
|
I put together a loop to do this.
|
|
And again, it took me a non-musician some time to get anything that sounded ok.
|
|
Once I had percussive loop, I added it to the main program in the first workspace, setting
|
|
up the loop in a separate thread so it would play simultaneously with the tune.
|
|
There are also a couple of drum beats to introduce the main theme, so again in a separate
|
|
workspace, I played around with sample drum sounds and timing to get something I was happy
|
|
with, and then inserted it into the main program.
|
|
For any Raspberry Pi owners or Apple Mac owners, that being the only other platform the apps
|
|
currently packaged for, I've added my two programs to the show notes.
|
|
I'm not sure that we're allowed to perform the hippopotamus song on a Creative Commons
|
|
podcast, so I'll not play it here.
|
|
Instead, to show what's possible when somebody talented programs with Sonic Pi, I'll play
|
|
back a piece from the Sonic Pi demos.
|
|
Yeah, yeah, yeah, yeah, yeah, yeah, yeah.
|
|
That was Shuffleit by Sam Aaron, that was just 41 lines of code, and I think for such a
|
|
small amount of code, that's an impressive soundscape.
|
|
The HPR Outro is Creative Commons compatible, so I'm going to end this episode with a result
|
|
of my less talented music endeavors, again, I'd refer you to the show notes for this listing
|
|
and I'd ask you to take it and hack on it, make it into something better, and yes,
|
|
make an episode about it.
|
|
You've been listening to Hacker Public Radio at Hacker Public Radio dot org.
|
|
We are a community podcast network that releases shows every weekday Monday through Friday.
|
|
Today's show, like all our shows, was contributed by an HPR listener like yourself.
|
|
If you ever thought of recording a podcast, then click on our contribute link to find out
|
|
how easy it really is. Hacker Public Radio was founded by the digital dog pound and the
|
|
infonomican computer club, and it's part of the binary revolution at binwreff.com.
|
|
If you have comments on today's show, please email the host directly, leave a comment on
|
|
the website or record a follow-up episode yourself, unless otherwise stated, today's show
|
|
is released on the creative comments, attribution, share a live 3.0 license.
|