MusicEventIterator problems
MusicEventIterator problems
- Subject: MusicEventIterator problems
- From: Scott Ruda <email@hidden>
- Date: Wed, 23 Jul 2003 20:34:08 -0700
I'm trying to use the MusicEventIterator of a MusicTrack (Java CA API)
and encountering a some problems.
I have code essentially like this (per the sparse comments in the
javadocs):
MusicEventIterator iter = mySequence.getIndTrack(trackNum).events();
while (iter.hasCurrentEvent()) {
int type = iter.getEventType();
double time = iter.getEventTime();
CAMemoryObject e = iter.getEvent();
int size = e.getSize();
...
iter.nextEvent();
}
When a MetaEvent is encountered the size returned appears to be bogus,
like values of 1385339653. NoteEvents and ChannelEvents seem to have a
correct size. Often times when calling iter.getEvent() I get the
following exception thrown:
java.lang.ClassCastException: Wrong size for type
at com.apple.audio.util.MIDIData.init(MIDIData.java:154)
at com.apple.audio.util.MIDIData.<init>(MIDIData.java:110)
at com.apple.audio.toolbox.JNIToolbox.newMIDIData(Native Method)
at
com.apple.audio.toolbox.MusicEventIterator.getEvent(MusicEventIterator.j
ava:251)
at MusicSequenceParser.parse(MusicSequenceParser.java:75)
The exception is not always thrown and that's when I can see the size
returned is out of whack.
Note though the javadocs say the return type of iter.getEvent() is a
CAMemoryObject, the debugger indicates it is actually a MIDIData object
(also the backtrace of the exception is in the construction of a
MIDIData object). If I cast the event object to a MIDIData object and
call its getMIDIDataLength() method I also get the wrong size.
I've seen some other comments on this list stating that the length of
sysex messages in MIDI driver callbacks is wrong too. This may be
related, but maybe not, as this is parsing an SMF and not MIDI wire
data and not sysex. It is possible that they both rely on some common
services that are determining MIDIData block lengths, and that is where
the underlying problem lies.
I'm using Java 141DP102. I hope that I've found something that can
still be fixed in the next Java GM release, as right now it appears
that the MusicEventIterator is unusable (well, unless I just ignore all
Meta messages, but I really need those to get the track names, tempos
etc.)
Unless someone can see something wrong in what I'm doing, I'll file a
bug report on this.
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.