RaspberryPi Basics: Part IV-Audio in Scratch!
Posted by Beyond
|Scratch is a programming language that makes it easy to create your own interactive stories, animations, games, music, and art — and share your creations on the web.As young people create and share Scratch projects, they learn important mathematical and computational ideas, while also learning to think creatively, reason systematically, and work collaboratively.|
Scratch is developed by the Lifelong Kindergarten Group at the MIT Media Lab, with financial support from the National Science Foundation, Microsoft, Intel Foundation, MacArthur Foundation, Google, Iomega and MIT Media Lab research consortia.
Woaahhhhhhhh!! quite a few BIG names and a big list! One may say the list of Virtoso’s in their realm.
Also, at elinux.org says,
There is a huge selection of programming languages which you can use to write interesting programs, games, applications and utilities. There are also more great links within the Education section. There is a huge selection to choose from (not just Python…) which should suit any ability and a range of purposes. If you are new to programming, there are plenty of tutorials for getting started in the Tutorials Section. Books about programming can be found in the Books Section. In the latest Debian, Python (+Pygame) and MIT Scratch are pre-installed.
So, we got Scratch pre-installed in the Debian image. But the problem is the audio not working. As the audio was working according to my previous posts, but when it comes to Scratch, it sucks!!
The sound buttons at the interface of the Scratch are not effective, as they play the sound, as what I guess, because the time in seconds do get incremented but no sound come off!!
So, I asked a friend of mine named Mr. Google, and he simply pointed me to the standard forum results leading to the solution of the problem.
I found a script that I assume is written in smalltalk that runs when you run scratch. It’s at /usr/bin/scratch
I removed code that *looks like* it’s setting up the sound, and added code that sets the sound to use alsa drivers – which I installed on my system when I was trying to get sound to output to the jack rather than the default auto select (I’m using HDMI it a monitor with a separate audio in).
I changed the lines that say:
if pulseaudio - - check 2>/dev/null ; then
if padsp true 2>/dev/null ; then
to say this instead
#if pulseaudio - - check 2>/dev/null ; then
# VMOPTIONS="$VMOPTIONS -vm-sound-oss"
# if padsp true 2>/dev/null ; then
- VMOPTIONS=”$VMOPTIONS -vm-sound-alsa”
The # symbols comment out the old code so it’s ignored. Now, the sound in the scratch is working. I dont know much of working in Scratch but I got the drum beats and Meow of cat audible 🙂