package io.github.daveho.gervill4beads.demo;

import java.io.File;
import java.io.IOException;
import java.util.Scanner;

import javax.sound.midi.MidiUnavailableException;

import com.sun.media.sound.SF2Soundbank;
import com.sun.media.sound.SoftSynthesizer;

/**
 * Demo to load a sound font (.sf2) file and play live.
 * Plays with whatever the sound font's default instrument is (?).
 */
public class DemoLoadSoundFont extends Demo {
	private String fileName;

	public DemoLoadSoundFont(String fileName) {
		this.fileName = fileName;
	}

	@Override
	public void start() throws MidiUnavailableException {
		try {
			SoftSynthesizer synth = gervill.getSynth();
			
			SF2Soundbank sb = new SF2Soundbank(new File(fileName));
			synth.loadAllInstruments(sb);
			
			super.start();
		} catch (IOException e) {
			throw new RuntimeException("Could not load sound font", e);
		}
	}
	
	public static void main(String[] args) throws MidiUnavailableException {
		@SuppressWarnings("resource")
		Scanner keyboard = new Scanner(System.in);
		String fileName = Util.chooseDirectoryAndFile(keyboard, ".sf2");
		DemoLoadSoundFont demo = new DemoLoadSoundFont(fileName);
		demo.start();
	}
}

@@ -950,40 +950,8 @@
 n %7B%0A
-%09%09@SuppressWarnings(%22resource%22)%0A
 %09%09Sc

fix an eclipse warning