Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consuming a lot of ram #245

Open
om3g4zell opened this issue Jan 31, 2019 · 5 comments
Open

Consuming a lot of ram #245

om3g4zell opened this issue Jan 31, 2019 · 5 comments

Comments

@om3g4zell
Copy link

Hi,

Is there another way to load an instrument than :

MIDI.loadResource({
        instrument: instrumentid,
        onprogress: function (state, percent) {
            console.log(state, percent);
        },
        onsuccess: function () {
            console.log("onSuccess : " + instrumentid);
            MIDI.programChange(channel, instrumentid);
        }
    });

Because each time I load an instrument the google tab has an increase of 100Mb of ram.
If there is no other way to load them can we unload instruments ?

@om3g4zell
Copy link
Author

Chrome tab*

@hmoffatt
Copy link

hmoffatt commented Feb 3, 2019

On load it decompresses all the samples back to raw PCM audio. The sound fonts (if generated with the included soundfont builder script) have 3 seconds of stereo audio for 80+ notes.. that is where your 100Mb+ per instrument comes from.

I reduced it in my application by trimming silence in the sound fonts so that they are not all 3 seconds. That will help for any instrument sound that decays, like a piano, or drums. It helps for drums especially because some of the notes do not even have a sound - with the original script you have 3 seconds of silence loaded!

@shivrajsa
Copy link

@hmoffatt , Could you please share how you have managed to trim silence in the audio file ?
Is there any quick way to process all samples in single operation ? please guide.

@hmoffatt
Copy link

hmoffatt commented Apr 23, 2019

I modified the converter (soundfont_builder.rb) to run sox before encoding in order to strip off the silence. The extra line is

run_command "#{SOX} #{target}.orig.wav #{target} reverse silence 1 0.1 0 pad 0.0001@0 reverse channels 1"

I haven't published my whole modified script anywhere as it has other unrelated changes but you get the idea from the above.

@shivrajsa
Copy link

Thank you @hmoffatt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants