@ked
I've added a "How to fix Scratch" page in the Wiki and added your link and instructions to it.
http://elinux.org/Scratch_on_RPi
Simon
Re: Scratch locks up? (when playing sound?)
Seeking help with Scratch and I/O stuff for Primary age children
http://cymplecy.wordpress.com/ @cymplecy on twitter
http://cymplecy.wordpress.com/ @cymplecy on twitter
Re: Scratch locks up? (when playing sound?)
I don't know if your problems been solved yet, but this happened to me too. Mine was when I was creating an alarm system, if you can replace the sound with a graphic (ie; replace alarm sound with a flashing red light) it should work fine. I think it may be that generating a sound is too much for the r-pi (don't know why). As for the cpu not getting really high, maybe a safety precaution scratch has? To stop it blowing up your pi...
... hope this solves your problem.
... hope this solves your problem.
-
- Posts: 75
- Joined: Tue Jul 24, 2012 9:10 pm
- Location: Silicon Valley, CA
Re: Scratch locks up? (when playing sound?)
I am not using a Linux Graphical environment for my Pi. I did for awhile and it was just too slow. For kids of course you can install Scratch on a Windows or Mac machine though.
I did have troubles with the ALSA audio driver for the BCM2835 and Python Pygame audio. Whereas the exact same code running under Windows could play back more than one sound at a time, doing it on the Pi just cut off all sound as soon as the second one started. However I have not had problems just playing one sound at a time. I am using HDMI audio.
I also tried installing JACK for some more elaborate audio fun (before I gave up on using Xfce/LXDE/etc.) , but the JACK system complained about the BCM2835 audio driver not supporting memory mapping, or something of the sort.
Note that I am using the Raspbian Pisces image which may have a different audio driver.
I did have troubles with the ALSA audio driver for the BCM2835 and Python Pygame audio. Whereas the exact same code running under Windows could play back more than one sound at a time, doing it on the Pi just cut off all sound as soon as the second one started. However I have not had problems just playing one sound at a time. I am using HDMI audio.
I also tried installing JACK for some more elaborate audio fun (before I gave up on using Xfce/LXDE/etc.) , but the JACK system complained about the BCM2835 audio driver not supporting memory mapping, or something of the sort.
Note that I am using the Raspbian Pisces image which may have a different audio driver.
Pi user since 2012. Python, Pygame
Support, remot3.it, Inc.
Support, remot3.it, Inc.
-
- Posts: 1
- Joined: Tue Jan 08, 2013 9:22 am
Re: Scratch locks up? (when playing sound?)
Scratch was locking up on my daughters new Pi with Raspberian (wheezy) when playing audio. I found this thread and then by chance this article: http://www.theregister.co.uk/2013/01/04 ... _bug_rage/
I d/l'd the latest wheezy build (12/16/12 I believe) and Scratch seems to be stable. I don't know if the bug and the article are related, but it seems like quite a coincidence.
I d/l'd the latest wheezy build (12/16/12 I believe) and Scratch seems to be stable. I don't know if the bug and the article are related, but it seems like quite a coincidence.
-
- Posts: 6
- Joined: Wed Jan 09, 2013 5:51 pm
- Location: Alaska
Re: Scratch locks up? (when playing sound?)
We're using:
-RASPBRRY-MODB-512M
-2012-12-16-wheezy-raspbian.img
-HDMI video
-USB mouse and keyboard
-1.7A power supply
-8G Patriot SD card
-RJ45 not connected
We've had Scratch hang while editing a "costume" for a sprite in the "paint editor".
We have also seen it hang during exercises in the Raspberry Pi Education Manual (RPEM).
When just the Scratch window hangs, I open a terminal and do a "ps -ef", locate the "Scratch" <PID> and "kill <PID>", and at other times, if the whole Raspberry Pi UI is unresponsive we have to pull the power cord.
We need the basic stability of the system patched please!
-RASPBRRY-MODB-512M
-2012-12-16-wheezy-raspbian.img
-HDMI video
-USB mouse and keyboard
-1.7A power supply
-8G Patriot SD card
-RJ45 not connected
We've had Scratch hang while editing a "costume" for a sprite in the "paint editor".
We have also seen it hang during exercises in the Raspberry Pi Education Manual (RPEM).
When just the Scratch window hangs, I open a terminal and do a "ps -ef", locate the "Scratch" <PID> and "kill <PID>", and at other times, if the whole Raspberry Pi UI is unresponsive we have to pull the power cord.
We need the basic stability of the system patched please!
Brian Jester
Re: Scratch locks up? (when playing sound?)
@ked, Can you tell us more about your audio plugin and how it works? Maybe someone here could take a crack at improving it.
It does not work for analog audio out for me. While running scratch with this plugin, all other audio output stops working as well.
-Paul
It does not work for analog audio out for me. While running scratch with this plugin, all other audio output stops working as well.
-Paul
Re: Scratch locks up? (when playing sound?)
@Paul: sound coming from Scratch is buffered and control past straight back to Scratch to maintain UI responsiveness. Meanwhile a writer-thread waits for new buffers and writes them out to the os/hw. That much is pretty generic. For the RPi I have used code from "/opt/vc/src/hello_pi/hello_audio" to output via the OpenMax IL audio component. Other than that example code I have no details on the RPi's audio capabilities/requirements and next to zero knowledge of OpenMax IL. I'm guessing but it might be worth experimenting with (smaller) buffer sizes for ana output. I'll have another play around at some point, although that's now unlikely until middle/end of Feb.
Re: Scratch locks up? (when playing sound?)
I'm having the exact same issues, driving me nuts last night trying to get it to work. My daughter has a science fair project she is finishing up and we cannot get it to work on the Pi, she is using a makey makey to use items to make sounds, problem is there are no sounds from scratch, it just locks up non stop when trying!
I finally managed to hear sound from another program so sound is apparently working, but never heard a thing from scratch. The only item I need to work is scratch and sound, what image should I try and download to get this done? My 12 year old is all worried now lol!
I need audio from 3.5mm jack too if it matters.
I finally managed to hear sound from another program so sound is apparently working, but never heard a thing from scratch. The only item I need to work is scratch and sound, what image should I try and download to get this done? My 12 year old is all worried now lol!
I need audio from 3.5mm jack too if it matters.
Re: Scratch locks up? (when playing sound?)
Thanks to ked's post and solution, which he provided here, i am up and running without any further locking up or freezing. Hooray! I'm new to the raspberryi pi and just purchased it and setup this month (jan 2013). Thank you!




