На сановском форуме тоже молчат...
I try to use Sonar 6 and Beatnik to get a good sequence.
My problem is I cant delete piano instrument from the sequence while playing.
I use MIDI Yoke 1.74. Sonar 6 and Beatnik 2.1.0.1
Java 1.6.0
My steps:
I.
1. Run Beatnik.
2. Set MIDI Yoke NT:1 as input device.
3. Create new session
4. Load some samples and create instrument (each sample to each note)
5. I export my instrument to load it in Java.
II.
1. Run Sonar 6.
2. Create new project(Template 16 Track MIDI)
3. Set Track N1 to MIDI Yoke as output.
4. Add notes to the track.(they sounds right)
5. Save As Midi 0(1)
Then when I'm trying to play this sequence with soundbank in Java, I hear standart Piano.
When I handly set program(my instrument) each channel I hear my samples from my
soundbank with standart piano samples simultaneously.
Where am I wrong?
public class Seq2SynthLink
{
public static void main(String[] args) throws MidiUnavailableException, InvalidMidiDataException, IOException
{
Synthesizer synth = null;
Soundbank soundbank;
MidiDevice device = null;
try
{
MidiDevice.Info[] devices = MidiSystem.getMidiDeviceInfo();
for( int i = 0; i < devices.length; i++)
{
System.out.println("Synthesizer: " + devices[i].getName());
if((MidiSystem.getMidiDevice(devices[i]) instanceof Synthesizer) && devices[i].getName().contains("Java"))
{
System.out.println("Choosed...");
device = MidiSystem.getMidiDevice(MidiSystem.getMidiDeviceInfo()[i]);
if(!device.isOpen())
{
device.open();
}
synth = (Synthesizer) device;
}
}
// load soundbank
File file = new File("./beatnik.rmf");
soundbank = MidiSystem.getSoundbank(file);
// get instruments
synth.loadAllInstruments(soundbank);
System.out.println("Default soundbank: " + synth.getDefaultSoundbank());
Sequencer sequencer = MidiSystem.getSequencer();
Sequence sequence = MidiSystem.getSequence(new File("./ff.mid"));
sequencer.setSequence(sequence);
Transmitter trans = sequencer.getTransmitter();
Receiver rcvr = synth.getReceiver();
MidiChannel[] channel = synth.getChannels();
channel[0].programChange(2, 0);
channel[1].programChange(2, 0);
channel[2].programChange(2, 0);
channel[3].programChange(2, 0);
channel[4].programChange(2, 0);
channel[5].programChange(2, 0);
channel[6].programChange(2, 0);
channel[7].programChange(2, 0);
channel[8].programChange(2, 0);
channel[9].programChange(2, 0);
channel[10].programChange(2, 0);
channel[11].programChange(2, 0);
channel[12].programChange(2, 0);
channel[13].programChange(2, 0);
channel[14].programChange(2, 0);
channel[15].programChange(2, 0);
sequencer.open();
synth.open();
trans.setReceiver(rcvr);
sequencer.start();
for (int i = 127; i > 0; i--)
{
Thread.sleep(127);
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
}