I'm hoping someone has a better idea, but my thought is that what you are trying to do is much more difficult using Scratch than, for example, Python. The reason for this is because Scratch was designed to get kids interested in programming, not to actually create practical programs.ikn wrote: ↑Mon Dec 30, 2019 4:29 pmI,ve doing a Scratch project which will be used as a music player with gpio buttons. I have managed to get it to autostart etc and everything was going well. I initially tried my project with just four songs just to test how it would react to button presesses etc. I need 100 songs (ranging from approx 3 to 5 minutes long), so kept adding more, but when it got to 60 songs the following message popped up: “Warning! Squeak is almost out of memory!” Obviously because of all the songs I added. I had no idea this could happen before I started my Scratch project. I really need 100 songs. Wha t I would like to know, is there a way to expand the Scratch / Squeak memory to accommodate the extra songs. I have already compressed them to their lowest sound quality using the edit feature in Scratch which brought each song down to an average of 9000KB. I am completely stuck. Any suggestions would be appreciated.
Reading your post has just reminded me that I have made a mistake in my original post. When I import MP3 and WAV files , Scratch converts them and makes MP3 files larger and WAV files smaller. Strangely enough MP3 and WAV files are then exactly the same size as each other (approx 9000KB). What I should have said in my original post is that when the 60 song files are then further compressed in Scratch they are now on average 1100KB each, not 9000KB like I originally stated. It is only the Scratch program which runs out of memory (reading up about it now , it seems projects in Scratch have a limit of 50mb for some reason. I wish I had known this before I started using Scratch). The Raspberry Pi itself should handle a lot more than 100 songs even at their uncompressed size, I assume it's only limited by the particular program you use and storage space on SD card or am I mistaken. Any thoughts from anybody on that would be appreciated as well. In the meantime I will take a look at Squeak Smalltalk like you suggested.timrowledge wrote: ↑Tue Dec 31, 2019 10:34 pmWell if your music samples are actulaly typically 9000kb - ie 9Mb, then 100 of them is almost the entirety of a Pi's memory. You can't be surprised if Scratch - or any program - complains about getting short of memory when loaded up that much!
Your problem is that the way Scratch handles sounds is to load them into memory rather than play from a file. That means there is a hard limit on the amount of sound data that can be loaded.
So, there are at least a couple of ways around this
a) the obvious one of simply reducing the number of sound samples you load into a single scratch project.
b) rewrite your system in some manner. Of course, a lot of people around here will urge you to do it in Python and you may prefer to do that. However, I suggest considering using Smalltalk, the language that Squeak is built in. All the sound handling and gpio reding that I think you're interested in are easily dealt with in Squeak Smalltalk. Let me know...
That's curious; I don't recall ever reading anything aobut that whilst doing the Scratch development work - but then I never tried to push the size of project files.
The problem here is that adding a sound sample to a Scratch project simply copies into the project and does some conversion (if needed) to a suitable data form. Then you write out the project and all the sound data as well as your scripts is written to a file.ikn wrote: ↑Wed Jan 01, 2020 3:38 pmThe Raspberry Pi itself should handle a lot more than 100 songs even at their uncompressed size, I assume it's only limited by the particular program you use and storage space on SD card or am I mistaken. Any thoughts from anybody on that would be appreciated as well. In the meantime I will take a look at Squeak Smalltalk like you suggested.
That is correct. I have 20 momentary buttons. 10 of which are labelled with numbers and the other 10 with letters. When a certain number button and letter button are pressed at same time then it will play a particular song associated with that particular number/letter combination. There are 100 button combinations, so in total 100 different songs can be selected.timrowledge wrote: ↑Thu Jan 02, 2020 2:36 am
I think what you probably want is a system where you have a directory of sound files, a program that reads some gpio attached buttons and plays the matching sound file - is that what you're really after? And IIRC you want this to start at boot, be headless and Just Work?
I have just tried it again with an empty project (no blocks) and with 60 songs imported and compressed and with no GPIO buttons but it still has the memory problem as soon as any more songs are added. It seems Scratch can't handle any more songs. It's a shame really because it seemed to be working well. There doesnt't seem to be any more that can be done to condense the project. I tried Scratch2 but this would only take 25 songs before the memory problem started.
How hard is it too make a new block in scratch that simply plays the specified music file from the filesystem?timrowledge wrote: ↑Thu Jan 16, 2020 2:28 amYeah, I can’t do any magic to make sound samples smaller but I probably can do some to make a way to play sounds from named files instead of samples loaded in the project file.
Failing that I can certainly make a way to do it in straight Smalltalk. Like I said, an interesting problem.
That sounds reasonable. I find it's always important for a GPIO server to have the ability to play arbitrary music files directly from the filesystem. Have you considered adding a feature for sending and receiving email as well?
Well thanks; same to you. Been busy the last couple of years being a CTO for an Ottawa based AI/Smalltalk company. I am hoping to do a refresh release of Scratch soon in order to update it to run in Squeak 5.3. A. bit faster, include full access to the Smalltalk behind the scenes, make sure it can be used easily for the sort of amusing script stuff that was discussed for the infamous ‘million character Fibonacci number ‘ thread.
I was just about to post a bet that you had already done this. So now the challenge is to help ikn work out installing it and converting their Scratch project. Cool!