private Sound(String path) {
    URL url = Sound.class.getResource(path);
    try {
      MidiSystem.getMidiFileFormat(url);
      isMidi = true;
    } catch (InvalidMidiDataException e) {
      isMidi = false;
    } catch (IOException e) {
      e.printStackTrace();
    }
    try {
      if (isMidi) {
        sequencer = MidiSystem.getSequencer();
        sequencer.open();

        Synthesizer synth = MidiSystem.getSynthesizer();
        synth.open();

        Transmitter transmitter = sequencer.getTransmitter();
        Receiver receiver = sequencer.getTransmitters().iterator().next().getReceiver();
        transmitter.setReceiver(receiver);

        sequence = MidiSystem.getSequence(url);
        sequencer.setSequence(sequence);

      } else {
        AudioInputStream audioIn = AudioSystem.getAudioInputStream(url);
        DataLine.Info info = new DataLine.Info(Clip.class, audioIn.getFormat());
        clip = (Clip) AudioSystem.getLine(info);
        clip.open(audioIn);
        audioIn.close();
      }
    } catch (InvalidMidiDataException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    } catch (MidiUnavailableException e) {
      e.printStackTrace();
    } catch (LineUnavailableException e) {
      e.printStackTrace();
    } catch (UnsupportedAudioFileException e) {
      e.printStackTrace();
    }
  }