simplesi
Posts: 2327
Joined: Fri Feb 24, 2012 6:19 pm
Location: Euxton, Lancashire, UK
Contact: Website

Re: Scratch locks up? (when playing sound?)

Fri Jan 04, 2013 11:50 pm

@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
Seeking help with Scratch and I/O stuff for Primary age children
http://cymplecy.wordpress.com/ @cymplecy on twitter

MightyMat
Posts: 3
Joined: Sun Jan 06, 2013 4:33 pm

Re: Scratch locks up? (when playing sound?)

Sun Jan 06, 2013 4:43 pm

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.

Digital Larry
Posts: 73
Joined: Tue Jul 24, 2012 9:10 pm
Location: Silicon Valley, CA

Re: Scratch locks up? (when playing sound?)

Sun Jan 06, 2013 4:53 pm

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.

bouncybomb
Posts: 1
Joined: Tue Jan 08, 2013 9:22 am

Re: Scratch locks up? (when playing sound?)

Tue Jan 08, 2013 9:30 am

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.

brianjester
Posts: 6
Joined: Wed Jan 09, 2013 5:51 pm
Location: Alaska
Contact: Website

Re: Scratch locks up? (when playing sound?)

Wed Jan 09, 2013 6:02 pm

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!
Brian Jester

rixon
Posts: 1
Joined: Sat Jan 12, 2013 10:28 pm
Location: Kansas City, Kansas, USA

Re: Scratch locks up? (when playing sound?)

Sat Jan 12, 2013 10:34 pm

@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

ked
Posts: 42
Joined: Thu Aug 04, 2011 9:18 am

Re: Scratch locks up? (when playing sound?)

Mon Jan 14, 2013 1:38 pm

@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.

trazer
Posts: 22
Joined: Fri Sep 28, 2012 2:32 pm

Re: Scratch locks up? (when playing sound?)

Wed Jan 23, 2013 12:22 pm

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.

jc9566
Posts: 1
Joined: Sat Jan 26, 2013 5:18 pm

Re: Scratch locks up? (when playing sound?)

Sat Jan 26, 2013 5:37 pm

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! :D :D :D

Mystel
Posts: 4
Joined: Mon Jan 28, 2013 1:40 pm

Re: Scratch locks up? (when playing sound?)

Mon Jan 28, 2013 1:45 pm

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.

nigeldean
Posts: 1
Joined: Tue Jan 29, 2013 3:12 pm

Re: Scratch locks up? (when playing sound?)

Tue Jan 29, 2013 3:31 pm

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

ked
Posts: 42
Joined: Thu Aug 04, 2011 9:18 am

Re: Scratch locks up? (when playing sound?)

Tue Jan 29, 2013 4:19 pm

@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.

dom
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5349
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge

Re: Scratch locks up? (when playing sound?)

Thu Feb 07, 2013 5:39 pm

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.

simplesi
Posts: 2327
Joined: Fri Feb 24, 2012 6:19 pm
Location: Euxton, Lancashire, UK
Contact: Website

Re: Scratch locks up? (when playing sound?)

Fri Feb 08, 2013 5:56 pm

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
Seeking help with Scratch and I/O stuff for Primary age children
http://cymplecy.wordpress.com/ @cymplecy on twitter

FrumiousB
Posts: 3
Joined: Wed Jan 02, 2013 3:13 am

Re: Scratch locks up? (when playing sound?)

Sun Feb 10, 2013 1:43 am

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. :P

dom
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5349
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge

Re: Scratch locks up? (when playing sound?)

Sun Feb 10, 2013 1:19 pm

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. :P
Good to hear it's fixed. Seems the vchiq channel between ARM and GPU was locking up.

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

FrumiousB
Posts: 3
Joined: Wed Jan 02, 2013 3:13 am

Re: Scratch locks up? (when playing sound?)

Sun Feb 10, 2013 8:51 pm

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?)

Bruder Jacob
Posts: 1
Joined: Thu Jan 03, 2013 8:35 pm

Re: Scratch locks up? (when playing sound?)

Sun Mar 03, 2013 7:49 pm

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.

dom
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5349
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge

Re: Scratch locks up? (when playing sound?)

Sun Mar 03, 2013 8:28 pm

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.
I believe it is fixed. Either use the latest (Feburary) wheezy image from http://www.raspberrypi.org/downloads.
Or run:

Code: Select all

sudo apt-get update && sudo apt-get upgrade
and reboot.

rajivnair
Posts: 2
Joined: Sun May 05, 2013 2:15 am

Re: Scratch locks up? (when playing sound?)

Sun May 05, 2013 2:21 am

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.

[email protected] ~ $ uname -a
Linux raspberrypi 3.6.11+ #434 PREEMPT Wed May 1 21:13:52 BST 2013 armv6l GNU/Linux

Please advise

simplesi
Posts: 2327
Joined: Fri Feb 24, 2012 6:19 pm
Location: Euxton, Lancashire, UK
Contact: Website

Re: Scratch locks up? (when playing sound?)

Sun May 05, 2013 10:00 am

Could you link us to a script that shows this locking up behaviour please :)

Simon
Seeking help with Scratch and I/O stuff for Primary age children
http://cymplecy.wordpress.com/ @cymplecy on twitter

dom
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5349
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge

Re: Scratch locks up? (when playing sound?)

Sun May 05, 2013 10:07 am

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.
Can you try this:
http://www.raspberrypi.org/phpBB3/viewt ... 50#p341882

rajivnair
Posts: 2
Joined: Sun May 05, 2013 2:15 am

Re: Scratch locks up? (when playing sound?)

Sun May 05, 2013 3:06 pm

That worked! Thanks

simplesi
Posts: 2327
Joined: Fri Feb 24, 2012 6:19 pm
Location: Euxton, Lancashire, UK
Contact: Website

Re: Scratch locks up? (when playing sound?)

Tue May 07, 2013 7:40 am

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
Seeking help with Scratch and I/O stuff for Primary age children
http://cymplecy.wordpress.com/ @cymplecy on twitter

dom
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5349
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge

Re: Scratch locks up? (when playing sound?)

Tue May 07, 2013 1:43 pm

simplesi wrote:I just tried a simple llop
when green falg
forever
play meow
wait 1 secs

and my RPi locks up too
What version of kernel?
Can you try with latest rpi-update with asound.conf file deleted?

Return to “Scratch”