How do i reduce my sound file size?

I’m working on a game called “Project PREFAB” and I made a cool menu theme song for it.
The problem is, the project media had already exceded 10MB, even though I only imported one costume and one sound. I don’t know how to check the song’s MB
Can you give me tips on how to reduce it?

This is the beepbox file for the song, though I actually imported it with a .wav file.

.wav files are very large as they are lossless. You would have better luck exporting it as an mp3 file. If you want even lower size, AAC and Opus files are very small. Overall, I’d say mp3’s are your best bet

Maybe a :link: MIDI :link: will be an option.

Try saving a measure or instrument part as a separate sound. If anything needs to repeat, it is better to make a short sound play twice instead of using one long sound.

The canonical solution to this common problem is not to include the media in the project at all, but instead have an initialization routine that uses the URL block to load the media directly from wherever you found them in the first place. There’s no limit on the size of a project while it’s running.

The problem with that is, there’s no built in way to import a sound from a url. Importing costumes is there, but it’s hidden in the extension block (which isn’t used in a library). The URL block doesn’t automatically parse the data as a sound or costume, it just returns the raw data as a string.

I feel like if you’re going to advocate for this, then there should be a library that provides easy to use blocks to import media.

P.S. Importing sounds could be in scisnap, I don’t know, but you shouldn’t need to import that huge library just to import a sound from a url.

Yeah, you’re right. I don’t suppose you’re volunteering?

Yeah, I’d be able to do it

Awesome, thanks!

I think reporters COSTUME FROM URL and SOUND FROM URL would be enough, combined with things we can already do, right?

Yeah, that’s what I was thinking. I’m planning on putting them in the web services library, since that’s related.

I’ve been working on it for a while, and got sounds to load. I did notice that the cst_load(url) extension function doesn’t handle svgs, which I’d like to do, but I’m not entirely sure how.

I should think that if the URL ends with “svg” you can call
IDE_Morph.prototype.loadSVG = function (anImage, name)
but I’m not sure, because that looks like it also puts the new costume in the current sprite’s wardrobe.

Hopefully after these COSTUME and SOUND URL blocks exist, I could use the COSTUME one (along with a URL for usernames) for my user guessing program. I tried to use “cst_load” (the extension), but as egolay_atman-bay described:

Can’t wait! Maybe even (and this may be a bit complicated), it could be a option to add a costume that saves as a link, and loads the costume itself FROM that link on startup, so a COSTUME FROM URL block won’t even be needed (although, that would still be useful)

???

Looking at extensions.js:

SnapExtensions.primitives.set(
    'cst_load(url)',
    function (url, proc) {
        if (!proc.context.accumulator) {
            proc.context.accumulator = {
                img: new Image(),
                cst: null,
            };
            proc.context.accumulator.img.onload = function () {
                var canvas = newCanvas(new Point(this.width, this.height));
                canvas.getContext('2d').drawImage(this, 0, 0);
                proc.context.accumulator.cst = new Costume(canvas);
            };
            proc.context.accumulator.img.src = url;
        } else if (proc.context.accumulator.cst) {
            return proc.context.accumulator.cst;
        }
        proc.pushContext('doYield');
        proc.pushContext();
    }
);

This may not work PERFECTLY with SVGs, which is what I’m pretty sure hes talking about.

I’m saying that what’s reported is a bitmap image of the svg, rather than an actual svg costume. You can notice the difference if you switch to that costume and increase the size of the sprite, or just add the costume to the sprite’s costumes and looking at the costumes tab, since that tells you if a costume is an svg or not.

Thanks for the PR!

Of course there may be a SVG variant

You’re welcome.


I eventually settled on how to detect svg images. I feel like the code now is pretty good, and hopefully should not break if there’s any errors.

For anyone curious, here’s my pull request.

Thanks! I was able to save my project!

but now i’m concerned. 2487 KB from a single sound? Please help

You may export music with File>Export Song, file type .mid => 11kB
It does not work for sound effects, i.e. natural sounds, animals, voices.