Re: Scratch locks up? (when playing sound?)
Thanks for posting the link to the fix.
Out of curiosity - how can you kill it when its running and locked up? I've checked the task manager-esque way of doing it, but not the normal "kill" command for linux. Bear with me - been a VERY long time since using any form of Linux (and that was on Fedora back in the day when it was plain ol RedHat) so not all of it is making sense yet!
I do wonder why so many people have the problem yet I know equal amounts who have never had it happen. One chap I know has an issue where sound simply doesn't play, but nothing crashes and when he restarts Scratch its fine.
Out of curiosity - how can you kill it when its running and locked up? I've checked the task manager-esque way of doing it, but not the normal "kill" command for linux. Bear with me - been a VERY long time since using any form of Linux (and that was on Fedora back in the day when it was plain ol RedHat) so not all of it is making sense yet!
I do wonder why so many people have the problem yet I know equal amounts who have never had it happen. One chap I know has an issue where sound simply doesn't play, but nothing crashes and when he restarts Scratch its fine.
Re: Scratch locks up? (when playing sound?)
Hi
I am having the same problem in that when ever we try to use sound in Scratch it locks up and can only be re set by un plugging the power. I am using an HDMI tv. I am very new to all this. I got the operating system pre loaded on an SD card direct from RS in December just before Christmas. All other operations work fine. My kids are very disapointed in this as am I. Is there an easy fix for this that I can do? I have no programing experiance except playing with a ZX81 when at school in the 80's. I hope someone can help.
Nigel
I am having the same problem in that when ever we try to use sound in Scratch it locks up and can only be re set by un plugging the power. I am using an HDMI tv. I am very new to all this. I got the operating system pre loaded on an SD card direct from RS in December just before Christmas. All other operations work fine. My kids are very disapointed in this as am I. Is there an easy fix for this that I can do? I have no programing experiance except playing with a ZX81 when at school in the 80's. I hope someone can help.
Nigel
Re: Scratch locks up? (when playing sound?)
@Nigel, see this post on pg 1 of this topic for zip which includes files and instructions...
http://www.raspberrypi.org/phpBB3/viewt ... 74#p239574
Instructions should be same/similar to the ones I gave in this post...
http://www.raspberrypi.org/phpBB3/viewt ... 75#p239075
Briefly, you simply add the new plug-in (one file) in same directory as existing Scratch/Squeak plug-in's and then edit the Scratch start-up script to use it instead of the current one (one minor change). HTH.
http://www.raspberrypi.org/phpBB3/viewt ... 74#p239574
Instructions should be same/similar to the ones I gave in this post...
http://www.raspberrypi.org/phpBB3/viewt ... 75#p239075
Briefly, you simply add the new plug-in (one file) in same directory as existing Scratch/Squeak plug-in's and then edit the Scratch start-up script to use it instead of the current one (one minor change). HTH.
-
- Raspberry Pi Engineer & Forum Moderator
- Posts: 6332
- Joined: Wed Aug 17, 2011 7:41 pm
- Location: Cambridge
Re: Scratch locks up? (when playing sound?)
I've pushed a firmware update that should fix the scratch alsa hang.
Disable ked's fix if you are using it. Run rpi-update. Let me know if scratch sound is better.
Disable ked's fix if you are using it. Run rpi-update. Let me know if scratch sound is better.
Re: Scratch locks up? (when playing sound?)
For those not already at the bleeding edge of RPi development - you might need to follow the steps here
https://github.com/Hexxeh/rpi-update
before you are able to try it out
regards
Simon
https://github.com/Hexxeh/rpi-update
before you are able to try it out

