1
0
Fork 0

fix tremolo

This commit is contained in:
Sen 2025-08-25 00:23:43 +02:00
parent c3b1693ee4
commit dd38d049d4
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
3 changed files with 27 additions and 17 deletions

View file

@ -3462,12 +3462,28 @@ public class Client implements IThreadListener {
}
MidiHandle midi;
try {
midi = new MidiHandle(data, this.midiNoWait, this.midiVoices, this.midiBank, this.midiKeep, this.midiUnknown, this.midiVelocity);
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;
}
};
}
catch(Throwable e) {
Log.SOUND.error(e, "Konnte MIDI '%s' nicht laden", file);
return;
}
midi.setDebug(this.midiDebug);
this.audio.alMidi(midi);
}

View file

@ -7876,12 +7876,12 @@ public class AudioInterface implements Runnable {
}
private void log(String fmt, Object ... args) {
Log.SOUND.info(fmt, args);
}
private void debug(String fmt, Object ... args) {
if(this.debug)
this.log(fmt, args);
Log.SOUND.debug(fmt, args);
}
private void processMeta(MidiTrack trk) {
@ -8252,7 +8252,7 @@ public class AudioInterface implements Runnable {
private static byte getnote(BankChannel ch, byte key, int id, boolean drum, BankInstr instr) {
int note = (int)key;
if(instr.fixed) { // || drum
note = instr.percnum + (int)instr.channels[id].offset;
note = instr.percnum + instr.channels[id].offset;
}
else {
note += instr.channels[id].offset;

View file

@ -18,7 +18,7 @@ public class OPLChip {
short getModulation();
}
private static interface envelope_sinfunc {
private static interface WaveFunc {
short calcPhase(short phase, short envelope);
}
@ -630,7 +630,7 @@ public class OPLChip {
{ 1, 1, 1, 0 }
};
private static final envelope_sinfunc[] WAVE_FUNCS = {
private static final WaveFunc[] WAVE_FUNCS = {
OPLChip::wave0,
OPLChip::wave1,
OPLChip::wave2,
@ -669,17 +669,11 @@ public class OPLChip {
private byte eg_state;
private byte eg_add;
private byte vibpos;
private byte tremolov;
private byte tremolopos;
private int noise;
private short tremolov;
private short tremolopos;
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)
@ -854,15 +848,15 @@ public class OPLChip {
if ((this.timer & 0x3f) == 0x3f)
{
this.tremolopos = (byte)((this.tremolopos + 1) % 210);
this.tremolopos = (short)((this.tremolopos + 1) % 210);
}
if (this.tremolopos < 105)
{
this.tremolov = (byte)(this.tremolopos >> this.tremoloshift);
this.tremolov = (short)(this.tremolopos >> this.tremoloshift);
}
else
{
this.tremolov = (byte)((210 - this.tremolopos) >> this.tremoloshift);
this.tremolov = (short)((210 - this.tremolopos) >> this.tremoloshift);
}
if ((this.timer & 0x3ff) == 0x3ff)