Can I integrate Java code in C#?

wolfsoul13

New member
Joined
Feb 2, 2006
Messages
2
Id like to use javax.sound.midi.* to generate MIDI (at a specific channel, instrument and frequency), something like this:

public static void PlayNote(int channel, int note, int instrum)
{
try {
Synthesizer synth = MidiSystem.getSynthesizer();
synth.open();

final MidiChannel[] mc = synth.getChannels();
Instrument[] instr = synth.getDefaultSoundbank().getInstruments();
synth.loadInstrument(instr[instrum]);
try {
Thread.sleep(100);
} catch (InterruptedException e) {}
mc[channel].noteOn(note,200);
}
} catch (MidiUnavailableException e) {}
}
}

Id like to be able to call this from a C# project.
Can I do that?
 
It seems unlikely that you will be able to call Java code from code based on the .Net Framework. As Java is not a low level language it requires J2EE (or one of the alternative runtime environments), as such it seems unlikely that it will be cross compatible with another language that also requires its own runtime environment (.Net Framework). Im no expert, thats just my 2p on the subject.
 
You would probably have better like finding a DLL/ActiveX/.Net based MIDI library that you could use from C#.
 
Back
Top