regards
Simon
Seeking help with Scratch and I/O stuff for Primary age children
http://cymplecy.wordpress.com/ @cymplecy on twitter
http://cymplecy.wordpress.com/ @cymplecy on twitter
Re: Scratch locks up? (when playing sound?)
I can confirm the updated kernel (#371 PREEMPT) does the trick. I am now able to play sound after sound in scratch without any hangs or other problems.
There is a separate issue now easier to experience that several of the sounds in the scratch media directory don't play and give an "unrecognized format" error when imported.
Dom -- what'dja fix?
In any case thanks and way to go.
There is a separate issue now easier to experience that several of the sounds in the scratch media directory don't play and give an "unrecognized format" error when imported.
Dom -- what'dja fix?
In any case thanks and way to go.

-
- Raspberry Pi Engineer & Forum Moderator
- Posts: 6332
- Joined: Wed Aug 17, 2011 7:41 pm
- Location: Cambridge
Re: Scratch locks up? (when playing sound?)
Good to hear it's fixed. Seems the vchiq channel between ARM and GPU was locking up.FrumiousB wrote:I can confirm the updated kernel (#371 PREEMPT) does the trick. I am now able to play sound after sound in scratch without any hangs or other problems.
There is a separate issue now easier to experience that several of the sounds in the scratch media directory don't play and give an "unrecognized format" error when imported.
Dom -- what'dja fix?
In any case thanks and way to go.
Changed to use a different machanism (using control rather bulk) and the hang has gone.
Need to talk to vchiq guy to find out if it's a bug in vchiq bulk messages, or some problem with how it was being called leadinjg to deadlock.
The good news is that it's probably more efficient using the control channel. The block size isn't big enough to benefit from bulk transfer,
and bulk transfers block until GPU has received the data, whereas control messages are asynchronous.
I think the unrecognised format is probably related to installed libs than the ALSA driver. Which sounds don't work?
If you run file on them, can you spot the pattern for the sounds that don't play? E.g. this plays:
Code: Select all
file /usr/share/scratch/Media/Sounds/Animal/Meow.wav
/usr/share/scratch/Media/Sounds/Animal/Meow.wav: RIFF (little-endian) data, WAVE audio, Microsoft PCM, 16 bit, mono 11025 Hz
Re: Scratch locks up? (when playing sound?)
Thanks for the hint - Turns out all the non-playing, non-importing files are MP3s, and all the working files are WAVs. Sherlock Holmes not required for this case.
aplay plays the .wavs fine, but interprets the .mp3s as raw data, playing static.
omxplayer (and vlc) seem to recognize both the .wavs and the .mp3s (via messages to stdout) but does not actually play the sounds (I bet this has to do with my lack of familiarity with omxplayer)
Thoughts? I can't quite figure out if this is best thought of as a Scratch problem or if there might be a broader issue as the aplay problem seems to suggest. (Undoubtedly though it is far afield from the alsa/vchiq issue which seems totally fixed by the new firmware. Maybe I should start another thread?)
aplay plays the .wavs fine, but interprets the .mp3s as raw data, playing static.
omxplayer (and vlc) seem to recognize both the .wavs and the .mp3s (via messages to stdout) but does not actually play the sounds (I bet this has to do with my lack of familiarity with omxplayer)
Thoughts? I can't quite figure out if this is best thought of as a Scratch problem or if there might be a broader issue as the aplay problem seems to suggest. (Undoubtedly though it is far afield from the alsa/vchiq issue which seems totally fixed by the new firmware. Maybe I should start another thread?)
-
- Posts: 1
- Joined: Thu Jan 03, 2013 8:35 pm
Re: Scratch locks up? (when playing sound?)
I have been having this issue recently and it does seem to be sound related.
I have no/very little computer experience but at the age of 30 bought a Pi as a New Year's resolution to learn more about computers, I was the target audience, big phone/Xbox/computer user with no actual knowledge!
I have been working through the 'The Rasperberry Pi: Education Manual' and following the tutorials in Scratch. All was going well, no freezes at all, until the tutorial 'The Level Crossing'. During this particular tutorial Scratch began freezing on a regular basis as described by other users, and I became so frustrated I stopped using my Pi and only today have jumped back on. Searching the forums for an answer and came across this thread.
I opened Scratch and loaded my level crossing file. After a few clicks it froze as usual. I restarted my Pi, opened Scratch, took out the script 'when t pressed play sound level crossing a' and hey-presto, over an hour of freeze-free Scratch-ing... and counting!
When I had completed earlier tutorials I hadn't fitted speakers to my Pi set-up, so hadn't bothered to use sounds in them, if I had I'm guessing I would have stumbled across this problem earlier.
I don't have any knowledge to fix/expand on this issue, but as previously stated I'm hoping it does get fixed.
I have no/very little computer experience but at the age of 30 bought a Pi as a New Year's resolution to learn more about computers, I was the target audience, big phone/Xbox/computer user with no actual knowledge!
I have been working through the 'The Rasperberry Pi: Education Manual' and following the tutorials in Scratch. All was going well, no freezes at all, until the tutorial 'The Level Crossing'. During this particular tutorial Scratch began freezing on a regular basis as described by other users, and I became so frustrated I stopped using my Pi and only today have jumped back on. Searching the forums for an answer and came across this thread.
I opened Scratch and loaded my level crossing file. After a few clicks it froze as usual. I restarted my Pi, opened Scratch, took out the script 'when t pressed play sound level crossing a' and hey-presto, over an hour of freeze-free Scratch-ing... and counting!
When I had completed earlier tutorials I hadn't fitted speakers to my Pi set-up, so hadn't bothered to use sounds in them, if I had I'm guessing I would have stumbled across this problem earlier.
I don't have any knowledge to fix/expand on this issue, but as previously stated I'm hoping it does get fixed.
-
- Raspberry Pi Engineer & Forum Moderator
- Posts: 6332
- Joined: Wed Aug 17, 2011 7:41 pm
- Location: Cambridge
Re: Scratch locks up? (when playing sound?)
I believe it is fixed. Either use the latest (Feburary) wheezy image from http://www.raspberrypi.org/downloads.Bruder Jacob wrote:I have been having this issue recently and it does seem to be sound related.
I have no/very little computer experience but at the age of 30 bought a Pi as a New Year's resolution to learn more about computers, I was the target audience, big phone/Xbox/computer user with no actual knowledge!
I have been working through the 'The Rasperberry Pi: Education Manual' and following the tutorials in Scratch. All was going well, no freezes at all, until the tutorial 'The Level Crossing'. During this particular tutorial Scratch began freezing on a regular basis as described by other users, and I became so frustrated I stopped using my Pi and only today have jumped back on. Searching the forums for an answer and came across this thread.
I opened Scratch and loaded my level crossing file. After a few clicks it froze as usual. I restarted my Pi, opened Scratch, took out the script 'when t pressed play sound level crossing a' and hey-presto, over an hour of freeze-free Scratch-ing... and counting!
When I had completed earlier tutorials I hadn't fitted speakers to my Pi set-up, so hadn't bothered to use sounds in them, if I had I'm guessing I would have stumbled across this problem earlier.
I don't have any knowledge to fix/expand on this issue, but as previously stated I'm hoping it does get fixed.
Or run:
Code: Select all
sudo apt-get update && sudo apt-get upgrade
Re: Scratch locks up? (when playing sound?)
I am running into the same issue - everything locks up when playing audio and I have to hard reboot.
I have updated firmware and also upgraded to the latest release with no luck.
pi@raspberrypi ~ $ uname -a
Linux raspberrypi 3.6.11+ #434 PREEMPT Wed May 1 21:13:52 BST 2013 armv6l GNU/Linux
Please advise
I have updated firmware and also upgraded to the latest release with no luck.
pi@raspberrypi ~ $ uname -a
Linux raspberrypi 3.6.11+ #434 PREEMPT Wed May 1 21:13:52 BST 2013 armv6l GNU/Linux
Please advise
Re: Scratch locks up? (when playing sound?)
Could you link us to a script that shows this locking up behaviour please 
Simon

Simon
Seeking help with Scratch and I/O stuff for Primary age children
http://cymplecy.wordpress.com/ @cymplecy on twitter
http://cymplecy.wordpress.com/ @cymplecy on twitter
-
- Raspberry Pi Engineer & Forum Moderator
- Posts: 6332
- Joined: Wed Aug 17, 2011 7:41 pm
- Location: Cambridge
Re: Scratch locks up? (when playing sound?)
Can you try this:rajivnair wrote:I am running into the same issue - everything locks up when playing audio and I have to hard reboot.
I have updated firmware and also upgraded to the latest release with no luck.
http://www.raspberrypi.org/phpBB3/viewt ... 50#p341882
Re: Scratch locks up? (when playing sound?)
That worked! Thanks
Re: Scratch locks up? (when playing sound?)
I just tried a simple llop
when green falg
forever
play meow
wait 1 secs
and my RPi locks up too
I don't have time to look into this further but if other Scratchers could just do a quick test please
Simon
when green falg
forever
play meow
wait 1 secs
and my RPi locks up too
I don't have time to look into this further but if other Scratchers could just do a quick test please
Simon
Seeking help with Scratch and I/O stuff for Primary age children
http://cymplecy.wordpress.com/ @cymplecy on twitter
http://cymplecy.wordpress.com/ @cymplecy on twitter
-
- Raspberry Pi Engineer & Forum Moderator
- Posts: 6332
- Joined: Wed Aug 17, 2011 7:41 pm
- Location: Cambridge
Re: Scratch locks up? (when playing sound?)
What version of kernel?simplesi wrote:I just tried a simple llop
when green falg
forever
play meow
wait 1 secs
and my RPi locks up too
Can you try with latest rpi-update with asound.conf file deleted?