Help capturing MIDI stream to file ...

Discussion in 'Java' started by Gerald, May 9, 2004.

  1. Gerald

    Gerald Guest

    Hi all,

    I'm trying to capture MIDI data from a Yamaha keyboard to a MIDI file.
    If I first get the MidiDevice for the Yamaha (the "YAMAHA CBX Driver")
    and hook this up to the default synthesizer, it plays on the computer
    great. However, if I try to dump it into a sequencer first and then
    play from the sequencer, it fails with a NullPointerException. Essence
    of the code is below. What am I doing wrong?

    Gerald.


    MidiDevice cbxa = getMidiDevice("YAMAHA CBX Driver");
    cbxa.open();

    Sequencer sqr = MidiSystem.getSequencer();
    sqr.open();

    Sequence s = new Sequence(Sequence.PPQ, 10);
    Track t = s.createTrack();
    sqr.setSequence(s);

    cbxa.getTransmitter().setReceiver(sqr.getReceiver());

    sqr.recordEnable(t, -1);
    System.out.println("Start recording");
    sqr.startRecording();
    Thread.sleep(5000);
    sqr.stopRecording();
    System.out.println("Stop recording");

    System.out.println("Try playing");
    Synthesizer syn = MidiSystem.getSynthesizer();
    syn.open();
    sqr.getTransmitter().setReceiver(syn.getReceiver());
    sqr.start();
    Thread.sleep(5000);
    sqr.stop();
    Gerald, May 9, 2004
    #1
    1. Advertising

  2. Gerald

    Roedy Green Guest

    Roedy Green, May 9, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. PJ

    Capturing Request Stream

    PJ, Jul 17, 2003, in forum: ASP .Net
    Replies:
    4
    Views:
    548
  2. Hugo Villeneuve

    Java MIDI output device to MIDI Yoke.

    Hugo Villeneuve, Jul 4, 2003, in forum: Java
    Replies:
    0
    Views:
    924
    Hugo Villeneuve
    Jul 4, 2003
  3. Eli
    Replies:
    6
    Views:
    7,899
    daniel08
    Apr 19, 2010
  4. Gilly
    Replies:
    6
    Views:
    409
    Ken Starks
    May 4, 2008
  5. Asbjørn Bjørnstad
    Replies:
    0
    Views:
    422
    Asbjørn Bjørnstad
    Oct 9, 2008
Loading...

Share This Page