addd midi test
This commit is contained in:
parent
dd38d049d4
commit
432b52ad6a
3 changed files with 42 additions and 16 deletions
|
@ -3462,22 +3462,7 @@ public class Client implements IThreadListener {
|
|||
}
|
||||
MidiHandle midi;
|
||||
try {
|
||||
midi = new MidiHandle(data, this.midiNoWait, this.midiVoices, this.midiBank, this.midiKeep, this.midiUnknown, this.midiVelocity) {
|
||||
private int pos = 0;
|
||||
|
||||
public long process() {
|
||||
this.bank.progchange(this.chip, (byte)0, (byte)(this.pos < 128 ? this.pos : 0));
|
||||
this.bank.progchange(this.chip, (byte)9, (byte)0);
|
||||
Log.SOUND.info("MIDI-Test #%d", this.pos);
|
||||
this.bank.noteon(this.chip, this.pos < 128 ? (byte)0 : (byte)9, (byte)(this.pos < 128 ? (byte)36 : (this.pos - 128)), (byte)127);
|
||||
this.pos++;
|
||||
if(this.pos == 128)
|
||||
this.pos = 128 + 35;
|
||||
else if(this.pos == 128 + 82)
|
||||
this.pos = 0;
|
||||
return 1000000000L;
|
||||
}
|
||||
};
|
||||
midi = new MidiHandle(data, this.midiNoWait, this.midiVoices, this.midiBank, this.midiKeep, this.midiUnknown, this.midiVelocity);
|
||||
}
|
||||
catch(Throwable e) {
|
||||
Log.SOUND.error(e, "Konnte MIDI '%s' nicht laden", file);
|
||||
|
@ -3487,6 +3472,16 @@ public class Client implements IThreadListener {
|
|||
this.audio.alMidi(midi);
|
||||
}
|
||||
|
||||
public void testMidi() {
|
||||
MidiHandle midi = new MidiHandle(this.midiVoices, this.midiBank, this.midiKeep, this.midiUnknown, this.midiVelocity);
|
||||
midi.setDebug(this.midiDebug);
|
||||
this.audio.alMidi(midi);
|
||||
}
|
||||
|
||||
public void stopMidi() {
|
||||
this.audio.alMidi(null);
|
||||
}
|
||||
|
||||
private void displayTick(int posX, int posY, int posZ) {
|
||||
int range = 16;
|
||||
Random rand = new Random();
|
||||
|
|
|
@ -7870,6 +7870,14 @@ public class AudioInterface implements Runnable {
|
|||
this.playing = true;
|
||||
}
|
||||
|
||||
public MidiHandle(int voices, MidiBank bank, boolean keep, boolean useunkn, int velofunc) {
|
||||
this.tracks = null;
|
||||
this.tpqn = 0;
|
||||
this.nowait = false;
|
||||
this.chip = new OPLChip(48000, voices, 0, false, false);
|
||||
this.bank = new BankHandle(this.chip, bank.getData(), keep, useunkn, (byte)velofunc);
|
||||
}
|
||||
|
||||
private void setTempo(int tempo) {
|
||||
this.uspb = tempo;
|
||||
this.ticktime = this.uspb / this.tpqn;
|
||||
|
@ -8122,6 +8130,19 @@ public class AudioInterface implements Runnable {
|
|||
}
|
||||
|
||||
public long process() {
|
||||
if(this.tracks == null) {
|
||||
this.bank.progchange(this.chip, (byte)0, (byte)(this.ticktime < 128 ? this.ticktime : 0));
|
||||
this.bank.progchange(this.chip, (byte)9, (byte)0);
|
||||
Log.SOUND.user("MIDI-Test %s%d", this.ticktime < 128 ? "#" : "P", this.ticktime < 128 ? this.ticktime : this.ticktime - 128);
|
||||
this.bank.noteon(this.chip, this.ticktime < 128 ? (byte)0 : (byte)9, (byte)(this.ticktime < 128 ? (byte)36 : (this.ticktime - 128)), (byte)127);
|
||||
this.ticktime++;
|
||||
if(this.ticktime == 128)
|
||||
this.ticktime = 128 + 35;
|
||||
else if(this.ticktime == 128 + 82)
|
||||
this.ticktime = 0;
|
||||
return 500000000L;
|
||||
}
|
||||
|
||||
if(!this.playing && (this.nowait || !this.chip.isPlaying())) {
|
||||
return -1L;
|
||||
}
|
||||
|
|
|
@ -116,6 +116,16 @@ public class GuiMenu extends Gui {
|
|||
});
|
||||
}
|
||||
}, "MIDI-Player"));
|
||||
this.add(new ActButton(0, 130, 180, 0, new ButtonCallback() {
|
||||
public void use(ActButton elem, PressType action) {
|
||||
GuiMenu.this.gm.testMidi();
|
||||
}
|
||||
}, "MIDI-Bank testen"));
|
||||
this.add(new ActButton(0, 150, 180, 0, new ButtonCallback() {
|
||||
public void use(ActButton elem, PressType action) {
|
||||
GuiMenu.this.gm.stopMidi();
|
||||
}
|
||||
}, "MIDI stoppen"));
|
||||
this.shift();
|
||||
this.add(new Label(4, 4, 200, 0, Color.VIOLET + Client.VERSION, true));
|
||||
this.splashLabel = this.add(new Label(0, 100, width, 0, ""));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue