initial midi test success!!
This commit is contained in:
parent
753f591898
commit
db6f87a740
7 changed files with 3451 additions and 30 deletions
|
@ -14,6 +14,7 @@ import java.net.InetAddress;
|
|||
import java.net.UnknownHostException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.file.Files;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Date;
|
||||
|
@ -29,10 +30,13 @@ import java.util.function.Function;
|
|||
import javax.imageio.ImageIO;
|
||||
import javax.swing.JFileChooser;
|
||||
|
||||
import org.lwjgl.opengl.GL;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL13;
|
||||
|
||||
import client.audio.AudioInterface;
|
||||
import client.audio.AudioInterface.MidiBank;
|
||||
import client.audio.AudioInterface.MidiHandle;
|
||||
import client.audio.SoundManager;
|
||||
import client.audio.Volume;
|
||||
import client.gui.FileCallback;
|
||||
|
@ -278,6 +282,12 @@ public class Client implements IThreadListener {
|
|||
}
|
||||
}
|
||||
|
||||
public static class MidiDebugFunction implements BoolFunction {
|
||||
public void apply(BoolVar cv, boolean value) {
|
||||
Client.CLIENT.setMidiDebug();
|
||||
}
|
||||
}
|
||||
|
||||
private interface DebugRunner {
|
||||
void execute(Keysym key);
|
||||
}
|
||||
|
@ -623,6 +633,27 @@ public class Client implements IThreadListener {
|
|||
@Variable(name = "snd_frame_size", category = CVarCategory.SOUND, min = 2, max = 8192, display = "Intervall")
|
||||
private int soundFrameSize = 32;
|
||||
|
||||
@Variable(name = "mid_dont_fade", category = CVarCategory.SOUND, display = "Nicht ausklingen")
|
||||
private boolean midiNoWait = false;
|
||||
@Variable(name = "mid_opl_voices", category = CVarCategory.SOUND, min = 4, max = 192, display = "OPL-Stimmen")
|
||||
private int midiVoices = 64;
|
||||
@Variable(name = "mid_keep_notes", category = CVarCategory.SOUND, display = "Stimmen behalten")
|
||||
private boolean midiKeep = false;
|
||||
@Variable(name = "mid_play_unknown", category = CVarCategory.SOUND, display = "Unbekannte Banken")
|
||||
private boolean midiUnknown = true;
|
||||
// STR(MID_VELO_LOG, "", "Log.+Minimum [m+nlog(x)]")
|
||||
// STR(MID_VELO_ATTN, "", "Log. Gedämpft [nlog(x)]")
|
||||
// STR(MID_VELO_LIN, "", "Linear [x]")
|
||||
// STR(MID_VELO_ONE, "", "Vollklang [1]")
|
||||
@Variable(name = "mid_velocity_func", category = CVarCategory.SOUND, min = -128, max = 127, display = "Anschlag")
|
||||
private int midiVelocity = 1;
|
||||
@Variable(name = "mid_opl_bank", category = CVarCategory.SOUND, display = "Bank")
|
||||
private MidiBank midiBank = MidiBank.DMX_DMX;
|
||||
@Variable(name = "mid_debug_events", category = CVarCategory.SOUND, display = "MIDI-Debug", callback = MidiDebugFunction.class)
|
||||
private boolean midiDebug = false;
|
||||
@Variable(name = "mid_visualizer", category = CVarCategory.SOUND, display = "Visualisation")
|
||||
private boolean midiVisualizer = true;
|
||||
|
||||
public static final Client CLIENT = new Client();
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
@ -642,8 +673,8 @@ public class Client implements IThreadListener {
|
|||
CLIENT.run(time);
|
||||
Window.end();
|
||||
}
|
||||
|
||||
private Client() {
|
||||
|
||||
private Client() {
|
||||
}
|
||||
|
||||
private NetConnection connect(InetAddress address, int port) {
|
||||
|
@ -2272,6 +2303,10 @@ public class Client implements IThreadListener {
|
|||
public void run(long time) {
|
||||
if(!Window.createWindow(VERSION, System.getProperty("opengl.debug") != null))
|
||||
System.exit(1);
|
||||
if(!GL.getCapabilities().OpenGL15) {
|
||||
Window.destroyWindow();
|
||||
Util.panic("Inkompatible OpenGL-Version", "OpenGL 1.5 oder höher ist erforderlich, um dieses Programm auszuführen.");
|
||||
}
|
||||
Log.SYSTEM.info("OpenGL %s", GL11.glGetString(GL11.GL_VERSION));
|
||||
Log.SYSTEM.info("GL_VENDOR: %s", GL11.glGetString(GL11.GL_VENDOR));
|
||||
Log.SYSTEM.info("GL_RENDERER: %s", GL11.glGetString(GL11.GL_RENDERER));
|
||||
|
@ -2557,6 +2592,14 @@ public class Client implements IThreadListener {
|
|||
this.renderer.setDisplayListEntitiesDirty();
|
||||
}
|
||||
|
||||
public void setMidiDebug() {
|
||||
if(this.audio != null) {
|
||||
MidiHandle midi = this.audio.alGetMidi();
|
||||
if(midi != null)
|
||||
midi.setDebug(this.midiDebug);
|
||||
}
|
||||
}
|
||||
|
||||
private void registerDebug(Keysym key, String help, DebugRunner runner) {
|
||||
if(this.debug.containsKey(key))
|
||||
throw new IllegalStateException("Debug-Taste " + key.getDisplay() + " ist bereits registriert");
|
||||
|
@ -3407,6 +3450,26 @@ public class Client implements IThreadListener {
|
|||
Log.NETWORK.debug("Variable %s = %s", name, value);
|
||||
}
|
||||
}
|
||||
|
||||
public void playMidi(File file) {
|
||||
byte[] data;
|
||||
try {
|
||||
data = Files.readAllBytes(file.toPath());
|
||||
}
|
||||
catch(Throwable e) {
|
||||
Log.SOUND.error(e, "Konnte Datei '%s' nicht laden", file);
|
||||
return;
|
||||
}
|
||||
MidiHandle midi;
|
||||
try {
|
||||
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);
|
||||
return;
|
||||
}
|
||||
this.audio.alMidi(midi);
|
||||
}
|
||||
|
||||
private void displayTick(int posX, int posY, int posZ) {
|
||||
int range = 16;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue