Re: Java and Core-Audio Midi interface
Re: Java and Core-Audio Midi interface
- Subject: Re: Java and Core-Audio Midi interface
- From: William Stewart <email@hidden>
- Date: Tue, 5 Dec 2006 16:04:48 -0800
The CAJava API has been deprecated since 10.3 and we're no longer
maintaining it. The sources that are used to build CA have been and
still are a part of the CA SDK 1.3.x (available in the SDK section of
developer.apple.com)
So, the recommendation is really one of two courses:
(1) Don't use the CAJava API - instead look at standard Java APIs to
implement the functionality you require. This is by far a preferred
option I think, as you tie into a community that is supporting the
technology.
(2) Fix the problem in the CAJava call (in this case its an
unimplemented intel code path for some of the callbacks from native
to java code) and distribute a modified version of these sources as
part of your java application.
Thanks and sorry for the inconvenience caused
Bill
On 05/12/2006, at 10:21 AM, Wolfgang Jung wrote:
Hi,
I'm trying to implement a simple java application listening to
incoming midi events. Since there is no implementation of
javax.sound.midi in
the JDK (besides Mandolane, which can't be used due to licensing
issues) i've used the more or less undocumented core-audio midi
classes.
All information found in the SDK and some search results led to the
following code, which crashes the VM after the first midi event:
import com.apple.audio.midi.*;
import com.apple.audio.util.CAFString;
public class CAMidi implements MIDIReadProc, MIDINotifyProc
{
public static void main(String[] args) throws Exception
{
CAMidi p = new CAMidi();
Thread.sleep(200000);
}
public CAMidi()
{
try {
MIDIClient mc = new MIDIClient(new CAFString("Client"), this);
MIDIInputPort ipA = mc.inputPortCreate(new CAFString("Client-
In"), this);
MIDIOutputPort outA = mc.outputPortCreate(new CAFString
("Client-Out"));
MIDIDevice bcr2000 = null;
int numberOfSources = MIDISetup.getNumberOfSources();
for (int i = 0; i < numberOfSources; i++) {
System.out.println("Source " + i + MIDISetup.getSource
(i).getStringProperty(MIDIConstants.kMIDIPropertyName));
}
for (int i = 0; i < MIDIDevice.getNumberOfDevices(); i++) {
MIDIDevice temp = MIDIDevice.getDevice(i);
if (temp.getStringProperty
(MIDIConstants.kMIDIPropertyName).toString().equals("IAC Driver")) {
bcr2000 = temp;
}
}
assert bcr2000 != null : "No IAC enabled";
MIDIEntity port1 = null;
for (int i = 0; i < bcr2000.getNumberOfEntities(); i++) {
MIDIEntity temp2 = bcr2000.getEntity(i);
if (temp2.getStringProperty
(MIDIConstants.kMIDIPropertyName).toString().equals("Bus 1")) {
port1 = temp2;
}
}
assert port1 != null : "No Bus 'IAC-Bus 1' found";
MIDIEndpoint INA = port1.getSource(0);
ipA.connectSource(INA);
System.out.println("connected");
} catch (Exception e) {
e.printStackTrace();
}
}
public void execute(MIDIInputPort port, MIDIEndpoint srcEndPoint,
MIDIPacketList list)
{
System.out.println(list.numPackets() + "packet(s).");
}
public void execute(MIDIClient arg0, MIDINotification arg1)
{
System.out.println(arg1 + " not");
}
}
No exception, but a "java.crash.log" indicating a:
Exception: EXC_BAD_ACCESS (0x0001)
Codes: KERN_PROTECTION_FAILURE (0x0002) at 0x00000015
Thread 10 Crashed:
0 CoreAudio 0x027ca2dd
Java_com_apple_audio_jdirect_MethodClosure_DisposeMethodClosure + 91
1 com.apple.audio.midi.CoreMIDI 0x9664a403
LocalMIDIReceiverList::HandleMIDIIn(void*, void*, MIDIPacketList*)
+ 195
2 com.apple.audio.midi.CoreMIDI 0x966270bf
MIDIInPortThread::Run() + 245
3 com.apple.audio.midi.CoreMIDI 0x96627d1b
XThread::RunHelper(void*) + 17
4 com.apple.audio.midi.CoreMIDI 0x9662f617 CAPThread::Entry
(CAPThread*) + 93
5 libSystem.B.dylib 0x90023d87 _pthread_body + 84
It's not a hardware issue, since the java-vm crashes even with
messages on the IAC bus. Whats going wrong with this
piece of code? I'm using 10.4.8 on an Intel MBP.
Any idea?
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
--
mailto:email@hidden
tel: +1 408 974 4056
________________________________________________________________________
__
"Much human ingenuity has gone into finding the ultimate Before.
The current state of knowledge can be summarized thus:
In the beginning, there was nothing, which exploded" - Terry Pratchett
________________________________________________________________________
__
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden