RaspberryPi Basics: Part IV-Audio in Scratch!

Scratch ???

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
VMOPTIONS="$VMOPTIONS -vm-sound-oss"
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
#          WRAPPER=padsp
#     fi
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 🙂


About Beyond

an electronics hobbyst, 8 bit microcontroller(8051/AVR/Arduino) programmer, Linux lover, in love with Embedded Linux systems ... TGL: just push it "BEYOND THE LIMITS"..

Posted on September 29, 2012, in Embedded Linux, Embedded Systems and tagged , , , , . Bookmark the permalink. 4 Comments.

  1. Hi, could you provide steps and filename you edited for a unix newbie? Think your edit will fix my lack of sound in scratch but not sure where to make this change.

  2. yeah, edit the file “/usr/bin/scratch” i.e a file in /usr/bin named scratch.
    and find the text like which I have mentioned above..
    just comment those out and finally write only one line for them..
    VMOPTIONS=”$VMOPTIONS -vm-sound-alsa

    do ask for further help iff it doesn;t get solved 🙂

  3. It worked, thanks for this, great article. Once I figured out that I had to run vi editor with sudo I was then able to write back these changes to the /usr/bin/scratch file.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s