hi, i’ve tried to play a midi sound file in J3d but i got an error as result.
Here is the code:
import javax.media.j3d.*;
import com.sun.j3d.utils.universe.*;
class TestSound
{
public static void main(String[] args)
{
String path = "file:myMusicFile.mid";
SimpleUniverse u = new SimpleUniverse();
u.getViewer().createAudioDevice();
MediaContainer media = new MediaContainer(path);
BackgroundSound sound = new BackgroundSound(media, 1, 10, false, false, true, new BoundingBox(), 1);
BranchGroup bg = new BranchGroup();
bg.addChild(sound);
u.addBranchGraph(bg);
}
}
And i get this error:
java.lang.ClassCastException
at com.sun.j3d.audioengines.headspace.J3DHaeStream.getSampleRate(J3DHaeStream.java:1035)
at com.sun.j3d.audioengines.headspace.HeadspaceMixer.prepareSound(HeadspaceMixer.java:441)
at javax.media.j3d.SoundScheduler.attachSoundData(SoundScheduler.java:2963)
...
It works perfectly with a .au file but doesn’t with midi ones. Have i missed something?