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;
|
||||
|
|
File diff suppressed because it is too large
Load diff
978
client/src/main/java/client/audio/OPLChip.java
Normal file
978
client/src/main/java/client/audio/OPLChip.java
Normal file
|
@ -0,0 +1,978 @@
|
|||
package client.audio;
|
||||
|
||||
public class OPLChip {
|
||||
private static enum ChType {
|
||||
CH2OP,
|
||||
CH4OP1,
|
||||
CH4OP2
|
||||
};
|
||||
|
||||
private static enum EnvState {
|
||||
ATTACK,
|
||||
DECAY,
|
||||
SUSTAIN,
|
||||
RELEASE
|
||||
};
|
||||
|
||||
private static interface ModGen {
|
||||
short getModulation();
|
||||
}
|
||||
|
||||
private static interface envelope_sinfunc {
|
||||
short calcPhase(short phase, short envelope);
|
||||
}
|
||||
|
||||
public class OPLSlot implements ModGen {
|
||||
OPLChannel channel;
|
||||
short out;
|
||||
short fbmodv;
|
||||
final ModGen fbmod = new ModGen() {
|
||||
public short getModulation() {
|
||||
return OPLSlot.this.fbmodv;
|
||||
}
|
||||
};
|
||||
ModGen mod;
|
||||
short prout;
|
||||
short eg_rout;
|
||||
short eg_out;
|
||||
EnvState eg_gen;
|
||||
byte eg_ksl;
|
||||
ModGen trem;
|
||||
byte reg_vib;
|
||||
byte reg_type;
|
||||
byte reg_ksr;
|
||||
byte reg_mult;
|
||||
byte reg_ksl;
|
||||
byte reg_tl;
|
||||
byte reg_ar;
|
||||
byte reg_dr;
|
||||
byte reg_sl;
|
||||
byte reg_rr;
|
||||
byte reg_wf;
|
||||
boolean key;
|
||||
boolean detrigger;
|
||||
boolean retrigger;
|
||||
boolean pg_reset;
|
||||
int pg_phase;
|
||||
short pg_phase_out;
|
||||
int slot_num;
|
||||
|
||||
public short getModulation() {
|
||||
return this.out;
|
||||
}
|
||||
|
||||
private void process()
|
||||
{
|
||||
// feedback
|
||||
if (this.channel.fb != 0x00)
|
||||
{
|
||||
this.fbmodv = (short)((this.prout + this.out) >> (0x09 - this.channel.fb));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.fbmodv = 0;
|
||||
}
|
||||
this.prout = this.out;
|
||||
// envelope
|
||||
boolean nonzero;
|
||||
byte rate;
|
||||
byte rate_hi;
|
||||
byte rate_lo;
|
||||
byte reg_rate = 0;
|
||||
byte ks;
|
||||
byte eg_shift, shift;
|
||||
short eg_rout;
|
||||
short eg_inc;
|
||||
boolean eg_off;
|
||||
boolean reset = false;
|
||||
if(this.retrigger) {
|
||||
this.eg_rout = 0x1ff;
|
||||
}
|
||||
this.eg_out = (short)(this.eg_rout + (this.reg_tl << 2)
|
||||
+ (this.eg_ksl >> KSL_SHIFT[this.reg_ksl]) + this.trem.getModulation());
|
||||
if (this.key && this.eg_gen == EnvState.RELEASE)
|
||||
{
|
||||
reset = true;
|
||||
reg_rate = this.reg_ar;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (this.eg_gen)
|
||||
{
|
||||
case ATTACK:
|
||||
reg_rate = this.reg_ar;
|
||||
break;
|
||||
case DECAY:
|
||||
reg_rate = this.reg_dr;
|
||||
break;
|
||||
case SUSTAIN:
|
||||
if (this.reg_type == 0)
|
||||
{
|
||||
reg_rate = this.reg_rr;
|
||||
}
|
||||
break;
|
||||
case RELEASE:
|
||||
reg_rate = this.reg_rr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.pg_reset = reset;
|
||||
ks = (byte)(this.channel.ksv >> ((this.reg_ksr ^ 1) << 1));
|
||||
nonzero = (reg_rate != 0);
|
||||
rate = (byte)(ks + (reg_rate << 2));
|
||||
rate_hi = (byte)(rate >> 2);
|
||||
rate_lo = (byte)(rate & 0x03);
|
||||
if ((rate_hi & 0x10) != 0)
|
||||
{
|
||||
rate_hi = 0x0f;
|
||||
}
|
||||
eg_shift = (byte)(rate_hi + OPLChip.this.eg_add);
|
||||
shift = 0;
|
||||
if (nonzero)
|
||||
{
|
||||
if (rate_hi < 12)
|
||||
{
|
||||
if (OPLChip.this.eg_state != 0)
|
||||
{
|
||||
switch (eg_shift)
|
||||
{
|
||||
case 12:
|
||||
shift = 1;
|
||||
break;
|
||||
case 13:
|
||||
shift = (byte)((rate_lo >> 1) & 0x01);
|
||||
break;
|
||||
case 14:
|
||||
shift = (byte)(rate_lo & 0x01);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
shift = (byte)((rate_hi & 0x03) + EG_INC[rate_lo][OPLChip.this.timer & 0x03]);
|
||||
if ((shift & 0x04) != 0)
|
||||
{
|
||||
shift = 0x03;
|
||||
}
|
||||
if (shift == 0)
|
||||
{
|
||||
shift = OPLChip.this.eg_state;
|
||||
}
|
||||
}
|
||||
}
|
||||
eg_rout = this.eg_rout;
|
||||
eg_inc = 0;
|
||||
eg_off = false;
|
||||
/* Instant attack */
|
||||
if (reset && rate_hi == 0x0f)
|
||||
{
|
||||
eg_rout = 0x00;
|
||||
}
|
||||
/* Envelope off */
|
||||
if ((this.eg_rout & 0x1f8) == 0x1f8)
|
||||
{
|
||||
eg_off = true;
|
||||
}
|
||||
if (this.eg_gen != EnvState.ATTACK && !reset && eg_off)
|
||||
{
|
||||
eg_rout = 0x1ff;
|
||||
}
|
||||
switch (this.eg_gen)
|
||||
{
|
||||
case ATTACK:
|
||||
if (this.eg_rout == 0)
|
||||
{
|
||||
this.eg_gen = EnvState.DECAY;
|
||||
}
|
||||
else if (this.key && shift > 0 && rate_hi != 0x0f)
|
||||
{
|
||||
eg_inc = (short)(~this.eg_rout >> (4 - shift));
|
||||
}
|
||||
break;
|
||||
case DECAY:
|
||||
if ((this.eg_rout >> 4) == this.reg_sl)
|
||||
{
|
||||
this.eg_gen = EnvState.SUSTAIN;
|
||||
}
|
||||
else if (!eg_off && !reset && shift > 0)
|
||||
{
|
||||
eg_inc = (short)(1 << (shift - 1));
|
||||
}
|
||||
break;
|
||||
case SUSTAIN:
|
||||
case RELEASE:
|
||||
if (!eg_off && !reset && shift > 0)
|
||||
{
|
||||
eg_inc = (short)(1 << (shift - 1));
|
||||
}
|
||||
break;
|
||||
}
|
||||
this.eg_rout = (short)((eg_rout + eg_inc) & 0x1ff);
|
||||
/* Key off */
|
||||
if (reset)
|
||||
{
|
||||
this.eg_gen = EnvState.ATTACK;
|
||||
}
|
||||
if (!(this.key))
|
||||
{
|
||||
this.eg_gen = EnvState.RELEASE;
|
||||
}
|
||||
this.detrigger = false;
|
||||
this.retrigger = false;
|
||||
// phase
|
||||
short f_num;
|
||||
int basefreq;
|
||||
short phase;
|
||||
f_num = this.channel.f_num;
|
||||
if (this.reg_vib != 0)
|
||||
{
|
||||
byte range;
|
||||
byte vibpos;
|
||||
range = (byte)((f_num >> 7) & 7);
|
||||
vibpos = OPLChip.this.vibpos;
|
||||
if ((vibpos & 3) == 0)
|
||||
{
|
||||
range = 0;
|
||||
}
|
||||
else if ((vibpos & 1) != 0)
|
||||
{
|
||||
range >>= 1;
|
||||
}
|
||||
range >>= OPLChip.this.vibshift;
|
||||
if ((vibpos & 4) != 0)
|
||||
{
|
||||
range = (byte)-range;
|
||||
}
|
||||
f_num += range;
|
||||
}
|
||||
basefreq = (f_num << this.channel.block) >> 1;
|
||||
phase = (short)(this.pg_phase >> 9);
|
||||
if (this.pg_reset)
|
||||
{
|
||||
this.pg_phase = 0;
|
||||
}
|
||||
this.pg_phase += (basefreq * MULT[this.reg_mult]) >> 1;
|
||||
this.pg_phase_out = phase;
|
||||
// output
|
||||
this.out = WAVE_FUNCS[this.reg_wf].calcPhase((short)(this.pg_phase_out + this.mod.getModulation()), this.eg_out);
|
||||
}
|
||||
|
||||
private void updateKSL()
|
||||
{
|
||||
short ksl = (short)((KSL[this.channel.f_num >> 6] << 2)
|
||||
- ((0x08 - this.channel.block) << 5));
|
||||
if (ksl < 0)
|
||||
{
|
||||
ksl = 0;
|
||||
}
|
||||
this.eg_ksl = (byte)ksl;
|
||||
}
|
||||
|
||||
private void keyOn()
|
||||
{
|
||||
this.key = true;
|
||||
if(this.detrigger) {
|
||||
this.eg_gen = EnvState.RELEASE;
|
||||
// this.eg_rout = 0x1ff;
|
||||
// this.eg_out = this.eg_rout = 0x1ff;
|
||||
this.detrigger = false;
|
||||
}
|
||||
this.retrigger = true;
|
||||
}
|
||||
|
||||
private void keyOff()
|
||||
{
|
||||
this.key = false;
|
||||
this.detrigger = true;
|
||||
this.retrigger = false;
|
||||
}
|
||||
|
||||
public void setFlags(boolean tremolo, boolean vibrato, boolean sustaining, boolean ksr) {
|
||||
if (tremolo)
|
||||
{
|
||||
this.trem = OPLChip.this.tremolo;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.trem = OPLChip.this.zeromod;
|
||||
}
|
||||
this.reg_vib = (byte)(vibrato ? 1 : 0);
|
||||
this.reg_type = (byte)(sustaining ? 1 : 0);
|
||||
this.reg_ksr = (byte)(ksr ? 1 : 0);
|
||||
}
|
||||
|
||||
public void setMultiplier(int mult) {
|
||||
this.reg_mult = (byte)(mult & 0x0f);
|
||||
}
|
||||
|
||||
public void setKSL(int ksl) {
|
||||
this.reg_ksl = (byte)(ksl & 0x03);
|
||||
this.updateKSL();
|
||||
}
|
||||
|
||||
public void setLevel(int level) {
|
||||
this.reg_tl = (byte)(level & 0x3f);
|
||||
}
|
||||
|
||||
public void setEnvelope(int attack, int decay, int sustain, int release) {
|
||||
this.reg_ar = (byte)(attack & 0x0f);
|
||||
this.reg_dr = (byte)(decay & 0x0f);
|
||||
this.reg_sl = (byte)(sustain & 0x0f);
|
||||
if (this.reg_sl == 0x0f)
|
||||
{
|
||||
this.reg_sl = 0x1f;
|
||||
}
|
||||
this.reg_rr = (byte)(release & 0x0f);
|
||||
if (this.reg_rr == 0x00)
|
||||
{
|
||||
this.reg_rr = 0x01;
|
||||
}
|
||||
}
|
||||
|
||||
public void setWaveform(int waveform) {
|
||||
this.reg_wf = (byte)(waveform & 0x07);
|
||||
}
|
||||
};
|
||||
|
||||
public class OPLChannel {
|
||||
OPLSlot[] slots = new OPLSlot[2];
|
||||
OPLChannel pair;
|
||||
ModGen[] out = new ModGen[4];
|
||||
|
||||
int[] level = new int[2];
|
||||
|
||||
ChType chtype;
|
||||
short f_num;
|
||||
byte block;
|
||||
byte fb;
|
||||
byte con;
|
||||
byte alg;
|
||||
byte ksv;
|
||||
int ch_num;
|
||||
|
||||
private void setupAlgo()
|
||||
{
|
||||
if ((this.alg & 0x08) != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if ((this.alg & 0x04) != 0)
|
||||
{
|
||||
this.pair.out[0] = OPLChip.this.zeromod;
|
||||
this.pair.out[1] = OPLChip.this.zeromod;
|
||||
this.pair.out[2] = OPLChip.this.zeromod;
|
||||
this.pair.out[3] = OPLChip.this.zeromod;
|
||||
switch (this.alg & 0x03)
|
||||
{
|
||||
case 0x00:
|
||||
this.pair.slots[0].mod = this.pair.slots[0].fbmod;
|
||||
this.pair.slots[1].mod = this.pair.slots[0];
|
||||
this.slots[0].mod = this.pair.slots[1];
|
||||
this.slots[1].mod = this.slots[0];
|
||||
this.out[0] = this.slots[1];
|
||||
this.out[1] = OPLChip.this.zeromod;
|
||||
this.out[2] = OPLChip.this.zeromod;
|
||||
this.out[3] = OPLChip.this.zeromod;
|
||||
break;
|
||||
case 0x01:
|
||||
this.pair.slots[0].mod = this.pair.slots[0].fbmod;
|
||||
this.pair.slots[1].mod = this.pair.slots[0];
|
||||
this.slots[0].mod = OPLChip.this.zeromod;
|
||||
this.slots[1].mod = this.slots[0];
|
||||
this.out[0] = this.pair.slots[1];
|
||||
this.out[1] = this.slots[1];
|
||||
this.out[2] = OPLChip.this.zeromod;
|
||||
this.out[3] = OPLChip.this.zeromod;
|
||||
break;
|
||||
case 0x02:
|
||||
this.pair.slots[0].mod = this.pair.slots[0].fbmod;
|
||||
this.pair.slots[1].mod = OPLChip.this.zeromod;
|
||||
this.slots[0].mod = this.pair.slots[1];
|
||||
this.slots[1].mod = this.slots[0];
|
||||
this.out[0] = this.pair.slots[0];
|
||||
this.out[1] = this.slots[1];
|
||||
this.out[2] = OPLChip.this.zeromod;
|
||||
this.out[3] = OPLChip.this.zeromod;
|
||||
break;
|
||||
case 0x03:
|
||||
this.pair.slots[0].mod = this.pair.slots[0].fbmod;
|
||||
this.pair.slots[1].mod = OPLChip.this.zeromod;
|
||||
this.slots[0].mod = this.pair.slots[1];
|
||||
this.slots[1].mod = OPLChip.this.zeromod;
|
||||
this.out[0] = this.pair.slots[0];
|
||||
this.out[1] = this.slots[0];
|
||||
this.out[2] = this.slots[1];
|
||||
this.out[3] = OPLChip.this.zeromod;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (this.alg & 0x01)
|
||||
{
|
||||
case 0x00:
|
||||
this.slots[0].mod = this.slots[0].fbmod;
|
||||
this.slots[1].mod = this.slots[0];
|
||||
this.out[0] = this.slots[1];
|
||||
this.out[1] = OPLChip.this.zeromod;
|
||||
this.out[2] = OPLChip.this.zeromod;
|
||||
this.out[3] = OPLChip.this.zeromod;
|
||||
break;
|
||||
case 0x01:
|
||||
this.slots[0].mod = this.slots[0].fbmod;
|
||||
this.slots[1].mod = OPLChip.this.zeromod;
|
||||
this.out[0] = this.slots[0];
|
||||
this.out[1] = this.slots[1];
|
||||
this.out[2] = OPLChip.this.zeromod;
|
||||
this.out[3] = OPLChip.this.zeromod;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateAlgo()
|
||||
{
|
||||
this.alg = this.con;
|
||||
if (this.chtype == ChType.CH4OP1)
|
||||
{
|
||||
this.pair.alg = (byte)(0x04 | (this.con << 1) | (this.pair.con));
|
||||
this.alg = 0x08;
|
||||
this.pair.setupAlgo();
|
||||
}
|
||||
else if (this.chtype == ChType.CH4OP2)
|
||||
{
|
||||
this.alg = (byte)(0x04 | (this.pair.con << 1) | (this.con));
|
||||
this.pair.alg = 0x08;
|
||||
this.setupAlgo();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setupAlgo();
|
||||
}
|
||||
}
|
||||
|
||||
public void setFrequency(int block, int f_num) {
|
||||
if (this.chtype == ChType.CH4OP2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
this.f_num = (short)(f_num & 0x3ff);
|
||||
this.block = (byte)(block & 0x07);
|
||||
this.ksv = (byte)((this.block << 1)
|
||||
| ((this.f_num >> (0x09 - OPLChip.this.nts)) & 0x01));
|
||||
this.slots[0].updateKSL();
|
||||
this.slots[1].updateKSL();
|
||||
if (this.chtype == ChType.CH4OP1)
|
||||
{
|
||||
this.pair.f_num = this.f_num;
|
||||
this.pair.block = this.block;
|
||||
this.pair.ksv = this.ksv;
|
||||
this.pair.slots[0].updateKSL();
|
||||
this.pair.slots[1].updateKSL();
|
||||
}
|
||||
}
|
||||
|
||||
public void setLevel(int output, int level) {
|
||||
this.level[output & 1] = level;
|
||||
}
|
||||
|
||||
public void set4Op(boolean op4) {
|
||||
if (op4)
|
||||
{
|
||||
this.chtype = ChType.CH4OP1;
|
||||
this.pair.chtype = ChType.CH4OP2;
|
||||
this.updateAlgo();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.chtype = ChType.CH2OP;
|
||||
this.pair.chtype = ChType.CH2OP;
|
||||
this.updateAlgo();
|
||||
this.pair.updateAlgo();
|
||||
}
|
||||
}
|
||||
|
||||
public void setFeedback(int feedback) {
|
||||
this.fb = (byte)(feedback & 0x07);
|
||||
}
|
||||
|
||||
public void setAM(boolean am) {
|
||||
this.con = (byte)(am ? 1 : 0);
|
||||
this.updateAlgo();
|
||||
}
|
||||
|
||||
public void keyOn()
|
||||
{
|
||||
if (this.chtype == ChType.CH4OP1)
|
||||
{
|
||||
this.slots[0].keyOn();
|
||||
this.slots[1].keyOn();
|
||||
this.pair.slots[0].keyOn();
|
||||
this.pair.slots[1].keyOn();
|
||||
}
|
||||
else if (this.chtype == ChType.CH2OP)
|
||||
{
|
||||
this.slots[0].keyOn();
|
||||
this.slots[1].keyOn();
|
||||
}
|
||||
}
|
||||
|
||||
public void keyOff()
|
||||
{
|
||||
if (this.chtype == ChType.CH4OP1)
|
||||
{
|
||||
this.slots[0].keyOff();
|
||||
this.slots[1].keyOff();
|
||||
this.pair.slots[0].keyOff();
|
||||
this.pair.slots[1].keyOff();
|
||||
}
|
||||
else if (this.chtype == ChType.CH2OP)
|
||||
{
|
||||
this.slots[0].keyOff();
|
||||
this.slots[1].keyOff();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static final int RSM_FRAC = 10;
|
||||
|
||||
//Tables
|
||||
|
||||
private static final short[] LOG_SIN = {
|
||||
0x859, 0x6c3, 0x607, 0x58b, 0x52e, 0x4e4, 0x4a6, 0x471,
|
||||
0x443, 0x41a, 0x3f5, 0x3d3, 0x3b5, 0x398, 0x37e, 0x365,
|
||||
0x34e, 0x339, 0x324, 0x311, 0x2ff, 0x2ed, 0x2dc, 0x2cd,
|
||||
0x2bd, 0x2af, 0x2a0, 0x293, 0x286, 0x279, 0x26d, 0x261,
|
||||
0x256, 0x24b, 0x240, 0x236, 0x22c, 0x222, 0x218, 0x20f,
|
||||
0x206, 0x1fd, 0x1f5, 0x1ec, 0x1e4, 0x1dc, 0x1d4, 0x1cd,
|
||||
0x1c5, 0x1be, 0x1b7, 0x1b0, 0x1a9, 0x1a2, 0x19b, 0x195,
|
||||
0x18f, 0x188, 0x182, 0x17c, 0x177, 0x171, 0x16b, 0x166,
|
||||
0x160, 0x15b, 0x155, 0x150, 0x14b, 0x146, 0x141, 0x13c,
|
||||
0x137, 0x133, 0x12e, 0x129, 0x125, 0x121, 0x11c, 0x118,
|
||||
0x114, 0x10f, 0x10b, 0x107, 0x103, 0x0ff, 0x0fb, 0x0f8,
|
||||
0x0f4, 0x0f0, 0x0ec, 0x0e9, 0x0e5, 0x0e2, 0x0de, 0x0db,
|
||||
0x0d7, 0x0d4, 0x0d1, 0x0cd, 0x0ca, 0x0c7, 0x0c4, 0x0c1,
|
||||
0x0be, 0x0bb, 0x0b8, 0x0b5, 0x0b2, 0x0af, 0x0ac, 0x0a9,
|
||||
0x0a7, 0x0a4, 0x0a1, 0x09f, 0x09c, 0x099, 0x097, 0x094,
|
||||
0x092, 0x08f, 0x08d, 0x08a, 0x088, 0x086, 0x083, 0x081,
|
||||
0x07f, 0x07d, 0x07a, 0x078, 0x076, 0x074, 0x072, 0x070,
|
||||
0x06e, 0x06c, 0x06a, 0x068, 0x066, 0x064, 0x062, 0x060,
|
||||
0x05e, 0x05c, 0x05b, 0x059, 0x057, 0x055, 0x053, 0x052,
|
||||
0x050, 0x04e, 0x04d, 0x04b, 0x04a, 0x048, 0x046, 0x045,
|
||||
0x043, 0x042, 0x040, 0x03f, 0x03e, 0x03c, 0x03b, 0x039,
|
||||
0x038, 0x037, 0x035, 0x034, 0x033, 0x031, 0x030, 0x02f,
|
||||
0x02e, 0x02d, 0x02b, 0x02a, 0x029, 0x028, 0x027, 0x026,
|
||||
0x025, 0x024, 0x023, 0x022, 0x021, 0x020, 0x01f, 0x01e,
|
||||
0x01d, 0x01c, 0x01b, 0x01a, 0x019, 0x018, 0x017, 0x017,
|
||||
0x016, 0x015, 0x014, 0x014, 0x013, 0x012, 0x011, 0x011,
|
||||
0x010, 0x00f, 0x00f, 0x00e, 0x00d, 0x00d, 0x00c, 0x00c,
|
||||
0x00b, 0x00a, 0x00a, 0x009, 0x009, 0x008, 0x008, 0x007,
|
||||
0x007, 0x007, 0x006, 0x006, 0x005, 0x005, 0x005, 0x004,
|
||||
0x004, 0x004, 0x003, 0x003, 0x003, 0x002, 0x002, 0x002,
|
||||
0x002, 0x001, 0x001, 0x001, 0x001, 0x001, 0x001, 0x001,
|
||||
0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000
|
||||
};
|
||||
|
||||
private static final short[] EXP = {
|
||||
0x7fa, 0x7f5, 0x7ef, 0x7ea, 0x7e4, 0x7df, 0x7da, 0x7d4,
|
||||
0x7cf, 0x7c9, 0x7c4, 0x7bf, 0x7b9, 0x7b4, 0x7ae, 0x7a9,
|
||||
0x7a4, 0x79f, 0x799, 0x794, 0x78f, 0x78a, 0x784, 0x77f,
|
||||
0x77a, 0x775, 0x770, 0x76a, 0x765, 0x760, 0x75b, 0x756,
|
||||
0x751, 0x74c, 0x747, 0x742, 0x73d, 0x738, 0x733, 0x72e,
|
||||
0x729, 0x724, 0x71f, 0x71a, 0x715, 0x710, 0x70b, 0x706,
|
||||
0x702, 0x6fd, 0x6f8, 0x6f3, 0x6ee, 0x6e9, 0x6e5, 0x6e0,
|
||||
0x6db, 0x6d6, 0x6d2, 0x6cd, 0x6c8, 0x6c4, 0x6bf, 0x6ba,
|
||||
0x6b5, 0x6b1, 0x6ac, 0x6a8, 0x6a3, 0x69e, 0x69a, 0x695,
|
||||
0x691, 0x68c, 0x688, 0x683, 0x67f, 0x67a, 0x676, 0x671,
|
||||
0x66d, 0x668, 0x664, 0x65f, 0x65b, 0x657, 0x652, 0x64e,
|
||||
0x649, 0x645, 0x641, 0x63c, 0x638, 0x634, 0x630, 0x62b,
|
||||
0x627, 0x623, 0x61e, 0x61a, 0x616, 0x612, 0x60e, 0x609,
|
||||
0x605, 0x601, 0x5fd, 0x5f9, 0x5f5, 0x5f0, 0x5ec, 0x5e8,
|
||||
0x5e4, 0x5e0, 0x5dc, 0x5d8, 0x5d4, 0x5d0, 0x5cc, 0x5c8,
|
||||
0x5c4, 0x5c0, 0x5bc, 0x5b8, 0x5b4, 0x5b0, 0x5ac, 0x5a8,
|
||||
0x5a4, 0x5a0, 0x59c, 0x599, 0x595, 0x591, 0x58d, 0x589,
|
||||
0x585, 0x581, 0x57e, 0x57a, 0x576, 0x572, 0x56f, 0x56b,
|
||||
0x567, 0x563, 0x560, 0x55c, 0x558, 0x554, 0x551, 0x54d,
|
||||
0x549, 0x546, 0x542, 0x53e, 0x53b, 0x537, 0x534, 0x530,
|
||||
0x52c, 0x529, 0x525, 0x522, 0x51e, 0x51b, 0x517, 0x514,
|
||||
0x510, 0x50c, 0x509, 0x506, 0x502, 0x4ff, 0x4fb, 0x4f8,
|
||||
0x4f4, 0x4f1, 0x4ed, 0x4ea, 0x4e7, 0x4e3, 0x4e0, 0x4dc,
|
||||
0x4d9, 0x4d6, 0x4d2, 0x4cf, 0x4cc, 0x4c8, 0x4c5, 0x4c2,
|
||||
0x4be, 0x4bb, 0x4b8, 0x4b5, 0x4b1, 0x4ae, 0x4ab, 0x4a8,
|
||||
0x4a4, 0x4a1, 0x49e, 0x49b, 0x498, 0x494, 0x491, 0x48e,
|
||||
0x48b, 0x488, 0x485, 0x482, 0x47e, 0x47b, 0x478, 0x475,
|
||||
0x472, 0x46f, 0x46c, 0x469, 0x466, 0x463, 0x460, 0x45d,
|
||||
0x45a, 0x457, 0x454, 0x451, 0x44e, 0x44b, 0x448, 0x445,
|
||||
0x442, 0x43f, 0x43c, 0x439, 0x436, 0x433, 0x430, 0x42d,
|
||||
0x42a, 0x428, 0x425, 0x422, 0x41f, 0x41c, 0x419, 0x416,
|
||||
0x414, 0x411, 0x40e, 0x40b, 0x408, 0x406, 0x403, 0x400
|
||||
};
|
||||
|
||||
private static final byte[] MULT = {
|
||||
1, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 20, 24, 24, 30, 30
|
||||
};
|
||||
|
||||
private static final byte[] KSL = {
|
||||
0, 32, 40, 45, 48, 51, 53, 55, 56, 58, 59, 60, 61, 62, 63, 64
|
||||
};
|
||||
|
||||
private static final byte[] KSL_SHIFT = {
|
||||
8, 1, 2, 0
|
||||
};
|
||||
|
||||
private static final byte[][] EG_INC = {
|
||||
{ 0, 0, 0, 0 },
|
||||
{ 1, 0, 0, 0 },
|
||||
{ 1, 0, 1, 0 },
|
||||
{ 1, 1, 1, 0 }
|
||||
};
|
||||
|
||||
private static final envelope_sinfunc[] WAVE_FUNCS = {
|
||||
OPLChip::wave0,
|
||||
OPLChip::wave1,
|
||||
OPLChip::wave2,
|
||||
OPLChip::wave3,
|
||||
OPLChip::wave4,
|
||||
OPLChip::wave5,
|
||||
OPLChip::wave6,
|
||||
OPLChip::wave7
|
||||
};
|
||||
|
||||
final OPLChannel[] channel;
|
||||
final OPLSlot[] slot;
|
||||
final ModGen tremolo = new ModGen() {
|
||||
public short getModulation() {
|
||||
return OPLChip.this.tremolov;
|
||||
}
|
||||
};
|
||||
final ModGen zeromod = new ModGen() {
|
||||
public short getModulation() {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
private final int[] mixbuff = new int[2];
|
||||
private final int[] oldsamples = new int[2];
|
||||
private final int[] samples = new int[2];
|
||||
private final int[] output = new int[2];
|
||||
private final int rateratio;
|
||||
|
||||
private final byte nts;
|
||||
private final byte vibshift;
|
||||
private final byte tremoloshift;
|
||||
|
||||
private short timer;
|
||||
private long eg_timer;
|
||||
private byte eg_timerrem;
|
||||
private byte eg_state;
|
||||
private byte eg_add;
|
||||
private byte vibpos;
|
||||
private byte tremolov;
|
||||
private byte tremolopos;
|
||||
private int noise;
|
||||
|
||||
private int samplecnt;
|
||||
|
||||
/* input: [0, 256), output: [0, 65536] */
|
||||
private static int oplSin(double x) {
|
||||
return ((int)(Math.sin((x) * Math.PI / 512.0) * 65536.0));
|
||||
}
|
||||
|
||||
//Envelope generator
|
||||
|
||||
private static short waveExp(int level)
|
||||
{
|
||||
if (level > 0x1fff)
|
||||
{
|
||||
level = 0x1fff;
|
||||
}
|
||||
return (short)((EXP[level & 0xff] << 1) >> (level >> 8));
|
||||
}
|
||||
|
||||
private static short wave0(short phase, short envelope)
|
||||
{
|
||||
short out = 0;
|
||||
short neg = 0;
|
||||
phase &= 0x3ff;
|
||||
if ((phase & 0x200) != 0)
|
||||
{
|
||||
neg = (short)0xffff;
|
||||
}
|
||||
if ((phase & 0x100) != 0)
|
||||
{
|
||||
out = LOG_SIN[(phase & 0xff) ^ 0xff];
|
||||
}
|
||||
else
|
||||
{
|
||||
out = LOG_SIN[phase & 0xff];
|
||||
}
|
||||
return (short)(waveExp(out + (envelope << 3)) ^ neg);
|
||||
}
|
||||
|
||||
private static short wave1(short phase, short envelope)
|
||||
{
|
||||
short out = 0;
|
||||
phase &= 0x3ff;
|
||||
if ((phase & 0x200) != 0)
|
||||
{
|
||||
out = 0x1000;
|
||||
}
|
||||
else if ((phase & 0x100) != 0)
|
||||
{
|
||||
out = LOG_SIN[(phase & 0xff) ^ 0xff];
|
||||
}
|
||||
else
|
||||
{
|
||||
out = LOG_SIN[phase & 0xff];
|
||||
}
|
||||
return waveExp(out + (envelope << 3));
|
||||
}
|
||||
|
||||
private static short wave2(short phase, short envelope)
|
||||
{
|
||||
short out = 0;
|
||||
phase &= 0x3ff;
|
||||
if ((phase & 0x100) != 0)
|
||||
{
|
||||
out = LOG_SIN[(phase & 0xff) ^ 0xff];
|
||||
}
|
||||
else
|
||||
{
|
||||
out = LOG_SIN[phase & 0xff];
|
||||
}
|
||||
return waveExp(out + (envelope << 3));
|
||||
}
|
||||
|
||||
private static short wave3(short phase, short envelope)
|
||||
{
|
||||
short out = 0;
|
||||
phase &= 0x3ff;
|
||||
if ((phase & 0x100) != 0)
|
||||
{
|
||||
out = 0x1000;
|
||||
}
|
||||
else
|
||||
{
|
||||
out = LOG_SIN[phase & 0xff];
|
||||
}
|
||||
return waveExp(out + (envelope << 3));
|
||||
}
|
||||
|
||||
private static short wave4(short phase, short envelope)
|
||||
{
|
||||
short out = 0;
|
||||
short neg = 0;
|
||||
phase &= 0x3ff;
|
||||
if ((phase & 0x300) == 0x100)
|
||||
{
|
||||
neg = (short)0xffff;
|
||||
}
|
||||
if ((phase & 0x200) != 0)
|
||||
{
|
||||
out = 0x1000;
|
||||
}
|
||||
else if ((phase & 0x80) != 0)
|
||||
{
|
||||
out = LOG_SIN[((phase ^ 0xff) << 1) & 0xff];
|
||||
}
|
||||
else
|
||||
{
|
||||
out = LOG_SIN[(phase << 1) & 0xff];
|
||||
}
|
||||
return (short)(waveExp(out + (envelope << 3)) ^ neg);
|
||||
}
|
||||
|
||||
private static short wave5(short phase, short envelope)
|
||||
{
|
||||
short out = 0;
|
||||
phase &= 0x3ff;
|
||||
if ((phase & 0x200) != 0)
|
||||
{
|
||||
out = 0x1000;
|
||||
}
|
||||
else if ((phase & 0x80) != 0)
|
||||
{
|
||||
out = LOG_SIN[((phase ^ 0xff) << 1) & 0xff];
|
||||
}
|
||||
else
|
||||
{
|
||||
out = LOG_SIN[(phase << 1) & 0xff];
|
||||
}
|
||||
return waveExp(out + (envelope << 3));
|
||||
}
|
||||
|
||||
private static short wave6(short phase, short envelope)
|
||||
{
|
||||
short neg = 0;
|
||||
phase &= 0x3ff;
|
||||
if ((phase & 0x200) != 0)
|
||||
{
|
||||
neg = (short)0xffff;
|
||||
}
|
||||
return (short)(waveExp(envelope << 3) ^ neg);
|
||||
}
|
||||
|
||||
private static short wave7(short phase, short envelope)
|
||||
{
|
||||
short out = 0;
|
||||
short neg = 0;
|
||||
phase &= 0x3ff;
|
||||
if ((phase & 0x200) != 0)
|
||||
{
|
||||
neg = (short)0xffff;
|
||||
phase = (short)((phase & 0x1ff) ^ 0x1ff);
|
||||
}
|
||||
out = (short)(phase << 3);
|
||||
return (short)(waveExp(out + (envelope << 3)) ^ neg);
|
||||
}
|
||||
|
||||
private void genFrame()
|
||||
{
|
||||
int[] mix = new int[2];
|
||||
|
||||
this.samples[0] = this.mixbuff[0];
|
||||
this.samples[1] = this.mixbuff[1];
|
||||
|
||||
for (int ii = 0; ii < this.slot.length; ii++)
|
||||
{
|
||||
this.slot[ii].process();
|
||||
}
|
||||
|
||||
mix[0] = mix[1] = 0;
|
||||
for (int ii = 0; ii < this.channel.length; ii++)
|
||||
{
|
||||
OPLChannel channel = this.channel[ii];
|
||||
ModGen[] out = channel.out;
|
||||
int accm = out[0].getModulation() + out[1].getModulation() + out[2].getModulation() + out[3].getModulation();
|
||||
mix[0] += (accm * channel.level[0]) >> 16;
|
||||
mix[1] += (accm * channel.level[1]) >> 16;
|
||||
}
|
||||
this.mixbuff[0] = mix[0];
|
||||
this.mixbuff[1] = mix[1];
|
||||
|
||||
if ((this.timer & 0x3f) == 0x3f)
|
||||
{
|
||||
this.tremolopos = (byte)((this.tremolopos + 1) % 210);
|
||||
}
|
||||
if (this.tremolopos < 105)
|
||||
{
|
||||
this.tremolov = (byte)(this.tremolopos >> this.tremoloshift);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.tremolov = (byte)((210 - this.tremolopos) >> this.tremoloshift);
|
||||
}
|
||||
|
||||
if ((this.timer & 0x3ff) == 0x3ff)
|
||||
{
|
||||
this.vibpos = (byte)((this.vibpos + 1) & 7);
|
||||
}
|
||||
|
||||
this.timer++;
|
||||
|
||||
this.eg_add = 0;
|
||||
if (this.eg_timer != 0)
|
||||
{
|
||||
byte shift = 0;
|
||||
while (shift < 36 && ((this.eg_timer >> shift) & 1) == 0)
|
||||
{
|
||||
shift++;
|
||||
}
|
||||
if (shift > 12)
|
||||
{
|
||||
this.eg_add = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.eg_add = (byte)(shift + 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.eg_timerrem != 0 || this.eg_state != 0)
|
||||
{
|
||||
if (this.eg_timer == 0xfffffffffL)
|
||||
{
|
||||
this.eg_timer = 0;
|
||||
this.eg_timerrem = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.eg_timer++;
|
||||
this.eg_timerrem = 0;
|
||||
}
|
||||
}
|
||||
|
||||
this.eg_state ^= 1;
|
||||
}
|
||||
|
||||
public int[] generate()
|
||||
{
|
||||
while (this.samplecnt >= this.rateratio)
|
||||
{
|
||||
this.oldsamples[0] = this.samples[0];
|
||||
this.oldsamples[1] = this.samples[1];
|
||||
this.genFrame();
|
||||
this.samplecnt -= this.rateratio;
|
||||
}
|
||||
this.output[0] = (this.oldsamples[0] * (this.rateratio - this.samplecnt)
|
||||
+ this.samples[0] * this.samplecnt) / this.rateratio;
|
||||
this.output[1] = (this.oldsamples[1] * (this.rateratio - this.samplecnt)
|
||||
+ this.samples[1] * this.samplecnt) / this.rateratio;
|
||||
this.samplecnt += 1 << RSM_FRAC;
|
||||
return this.output;
|
||||
}
|
||||
|
||||
public OPLChip(int samplerate, int voices, int nts, boolean deeptremolo, boolean deepvibrato) {
|
||||
this.channel = new OPLChannel[voices];
|
||||
this.slot = new OPLSlot[voices * 2];
|
||||
this.rateratio = (samplerate << RSM_FRAC) / 49716;
|
||||
this.nts = (byte)nts;
|
||||
this.tremoloshift = (byte)(deeptremolo ? 2 : 4);
|
||||
this.vibshift = (byte)(deepvibrato ? 0 : 1);
|
||||
for (int slotnum = 0; slotnum < this.slot.length; slotnum++)
|
||||
{
|
||||
OPLSlot slot = this.slot[slotnum] = new OPLSlot();
|
||||
slot.mod = this.zeromod;
|
||||
slot.eg_rout = 0x1ff;
|
||||
slot.eg_out = 0x1ff;
|
||||
slot.eg_gen = EnvState.RELEASE;
|
||||
slot.trem = this.zeromod;
|
||||
slot.slot_num = slotnum;
|
||||
}
|
||||
for (int channum = 0; channum < this.channel.length; channum++)
|
||||
{
|
||||
OPLChannel channel = this.channel[channum] = new OPLChannel();
|
||||
channel.slots[0] = this.slot[channum * 2];
|
||||
channel.slots[1] = this.slot[channum * 2 + 1];
|
||||
this.slot[channum * 2].channel = channel;
|
||||
this.slot[channum * 2 + 1].channel = channel;
|
||||
channel.out[0] = this.zeromod;
|
||||
channel.out[1] = this.zeromod;
|
||||
channel.out[2] = this.zeromod;
|
||||
channel.out[3] = this.zeromod;
|
||||
channel.chtype = ChType.CH2OP;
|
||||
channel.level[0] = 0x10000;
|
||||
channel.level[1] = 0x10000;
|
||||
channel.ch_num = channum;
|
||||
}
|
||||
for (int channum = 0; channum < this.channel.length; channum++)
|
||||
{
|
||||
this.channel[channum].pair = this.channel[(channum & 1) != 0 ? (channum - 1) : (channum + 1)];
|
||||
}
|
||||
for (int channum = 0; channum < this.channel.length; channum++)
|
||||
{
|
||||
this.channel[channum].setupAlgo();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isPlaying() {
|
||||
for(OPLSlot slot : this.slot) {
|
||||
if(slot.eg_out <= 0x100)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,6 +1,9 @@
|
|||
package client.gui;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import client.Client;
|
||||
import client.Client.FileMode;
|
||||
import client.gui.character.GuiChar;
|
||||
import client.gui.character.GuiCharacters;
|
||||
import client.gui.element.ActButton;
|
||||
|
@ -104,6 +107,15 @@ public class GuiMenu extends Gui {
|
|||
GuiMenu.this.gm.interrupted = true;
|
||||
}
|
||||
}, "Client schließen"));
|
||||
this.add(new ActButton(0, 110, 180, 0, new ButtonCallback() {
|
||||
public void use(ActButton elem, PressType action) {
|
||||
GuiMenu.this.gm.showFileDialog(FileMode.FILE_LOAD, "MIDI laden", null, new FileCallback() {
|
||||
public void selected(File file) {
|
||||
GuiMenu.this.gm.playMidi(file);
|
||||
}
|
||||
});
|
||||
}
|
||||
}, "MIDI-Player"));
|
||||
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, ""));
|
||||
|
@ -120,6 +132,15 @@ public class GuiMenu extends Gui {
|
|||
// GuiMenu.this.gm.displayGuiScreen(INSTANCE);
|
||||
}
|
||||
}, "Server verlassen"));
|
||||
this.add(new ActButton(0, this.gm.charEditor ? 70 : 90, 180, 0, new ButtonCallback() {
|
||||
public void use(ActButton elem, PressType action) {
|
||||
GuiMenu.this.gm.showFileDialog(FileMode.FILE_LOAD, "MIDI laden", null, new FileCallback() {
|
||||
public void selected(File file) {
|
||||
GuiMenu.this.gm.playMidi(file);
|
||||
}
|
||||
});
|
||||
}
|
||||
}, "MIDI-Player"));
|
||||
this.shift();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,20 @@ public class GuiSound extends GuiOptions {
|
|||
GuiSound.this.gm.restartSound(false);
|
||||
}
|
||||
}, "Übernehmen und Audio neu starten"));
|
||||
|
||||
|
||||
|
||||
this.addSelector("mid_opl_voices", 0, 130, 240, 0);
|
||||
this.addSelector("mid_opl_bank", 242, 130, 240, 0);
|
||||
|
||||
this.addSelector("mid_velocity_func", 0, 150, 240, 0);
|
||||
this.addSelector("mid_keep_notes", 242, 150, 240, 0);
|
||||
|
||||
this.addSelector("mid_dont_fade", 0, 170, 240, 0);
|
||||
this.addSelector("mid_play_unknown", 242, 170, 240, 0);
|
||||
|
||||
this.addSelector("mid_visualizer", 0, 190, 240, 0);
|
||||
this.addSelector("mid_debug_events", 242, 190, 240, 0);
|
||||
|
||||
super.init(width, height);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import java.io.InputStream;
|
|||
import java.nio.charset.Charset;
|
||||
|
||||
public class FileUtils {
|
||||
private static final Charset UTF_8 = Charset.forName("UTF-8");
|
||||
public static final Charset UTF_8 = Charset.forName("UTF-8");
|
||||
|
||||
public static String read(File file) throws IOException {
|
||||
FileInputStream in = null;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue