Discuss Scratch

PurplePyramid
Scratcher
46 posts

How much RAM do sound files take up compared to their disc storage size?

Lets say I have a sound file in my project that is 70 kb on the disc. How much RAM will it take up? Also 70 kb?

Images take up way more RAM than disc space with scratch. Like, a small 60 kb image on the disc takes up a whole MB of RAM (1200 kg) when opened in a scratch project. I think this is because a lot more info on the image is loaded for easy access to the color rastor, and also because scratch might be storing the image twice (I know it used to store lists twice). So, do sound files get blown up when loaded on scratch in the RAM like image files do?

I've tried testing myself, but the RAM is fluctuating a lot on my scratch project so I can't get an accurate read when loading different versions with different amounts of sound files in them. (Technically I'm doing this on Turbowarp, but I assume its the same for scratch projects).

Trying to plan for a project. If I have 100 MB of sound files in total, will that get completely blown up to multiple gigbytes and crash on systems without much RAM? Or will it be about 100 MB of sound in RAM when loaded?

Last edited by PurplePyramid (May 15, 2024 06:05:53)

dynamicsofscratch
Scratcher
1000+ posts

How much RAM do sound files take up compared to their disc storage size?

RAM usage doesn't directly correlate with size of a sound file.
RAM usage (as far as I know) for sounds varies upon the Bitrate. Higher Bitrate should mean higher RAM usage (I don't know I'm not an audio guy)

aII toasters toast toast, but what happens when there are no longer toasters being produced? will their technology simply become obsolete, with humans moving onto bigger, better things? will toast become a distant memory, written in textbooks of the future as foods us simpler generations ate? who's to say! society is constantly moving, changing, evolving, ideas being built upon, improved upon, theories being proven or disproven. are we but a blip on the timeline? sure, our names may not be remembered, but that's not the point. you can make a change. you can make a difference. you can make the world better, even if you don't know yet. and the first step is to go for it. even if you are afraid of failure. going back to the example of toasters, do you know off the top of your head who invented them? no? have you used one? probably. so, even if you don't remember my name, if I was able to help awnser your question, that is enough. if I was able to help you, even in the slightest way, this could push you to continue with scratch and not give up after the program crashes, and maybe one day learn other programming languages and change the world. everything is a cause and effect reaction, new inventions lead to the technology of the future, and even as the generations of the past are slowly forgotten, their influence lives on to this day, affecting how the world eventually turned out and how it will be for generations to come.

and, without toasters, we wouldn't have toast.


Regards
dynamicsofscratch

Anything above that grey line is a signature!
Also, anything can be put in your signature, (also referred as a siggy) including ads but! You cannot do anything else that violates the community guidelines as, you will be reported and you could be banned/muted.
Computer enthusiast, coder, designer and a offline veteran.
700th post
PurplePyramid
Scratcher
46 posts

How much RAM do sound files take up compared to their disc storage size?

dynamicsofscratch wrote:

RAM usage doesn't directly correlate with size of a sound file.
RAM usage (as far as I know) for sounds varies upon the Bitrate. Higher Bitrate should mean higher RAM usage (I don't know I'm not an audio guy)

Thanks, this gives me a starting point to look into!
CST1229
Scratcher
1000+ posts

How much RAM do sound files take up compared to their disc storage size?

To test this, I made a blank (stereo, 44100Hz EDIT: apparently TurboWarp says it's 48000Hz?) .mp3 file in Audacity that's over an hour long, 1:01:28 to be exact. It was 14.6 megabytes in size. For comparison I also made an uncompressed .wav version (using a 16-bit encoding), which is a whopping 650 MB.

I then opened TurboWarp (because I don't feel like using vanilla, since that would pretty much either require logging out or using the offline editor which I don't have, as the sound is over 10MB even when compressed), put the .mp3 version of the sound into a blank project and saved it.
I then reloaded the page, opened Firefox's Task Manager (which lets you see the memory usage of tabs) and loaded the project. As it loaded, I saw the memory usage increase all the way up to 4GB (Firefox doesn't let me see a more accurate number), but when the project finished loading it dropped back down to 1GB. It also took around 22 seconds to load.

(I was gonna put more detailed findings here involving Firefox's developer tools but then I realized i did all those observerations in the editor, so they probably took up more RAM. The relevant thing you need to know is that sounds in memory are stored uncompressed in RAM and they seem to take up around twice as much RAM as a normal 16-bit encoding.)

So, for measurement, I resaved that .mp3 file as an uncompressed .wav, in a 32-bit format. It took up 1.3GB of space on my hard drive.
Additionally, I wanted to test what other factors can affect the memory usage. So I made 2 more versions of that .mp3 file. One was converted to mono (from stereo), and for the other I lowered the sample rate down to 11025Hz, a quarter of the usual sample rate, and then I saved 2 blank projects with those 2 sounds.
The mono sound project ended up using around 800 megabytes of RAM, most likely half of the full sound's RAM usage. The quarter sample rate project… still used 1GB of RAM.

So: Sounds seem to take up around 2x as much RAM as how much they would take if you saved them as a regular 44100Hz .wav file in a 16-bit encoding, alongside the original compressed sound's file size. However, while loading, they might take up as much as 8x RAM, and it will also increase loading times. They might also take up more memory in the editor too.
The memory usage can't be decreased by compressing the sound or lowering its sample rate, as Scratch uncompresses and reencodes it when loading the project. However, you can decrease it by making the sound mono instead of stereo, though this will also decrease the quality of it a bit.

Last edited by CST1229 (May 16, 2024 04:37:35)


This is a signature. It's a piece of text that appears below every post I write. Click here to learn more, including how to make your own.
RIP assets image hosting. 2013?-2023



dynamicsofscratch
Scratcher
1000+ posts

How much RAM do sound files take up compared to their disc storage size?

CST1229 wrote:

(#4)
To test this, I made a blank (stereo, 44100Hz) .mp3 file that's over an hour long, 1:01:28 to be exact. It was 14.6 megabytes in size. For comparison I also made an uncompressed .wav version (using a 16-bit encoding), which is a whopping 650 MB.

I then opened TurboWarp (because I don't feel like using vanilla, since that would pretty much either require logging out or using the offline editor which I don't have, as the sound is over 10MB even when compressed), put the .mp3 version of the sound into a blank project and saved it.
I then reloaded the page, opened Firefox's Task Manager (which lets you see the memory usage of tabs) and loaded the project. As it loaded, I saw the memory usage increase all the way up to 4GB (Firefox doesn't let me see a more accurate number), but when the project finished loading it dropped back down to 1GB. It also took around 22 seconds to load.

(I was gonna put more detailed findings here involving Firefox's developer tools but then I realized i did all those observerations in the editor, so they probably took up more RAM. The relevant thing you need to know is that sounds in memory are stored uncompressed in RAM and they seem to take up around twice as much RAM as a normal 16-bit encoding.)

So, for measurement, I resaved that .mp3 file as an uncompressed .wav, in a 32-bit format. It took up 1.3GB of space on my hard drive.
Additionally, I wanted to test what other factors can affect the memory usage. So I made 2 more versions of that .mp3 file. One was converted to mono (from stereo), and for the other I lowered the sample rate down to 11025Hz, a quarter of the usual sample rate, and then I saved 2 blank projects with those 2 sounds.
The mono sound project ended up using around 800 megabytes of RAM, most likely half of the full sound's RAM usage. The quarter sample rate project… still used 1GB of RAM.

So: Sounds seem to take up around 2x as much RAM as how much they would take if you saved them as a regular 44100Hz .wav file in a 16-bit encoding, alongside the original compressed sound's file size. However, while loading, they might take up as much as 8x RAM, and it will also increase loading times. They might also take up more memory in the editor too.
The memory usage can't be decreased by compressing the sound or lowering its sample rate, as Scratch uncompresses and reencodes it when loading the project. However, you can decrease it by making the sound mono instead of stereo, though this will also decrease the quality of it a bit.
holy
edit: im gonna also test this stuff out in chrome

Last edited by dynamicsofscratch (May 15, 2024 16:24:20)


aII toasters toast toast, but what happens when there are no longer toasters being produced? will their technology simply become obsolete, with humans moving onto bigger, better things? will toast become a distant memory, written in textbooks of the future as foods us simpler generations ate? who's to say! society is constantly moving, changing, evolving, ideas being built upon, improved upon, theories being proven or disproven. are we but a blip on the timeline? sure, our names may not be remembered, but that's not the point. you can make a change. you can make a difference. you can make the world better, even if you don't know yet. and the first step is to go for it. even if you are afraid of failure. going back to the example of toasters, do you know off the top of your head who invented them? no? have you used one? probably. so, even if you don't remember my name, if I was able to help awnser your question, that is enough. if I was able to help you, even in the slightest way, this could push you to continue with scratch and not give up after the program crashes, and maybe one day learn other programming languages and change the world. everything is a cause and effect reaction, new inventions lead to the technology of the future, and even as the generations of the past are slowly forgotten, their influence lives on to this day, affecting how the world eventually turned out and how it will be for generations to come.

and, without toasters, we wouldn't have toast.


Regards
dynamicsofscratch

Anything above that grey line is a signature!
Also, anything can be put in your signature, (also referred as a siggy) including ads but! You cannot do anything else that violates the community guidelines as, you will be reported and you could be banned/muted.
Computer enthusiast, coder, designer and a offline veteran.
700th post
PurplePyramid
Scratcher
46 posts

How much RAM do sound files take up compared to their disc storage size?

CST1229 wrote:

To test this, I made a blank (stereo, 44100Hz) .mp3 file in Audacity that's over an hour long, 1:01:28 to be exact. It was 14.6 megabytes in size. For comparison I also made an uncompressed .wav version (using a 16-bit encoding), which is a whopping 650 MB.

I then opened TurboWarp (because I don't feel like using vanilla, since that would pretty much either require logging out or using the offline editor which I don't have, as the sound is over 10MB even when compressed), put the .mp3 version of the sound into a blank project and saved it.
I then reloaded the page, opened Firefox's Task Manager (which lets you see the memory usage of tabs) and loaded the project. As it loaded, I saw the memory usage increase all the way up to 4GB (Firefox doesn't let me see a more accurate number), but when the project finished loading it dropped back down to 1GB. It also took around 22 seconds to load.

(I was gonna put more detailed findings here involving Firefox's developer tools but then I realized i did all those observerations in the editor, so they probably took up more RAM. The relevant thing you need to know is that sounds in memory are stored uncompressed in RAM and they seem to take up around twice as much RAM as a normal 16-bit encoding.)

So, for measurement, I resaved that .mp3 file as an uncompressed .wav, in a 32-bit format. It took up 1.3GB of space on my hard drive.
Additionally, I wanted to test what other factors can affect the memory usage. So I made 2 more versions of that .mp3 file. One was converted to mono (from stereo), and for the other I lowered the sample rate down to 11025Hz, a quarter of the usual sample rate, and then I saved 2 blank projects with those 2 sounds.
The mono sound project ended up using around 800 megabytes of RAM, most likely half of the full sound's RAM usage. The quarter sample rate project… still used 1GB of RAM.

So: Sounds seem to take up around 2x as much RAM as how much they would take if you saved them as a regular 44100Hz .wav file in a 16-bit encoding, alongside the original compressed sound's file size. However, while loading, they might take up as much as 8x RAM, and it will also increase loading times. They might also take up more memory in the editor too.
The memory usage can't be decreased by compressing the sound or lowering its sample rate, as Scratch uncompresses and reencodes it when loading the project. However, you can decrease it by making the sound mono instead of stereo, though this will also decrease the quality of it a bit.

Thanks for this in-depth testing! The early startup high ram usage and then going back down was what I experienced as well in my testing, which I brushed off as fluctuations and discounted entirely. In my testing I had one project with about 2 Mb of sound, and the other had 0. Both on startup were using ~600 Mb of RAM, and dropped down to ~300 after a minute or so. It might have been more pronounced if I had used a larger sample size of sound to compare to.

The mono vs stereo trick I did not expect. In the editor it shows (what I'm guessing is) the compressed file size, and whenever I convert from stereo to mono the file size goes up ~4x, as well as warning you before you do it that you won't be able to convert it back to stereo, so I assumed stereo would be better for RAM.
dynamicsofscratch
Scratcher
1000+ posts

How much RAM do sound files take up compared to their disc storage size?

PurplePyramid wrote:

(#6)

CST1229 wrote:

To test this, I made a blank (stereo, 44100Hz) .mp3 file in Audacity that's over an hour long, 1:01:28 to be exact. It was 14.6 megabytes in size. For comparison I also made an uncompressed .wav version (using a 16-bit encoding), which is a whopping 650 MB.

I then opened TurboWarp (because I don't feel like using vanilla, since that would pretty much either require logging out or using the offline editor which I don't have, as the sound is over 10MB even when compressed), put the .mp3 version of the sound into a blank project and saved it.
I then reloaded the page, opened Firefox's Task Manager (which lets you see the memory usage of tabs) and loaded the project. As it loaded, I saw the memory usage increase all the way up to 4GB (Firefox doesn't let me see a more accurate number), but when the project finished loading it dropped back down to 1GB. It also took around 22 seconds to load.

(I was gonna put more detailed findings here involving Firefox's developer tools but then I realized i did all those observerations in the editor, so they probably took up more RAM. The relevant thing you need to know is that sounds in memory are stored uncompressed in RAM and they seem to take up around twice as much RAM as a normal 16-bit encoding.)

So, for measurement, I resaved that .mp3 file as an uncompressed .wav, in a 32-bit format. It took up 1.3GB of space on my hard drive.
Additionally, I wanted to test what other factors can affect the memory usage. So I made 2 more versions of that .mp3 file. One was converted to mono (from stereo), and for the other I lowered the sample rate down to 11025Hz, a quarter of the usual sample rate, and then I saved 2 blank projects with those 2 sounds.
The mono sound project ended up using around 800 megabytes of RAM, most likely half of the full sound's RAM usage. The quarter sample rate project… still used 1GB of RAM.

So: Sounds seem to take up around 2x as much RAM as how much they would take if you saved them as a regular 44100Hz .wav file in a 16-bit encoding, alongside the original compressed sound's file size. However, while loading, they might take up as much as 8x RAM, and it will also increase loading times. They might also take up more memory in the editor too.
The memory usage can't be decreased by compressing the sound or lowering its sample rate, as Scratch uncompresses and reencodes it when loading the project. However, you can decrease it by making the sound mono instead of stereo, though this will also decrease the quality of it a bit.

Thanks for this in-depth testing! The early startup high ram usage and then going back down was what I experienced as well in my testing, which I brushed off as fluctuations and discounted entirely. In my testing I had one project with about 2 Mb of sound, and the other had 0. Both on startup were using ~600 Mb of RAM, and dropped down to ~300 after a minute or so. It might have been more pronounced if I had used a larger sample size of sound to compare to.

The mono vs stereo trick I did not expect. In the editor it shows (what I'm guessing is) the compressed file size, and whenever I convert from stereo to mono the file size goes up ~4x, as well as warning you before you do it that you won't be able to convert it back to stereo, so I assumed stereo would be better for RAM.
you can test things yourself by using chrome's inbuilt ram monitor

aII toasters toast toast, but what happens when there are no longer toasters being produced? will their technology simply become obsolete, with humans moving onto bigger, better things? will toast become a distant memory, written in textbooks of the future as foods us simpler generations ate? who's to say! society is constantly moving, changing, evolving, ideas being built upon, improved upon, theories being proven or disproven. are we but a blip on the timeline? sure, our names may not be remembered, but that's not the point. you can make a change. you can make a difference. you can make the world better, even if you don't know yet. and the first step is to go for it. even if you are afraid of failure. going back to the example of toasters, do you know off the top of your head who invented them? no? have you used one? probably. so, even if you don't remember my name, if I was able to help awnser your question, that is enough. if I was able to help you, even in the slightest way, this could push you to continue with scratch and not give up after the program crashes, and maybe one day learn other programming languages and change the world. everything is a cause and effect reaction, new inventions lead to the technology of the future, and even as the generations of the past are slowly forgotten, their influence lives on to this day, affecting how the world eventually turned out and how it will be for generations to come.

and, without toasters, we wouldn't have toast.


Regards
dynamicsofscratch

Anything above that grey line is a signature!
Also, anything can be put in your signature, (also referred as a siggy) including ads but! You cannot do anything else that violates the community guidelines as, you will be reported and you could be banned/muted.
Computer enthusiast, coder, designer and a offline veteran.
700th post

Powered by DjangoBB