Results 1 to 1 of 1
- 02-19-2011, 11:01 AM #1
Member
- Join Date
- Feb 2011
- Posts
- 1
- Rep Power
- 0
MidiEvent status not recognised by Java
Dear all,
I am developing some software that can deal with MIDI files and do some fun stuff with them, but I am running into some strange trouble when analysing the MidiEvents.
I want to list all the MidiEvents occurring in a particular Track, with their tickposition, status, and precise byte-message. The tick position works fine, but I am having troubles with the status bytes.
Many of the MidiEvents are not recognised by Java and are neither NoteOn nor NoteOff events, although I think they should be. Is it me having implemented something wrong, or are these MIDI-files with a really strange format?
The following is an excerpt of the code:
Please assume that I have a class RedBlackTree that works fine, and which contains a method printTree() that executes myMidiEvent.toString() at all the nodes it contains.Java Code:public class MidiEventStorage { static Sequencer midiSequencer; public static void main(String[] args) { Sequence mySequence = loadMidiSequence(); RedBlackTree<MyMidiEvent> midiEventTree = midiSequenceToTree(mySequence); midiSequencer.start(); midiEventTree.printTree(); /*----*/pauseProg();/*--------------------------------------*/ midiSequencer.stop(); midiSequencer.close(); }// End main private static Sequence loadMidiSequence() { Sequence midiSequence; File myFile = new File(System.getProperty("user.dir")); JFileChooser fileChooser = new JFileChooser(myFile); if (fileChooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { if ( fileChooser.getSelectedFile().exists()) { try { midiSequencer = MidiSystem.getSequencer(); midiSequencer.open(); midiSequence = MidiSystem.getSequence(fileChooser.getSelectedFile()); midiSequencer.setSequence(midiSequence); return midiSequence; } catch (MidiUnavailableException e) {} catch (InvalidMidiDataException e) {} catch (IOException e) {} } } return null; } public static RedBlackTree<MyMidiEvent> midiSequenceToTree(Sequence midiSequence) { RedBlackTree<MyMidiEvent> midiEventTree = new RedBlackTree<MyMidiEvent>(); Track [] midiTracks = midiSequence.getTracks(); Track currentTrack; int size; for (int ii = 0; ii < midiTracks.length; ii++) { currentTrack = midiTracks[ii]; size = currentTrack.size(); for (int jj = 0; jj < size; jj++) { midiEventTree.insert( new MyMidiEvent(currentTrack.get(jj), ii) ); } } return midiEventTree; } public static void pauseProg() { System.out.print("Press [ENTER] to continue..."); try { System.in.read(); System.in.skip(System.in.available()); } catch(Exception e){e.printStackTrace();} } }
The System output that I tend to get generally looks like this (this is only a tiny part of the thousands of events):
So some events are recognised, but many are not. Can someone tell me why not? What is going on in the brains of Java?Java Code:@ tick 576: 153-Unknown ( 10011001 00101010 01011010), track 3 @ tick 636: 153-Unknown ( 10011001 00101010 00000000), track 3 @ tick 664: 149-Unknown ( 10010101 00100110 00000000), track 1 @ tick 768: 144-NoteOn ( 10010000 01000011 01000000), track 0 @ tick 768: 153-Unknown ( 10011001 00111000 01000000), track 3 @ tick 812: 128-NoteOff ( 10000000 01000011 00000000), track 0 @ tick 816: 144-NoteOn ( 10010000 01000010 01001010), track 0 @ tick 828: 153-Unknown ( 10011001 00111000 00000000), track 3 @ tick 860: 128-NoteOff ( 10000000 01000010 00000000), track 0 @ tick 864: 144-NoteOn ( 10010000 01000001 01011110), track 0 @ tick 864: 149-Unknown ( 10010101 00101010 01000000), track 1 @ tick 908: 128-NoteOff ( 10000000 01000001 00000000), track 0 @ tick 912: 144-NoteOn ( 10010000 01000000 01110010), track 0 @ tick 956: 128-NoteOff ( 10000000 01000000 00000000), track 0 @ tick 956: 149-Unknown ( 10010101 00101010 00000000), track 1 @ tick 960: 153-Unknown ( 10011001 00111000 00010000), track 3
Best,
Jelle
Similar Threads
-
HTTP Status 500 - java.lang.NullPointerException
By hari krishna in forum Java ServletReplies: 6Last Post: 11-26-2010, 01:18 AM -
javac not recognised
By elobire in forum New To JavaReplies: 6Last Post: 10-05-2010, 05:20 PM -
Whats the best recognised java diploma
By Haze in forum New To JavaReplies: 0Last Post: 01-27-2010, 09:09 AM -
Check LAN connection status through JAVA
By shanmathi in forum Advanced JavaReplies: 1Last Post: 04-09-2009, 03:19 PM -
java.util.Scanner not recognised
By pjm35@st-and.ac.uk in forum New To JavaReplies: 4Last Post: 06-07-2008, 03:32 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks