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

How to fix "Synthesizer not found" and "invalid meta event" ? #13

Open
ghopretz opened this issue Sep 28, 2018 · 2 comments
Open

How to fix "Synthesizer not found" and "invalid meta event" ? #13

ghopretz opened this issue Sep 28, 2018 · 2 comments

Comments

@ghopretz
Copy link

ghopretz commented Sep 28, 2018

screenshot_1538156860
screenshot_1538156808

My Code in Android Studio is:

	try {
		Synthesizer synthesizer = MidiSystem.getSynthesizer();
		synthesizer.open();
		synthesizer.unloadAllInstruments(synthesizer.getDefaultSoundbank());
synthesizer.loadAllInstruments(MidiSystem.getSoundbank(getAssets().open("SmallTimGM6mb.sf2")));

		Sequencer sequencer = MidiSystem.getSequencer(false);
		sequencer.open();
		sequencer.getTransmitter().setReceiver(synthesizer.getReceiver());

		InputStream inputStream = new BufferedInputStream(getAssets().open("lagu.mid"));
		sequencer.setSequence(inputStream);
		sequencer.start();
		Toast.makeText(this, "play", Toast.LENGTH_SHORT).show();
	} catch (Exception e) {
		Toast.makeText(this, "error "+e.toString(), Toast.LENGTH_SHORT).show();
	}
@liuyubupt
Copy link

Have you solved your problem, I have a problem similar to yours.
the same code ' Synthesizer synthesizer = MidiSystem.getSynthesizer(); ', but the synthesizer is null.
and when i use 'sequencer.start()', there is no sound.

@bmaupin
Copy link

bmaupin commented Feb 24, 2022

MidiSystem.getSynthesizer()

This library appears to be a port of javax.sound.midi, which I don't believe includes a synthesizer.

Someone else has ported the synthesizer from com.sun.media.sound, which also conveniently bundles this library: https://github.com/KyoSherlock/MidiDriver

It also bundles a sample app which shows you how to use it: https://github.com/KyoSherlock/MidiDriver/blob/master/sample/src/main/java/cn/sherlock/midi/sample/MainActivity.java

I have an updated fork of that project here in case it helps: https://github.com/bmaupin/MidiDriver

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