getAdpcmEventsSub(int channel, int packetId, int s
if (moduloOfChunks != 0) {
byte[] chunk = new byte[moduloOfChunks];
System.arraycopy(adpcm, MAX_BLOCK * numberOfChunks, chunk, 0, moduloOfChunks);
-Debug.println(Level.FINE, "wave chunk(" + numberOfChunks + "): " + chunk.length);
+logger.log(Level.DEBUG, "wave chunk(" + numberOfChunks + "): " + chunk.length);
// 0x84 adpcm data
events.add(getWaveEvent(channel, packetId, sampleRate, bits, false, numberOfChunks == 0 ? adpcm.length : 0, chunk));
diff --git a/src/main/java/vavi/sound/mfi/vavi/sharp/SharpSequencer.java b/src/main/java/vavi/sound/mfi/vavi/sharp/SharpSequencer.java
index 5567d80..e46d42c 100644
--- a/src/main/java/vavi/sound/mfi/vavi/sharp/SharpSequencer.java
+++ b/src/main/java/vavi/sound/mfi/vavi/sharp/SharpSequencer.java
@@ -6,7 +6,8 @@
package vavi.sound.mfi.vavi.sharp;
-import java.util.logging.Level;
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
import vavi.sound.mfi.InvalidMfiDataException;
import vavi.sound.mfi.vavi.sequencer.MachineDependentFunction;
@@ -14,7 +15,8 @@
import vavi.sound.mfi.vavi.track.MachineDependentMessage;
import vavi.sound.mobile.AudioEngine;
import vavi.sound.mobile.FuetrekAudioEngine;
-import vavi.util.Debug;
+
+import static java.lang.System.getLogger;
/**
@@ -29,6 +31,8 @@
*/
public class SharpSequencer implements MachineDependentSequencer {
+ private static final Logger logger = getLogger(SharpSequencer.class.getName());
+
/**
*
* @param message see below
@@ -39,20 +43,20 @@ public void sequence(MachineDependentMessage message)
byte[] data = message.getMessage();
int function = data[6] & 0xff;
-Debug.printf(Level.FINER, "function: 0x%02x", function);
+logger.log(Level.TRACE, String.format("function: 0x%02x", function));
MachineDependentFunction mdf = factory.getFunction(String.valueOf(function));
if (mdf != null) {
mdf.process(message);
} else {
-Debug.printf(Level.WARNING, "unsupported function: 0x%02x", function);
+logger.log(Level.WARNING, String.format("unsupported function: 0x%02x", function));
}
}
//-------------------------------------------------------------------------
/** */
- private static AudioEngine player = new FuetrekAudioEngine();
+ private static final AudioEngine player = new FuetrekAudioEngine();
/** */
static AudioEngine getAudioEngine() {
@@ -62,6 +66,6 @@ static AudioEngine getAudioEngine() {
//-------------------------------------------------------------------------
/** */
- private static MachineDependentFunction.Factory factory =
+ private static final MachineDependentFunction.Factory factory =
new MachineDependentFunction.Factory("/vavi/sound/mfi/vavi/sharp/sharp.properties");
}
diff --git a/src/main/java/vavi/sound/mfi/vavi/track/AudioPlayMessage.java b/src/main/java/vavi/sound/mfi/vavi/track/AudioPlayMessage.java
index d1927c3..da00e71 100644
--- a/src/main/java/vavi/sound/mfi/vavi/track/AudioPlayMessage.java
+++ b/src/main/java/vavi/sound/mfi/vavi/track/AudioPlayMessage.java
@@ -37,7 +37,7 @@ public class AudioPlayMessage extends LongMessage
/** */
private int voice;
/** */
- private int index;
+ private final int index;
/** */
private int velocity = 63;
diff --git a/src/main/java/vavi/sound/mfi/vavi/track/AudioStopMessage.java b/src/main/java/vavi/sound/mfi/vavi/track/AudioStopMessage.java
index 7c3b27d..0c1f6f4 100644
--- a/src/main/java/vavi/sound/mfi/vavi/track/AudioStopMessage.java
+++ b/src/main/java/vavi/sound/mfi/vavi/track/AudioStopMessage.java
@@ -37,7 +37,7 @@ public class AudioStopMessage extends LongMessage
/** */
private int voice;
/** */
- private int index;
+ private final int index;
/**
* for {@link vavi.sound.mfi.vavi.TrackMessage}
diff --git a/src/main/java/vavi/sound/mfi/vavi/track/ChangeBankMessage.java b/src/main/java/vavi/sound/mfi/vavi/track/ChangeBankMessage.java
index 0f8a588..1968bce 100644
--- a/src/main/java/vavi/sound/mfi/vavi/track/ChangeBankMessage.java
+++ b/src/main/java/vavi/sound/mfi/vavi/track/ChangeBankMessage.java
@@ -97,9 +97,9 @@ public MidiEvent[] getMidiEvents(MidiContext context)
throws InvalidMidiDataException {
int channel = getVoice() + 4 * context.getMfiTrackNumber();
-//Debug.println("track: "+context.getTrackNumber()+", voice: "+getVoice());
+//logger.log(Level.DEBUG, "track: "+context.getTrackNumber()+", voice: "+getVoice());
-//Debug.println("bank[" + channel + "]: " + getBank());
+//logger.log(Level.DEBUG, "bank[" + channel + "]: " + getBank());
channel = context.setBank(channel, getBank());
return null;
diff --git a/src/main/java/vavi/sound/mfi/vavi/track/ChangeVoiceMessage.java b/src/main/java/vavi/sound/mfi/vavi/track/ChangeVoiceMessage.java
index 9d643d8..05f41c3 100644
--- a/src/main/java/vavi/sound/mfi/vavi/track/ChangeVoiceMessage.java
+++ b/src/main/java/vavi/sound/mfi/vavi/track/ChangeVoiceMessage.java
@@ -103,7 +103,7 @@ public MidiEvent[] getMidiEvents(MidiContext context)
int channel = getVoice() + 4 * context.getMfiTrackNumber();
-//Debug.println("program[" + channel + "]: " + StringUtil.toHex2(getProgram()));
+//logger.log(Level.DEBUG, "program[" + channel + "]: " + StringUtil.toHex2(getProgram()));
channel = context.setProgram(channel, getProgram());
ShortMessage shortMessage = new ShortMessage();
@@ -137,7 +137,7 @@ public MfiEvent[] getMfiEvents(MidiEvent midiEvent, MfiContext context)
changeBankMessage.setBank(((data1 & 0xc0) >> 6) + 2); // TODO 2 ???
context.setPreviousTick(track, midiEvent.getTick());
-//Debug.println(channel + ": " + StringUtil.toHex2(data1) + ", " + StringUtil.toHex2(changeVoiceMessage.getProgram()) + ", " + changeBankMessage.getBank());
+//logger.log(Level.DEBUG, channel + ": " + StringUtil.toHex2(data1) + ", " + StringUtil.toHex2(changeVoiceMessage.getProgram()) + ", " + changeBankMessage.getBank());
return new MfiEvent[] {
new MfiEvent(changeBankMessage, midiEvent.getTick()),
diff --git a/src/main/java/vavi/sound/mfi/vavi/track/ChannelChangeMessage.java b/src/main/java/vavi/sound/mfi/vavi/track/ChannelChangeMessage.java
index 7217750..c694167 100644
--- a/src/main/java/vavi/sound/mfi/vavi/track/ChannelChangeMessage.java
+++ b/src/main/java/vavi/sound/mfi/vavi/track/ChannelChangeMessage.java
@@ -6,13 +6,16 @@
package vavi.sound.mfi.vavi.track;
-import java.util.logging.Level;
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
import javax.sound.midi.MidiEvent;
+
import vavi.sound.mfi.ChannelMessage;
import vavi.sound.mfi.ShortMessage;
import vavi.sound.mfi.vavi.MidiContext;
import vavi.sound.mfi.vavi.MidiConvertible;
-import vavi.util.Debug;
+
+import static java.lang.System.getLogger;
/**
@@ -32,10 +35,12 @@
public class ChannelChangeMessage extends ShortMessage
implements ChannelMessage, MidiConvertible {
+ private static final Logger logger = getLogger(ChannelChangeMessage.class.getName());
+
/** */
private int voice;
/** 0 - 15 ch */
- private int channel;
+ private final int channel;
/**
* for {@link vavi.sound.mfi.vavi.TrackMessage}
@@ -84,7 +89,7 @@ public String toString() {
@Override
public MidiEvent[] getMidiEvents(MidiContext context) {
-Debug.println(Level.INFO, "ignore: " + this);
+logger.log(Level.INFO, "ignore: " + this);
return null;
}
}
diff --git a/src/main/java/vavi/sound/mfi/vavi/track/ChannelConfigurationMessage.java b/src/main/java/vavi/sound/mfi/vavi/track/ChannelConfigurationMessage.java
index 7d6d461..97fb526 100644
--- a/src/main/java/vavi/sound/mfi/vavi/track/ChannelConfigurationMessage.java
+++ b/src/main/java/vavi/sound/mfi/vavi/track/ChannelConfigurationMessage.java
@@ -6,12 +6,15 @@
package vavi.sound.mfi.vavi.track;
-import java.util.logging.Level;
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
import javax.sound.midi.MidiEvent;
+
import vavi.sound.mfi.ShortMessage;
import vavi.sound.mfi.vavi.MidiContext;
import vavi.sound.mfi.vavi.MidiConvertible;
-import vavi.util.Debug;
+
+import static java.lang.System.getLogger;
/**
@@ -27,10 +30,12 @@
public class ChannelConfigurationMessage extends ShortMessage
implements MidiConvertible {
+ private static final Logger logger = getLogger(ChannelConfigurationMessage.class.getName());
+
/** */
- private int channel;
+ private final int channel;
/** */
- private boolean drum;
+ private final boolean drum;
/**
* for {@link vavi.sound.mfi.vavi.TrackMessage}
@@ -76,7 +81,7 @@ public String toString() {
*/
@Override
public MidiEvent[] getMidiEvents(MidiContext context) {
-Debug.println(Level.FINE, this);
+logger.log(Level.DEBUG, this);
context.setDrum(getChannel(), isDrum() ? MidiContext.ChannelConfiguration.PERCUSSION :
MidiContext.ChannelConfiguration.SOUND_SET);
diff --git a/src/main/java/vavi/sound/mfi/vavi/track/CuePointMessage.java b/src/main/java/vavi/sound/mfi/vavi/track/CuePointMessage.java
index 710d180..5d58ea0 100644
--- a/src/main/java/vavi/sound/mfi/vavi/track/CuePointMessage.java
+++ b/src/main/java/vavi/sound/mfi/vavi/track/CuePointMessage.java
@@ -32,7 +32,7 @@ public class CuePointMessage extends ShortMessage
implements MidiConvertible {
/** 00: start, 01: end */
- private boolean start;
+ private final boolean start;
/**
* 0xd0
@@ -92,7 +92,7 @@ public MidiEvent[] getMidiEvents(MidiContext context) throws InvalidMidiDataExce
// new MidiEvent(sysexMessage, context.getCurrent())
// };
// } else {
-//Debug.println("ignore: " + this);
+//logger.log(Level.DEBUG, "ignore: " + this);
// return null;
// }
MetaMessage metaMessage = new MetaMessage();
diff --git a/src/main/java/vavi/sound/mfi/vavi/track/EndOfTrackMessage.java b/src/main/java/vavi/sound/mfi/vavi/track/EndOfTrackMessage.java
index f696f3a..0a2f963 100644
--- a/src/main/java/vavi/sound/mfi/vavi/track/EndOfTrackMessage.java
+++ b/src/main/java/vavi/sound/mfi/vavi/track/EndOfTrackMessage.java
@@ -75,7 +75,7 @@ public MidiEvent[] getMidiEvents(MidiContext context) {
// new MidiEvent(metaMessage, context.getCurrent())
// };
-//Debug.println("ignore: " + this);
+//logger.log(Level.DEBUG, "ignore: " + this);
return null;
}
diff --git a/src/main/java/vavi/sound/mfi/vavi/track/ExpressionMessage.java b/src/main/java/vavi/sound/mfi/vavi/track/ExpressionMessage.java
index 296956a..03b221e 100644
--- a/src/main/java/vavi/sound/mfi/vavi/track/ExpressionMessage.java
+++ b/src/main/java/vavi/sound/mfi/vavi/track/ExpressionMessage.java
@@ -109,7 +109,7 @@ public MidiEvent[] getMidiEvents(MidiContext context)
int channel = getVoice() + 4 * context.getMfiTrackNumber();
-//Debug.println("volume rel: " + channel + ": " + getVolume());
+//logger.log(Level.DEBUG, "volume rel: " + channel + ": " + getVolume());
// context.addVolume(channel, getVolume());
// MidiEvent[] events = new MidiEvent[2];
diff --git a/src/main/java/vavi/sound/mfi/vavi/track/ExtendedEditMessage.java b/src/main/java/vavi/sound/mfi/vavi/track/ExtendedEditMessage.java
index 03adc63..709d7ef 100644
--- a/src/main/java/vavi/sound/mfi/vavi/track/ExtendedEditMessage.java
+++ b/src/main/java/vavi/sound/mfi/vavi/track/ExtendedEditMessage.java
@@ -7,13 +7,15 @@
package vavi.sound.mfi.vavi.track;
import java.io.DataInputStream;
-import java.io.InputStream;
import java.io.IOException;
-import java.util.logging.Level;
+import java.io.InputStream;
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
import vavi.sound.mfi.InvalidMfiDataException;
import vavi.sound.mfi.SysexMessage;
-import vavi.util.Debug;
+
+import static java.lang.System.getLogger;
/**
@@ -29,6 +31,8 @@
*/
public class ExtendedEditMessage extends SysexMessage {
+ private static final Logger logger = getLogger(ExtendedEditMessage.class.getName());
+
/** */
protected ExtendedEditMessage(byte[] message) {
super(message);
@@ -49,7 +53,7 @@ public static ExtendedEditMessage readFrom(int delta, int status, int data1, Inp
dummy = dis.read(); // 0x01
int part = dis.read();
int zwitch = dis.read();
-Debug.println(Level.FINE, "dummy " + dummy + ", part " + part + ", switch " + zwitch);
+logger.log(Level.DEBUG, "dummy " + dummy + ", part " + part + ", switch " + zwitch);
throw new InvalidMfiDataException("unsupported: " + 0xf2);
}
diff --git a/src/main/java/vavi/sound/mfi/vavi/track/LoopPointMessage.java b/src/main/java/vavi/sound/mfi/vavi/track/LoopPointMessage.java
index dd43472..f6309e2 100644
--- a/src/main/java/vavi/sound/mfi/vavi/track/LoopPointMessage.java
+++ b/src/main/java/vavi/sound/mfi/vavi/track/LoopPointMessage.java
@@ -6,12 +6,15 @@
package vavi.sound.mfi.vavi.track;
-import java.util.logging.Level;
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
import javax.sound.midi.MidiEvent;
+
import vavi.sound.mfi.ShortMessage;
import vavi.sound.mfi.vavi.MidiContext;
import vavi.sound.mfi.vavi.MidiConvertible;
-import vavi.util.Debug;
+
+import static java.lang.System.getLogger;
/**
@@ -29,12 +32,14 @@
public class LoopPointMessage extends ShortMessage
implements MidiConvertible {
+ private static final Logger logger = getLogger(LoopPointMessage.class.getName());
+
/** 0 ~ 3 */
- private int nest;
+ private final int nest;
/** loop times, 01111b means forever */
private int times;
/** 00b: start, 01b: end */
- private int start;
+ private final int start;
/**
* for {@link vavi.sound.mfi.vavi.TrackMessage}
@@ -88,7 +93,7 @@ public String toString() {
@Override
public MidiEvent[] getMidiEvents(MidiContext context) {
-Debug.println(Level.INFO, "ignore: " + this);
+logger.log(Level.INFO, "ignore: " + this);
return null;
}
}
diff --git a/src/main/java/vavi/sound/mfi/vavi/track/MachineDependentMessage.java b/src/main/java/vavi/sound/mfi/vavi/track/MachineDependentMessage.java
index fc73247..b9be66b 100644
--- a/src/main/java/vavi/sound/mfi/vavi/track/MachineDependentMessage.java
+++ b/src/main/java/vavi/sound/mfi/vavi/track/MachineDependentMessage.java
@@ -10,8 +10,8 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.Serializable;
-import java.util.logging.Level;
-
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
import javax.sound.midi.InvalidMidiDataException;
import javax.sound.midi.MetaMessage;
import javax.sound.midi.MidiEvent;
@@ -23,7 +23,8 @@
import vavi.sound.mfi.vavi.sequencer.MachineDependentSequencer;
import vavi.sound.mfi.vavi.sequencer.MfiMessageStore;
import vavi.sound.midi.VaviMidiDeviceProvider;
-import vavi.util.Debug;
+
+import static java.lang.System.getLogger;
/**
@@ -42,6 +43,8 @@
public class MachineDependentMessage extends SysexMessage
implements MidiConvertible, Serializable {
+ private static final Logger logger = getLogger(MachineDependentMessage.class.getName());
+
/** */
protected MachineDependentMessage(byte[] message) {
super(message);
@@ -61,7 +64,7 @@ public void setMessage(int delta, byte[] message)
throws InvalidMfiDataException {
byte[] tmp = new byte[5 + message.length];
-//Debug.println("data: " + message.length);
+//logger.log(Level.DEBUG, "data: " + message.length);
tmp[0] = (byte) (delta & 0xff);
tmp[1] = (byte) 0xff;
tmp[2] = (byte) 0xff;
@@ -70,7 +73,7 @@ public void setMessage(int delta, byte[] message)
//Debug.dump(new ByteArrayInputStream(tmp, 0, 5));
System.arraycopy(message, 0, tmp, 5, message.length);
-//Debug.println("message: " + tmp.length);
+//logger.log(Level.DEBUG, "message: " + tmp.length);
super.setMessage(tmp, tmp.length);
//Debug.dump(new ByteArrayInputStream(this.data, 0, 10));
}
@@ -87,7 +90,7 @@ public static MachineDependentMessage readFrom(int delta, int status, int data1,
DataInputStream dis = new DataInputStream(is);
int length = dis.readUnsignedShort();
-//Debug.println("length: " + length);
+//logger.log(Level.DEBUG, "length: " + length);
byte[] data = new byte[length + 5];
@@ -103,7 +106,7 @@ public static MachineDependentMessage readFrom(int delta, int status, int data1,
// 5 vendor | carrier
// 6
// 7
-Debug.printf(Level.FINE, "MachineDepend: %02x, %02x, %02x %02x %02x %02x %02x\n", data[0], data[5], data[6], data[7], (data.length > 8 ? data[8] : 0), (data.length > 9 ? data[9] : 0), (data.length > 10 ? data[10] : 0));
+logger.log(Level.DEBUG, String.format("MachineDepend: %02x, %02x, %02x %02x %02x %02x %02x", data[0], data[5], data[6], data[7], (data.length > 8 ? data[8] : 0), (data.length > 9 ? data[9] : 0), (data.length > 10 ? data[10] : 0)));
MachineDependentMessage message = new MachineDependentMessage(data);
return message;
}
diff --git a/src/main/java/vavi/sound/mfi/vavi/track/MfiConvertibleMessage.java b/src/main/java/vavi/sound/mfi/vavi/track/MfiConvertibleMessage.java
index 6828ce2..e72b8c8 100644
--- a/src/main/java/vavi/sound/mfi/vavi/track/MfiConvertibleMessage.java
+++ b/src/main/java/vavi/sound/mfi/vavi/track/MfiConvertibleMessage.java
@@ -25,9 +25,9 @@
public class MfiConvertibleMessage implements MfiConvertible {
/** BANK LSB */
- private int[] bankLSB = new int[MidiContext.MAX_MIDI_CHANNELS];
+ private final int[] bankLSB = new int[MidiContext.MAX_MIDI_CHANNELS];
/** BANK MSB */
- private int[] bankMSB = new int[MidiContext.MAX_MIDI_CHANNELS];
+ private final int[] bankMSB = new int[MidiContext.MAX_MIDI_CHANNELS];
/** */
public static final int RPN_PITCH_BEND_SENSITIVITY = 0x0000;
@@ -43,14 +43,14 @@ public class MfiConvertibleMessage implements MfiConvertible {
public static final int RPN_NULL = 0x7f7f;
/** RPN LSB */
- private int[] rpnLSB = new int[MidiContext.MAX_MIDI_CHANNELS];
+ private final int[] rpnLSB = new int[MidiContext.MAX_MIDI_CHANNELS];
/** RPN MSB */
- private int[] rpnMSB = new int[MidiContext.MAX_MIDI_CHANNELS];
+ private final int[] rpnMSB = new int[MidiContext.MAX_MIDI_CHANNELS];
/** NRPN LSB */
- private int[] nrpnLSB = new int[MidiContext.MAX_MIDI_CHANNELS];
+ private final int[] nrpnLSB = new int[MidiContext.MAX_MIDI_CHANNELS];
/** NRPN MSB */
- private int[] nrpnMSB = new int[MidiContext.MAX_MIDI_CHANNELS];
+ private final int[] nrpnMSB = new int[MidiContext.MAX_MIDI_CHANNELS];
/** bank, rpn, nrpn */
@Override
@@ -90,13 +90,13 @@ public MfiEvent[] getMfiEvents(MidiEvent midiEvent, MfiContext context)
// case RPN_PITCH_BEND_SENSITIVITY:
// MfiConvertible converter = new vavi.sound.mfi.vavi.channel.PitchBendRangeMessage();
// return converter.getMfiEvents(midiEvent, context);
-//Debug.println("rpn: MSB:" + rpnMSB[channel] + ", LSB:" + rpnLSB[channel]);
+//logger.log(Level.DEBUG, "rpn: MSB:" + rpnMSB[channel] + ", LSB:" + rpnLSB[channel]);
// default:
-//Debug.println("data entry: no handler for rpn: " + rpn[channel]);
+//logger.log(Level.DEBUG, "data entry: no handler for rpn: " + rpn[channel]);
// break;
// }
default:
-//Debug.println("not implemented: " + data1);
+//logger.log(Level.DEBUG, "not implemented: " + data1);
break;
}
diff --git a/src/main/java/vavi/sound/mfi/vavi/track/Nop2Message.java b/src/main/java/vavi/sound/mfi/vavi/track/Nop2Message.java
index c9e2f97..1dffa27 100644
--- a/src/main/java/vavi/sound/mfi/vavi/track/Nop2Message.java
+++ b/src/main/java/vavi/sound/mfi/vavi/track/Nop2Message.java
@@ -6,13 +6,15 @@
package vavi.sound.mfi.vavi.track;
-import java.util.logging.Level;
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
import javax.sound.midi.MidiEvent;
import vavi.sound.mfi.ShortMessage;
import vavi.sound.mfi.vavi.MidiContext;
import vavi.sound.mfi.vavi.MidiConvertible;
-import vavi.util.Debug;
+
+import static java.lang.System.getLogger;
/**
@@ -29,6 +31,8 @@
public class Nop2Message extends ShortMessage
implements MidiConvertible {
+ private static final Logger logger = getLogger(Nop2Message.class.getName());
+
public static final int maxDelta = 0xff * 0x100 + 0xff;
/**
@@ -43,7 +47,7 @@ public class Nop2Message extends ShortMessage
*/
public Nop2Message(int delta, int data2) {
super(delta, 0xff, 0xdc, data2);
-Debug.println(Level.FINE, "NOP2: delta: " + delta);
+logger.log(Level.DEBUG, "NOP2: delta: " + delta);
}
/**
@@ -55,7 +59,7 @@ public Nop2Message(int delta, int data2) {
*/
public Nop2Message(int delta, int status, int data1, int data2) {
super(delta, 0xff, 0xdc, data2);
-Debug.println(Level.FINE, "NOP2: delta: " + delta);
+logger.log(Level.DEBUG, "NOP2: delta: " + delta);
}
/** */
@@ -67,7 +71,7 @@ public String toString() {
@Override
public MidiEvent[] getMidiEvents(MidiContext context) {
-//Debug.println("ignore: " + this);
+//logger.log(Level.DEBUG, "ignore: " + this);
return null;
}
}
diff --git a/src/main/java/vavi/sound/mfi/vavi/track/NopMessage.java b/src/main/java/vavi/sound/mfi/vavi/track/NopMessage.java
index 50345b0..52db685 100644
--- a/src/main/java/vavi/sound/mfi/vavi/track/NopMessage.java
+++ b/src/main/java/vavi/sound/mfi/vavi/track/NopMessage.java
@@ -36,7 +36,7 @@ public class NopMessage extends ShortMessage
*/
public NopMessage(int delta, int data2) {
super(delta, 0xff, 0xde, data2);
-//Debug.println("NOP: delta: " + delta);
+//logger.log(Level.DEBUG, "NOP: delta: " + delta);
}
/**
@@ -48,7 +48,7 @@ public NopMessage(int delta, int data2) {
*/
public NopMessage(int delta, int status, int data1, int data2) {
super(delta, 0xff, 0xde, data2);
-//Debug.println("NOP: delta: " + delta);
+//logger.log(Level.DEBUG, "NOP: delta: " + delta);
}
/** */
@@ -60,7 +60,7 @@ public String toString() {
@Override
public MidiEvent[] getMidiEvents(MidiContext context) {
-//Debug.println("ignore: " + this);
+//logger.log(Level.DEBUG, "ignore: " + this);
return null;
}
}
diff --git a/src/main/java/vavi/sound/mfi/vavi/track/PitchBendMessage.java b/src/main/java/vavi/sound/mfi/vavi/track/PitchBendMessage.java
index dc79ef7..2070c8c 100644
--- a/src/main/java/vavi/sound/mfi/vavi/track/PitchBendMessage.java
+++ b/src/main/java/vavi/sound/mfi/vavi/track/PitchBendMessage.java
@@ -102,7 +102,7 @@ public MidiEvent[] getMidiEvents(MidiContext context)
throws InvalidMidiDataException {
int channel = getVoice() + 4 * context.getMfiTrackNumber();
-//Debug.println(this);
+//logger.log(Level.DEBUG, this);
// context.setPitchBend(channel, getPitchBend());
// int pitch = context.retrieveRealPitch(channel);
diff --git a/src/main/java/vavi/sound/mfi/vavi/track/PitchBendRangeMessage.java b/src/main/java/vavi/sound/mfi/vavi/track/PitchBendRangeMessage.java
index cd5de67..92e41e9 100644
--- a/src/main/java/vavi/sound/mfi/vavi/track/PitchBendRangeMessage.java
+++ b/src/main/java/vavi/sound/mfi/vavi/track/PitchBendRangeMessage.java
@@ -103,7 +103,7 @@ public MidiEvent[] getMidiEvents(MidiContext context)
throws InvalidMidiDataException {
int channel = getVoice() + 4 * context.getMfiTrackNumber();
-//Debug.println(this);
+//logger.log(Level.DEBUG, this);
// context.setPitchBendRange(channel, getPitchBendRange());
MidiEvent[] events = new MidiEvent[3];
@@ -143,7 +143,7 @@ public MfiEvent[] getMfiEvents(MidiEvent midiEvent, MfiContext context)
mfiMessage.setDelta(context.getDelta(context.retrieveMfiTrack(channel)));
mfiMessage.setVoice(voice);
// if (data2 / 2 > 24) {
-// Debug.println("range: " + data2 / 2);
+// logger.log(Level.DEBUG, "range: " + data2 / 2);
// }
mfiMessage.setPitchBendRange(Math.min(data2 / 2, 24));
diff --git a/src/main/java/vavi/sound/mfi/vavi/track/TempoMessage.java b/src/main/java/vavi/sound/mfi/vavi/track/TempoMessage.java
index 33601dd..37196b0 100644
--- a/src/main/java/vavi/sound/mfi/vavi/track/TempoMessage.java
+++ b/src/main/java/vavi/sound/mfi/vavi/track/TempoMessage.java
@@ -6,10 +6,10 @@
package vavi.sound.mfi.vavi.track;
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
import java.util.ArrayList;
import java.util.List;
-import java.util.logging.Level;
-
import javax.sound.midi.InvalidMidiDataException;
import javax.sound.midi.MetaMessage;
import javax.sound.midi.MidiEvent;
@@ -21,7 +21,8 @@
import vavi.sound.mfi.vavi.MfiConvertible;
import vavi.sound.mfi.vavi.MidiContext;
import vavi.sound.mfi.vavi.MidiConvertible;
-import vavi.util.Debug;
+
+import static java.lang.System.getLogger;
/**
@@ -38,6 +39,8 @@
public class TempoMessage extends ShortMessage
implements MidiConvertible, MfiConvertible {
+ private static final Logger logger = getLogger(TempoMessage.class.getName());
+
/** quarter note resolution @see #timeBaseTable */
private int timeBase;
/** quarter note count per minute 20 ~ 125 ~ 255 */
@@ -61,7 +64,7 @@ public TempoMessage(int delta, int status, int data1, int data2) {
super(delta, 0xff, data1, data2);
this.timeBase = timeBaseTable[data1 & 0x0f];
- this.tempo = data2 < 20 ? 20 : data2;
+ this.tempo = Math.max(data2, 20);
}
/** for {@link MfiConvertible} */
@@ -84,7 +87,7 @@ public void setTimeBase(int timeBase) {
for (int i = 0; i < timeBaseTable.length; i++) {
if (timeBase == timeBaseTable[i]) {
if (timeBase < 0) {
- Debug.println(Level.WARNING, "timeBase < 0: " + timeBase);
+ logger.log(Level.WARNING, "timeBase < 0: " + timeBase);
}
this.data[2] = (byte) (0xc0 | i);
return;
@@ -121,8 +124,8 @@ public MidiEvent[] getMidiEvents(MidiContext context)
int timeBase = getTimeBase();
// quarter note length in μsec TODO is round OK?, TODO 48??? (actually 60 * 10^6 / tempo)
int l = (int) Math.round(60d * 1000000d / ((48d / timeBase) * tempo));
-//Debug.println(this);
-//Debug.println(l + " = " +
+//logger.log(Level.DEBUG, this);
+//logger.log(Level.DEBUG, l + " = " +
// StringUtil.toHex2( ((l / 0x10000) & 0xff)) + ", " +
// StringUtil.toHex2((((l % 0x10000) / 0x100) & 0xff)) + ", " +
// StringUtil.toHex2( ((l % 0x100) & 0xff)));
@@ -145,23 +148,23 @@ public MfiEvent[] getMfiEvents(MidiEvent midiEvent, MfiContext context)
MetaMessage metaMessage = (MetaMessage) midiEvent.getMessage();
// int type = metaMessage.getType();
byte[] data = metaMessage.getData();
-//Debug.println("data.length: " + data.length);
+//logger.log(Level.DEBUG, "data.length: " + data.length);
int timeBase = getNearestTimeBase(context.getTimeBase());
int l = ((data[0] & 0xff) << 16) |
((data[1] & 0xff) << 8) |
(data[2] & 0xff);
-//Debug.println("(CALC) timeBase: " + timeBase + ", tempo: " + tempo + ", l; " + l);
+//logger.log(Level.DEBUG, "(CALC) timeBase: " + timeBase + ", tempo: " + tempo + ", l; " + l);
// TODO no more change if scale is changed once?
if (context.isScaleChanged()) {
timeBase = getNearestTimeBase((int) (context.getTimeBase() / context.getScale()));
tempo = (int) Math.round(60d * 1000000d / ((48d / timeBase) * l));
-//Debug.println("(SET) tempo > " + MAX_SCALELESS + ": timeBase: " + timeBase + ", tempo: " + tempo);
+//logger.log(Level.DEBUG, "(SET) tempo > " + MAX_SCALELESS + ": timeBase: " + timeBase + ", tempo: " + tempo);
} else {
timeBase = getNearestTimeBase(context.getTimeBase());
tempo = (int) Math.round(60d * 1000000d / ((48d / timeBase) * l));
-//Debug.println("(SET) timeBase: " + timeBase + ", tempo: " + tempo);
+//logger.log(Level.DEBUG, "(SET) timeBase: " + timeBase + ", tempo: " + tempo);
}
TempoMessage mfiMessage = new TempoMessage();
@@ -178,8 +181,8 @@ public MfiEvent[] getMfiEvents(MidiEvent midiEvent, MfiContext context)
/** for sorting */
private static class Pair {
- int index;
- int value;
+ final int index;
+ final int value;
Pair(int index, int value) {
this.index = index;
this.value = value;
@@ -204,9 +207,9 @@ public static int getNearestTimeBase(int timeBase) {
return v1 - v2;
});
//for (int i = 0; i < table.size(); i++) {
-// Debug.println("(" + i + ") timeBaseTable[" + table.get(i).index + "], " + table.get(i).value);
+// logger.log(Level.DEBUG, "(" + i + ") timeBaseTable[" + table.get(i).index + "], " + table.get(i).value);
//}
-//Debug.println("(CHANGE) " + timeBase + " -> " + timeBaseTable[table.get(0).index]);
+//logger.log(Level.DEBUG, "(CHANGE) " + timeBase + " -> " + timeBaseTable[table.get(0).index]);
return timeBaseTable[table.get(0).index];
}
}
diff --git a/src/main/java/vavi/sound/mfi/vavi/track/UndefinedMessage.java b/src/main/java/vavi/sound/mfi/vavi/track/UndefinedMessage.java
index 8c5134d..b42ced0 100644
--- a/src/main/java/vavi/sound/mfi/vavi/track/UndefinedMessage.java
+++ b/src/main/java/vavi/sound/mfi/vavi/track/UndefinedMessage.java
@@ -6,14 +6,17 @@
package vavi.sound.mfi.vavi.track;
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
import javax.sound.midi.MidiEvent;
import vavi.sound.mfi.MfiMessage;
import vavi.sound.mfi.vavi.MidiContext;
import vavi.sound.mfi.vavi.MidiConvertible;
-import vavi.util.Debug;
import vavi.util.StringUtil;
+import static java.lang.System.getLogger;
+
/**
* UndefinedMessage
@@ -25,6 +28,8 @@
public class UndefinedMessage extends MfiMessage
implements MidiConvertible {
+ private static final Logger logger = getLogger(UndefinedMessage.class.getName());
+
/**
*
* @param delta delta time
@@ -61,7 +66,7 @@ public String toString() {
@Override
public MidiEvent[] getMidiEvents(MidiContext context) {
-Debug.println(this);
+logger.log(Level.DEBUG, this);
return null;
}
}
diff --git a/src/main/java/vavi/sound/mfi/vavi/track/VolumeMessage.java b/src/main/java/vavi/sound/mfi/vavi/track/VolumeMessage.java
index afdbf1f..ba0422c 100644
--- a/src/main/java/vavi/sound/mfi/vavi/track/VolumeMessage.java
+++ b/src/main/java/vavi/sound/mfi/vavi/track/VolumeMessage.java
@@ -102,7 +102,7 @@ public MidiEvent[] getMidiEvents(MidiContext context)
int channel = getVoice() + 4 * context.getMfiTrackNumber();
-//Debug.println("volume: " + channel + ": " + getVolume());
+//logger.log(Level.DEBUG, "volume: " + channel + ": " + getVolume());
context.setVolume(channel, volume);
MidiEvent[] events = new MidiEvent[1];
@@ -136,7 +136,7 @@ public MfiEvent[] getMfiEvents(MidiEvent midiEvent, MfiContext context)
mfiMessage.setDelta(context.getDelta(context.retrieveMfiTrack(channel)));
mfiMessage.setVoice(voice);
mfiMessage.setVolume(data2 / 2);
-//Debug.println(mfiMessage.getVoice() + ", " + ((mfiMessage.getMessage()[3] & 0xc0) >> 6));
+//logger.log(Level.DEBUG, mfiMessage.getVoice() + ", " + ((mfiMessage.getMessage()[3] & 0xc0) >> 6));
context.setPreviousTick(track, midiEvent.getTick());
diff --git a/src/main/java/vavi/sound/midi/BasicMidiFileReader.java b/src/main/java/vavi/sound/midi/BasicMidiFileReader.java
index c0f333b..6325a41 100644
--- a/src/main/java/vavi/sound/midi/BasicMidiFileReader.java
+++ b/src/main/java/vavi/sound/midi/BasicMidiFileReader.java
@@ -12,17 +12,17 @@
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
import java.net.URL;
import java.nio.file.Files;
-import java.util.logging.Level;
-
import javax.sound.midi.InvalidMidiDataException;
import javax.sound.midi.MidiFileFormat;
import javax.sound.midi.MidiSystem;
import javax.sound.midi.Sequence;
import javax.sound.midi.spi.MidiFileReader;
-import vavi.util.Debug;
+import static java.lang.System.getLogger;
/**
@@ -33,6 +33,8 @@
*/
public abstract class BasicMidiFileReader extends MidiFileReader {
+ private static final Logger logger = getLogger(BasicMidiFileReader.class.getName());
+
/**
* Gets MIDI Sequence converted by a method {@link #getSequence(InputStream)}
* implemented in a sub class.
@@ -44,12 +46,12 @@ public MidiFileFormat getMidiFileFormat(InputStream stream)
throws InvalidMidiDataException,
IOException {
-//Debug.println("here ★");
+//logger.log(Level.DEBUG, "here ★");
Sequence midiSequence = getSequence(stream);
ByteArrayOutputStream os = new ByteArrayOutputStream();
MidiSystem.write(midiSequence, 0, os);
ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray());
-//Debug.println("temporary midi:\n" + StringUtil.getDump(os.toByteArray(), 128));
+//logger.log(Level.DEBUG, "temporary midi:\n" + StringUtil.getDump(os.toByteArray(), 128));
MidiFileFormat midiFF = MidiSystem.getMidiFileFormat(is);
return midiFF;
}
@@ -59,7 +61,7 @@ public MidiFileFormat getMidiFileFormat(File file)
throws InvalidMidiDataException,
IOException {
-Debug.println(Level.FINE, "file: " + file);
+logger.log(Level.DEBUG, "file: " + file);
InputStream is = new BufferedInputStream(Files.newInputStream(file.toPath()));
return getMidiFileFormat(is);
}
diff --git a/src/main/java/vavi/sound/midi/MidiConstants.java b/src/main/java/vavi/sound/midi/MidiConstants.java
index 33c8127..3aef812 100644
--- a/src/main/java/vavi/sound/midi/MidiConstants.java
+++ b/src/main/java/vavi/sound/midi/MidiConstants.java
@@ -7,12 +7,13 @@
package vavi.sound.midi;
import java.io.IOException;
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.Properties;
-import java.util.logging.Level;
-import vavi.util.Debug;
+import static java.lang.System.getLogger;
/**
@@ -23,13 +24,15 @@
*/
public final class MidiConstants {
+ private static final Logger logger = getLogger(MidiConstants.class.getName());
+
private MidiConstants() {
}
/** instrument names */
- private static Properties props = new Properties();
+ private static final Properties props = new Properties();
- /** */
+ /** */
public static String getInstrumentName(int index) {
return props.getProperty("midi.inst.gm." + index);
}
@@ -237,7 +240,7 @@ public static MetaEvent valueOf(int number) {
return Arrays.stream(values()).filter(e -> e.number == number).findFirst().get();
} catch (NoSuchElementException e) {
META_UNDEFINED.number = number; // TODO evil and not thread safe.
- Debug.println(Level.WARNING, "undefined meta: " + number);
+ logger.log(Level.WARNING, "undefined meta: " + number);
return META_UNDEFINED;
}
}
@@ -305,7 +308,7 @@ public String toString() {
final Class> clazz = MidiConstants.class;
props.load(clazz.getResourceAsStream("midi.properties"));
} catch (IOException e) {
- Debug.println(e);
+ logger.log(Level.DEBUG, e);
throw new IllegalStateException(e);
}
}
diff --git a/src/main/java/vavi/sound/midi/MidiUtil.java b/src/main/java/vavi/sound/midi/MidiUtil.java
index 1e8131b..5518522 100644
--- a/src/main/java/vavi/sound/midi/MidiUtil.java
+++ b/src/main/java/vavi/sound/midi/MidiUtil.java
@@ -10,10 +10,10 @@
import java.io.DataOutput;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
import java.util.Properties;
import java.util.ServiceLoader;
-import java.util.logging.Level;
-
import javax.sound.midi.InvalidMidiDataException;
import javax.sound.midi.MetaMessage;
import javax.sound.midi.MidiDevice;
@@ -27,6 +27,8 @@
import vavi.util.Debug;
+import static java.lang.System.getLogger;
+
/**
* MidiUtil.
@@ -36,6 +38,8 @@
*/
public final class MidiUtil {
+ private static final Logger logger = getLogger(MidiUtil.class.getName());
+
/** */
private MidiUtil() {
}
@@ -53,8 +57,7 @@ public static void volume(Receiver receiver, float volume) throws InvalidMidiDat
/** */
public static String paramString(MidiMessage midiMessage) {
String result = null;
- if (midiMessage instanceof ShortMessage) {
- ShortMessage msg = (ShortMessage) midiMessage;
+ if (midiMessage instanceof ShortMessage msg) {
int channel = msg.getChannel();
int command = msg.getCommand();
int data1 = msg.getData1();
@@ -63,8 +66,7 @@ public static String paramString(MidiMessage midiMessage) {
",event=" + getChannelMessage(command, data1) +
",data1=" + (command == ShortMessage.PROGRAM_CHANGE ? data1 + " " + MidiConstants.getInstrumentName(data1) : String.valueOf(data1)) +
",data2=" + data2;
- } else if (midiMessage instanceof SysexMessage) {
- SysexMessage msg = (SysexMessage) midiMessage;
+ } else if (midiMessage instanceof SysexMessage msg) {
byte[] data = msg.getData();
StringBuilder sb = new StringBuilder();
for (byte datum : data) {
@@ -75,8 +77,7 @@ public static String paramString(MidiMessage midiMessage) {
",event=SYSX" +
",data1=" + sb +
",data2=";
- } else if (midiMessage instanceof MetaMessage) {
- MetaMessage msg = (MetaMessage) midiMessage;
+ } else if (midiMessage instanceof MetaMessage msg) {
int type = msg.getType();
byte[] data = msg.getData();
StringBuilder sb = new StringBuilder();
@@ -176,12 +177,12 @@ public static String getDecodedMessage(byte[] data, String encoding) {
// 01 0x03 ?
// 02 length
try {
-//Debug.println("META: " + data[1] + ", " + data[2] + ", " + StringUtil.getDump(data, start, length));
+//logger.log(Level.DEBUG, "META: " + data[1] + ", " + data[2] + ", " + StringUtil.getDump(data, start, length));
start = 3;
length -= 3;
return new String(data, start, length, encoding);
} catch (UnsupportedEncodingException e) {
-Debug.println(Level.WARNING, "unknown cp: " + e.getMessage());
+logger.log(Level.WARNING, "unknown cp: " + e.getMessage());
}
}
try {
@@ -205,7 +206,7 @@ public static byte[] getEncodedMessage(String text, String encoding) {
try {
textData = text.getBytes(encoding);
} catch (UnsupportedEncodingException e) {
-Debug.println(Level.WARNING, "unknown cp: " + e.getMessage());
+logger.log(Level.WARNING, "unknown cp: " + e.getMessage());
textData = text.getBytes();
}
byte[] data = new byte[textData.length + 3];
@@ -240,20 +241,20 @@ public static byte[] getEncodedMessage(String text, String encoding) {
String value = props.getProperty("decodingEncoding");
if (value != null) {
decodingEncoding = value;
-Debug.println(Level.FINE, "decodingEncoding: " + decodingEncoding);
+logger.log(Level.DEBUG, "decodingEncoding: " + decodingEncoding);
}
value = props.getProperty("encodingEncoding");
if (value != null) {
encodingEncoding = value;
-Debug.println(Level.FINE, "encodingEncoding: " + encodingEncoding);
+logger.log(Level.DEBUG, "encodingEncoding: " + encodingEncoding);
}
// defaultSequencer
value = props.getProperty("defaultSequencer");
if (value != null) {
String defaultSequencer = value;
-Debug.println(Level.FINE, "defaultSequencer: " + defaultSequencer);
+logger.log(Level.DEBUG, "defaultSequencer: " + defaultSequencer);
if (defaultSequencer.contains("#")) {
String[] pair = defaultSequencer.split("#");
sequencerClassName = pair[0];
@@ -262,14 +263,14 @@ public static byte[] getEncodedMessage(String text, String encoding) {
sequencerClassName = defaultSequencer;
}
}
-Debug.println(Level.FINE, "sequencerClassName: " + sequencerClassName);
-Debug.println(Level.FINE, "sequencerDeviceName: " + sequencerDeviceName);
+logger.log(Level.DEBUG, "sequencerClassName: " + sequencerClassName);
+logger.log(Level.DEBUG, "sequencerDeviceName: " + sequencerDeviceName);
// defaultSynthesizer
value = props.getProperty("defaultSynthesizer");
if (value != null) {
String defaultSynthesizer = value;
-Debug.println(Level.FINE, "defaultSynthesizer: " + defaultSynthesizer);
+logger.log(Level.DEBUG, "defaultSynthesizer: " + defaultSynthesizer);
if (defaultSynthesizer.contains("#")) {
String[] pair = defaultSynthesizer.split("#");
synthesizerClassName = pair[0];
@@ -278,10 +279,10 @@ public static byte[] getEncodedMessage(String text, String encoding) {
synthesizerClassName = defaultSynthesizer;
}
}
-Debug.println(Level.FINE, "sequencerClassName: " + sequencerClassName);
-Debug.println(Level.FINE, "sequencerDeviceName: " + sequencerDeviceName);
+logger.log(Level.DEBUG, "sequencerClassName: " + sequencerClassName);
+logger.log(Level.DEBUG, "sequencerDeviceName: " + sequencerDeviceName);
} catch (Exception e) {
-Debug.printStackTrace(e);
+logger.log(Level.ERROR, e.getMessage(), e);
throw new IllegalStateException(e);
}
}
@@ -301,19 +302,19 @@ public static Synthesizer getDefaultSynthesizer(Class extends MidiDeviceProvid
byte[] bytes = info.getName().getBytes("ISO8859-1");
name = new String(bytes /* , "Windows-31J" */);
} catch (IOException e) {
-Debug.println(e);
+logger.log(Level.DEBUG, e);
}
if (synthesizerDeviceName != null) {
if (synthesizerDeviceName.equals(name)) {
MidiDevice device = provider.getDevice(info);
-Debug.println(Level.FINE, "default synthesizer: " + provider.getClass().getName() + ", " + device.getClass().getName() + ", " + name + ", " + device.hashCode());
+logger.log(Level.DEBUG, "default synthesizer: " + provider.getClass().getName() + ", " + device.getClass().getName() + ", " + name + ", " + device.hashCode());
return (Synthesizer) device;
}
} else {
MidiDevice device = provider.getDevice(info);
if (device instanceof Synthesizer) {
if (device.getClass().getName().equals(synthesizerClassName)) {
-Debug.println(Level.FINE, "default synthesizer: " + provider.getClass().getName() + ", " + device.getClass().getName() + ", " + name + ", " + device.hashCode());
+logger.log(Level.DEBUG, "default synthesizer: " + provider.getClass().getName() + ", " + device.getClass().getName() + ", " + name + ", " + device.hashCode());
return (Synthesizer) device;
}
}
@@ -339,19 +340,19 @@ public static Sequencer getDefaultSequencer(Class extends MidiDeviceProvider>
byte[] bytes = info.getName().getBytes("ISO8859-1");
name = new String(bytes /* , "Windows-31J" */);
} catch (IOException e) {
-Debug.println(e);
+logger.log(Level.DEBUG, e);
}
if (sequencerDeviceName != null) {
if (sequencerDeviceName.equals(name)) {
MidiDevice device = provider.getDevice(info);
-Debug.println(Level.FINE, "default sequencer: " + provider.getClass().getName() + ", " + device.getClass().getName() + ", " + name + ", " + device.hashCode());
+logger.log(Level.DEBUG, "default sequencer: " + provider.getClass().getName() + ", " + device.getClass().getName() + ", " + name + ", " + device.hashCode());
return (Sequencer) device;
}
} else {
MidiDevice device = provider.getDevice(info);
if (device instanceof Sequencer) {
if (device.getClass().getName().equals(sequencerClassName)) {
-Debug.println(Level.FINE, "default sequencer: " + provider.getClass().getName() + ", " + device.getClass().getName() + ", " + name + ", " + device.hashCode());
+logger.log(Level.DEBUG, "default sequencer: " + provider.getClass().getName() + ", " + device.getClass().getName() + ", " + name + ", " + device.hashCode());
return (Sequencer) device;
}
}
@@ -371,11 +372,11 @@ public static Sequencer getDefaultSequencer(Class extends MidiDeviceProvider>
static {
try {
providers = ServiceLoader.load(javax.sound.midi.spi.MidiDeviceProvider.class);
-if (Debug.isLoggable(Level.FINE)) {
+if (Debug.isLoggable(java.util.logging.Level.FINE)) {
providers.forEach(provider -> System.err.println(provider.getClass()));
}
} catch (Throwable t) {
-Debug.printStackTrace(Level.FINE, t);
+logger.log(Level.DEBUG, t.getMessage(), t);
}
}
}
diff --git a/src/main/java/vavi/sound/midi/VaviMidiDeviceProvider.java b/src/main/java/vavi/sound/midi/VaviMidiDeviceProvider.java
index dec8a19..abb89e8 100644
--- a/src/main/java/vavi/sound/midi/VaviMidiDeviceProvider.java
+++ b/src/main/java/vavi/sound/midi/VaviMidiDeviceProvider.java
@@ -6,12 +6,12 @@
package vavi.sound.midi;
-import java.util.logging.Level;
-
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
import javax.sound.midi.MidiDevice;
import javax.sound.midi.spi.MidiDeviceProvider;
-import vavi.util.Debug;
+import static java.lang.System.getLogger;
/**
@@ -22,6 +22,8 @@
*/
public class VaviMidiDeviceProvider extends MidiDeviceProvider {
+ private static final Logger logger = getLogger(VaviMidiDeviceProvider.class.getName());
+
/**
* TODO used without asking
* TODO 0x5f is occupied by "SD Card Association"
@@ -46,11 +48,11 @@ public MidiDevice getDevice(MidiDevice.Info info) {
if (info == VaviSequencer.info) {
//new Exception("*** DUMMY ***").printStackTrace();
-Debug.println(Level.FINE, "★1 info: " + info);
+logger.log(Level.DEBUG, "★1 info: " + info);
VaviSequencer wrappedSequencer = new VaviSequencer();
return wrappedSequencer;
} else {
-Debug.println(Level.FINE, "★1 not suitable for this provider: " + info);
+logger.log(Level.DEBUG, "★1 not suitable for this provider: " + info);
throw new IllegalArgumentException("info is not suitable for this provider");
}
}
diff --git a/src/main/java/vavi/sound/midi/VaviSequencer.java b/src/main/java/vavi/sound/midi/VaviSequencer.java
index 1df211e..e9b6576 100644
--- a/src/main/java/vavi/sound/midi/VaviSequencer.java
+++ b/src/main/java/vavi/sound/midi/VaviSequencer.java
@@ -8,10 +8,10 @@
import java.io.IOException;
import java.io.InputStream;
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
import java.util.List;
import java.util.Properties;
-import java.util.logging.Level;
-
import javax.sound.midi.ControllerEventListener;
import javax.sound.midi.InvalidMidiDataException;
import javax.sound.midi.MetaEventListener;
@@ -23,7 +23,7 @@
import javax.sound.midi.Track;
import javax.sound.midi.Transmitter;
-import vavi.util.Debug;
+import static java.lang.System.getLogger;
/**
@@ -34,6 +34,8 @@
*/
class VaviSequencer implements Sequencer {
+ private static final Logger logger = getLogger(VaviSequencer.class.getName());
+
static {
try {
try (InputStream is = VaviSequencer.class.getResourceAsStream("/META-INF/maven/vavi/vavi-sound/pom.properties")) {
@@ -60,7 +62,7 @@ class VaviSequencer implements Sequencer {
"Version " + version) {};
/** */
- private Sequencer sequencer = MidiUtil.getDefaultSequencer(VaviMidiDeviceProvider.class);
+ private final Sequencer sequencer = MidiUtil.getDefaultSequencer(VaviMidiDeviceProvider.class);
/** */
private VaviSequence vaviSequence;
@@ -69,31 +71,31 @@ class VaviSequencer implements Sequencer {
public void start() {
if (vaviSequence != null) {
sequencer.addMetaEventListener(vaviSequence.getMetaEventListener()); // TODO more smart way
-Debug.println(Level.FINE, "★1 mel: " + vaviSequence);
+logger.log(Level.DEBUG, "★1 mel: " + vaviSequence);
}
sequencer.start();
-Debug.println(Level.FINE, "★1 start: " + sequencer.hashCode());
+logger.log(Level.DEBUG, "★1 start: " + sequencer.hashCode());
}
@Override
public void stop() {
-Debug.println(Level.FINE, "★1 stop: " + sequencer.hashCode());
+logger.log(Level.DEBUG, "★1 stop: " + sequencer.hashCode());
sequencer.stop();
if (vaviSequence != null) {
-Debug.println(Level.FINE, "★1 mel: " + vaviSequence);
+logger.log(Level.DEBUG, "★1 mel: " + vaviSequence);
sequencer.removeMetaEventListener(vaviSequence.getMetaEventListener()); // TODO more smart way
}
}
@Override
public void close() {
-Debug.println(Level.FINE, "★1 close: " + sequencer.hashCode());
+logger.log(Level.DEBUG, "★1 close: " + sequencer.hashCode());
sequencer.close();
}
@Override
public void open() throws MidiUnavailableException {
-Debug.println(Level.FINE, "★1 open: " + sequencer.hashCode());
+logger.log(Level.DEBUG, "★1 open: " + sequencer.hashCode());
sequencer.open();
}
@@ -262,7 +264,7 @@ public void setSequence(Sequence sequence) throws InvalidMidiDataException {
private void setVaviSequence() {
if (getSequence() instanceof VaviSequence) {
vaviSequence = (VaviSequence) getSequence();
-Debug.println(Level.FINE, "vaviSequence: " + vaviSequence);
+logger.log(Level.DEBUG, "vaviSequence: " + vaviSequence);
} else {
vaviSequence = null;
}
diff --git a/src/main/java/vavi/sound/midi/mfi/MfiMidiFileReader.java b/src/main/java/vavi/sound/midi/mfi/MfiMidiFileReader.java
index 20a9255..77c2aac 100644
--- a/src/main/java/vavi/sound/midi/mfi/MfiMidiFileReader.java
+++ b/src/main/java/vavi/sound/midi/mfi/MfiMidiFileReader.java
@@ -9,9 +9,9 @@
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
import java.util.Arrays;
-import java.util.logging.Level;
-
import javax.sound.midi.InvalidMidiDataException;
import javax.sound.midi.Sequence;
@@ -19,7 +19,8 @@
import vavi.sound.mfi.MfiSystem;
import vavi.sound.mfi.MfiUnavailableException;
import vavi.sound.midi.BasicMidiFileReader;
-import vavi.util.Debug;
+
+import static java.lang.System.getLogger;
/**
@@ -30,6 +31,8 @@
*/
public class MfiMidiFileReader extends BasicMidiFileReader {
+ private static final Logger logger = getLogger(MfiMidiFileReader.class.getName());
+
/** Gets a MIDI Sequence converted from MFi */
@Override
public Sequence getSequence(InputStream is)
@@ -57,14 +60,13 @@ public Sequence getSequence(InputStream is)
}
vavi.sound.mfi.Sequence mfiSequence = MfiSystem.getSequence(is);
-//Debug.println(mfiSequence);
+//logger.log(Level.DEBUG, mfiSequence);
return MfiSystem.toMidiSequence(mfiSequence);
} catch (InvalidMfiDataException e) {
-Debug.println(Level.FINE, e);
-//Debug.printStackTrace(e);
+logger.log(Level.ERROR, e.getMessage(), e);
throw (InvalidMidiDataException) new InvalidMidiDataException().initCause(e);
} catch (MfiUnavailableException e) {
-Debug.println(Level.SEVERE, e);
+logger.log(Level.ERROR, e.getMessage(), e);
throw new IOException(e);
} finally {
try {
@@ -72,7 +74,7 @@ public Sequence getSequence(InputStream is)
is.reset();
}
} catch (IOException e) {
-Debug.println(Level.SEVERE, e);
+logger.log(Level.ERROR, e.getMessage(), e);
}
}
}
diff --git a/src/main/java/vavi/sound/midi/mfi/MfiMidiFileWriter.java b/src/main/java/vavi/sound/midi/mfi/MfiMidiFileWriter.java
index 7125e5c..b9b92f2 100644
--- a/src/main/java/vavi/sound/midi/mfi/MfiMidiFileWriter.java
+++ b/src/main/java/vavi/sound/midi/mfi/MfiMidiFileWriter.java
@@ -8,16 +8,17 @@
import java.io.IOException;
import java.io.OutputStream;
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
import java.util.Arrays;
-import java.util.logging.Level;
-
import javax.sound.midi.InvalidMidiDataException;
import javax.sound.midi.Sequence;
import vavi.sound.mfi.MfiSystem;
import vavi.sound.mfi.MfiUnavailableException;
import vavi.sound.midi.BasicMidiFileWriter;
-import vavi.util.Debug;
+
+import static java.lang.System.getLogger;
/**
@@ -30,23 +31,25 @@
*/
public class MfiMidiFileWriter extends BasicMidiFileWriter {
+ private static final Logger logger = getLogger(MfiMidiFileWriter.class.getName());
+
@Override
public int[] getMidiFileTypes() {
-Debug.println(Level.FINE, "(1): " + Arrays.toString(MfiSystem.getMfiFileTypes()));
+logger.log(Level.DEBUG, "(1): " + Arrays.toString(MfiSystem.getMfiFileTypes()));
return MfiSystem.getMfiFileTypes();
}
/** @param sequence MIDI sequence */
@Override
public int[] getMidiFileTypes(Sequence sequence) {
-Debug.println(Level.FINE, "(2): " + Arrays.toString(MfiSystem.getMfiFileTypes()));
+logger.log(Level.DEBUG, "(2): " + Arrays.toString(MfiSystem.getMfiFileTypes()));
return MfiSystem.getMfiFileTypes();
}
/** @param fileType supports 0x88:MFi (vavi) */
@Override
public boolean isFileTypeSupported(int fileType) {
-Debug.println(Level.FINE, "(1): fileType: " + fileType);
+logger.log(Level.DEBUG, "(1): fileType: " + fileType);
return MfiSystem.isFileTypeSupported(fileType);
}
@@ -56,8 +59,8 @@ public boolean isFileTypeSupported(int fileType) {
*/
@Override
public boolean isFileTypeSupported(int fileType, Sequence sequence) {
-Debug.println(Level.FINE, "(2): fileType: " + fileType);
-//Debug.println(sequence);
+logger.log(Level.DEBUG, "(2): fileType: " + fileType);
+//logger.log(Level.DEBUG, sequence);
return MfiSystem.isFileTypeSupported(fileType);
}
@@ -69,15 +72,15 @@ public boolean isFileTypeSupported(int fileType, Sequence sequence) {
@Override
public int write(Sequence in, int fileType, OutputStream out)
throws IOException {
-Debug.println(Level.FINE, "in: " + in);
-Debug.println(Level.FINE, "fileType: " + fileType);
-Debug.println(Level.FINE, "out: " + out);
+logger.log(Level.DEBUG, "in: " + in);
+logger.log(Level.DEBUG, "fileType: " + fileType);
+logger.log(Level.DEBUG, "out: " + out);
try {
if (isFileTypeSupported(fileType)) {
vavi.sound.mfi.Sequence mfiSequence = MfiSystem.toMfiSequence(in, fileType);
return MfiSystem.write(mfiSequence, fileType, out);
} else {
-Debug.println(Level.WARNING, "unknown fileType: " + fileType);
+logger.log(Level.WARNING, "unknown fileType: " + fileType);
return 0;
}
} catch (InvalidMidiDataException | MfiUnavailableException e) {
diff --git a/src/main/java/vavi/sound/midi/smaf/SmafMidiFileReader.java b/src/main/java/vavi/sound/midi/smaf/SmafMidiFileReader.java
index 77f7383..78385a2 100644
--- a/src/main/java/vavi/sound/midi/smaf/SmafMidiFileReader.java
+++ b/src/main/java/vavi/sound/midi/smaf/SmafMidiFileReader.java
@@ -9,9 +9,9 @@
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
import java.util.Arrays;
-import java.util.logging.Level;
-
import javax.sound.midi.InvalidMidiDataException;
import javax.sound.midi.Sequence;
@@ -19,7 +19,8 @@
import vavi.sound.smaf.InvalidSmafDataException;
import vavi.sound.smaf.SmafSystem;
import vavi.sound.smaf.SmafUnavailableException;
-import vavi.util.Debug;
+
+import static java.lang.System.getLogger;
/**
@@ -30,6 +31,8 @@
*/
public class SmafMidiFileReader extends BasicMidiFileReader {
+ private static final Logger logger = getLogger(SmafMidiFileReader.class.getName());
+
@Override
public Sequence getSequence(InputStream is)
throws InvalidMidiDataException,
@@ -56,14 +59,14 @@ public Sequence getSequence(InputStream is)
}
vavi.sound.smaf.Sequence sequence = SmafSystem.getSequence(is);
-//Debug.println(sequence);
+//logger.log(Level.DEBUG, sequence);
return SmafSystem.toMidiSequence(sequence);
} catch (InvalidSmafDataException e) {
-Debug.println(Level.INFO, e);
-//Debug.printStackTrace(e);
+logger.log(Level.INFO, e);
+//logger.log(Level.ERROR, e.getMessage(), e);
throw (InvalidMidiDataException) new InvalidMidiDataException().initCause(e);
} catch (SmafUnavailableException e) {
-Debug.println(Level.SEVERE, e);
+logger.log(Level.ERROR, e.getMessage(), e);
throw new IOException(e);
} finally {
try {
@@ -71,7 +74,7 @@ public Sequence getSequence(InputStream is)
is.reset();
}
} catch (IOException e) {
-Debug.println(Level.SEVERE, e);
+logger.log(Level.ERROR, e.getMessage(), e);
}
}
}
diff --git a/src/main/java/vavi/sound/midi/smaf/SmafMidiFileWriter.java b/src/main/java/vavi/sound/midi/smaf/SmafMidiFileWriter.java
index 076e392..d5f0005 100644
--- a/src/main/java/vavi/sound/midi/smaf/SmafMidiFileWriter.java
+++ b/src/main/java/vavi/sound/midi/smaf/SmafMidiFileWriter.java
@@ -8,8 +8,8 @@
import java.io.IOException;
import java.io.OutputStream;
-import java.util.logging.Level;
-
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
import javax.sound.midi.InvalidMidiDataException;
import javax.sound.midi.Sequence;
@@ -17,7 +17,8 @@
import vavi.sound.smaf.SmafFileFormat;
import vavi.sound.smaf.SmafSystem;
import vavi.sound.smaf.SmafUnavailableException;
-import vavi.util.Debug;
+
+import static java.lang.System.getLogger;
/**
@@ -30,6 +31,8 @@
*/
public class SmafMidiFileWriter extends BasicMidiFileWriter {
+ private static final Logger logger = getLogger(SmafMidiFileWriter.class.getName());
+
@Override
public int[] getMidiFileTypes() {
return new int[] { SmafFileFormat.FILE_TYPE };
@@ -63,15 +66,15 @@ public boolean isFileTypeSupported(int fileType, Sequence sequence) {
@Override
public int write(Sequence in, int fileType, OutputStream out)
throws IOException {
-Debug.println(Level.FINE, "in: " + in);
-Debug.println(Level.FINE, "fileType: " + fileType);
-Debug.println(Level.FINE, "out: " + out);
+logger.log(Level.DEBUG, "in: " + in);
+logger.log(Level.DEBUG, "fileType: " + fileType);
+logger.log(Level.DEBUG, "out: " + out);
try {
if (isFileTypeSupported(fileType)) {
vavi.sound.smaf.Sequence smafSequence = SmafSystem.toSmafSequence(in, fileType);
return SmafSystem.write(smafSequence, fileType, out);
} else {
-Debug.println(Level.WARNING, "unknown fileType: " + fileType);
+logger.log(Level.WARNING, "unknown fileType: " + fileType);
return 0;
}
} catch (InvalidMidiDataException | SmafUnavailableException e) {
diff --git a/src/main/java/vavi/sound/mobile/BasicAudioEngine.java b/src/main/java/vavi/sound/mobile/BasicAudioEngine.java
index f1eb8af..a207567 100644
--- a/src/main/java/vavi/sound/mobile/BasicAudioEngine.java
+++ b/src/main/java/vavi/sound/mobile/BasicAudioEngine.java
@@ -11,18 +11,18 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
import java.nio.ByteOrder;
-import java.util.logging.Level;
-
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.DataLine;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.SourceDataLine;
-import vavi.util.Debug;
import vavi.util.StringUtil;
+import static java.lang.System.getLogger;
import static vavi.sound.SoundUtil.volume;
@@ -34,6 +34,8 @@
*/
public abstract class BasicAudioEngine implements AudioEngine {
+ private static final Logger logger = getLogger(BasicAudioEngine.class.getName());
+
/** */
protected Data[] data;
@@ -64,7 +66,7 @@ public void setData(int streamNumber,
}
datum.continued = continued;
this.data[streamNumber] = datum;
-// debug1();
+//debug1();
}
@Override
@@ -82,7 +84,7 @@ public void start(int streamNumber) {
int channels = getChannels(streamNumber);
if (channels == -1) {
-Debug.println(Level.INFO, "always used: no: " + streamNumber + ", ch: " + this.data[streamNumber].channel);
+logger.log(Level.INFO, "always used: no: " + streamNumber + ", ch: " + this.data[streamNumber].channel);
return;
}
@@ -94,15 +96,15 @@ public void start(int streamNumber) {
2 * channels,
this.data[streamNumber].sampleRate,
false);
-Debug.println(Level.FINE, audioFormat);
+logger.log(Level.DEBUG, audioFormat);
try {
-//Debug.println(data.length);
+//logger.log(Level.DEBUG, data.length);
InputStream[] iss = getInputStreams(streamNumber, channels);
-//Debug.println("is: " + is.available());
-// OutputStream os = debug2();
+//logger.log(Level.DEBUG, "is: " + is.available());
+//OutputStream os = debug2();
DataLine.Info info = new DataLine.Info(SourceDataLine.class, audioFormat);
SourceDataLine line = (SourceDataLine) AudioSystem.getLine(info);
@@ -113,13 +115,13 @@ public void start(int streamNumber) {
while (iss[0].available() > 0) {
if (channels == 1) {
int l = iss[0].read(buf, 0, 1024);
-Debug.println(Level.FINEST, "data:\n" + StringUtil.getDump(buf, 64));
+logger.log(Level.TRACE, "data:\n" + StringUtil.getDump(buf, 64));
line.write(buf, 0, l);
-// debug3(os);
+//debug3(os);
} else {
int lL = iss[0].read(buf, 0, 512);
int lR = iss[1].read(buf, 512, 512);
-//System.err.println("l : " + lL + ", r: " + lR);
+//logger.log(Level.DEBUG, "l : " + lL + ", r: " + lR);
for (int i = 0; i < lL / 2; i++) {
byte[] temp = new byte[4];
temp[0] = buf[i * 2];
@@ -133,7 +135,7 @@ public void start(int streamNumber) {
line.drain();
line.stop();
line.close();
-// debug4(os);
+//debug4(os);
} catch (IOException | LineUnavailableException e) {
throw new IllegalStateException(e);
}
@@ -152,11 +154,11 @@ public byte[] encode(int bits, int channels, byte[] pcm) {
InputStream is = new ByteArrayInputStream(pcm);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = getOutputStream(baos);
-Debug.println(Level.FINE, "pcm length: " + is.available());
+logger.log(Level.DEBUG, "pcm length: " + is.available());
while (is.available() > 0) {
int c = is.read();
if (c == -1) {
-Debug.println(Level.FINE, "read returns -1");
+logger.log(Level.DEBUG, "read returns -1");
break;
}
os.write(c);
@@ -170,11 +172,11 @@ public byte[] encode(int bits, int channels, byte[] pcm) {
InputStream is = new ByteArrayInputStream(monos[0]);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = getOutputStream(baos);
-Debug.println(Level.FINE, "pcm L length: " + is.available());
+logger.log(Level.DEBUG, "pcm L length: " + is.available());
while (is.available() > 0) {
int c = is.read();
if (c == -1) {
-Debug.println(Level.FINE, "Illegal EOF L: " + is.available());
+logger.log(Level.DEBUG, "Illegal EOF L: " + is.available());
break;
}
os.write(c);
@@ -184,11 +186,11 @@ public byte[] encode(int bits, int channels, byte[] pcm) {
is = new ByteArrayInputStream(monos[1]);
baos = new ByteArrayOutputStream();
os = getOutputStream(baos);
-Debug.println(Level.FINE, "pcm R length: " + is.available());
+logger.log(Level.DEBUG, "pcm R length: " + is.available());
while (is.available() > 0) {
int c = is.read();
if (c == -1) {
-Debug.println(Level.FINE, "Illegal EOF R: " + is.available());
+logger.log(Level.DEBUG, "Illegal EOF R: " + is.available());
break;
}
os.write(c);
diff --git a/src/main/java/vavi/sound/mobile/FuetrekAudioEngine.java b/src/main/java/vavi/sound/mobile/FuetrekAudioEngine.java
index 1d64f62..a41aaa3 100644
--- a/src/main/java/vavi/sound/mobile/FuetrekAudioEngine.java
+++ b/src/main/java/vavi/sound/mobile/FuetrekAudioEngine.java
@@ -9,13 +9,15 @@
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.OutputStream;
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
import java.nio.ByteOrder;
-import java.util.logging.Level;
import vavi.sound.adpcm.ccitt.G721InputStream;
import vavi.sound.adpcm.ccitt.G721OutputStream;
import vavi.sound.adpcm.ccitt.G723_16InputStream;
-import vavi.util.Debug;
+
+import static java.lang.System.getLogger;
/**
@@ -26,6 +28,8 @@
*/
public class FuetrekAudioEngine extends BasicAudioEngine {
+ private static final Logger logger = getLogger(FuetrekAudioEngine.class.getName());
+
/** */
private static final int MAX_ID = 16;
@@ -49,7 +53,7 @@ protected int getChannels(int streamNumber) {
if (data[streamNumber].channel != -1) {
// from MachineDependent
if (streamNumber % 2 == 1 && data[streamNumber].channel % 2 == 1 && (data[streamNumber - 1] != null && data[streamNumber - 1].channel % 2 == 0)) {
-Debug.println(Level.FINE, "always used: no: " + streamNumber + ", ch: " + data[streamNumber].channel);
+logger.log(Level.DEBUG, "always used: no: " + streamNumber + ", ch: " + data[streamNumber].channel);
return -1;
}
diff --git a/src/main/java/vavi/sound/mobile/PcmAudioEngine.java b/src/main/java/vavi/sound/mobile/PcmAudioEngine.java
index 550f102..72f553d 100644
--- a/src/main/java/vavi/sound/mobile/PcmAudioEngine.java
+++ b/src/main/java/vavi/sound/mobile/PcmAudioEngine.java
@@ -10,15 +10,15 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.DataLine;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.SourceDataLine;
-import vavi.util.Debug;
-
+import static java.lang.System.getLogger;
import static vavi.sound.SoundUtil.volume;
@@ -44,6 +44,8 @@
*/
public class PcmAudioEngine extends BasicAudioEngine {
+ private static final Logger logger = getLogger(PcmAudioEngine.class.getName());
+
/**
*
* L0 + L2 + ...
@@ -63,7 +65,7 @@ protected int getChannels(int streamNumber) {
channels = 2;
} else {
if (streamNumber % 2 == 1 && data[streamNumber].channels != 2 && (data[streamNumber - 1] != null && data[streamNumber - 1].channels != 2)) {
-Debug.println("always used: no: " + streamNumber + ", ch: " + data[streamNumber].channel);
+logger.log(Level.DEBUG, "always used: no: " + streamNumber + ", ch: " + data[streamNumber].channel);
return -1;
}
@@ -75,7 +77,7 @@ protected int getChannels(int streamNumber) {
// from 240_2, channels always 1
if (streamNumber % 2 == 1 && data[streamNumber].channel % 2 == 1 && (data[streamNumber - 1] != null && data[streamNumber - 1].channel % 2 == 0)) {
-Debug.println("always used: no: " + streamNumber + ", ch: " + data[streamNumber].channel);
+logger.log(Level.DEBUG, "always used: no: " + streamNumber + ", ch: " + data[streamNumber].channel);
return -1;
}
@@ -117,7 +119,7 @@ public void start(int streamNumber) {
int channels = getChannels(streamNumber);
if (channels == -1) {
-Debug.println("always used: no: " + streamNumber + ", ch: " + this.data[streamNumber].channel);
+logger.log(Level.DEBUG, "always used: no: " + streamNumber + ", ch: " + this.data[streamNumber].channel);
return;
}
@@ -129,14 +131,14 @@ public void start(int streamNumber) {
1 * channels,
this.data[streamNumber].sampleRate,
false);
-Debug.println(audioFormat);
+logger.log(Level.DEBUG, audioFormat);
try {
-//Debug.println(data.length);
+//logger.log(Level.DEBUG, data.length);
InputStream[] iss = getInputStreams(streamNumber, channels);
-//Debug.println("is: " + is.available());
+//logger.log(Level.DEBUG, "is: " + is.available());
// OutputStream os = debug2();
DataLine.Info info = new DataLine.Info(SourceDataLine.class, audioFormat);
@@ -154,7 +156,7 @@ public void start(int streamNumber) {
} else {
int lL = iss[0].read(buf, 0, 512);
/*int lR = */iss[1].read(buf, 512, 512);
-//System.err.println("l : " + lL + ", r: " + lR);
+//logger.log(Level.DEBUG, "l : " + lL + ", r: " + lR);
for (int i = 0; i < lL / 2; i++) {
byte[] temp = new byte[4];
temp[0] = buf[i * 2];
diff --git a/src/main/java/vavi/sound/mobile/YamahaAudioEngine.java b/src/main/java/vavi/sound/mobile/YamahaAudioEngine.java
index 33b3cab..1ce01f8 100644
--- a/src/main/java/vavi/sound/mobile/YamahaAudioEngine.java
+++ b/src/main/java/vavi/sound/mobile/YamahaAudioEngine.java
@@ -9,11 +9,14 @@
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.OutputStream;
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
import java.nio.ByteOrder;
import vavi.sound.adpcm.ma.MaInputStream;
import vavi.sound.adpcm.ma.MaOutputStream;
-import vavi.util.Debug;
+
+import static java.lang.System.getLogger;
/**
@@ -24,6 +27,8 @@
*/
public class YamahaAudioEngine extends BasicAudioEngine {
+ private static final Logger logger = getLogger(YamahaAudioEngine.class.getName());
+
/**
*
* L0 + L2 + ...
@@ -43,7 +48,7 @@ protected int getChannels(int streamNumber) {
channels = 2;
} else {
if (streamNumber % 2 == 1 && data[streamNumber].channels != 2 && (data[streamNumber - 1] != null && data[streamNumber - 1].channels != 2)) {
-Debug.println("always used: no: " + streamNumber + ", ch: " + data[streamNumber].channel);
+logger.log(Level.DEBUG, "always used: no: " + streamNumber + ", ch: " + data[streamNumber].channel);
return -1;
}
@@ -55,7 +60,7 @@ protected int getChannels(int streamNumber) {
// from 240_2, channels always 1
if (streamNumber % 2 == 1 && data[streamNumber].channel % 2 == 1 && (data[streamNumber - 1] != null && data[streamNumber - 1].channel % 2 == 0)) {
-Debug.println("always used: no: " + streamNumber + ", ch: " + data[streamNumber].channel);
+logger.log(Level.DEBUG, "always used: no: " + streamNumber + ", ch: " + data[streamNumber].channel);
return -1;
}
diff --git a/src/main/java/vavi/sound/pcm/resampling/ssrc/SSRC.java b/src/main/java/vavi/sound/pcm/resampling/ssrc/SSRC.java
index c8a6a1f..ef560b8 100644
--- a/src/main/java/vavi/sound/pcm/resampling/ssrc/SSRC.java
+++ b/src/main/java/vavi/sound/pcm/resampling/ssrc/SSRC.java
@@ -12,6 +12,8 @@
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.RandomAccessFile;
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.channels.FileChannel;
@@ -19,10 +21,10 @@
import java.nio.channels.WritableByteChannel;
import java.util.Map;
import java.util.Random;
-import java.util.logging.Logger;
import vavi.util.I0Bessel;
+import static java.lang.System.getLogger;
import static vavi.util.SplitRadixFft.rdft;
@@ -38,7 +40,7 @@
public class SSRC {
/** */
- private static final Logger logger = Logger.getLogger(SSRC.class.getName());
+ private static final Logger logger = getLogger(SSRC.class.getName());
/** */
private static final ByteOrder byteOrder = ByteOrder.LITTLE_ENDIAN;
@@ -170,7 +172,7 @@ private int initShaper(int freq, int nch, int min, int max, int dType, int pdf,
}
}
if ((dType == 3 || dType == 4) && i == 6) {
- logger.warning(String.format("ATH based noise shaping for destination frequency %dHz is not available, using triangular dither\n", freq));
+ logger.log(Level.WARNING, String.format("ATH based noise shaping for destination frequency %dHz is not available, using triangular dither", freq));
}
if (dType == 2 || i == 6) {
i = 0;
@@ -336,7 +338,7 @@ private void quitShaper(int nch) {
}
/** */
- private Shaper shaper = new Shaper();
+ private final Shaper shaper = new Shaper();
/** */
private static double alpha(double a) {
@@ -548,7 +550,7 @@ int resample(ReadableByteChannel fpi, WritableByteChannel fpo) throws IOExceptio
alp = alpha(aa);
iza = I0Bessel.value(alp);
-//System.err.printf("iza = %g\n",iza);
+//logger.log(Level.DEBUG, String.format("iza = %g",iza));
n1y = fs1 / sfrq;
n1x = n1 / n1y + 1;
@@ -828,7 +830,7 @@ int resample(ReadableByteChannel fpi, WritableByteChannel fpo) throws IOExceptio
buf2[ch][p] = 0;
}
-//for (i = 0; i < n2b2; i++) { System.err.printf("%d:%g",i,buf2[ch][i]); }
+//for (i = 0; i < n2b2; i++) { logger.log(Level.DEBUG, String.format("%d:%g",i,buf2[ch][i])); }
rdft(n2b, 1, buf2[ch], fft_ip, fft_w);
@@ -841,7 +843,7 @@ int resample(ReadableByteChannel fpi, WritableByteChannel fpo) throws IOExceptio
re = stage2[i * 2] * buf2[ch][i * 2] - stage2[i * 2 + 1] * buf2[ch][i * 2 + 1];
im = stage2[i * 2 + 1] * buf2[ch][i * 2] + stage2[i * 2] * buf2[ch][i * 2 + 1];
-//System.err.printf("%d : %g %g %g %g %g %g\n", i, stage2[i * 2],stage2[i * 2 + 1],buf2[ch][i * 2],buf2[ch][i * 2 + 1], re, im);
+//logger.log(Level.DEBUG, String.format("%d : %g %g %g %g %g %g", i, stage2[i * 2],stage2[i * 2 + 1],buf2[ch][i * 2],buf2[ch][i * 2 + 1], re, im));
buf2[ch][i * 2] = re;
buf2[ch][i * 2 + 1] = im;
@@ -1127,7 +1129,7 @@ int resample(ReadableByteChannel fpi, WritableByteChannel fpo) throws IOExceptio
alp = alpha(aa);
iza = I0Bessel.value(alp);
-//System.err.printf("iza %f, alp: %f\n", iza, alp); // OK
+//logger.log(Level.DEBUG, String.format("iza %f, alp: %f", iza, alp)); // OK
for (n1b = 1; n1b < n1; n1b *= 2) {
}
@@ -1137,7 +1139,7 @@ int resample(ReadableByteChannel fpi, WritableByteChannel fpo) throws IOExceptio
for (i = -(n1 / 2); i <= n1 / 2; i++) {
stage1[i + n1 / 2] = win(i, n1, alp, iza) * hn_lpf(i, lpf, fs1) * fs1 / sfrq / n1b * 2;
-//System.err.printf("1: %06d: %e\n", i + n1 / 2, stage1[i + n1 / 2]); // OK
+//logger.log(Level.DEBUG, String.format("1: %06d: %e", i + n1 / 2, stage1[i + n1 / 2])); // OK
}
ipsize = (int) (2 + Math.sqrt(n1b));
@@ -1148,13 +1150,13 @@ int resample(ReadableByteChannel fpi, WritableByteChannel fpo) throws IOExceptio
rdft(n1b, 1, stage1, fft_ip, fft_w);
//for (i = -(n1 / 2); i <= n1 / 2; i++) {
-// System.err.printf("1': %06d: %e\n", i + n1 / 2, stage1[i + n1 / 2]);
+// logger.log(Level.DEBUG, String.format("1': %06d: %e", i + n1 / 2, stage1[i + n1 / 2]));
//}
//for (i = 0; i < ipsize; i++) {
-// System.err.printf("ip: %06d: %d\n", i, fft_ip[i]); // OK
+// logger.log(Level.DEBUG, String.format("ip: %06d: %d", i, fft_ip[i])); // OK
//}
//for (i = 0; i < wsize; i++) {
-// System.err.printf("w: %06d: %e\n", i, fft_w[i]); // OK
+// logger.log(Level.DEBUG, String.format("w: %06d: %e", i, fft_w[i])); // OK
//}
}
@@ -1195,7 +1197,7 @@ int resample(ReadableByteChannel fpi, WritableByteChannel fpo) throws IOExceptio
alp = alpha(aa);
iza = I0Bessel.value(alp);
-//System.err.printf("iza %f, alp: %f\n", iza, alp); // OK
+//logger.log(Level.DEBUG, String.format("iza %f, alp: %f", iza, alp)); // OK
n2y = fs2 / fs1; // how many samples are there in fs2 that is not 0?
n2x = n2 / n2y + 1;
@@ -1218,10 +1220,10 @@ int resample(ReadableByteChannel fpi, WritableByteChannel fpo) throws IOExceptio
stage2 = new double[n2y][n2x];
-//System.err.printf("n2y: %d, n2: %d\n", n2y, n2);
+//logger.log(Level.DEBUG, String.format("n2y: %d, n2: %d", n2y, n2));
for (i = -(n2 / 2); i <= n2 / 2; i++) {
stage2[(i + n2 / 2) % n2y][(i + n2 / 2) / n2y] = win(i, n2, alp, iza) * hn_lpf(i, lpf, fs2) * fs2 / fs1;
-//System.err.printf(" stage2[%02d][%02d]: %f\n", (i + n2 / 2) % n2y, (i + n2 / 2) / n2y, win(i, n2, alp, iza) * hn_lpf(i, lpf, fs2) * fs2 / fs1); // OK
+//logger.log(Level.DEBUG, String.format(" stage2[%02d][%02d]: %f", (i + n2 / 2) % n2y, (i + n2 / 2) / n2y, win(i, n2, alp, iza) * hn_lpf(i, lpf, fs2) * fs2 / fs1)); // OK
}
}
@@ -1266,7 +1268,7 @@ int resample(ReadableByteChannel fpi, WritableByteChannel fpo) throws IOExceptio
buf2 = new double[nch][n2x + 1 + n1b2];
rawinbuf = ByteBuffer.allocate((nch * (n1b2 / osf + osf + 1)) * bps);
-//System.err.println((double) n1b2 * sfrq / dfrq + 1);
+//logger.log(Level.DEBUG, (double) n1b2 * sfrq / dfrq + 1);
rawoutbuf = ByteBuffer.allocate((int) (((double) n1b2 * sfrq / dfrq + 1) * (dbps * nch)));
inbuf = new double[nch * (n1b2 / osf + osf + 1)];
outbuf = new double[(int) (nch * ((double) n1b2 * sfrq / dfrq + 1))];
@@ -1312,7 +1314,7 @@ int resample(ReadableByteChannel fpi, WritableByteChannel fpo) throws IOExceptio
for (i = 0; i < nsmplread * nch; i++) {
int v = rawinbuf.order(byteOrder).asShortBuffer().get(i);
inbuf[nch * inbuflen + i] = (1 / (double) 0x7fff) * v;
-//System.err.printf("I: %f\n", inbuf[nch * inbuflen + i]);
+//logger.log(Level.DEBUG, String.format("I: %f", inbuf[nch * inbuflen + i]));
}
break;
@@ -1418,13 +1420,13 @@ int resample(ReadableByteChannel fpi, WritableByteChannel fpo) throws IOExceptio
assert ((bp2 - (buf2[0].length * ch)) * (fs2 / fs1) - (rp2 + p * (fs2 / dfrq)) == s2o); // &(buf2[ch][0])
for (i = 0; i < n2x; i++) {
-//System.err.printf("%d (%d, %d)\n", i, bp2 / buf2[0].length, bp2 % buf2[0].length);
+//logger.log(Level.DEBUG, String.format("%d (%d, %d)", i, bp2 / buf2[0].length, bp2 % buf2[0].length));
tmp += stage2[s2o][i] * buf2[bp2 / buf2[0].length][bp2 % buf2[0].length]; // *bp2++
bp2++;
}
outbuf[op + p * nch + ch] = tmp;
-//System.err.printf("O: %06d: %f\n", op + p * nch + ch, tmp);
+//logger.log(Level.DEBUG, String.format("O: %06d: %f", op + p * nch + ch, tmp));
}
nsmplwrt2 = p;
@@ -1437,12 +1439,12 @@ int resample(ReadableByteChannel fpi, WritableByteChannel fpo) throws IOExceptio
for (i = 0; i < nsmplwrt2 * nch; i++) {
double f = outbuf[i] > 0 ? outbuf[i] : -outbuf[i];
peak[0] = Math.max(peak[0], f);
-//System.err.println("p: " + rawoutbuf.position() + ", l: " + rawoutbuf.limit());
+//logger.log(Level.DEBUG, "p: " + rawoutbuf.position() + ", l: " + rawoutbuf.limit());
rawoutbuf.asDoubleBuffer().put(i, outbuf[i]);
//if (i < 100) {
-// System.err.printf("1: %06d: %f\n", i, outbuf[i]);
+// logger.log(Level.DEBUG, String.format("1: %06d: %f", i, outbuf[i]));
//}
-//System.err.print(StringUtil.getDump(rawoutbuf, i, 8));
+//logger.log(Level.DEBUG, "\n" + StringUtil.getDump(rawoutbuf, i, 8));
}
} else {
switch (dbps) {
@@ -1806,93 +1808,86 @@ public void exec(String[] argv) throws IOException {
break;
}
- if (argv[i].equals("--rate")) {
- dfrq = Integer.parseInt(argv[++i]);
-//System.err.printf("dfrq: %d\n", dfrq);
- continue;
- }
-
- if (argv[i].equals("--att")) {
- att = Float.parseFloat(argv[++i]);
- continue;
- }
-
- if (argv[i].equals("--bits")) {
- dbps = Integer.parseInt(argv[++i]);
- if (dbps != 8 && dbps != 16 && dbps != 24) {
- throw new IllegalArgumentException("Error: Only 8bit, 16bit and 24bit PCM are supported.");
+ switch (argv[i]) {
+ case "--rate" -> {
+ dfrq = Integer.parseInt(argv[++i]);
+//logger.log(Level.DEBUG, String.format("dfrq: %d", dfrq));
+ continue;
}
- dbps /= 8;
- continue;
- }
-
- if (argv[i].equals("--twopass")) {
- twopass = true;
- continue;
- }
-
- if (argv[i].equals("--normalize")) {
- twopass = true;
- normalize = true;
- continue;
- }
-
- if (argv[i].equals("--dither")) {
- try {
- dither = Integer.parseInt(argv[i + 1]);
- if (dither < 0 || dither > 4) {
- throw new IllegalArgumentException("unrecognized dither type : " + argv[i + 1]);
+ case "--att" -> {
+ att = Float.parseFloat(argv[++i]);
+ continue;
+ }
+ case "--bits" -> {
+ dbps = Integer.parseInt(argv[++i]);
+ if (dbps != 8 && dbps != 16 && dbps != 24) {
+ throw new IllegalArgumentException("Error: Only 8bit, 16bit and 24bit PCM are supported.");
}
- i++;
- } catch (NumberFormatException e) {
- dither = -1;
+ dbps /= 8;
+ continue;
+ }
+ case "--twopass" -> {
+ twopass = true;
+ continue;
+ }
+ case "--normalize" -> {
+ twopass = true;
+ normalize = true;
+ continue;
+ }
+ case "--dither" -> {
+ try {
+ dither = Integer.parseInt(argv[i + 1]);
+ if (dither < 0 || dither > 4) {
+ throw new IllegalArgumentException("unrecognized dither type : " + argv[i + 1]);
+ }
+ i++;
+ } catch (NumberFormatException e) {
+ dither = -1;
+ }
+ continue;
}
- continue;
- }
-
- if (argv[i].equals("--pdf")) {
- try {
- pdf = Integer.parseInt(argv[i + 1]);
- if (pdf < 0 || pdf > 2) {
+ case "--pdf" -> {
+ try {
+ pdf = Integer.parseInt(argv[i + 1]);
+ if (pdf < 0 || pdf > 2) {
+ throw new IllegalArgumentException("unrecognized p.d.f. type : " + argv[i + 1]);
+ }
+ i++;
+ } catch (NumberFormatException e) {
throw new IllegalArgumentException("unrecognized p.d.f. type : " + argv[i + 1]);
}
- i++;
- } catch (NumberFormatException e) {
- throw new IllegalArgumentException("unrecognized p.d.f. type : " + argv[i + 1]);
- }
-
- try {
- noiseamp = Double.parseDouble(argv[i + 1]);
- i++;
- } catch (NumberFormatException e) {
- noiseamp = presets[pdf];
- }
-
- continue;
- }
-
- if (argv[i].equals("--quiet")) {
- quiet = true;
- continue;
- }
- if (argv[i].equals("--tmpfile")) {
- tmpfn = argv[++i];
- continue;
- }
+ try {
+ noiseamp = Double.parseDouble(argv[i + 1]);
+ i++;
+ } catch (NumberFormatException e) {
+ noiseamp = presets[pdf];
+ }
- if (argv[i].equals("--profile")) {
- if (argv[i + 1].equals("fast")) {
- AA = 96;
- DF = 8000;
- FFTFIRLEN = 1024;
- } else if (argv[i + 1].equals("standard")) {
- /* nothing to do */
- } else {
- throw new IllegalArgumentException("unrecognized profile : " + argv[i + 1]);
+ continue;
+ }
+ case "--quiet" -> {
+ quiet = true;
+ continue;
+ }
+ case "--tmpfile" -> {
+ tmpfn = argv[++i];
+ continue;
+ }
+ case "--profile" -> {
+ if (argv[i + 1].equals("fast")) {
+ AA = 96;
+ DF = 8000;
+ FFTFIRLEN = 1024;
+ } else if (argv[i + 1].equals("standard")) {
+ /* nothing to do */
+ } else {
+ throw new IllegalArgumentException("unrecognized profile : " + argv[i + 1]);
+ }
+ i++;
+ continue;
}
- i++;
- continue;
}
throw new IllegalArgumentException("unrecognized option : " + argv[i]);
@@ -1926,7 +1921,7 @@ public void exec(String[] argv) throws IOException {
bb.limit(36);
fpi.read(bb);
bb.flip();
-System.err.println("p: " + bb.position() + ", l: " + bb.limit());
+logger.log(Level.DEBUG, "p: " + bb.position() + ", l: " + bb.limit());
if (bb.get() != 'R') error(1);
if (bb.get() != 'I') error(1);
if (bb.get() != 'F') error(1);
@@ -2118,7 +2113,7 @@ public void exec(String[] argv) throws IOException {
try (FileOutputStream tfos= new FileOutputStream(ft)) {
fpto = tfos.getChannel();
-//System.err.printf("nch: %d, bps: %d, size: %d, sfrq: %d, dfrq: %d, ???: %d, ???: %d, twopass: %b, dither: %d\n", nch, bps, 8, sfrq, dfrq, 1, length / bps / nch, twopass, dither);
+//logger.log(Level.DEBUG, String.format("nch: %d, bps: %d, size: %d, sfrq: %d, dfrq: %d, ???: %d, ???: %d, twopass: %b, dither: %d", nch, bps, 8, sfrq, dfrq, 1, length / bps / nch, twopass, dither));
Resampler resampler;
if (sfrq < dfrq) {
resampler = new Upsampler();
@@ -2157,36 +2152,29 @@ public void exec(String[] argv) throws IOException {
}
if (dither != 0) {
- switch (dbps) {
- case 1:
- gain = (normalize || peak[0] >= (0x7f - samp) / (double) 0x7f) ? 1 / peak[0] * (0x7f - samp) : 1 / peak[0] * 0x7f;
- break;
- case 2:
- gain = (normalize || peak[0] >= (0x7fff - samp) / (double) 0x7fff) ? 1 / peak[0] * (0x7fff - samp) : 1 / peak[0] * 0x7fff;
- break;
- case 3:
- gain = (normalize || peak[0] >= (0x7fffff - samp) / (double) 0x7fffff) ? 1 / peak[0] * (0x7fffff - samp) : 1 / peak[0] * 0x7fffff;
- break;
- }
+ gain = switch (dbps) {
+ case 1 ->
+ (normalize || peak[0] >= (0x7f - samp) / (double) 0x7f) ? 1 / peak[0] * (0x7f - samp) : 1 / peak[0] * 0x7f;
+ case 2 ->
+ (normalize || peak[0] >= (0x7fff - samp) / (double) 0x7fff) ? 1 / peak[0] * (0x7fff - samp) : 1 / peak[0] * 0x7fff;
+ case 3 ->
+ (normalize || peak[0] >= (0x7fffff - samp) / (double) 0x7fffff) ? 1 / peak[0] * (0x7fffff - samp) : 1 / peak[0] * 0x7fffff;
+ default -> gain;
+ };
} else {
- switch (dbps) {
- case 1:
- gain = 1 / peak[0] * 0x7f;
- break;
- case 2:
- gain = 1 / peak[0] * 0x7fff;
- break;
- case 3:
- gain = 1 / peak[0] * 0x7fffff;
- break;
- }
+ gain = switch (dbps) {
+ case 1 -> 1 / peak[0] * 0x7f;
+ case 2 -> 1 / peak[0] * 0x7fff;
+ case 3 -> 1 / peak[0] * 0x7fffff;
+ default -> gain;
+ };
}
shaper.randPtr = 0;
setStartTime();
fptlen = (int) (ft.length() / 8);
-//System.err.println("tmp: " + fpt.getFilePointer());
+//logger.log(Level.DEBUG, "tmp: " + fpt.getFilePointer());
try (FileInputStream fisf = new FileInputStream(ft)) {
FileChannel fpti = fisf.getChannel();
@@ -2200,7 +2188,7 @@ public void exec(String[] argv) throws IOException {
bb.flip();
f = bb.getDouble();
//if (sumread < 100) {
-// System.err.printf("2: %06d: %f\n", sumread, f);
+// logger.log(Level.DEBUG, String.format("2: %06d: %f", sumread, f));
//}
f *= gain;
sumread++;
@@ -2257,7 +2245,7 @@ public void exec(String[] argv) throws IOException {
}
fpti.close();
}
- //System.err.println("ft: " + ft);
+ //logger.log(Level.DEBUG, "ft: " + ft);
if (!ft.delete()) {
System.err.printf("Failed to remove %s\n", ft);
}
@@ -2358,7 +2346,7 @@ void io(ReadableByteChannel fpi, WritableByteChannel fpo, int length, int nch, i
break;
}
-logger.fine(String.format("nch: %d, sfrq: %d, bps: %d, sfrq: %d, bps: %d\n", nch, sfrq, bps, dfrq, dbps));
+logger.log(Level.DEBUG, String.format("nch: %d, sfrq: %d, bps: %d, sfrq: %d, bps: %d", nch, sfrq, bps, dfrq, dbps));
if (bps != 1 && bps != 2 && bps != 3 && bps != 4) {
throw new IllegalArgumentException("Only 8bit, 16bit, 24bit and 32bit PCM are supported.");
@@ -2432,7 +2420,7 @@ void io(ReadableByteChannel fpi, WritableByteChannel fpo, int length, int nch, i
System.err.print("Pass 1\n");
}
-logger.fine(String.format("nch: %d, bps: %d, size: %d, sfrq: %d, dfrq: %d, ???: %d, ???: %d, twopass: %b, dither: %d\n", nch, bps, 8, sfrq, dfrq, 1, length / bps / nch, twopass, dither));
+logger.log(Level.DEBUG, String.format("nch: %d, bps: %d, size: %d, sfrq: %d, dfrq: %d, ???: %d, ???: %d, twopass: %b, dither: %d", nch, bps, 8, sfrq, dfrq, 1, length / bps / nch, twopass, dither));
Resampler resampler;
if (sfrq < dfrq) {
resampler = new Upsampler();
@@ -2470,29 +2458,22 @@ void io(ReadableByteChannel fpi, WritableByteChannel fpo, int length, int nch, i
}
if (dither != 0) {
- switch (dbps) {
- case 1:
- gain = (normalize || peak[0] >= (0x7f - samp) / (double) 0x7f) ? 1 / peak[0] * (0x7f - samp) : 1 / peak[0] * 0x7f;
- break;
- case 2:
- gain = (normalize || peak[0] >= (0x7fff - samp) / (double) 0x7fff) ? 1 / peak[0] * (0x7fff - samp) : 1 / peak[0] * 0x7fff;
- break;
- case 3:
- gain = (normalize || peak[0] >= (0x7fffff - samp) / (double) 0x7fffff) ? 1 / peak[0] * (0x7fffff - samp) : 1 / peak[0] * 0x7fffff;
- break;
- }
+ gain = switch (dbps) {
+ case 1 ->
+ (normalize || peak[0] >= (0x7f - samp) / (double) 0x7f) ? 1 / peak[0] * (0x7f - samp) : 1 / peak[0] * 0x7f;
+ case 2 ->
+ (normalize || peak[0] >= (0x7fff - samp) / (double) 0x7fff) ? 1 / peak[0] * (0x7fff - samp) : 1 / peak[0] * 0x7fff;
+ case 3 ->
+ (normalize || peak[0] >= (0x7fffff - samp) / (double) 0x7fffff) ? 1 / peak[0] * (0x7fffff - samp) : 1 / peak[0] * 0x7fffff;
+ default -> gain;
+ };
} else {
- switch (dbps) {
- case 1:
- gain = 1 / peak[0] * 0x7f;
- break;
- case 2:
- gain = 1 / peak[0] * 0x7fff;
- break;
- case 3:
- gain = 1 / peak[0] * 0x7fffff;
- break;
- }
+ gain = switch (dbps) {
+ case 1 -> 1 / peak[0] * 0x7f;
+ case 2 -> 1 / peak[0] * 0x7fff;
+ case 3 -> 1 / peak[0] * 0x7fffff;
+ default -> gain;
+ };
}
shaper.randPtr = 0;
@@ -2510,7 +2491,7 @@ void io(ReadableByteChannel fpi, WritableByteChannel fpo, int length, int nch, i
bb.flip();
f = bb.getDouble();
//if (sumread < 100) {
-// System.err.printf("2: %06d: %f\n", sumread, f);
+// logger.log(Level.DEBUG, String.format("2: %06d: %f", sumread, f));
//}
f *= gain;
sumread++;
diff --git a/src/main/java/vavi/sound/pcm/resampling/ssrc/SSRCInputStream.java b/src/main/java/vavi/sound/pcm/resampling/ssrc/SSRCInputStream.java
index 81ca167..50bdf24 100644
--- a/src/main/java/vavi/sound/pcm/resampling/ssrc/SSRCInputStream.java
+++ b/src/main/java/vavi/sound/pcm/resampling/ssrc/SSRCInputStream.java
@@ -9,6 +9,8 @@
import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
import java.nio.channels.Channels;
import java.nio.channels.Pipe;
import java.util.Map;
@@ -16,6 +18,8 @@
import java.util.concurrent.Executors;
import javax.sound.sampled.AudioFormat;
+import static java.lang.System.getLogger;
+
/**
* SSRC InputStream
@@ -32,6 +36,8 @@
*/
public class SSRCInputStream extends FilterInputStream {
+ private static final Logger logger = getLogger(SSRCInputStream.class.getName());
+
/** use in properties */
public SSRCInputStream(AudioFormat in, AudioFormat out, InputStream is) throws IOException {
@@ -44,7 +50,7 @@ public SSRCInputStream(AudioFormat in, AudioFormat out, InputStream is) throws I
in.properties()));
}
- private static ExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
+ private static final ExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
/**
* @param in source stream
@@ -65,7 +71,7 @@ private static InputStream init(InputStream in, int ch, int iFrq, int iBps, int
ssrc.io(Channels.newChannel(in), pipe.sink(), in.available(), ch, iFrq, iBps, oFrq, oBps, props);
pipe.sink().close();
} catch (IOException e) {
- e.printStackTrace();
+ logger.log(Level.ERROR, e.getMessage(), e);
}
});
return Channels.newInputStream(pipe.source());
diff --git a/src/main/java/vavi/sound/sampled/MonauralInputFilter.java b/src/main/java/vavi/sound/sampled/MonauralInputFilter.java
index d7ece05..1c7ac01 100644
--- a/src/main/java/vavi/sound/sampled/MonauralInputFilter.java
+++ b/src/main/java/vavi/sound/sampled/MonauralInputFilter.java
@@ -7,14 +7,14 @@
package vavi.sound.sampled;
import java.io.IOException;
-import java.util.logging.Level;
-
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.UnsupportedAudioFileException;
-import vavi.util.Debug;
+import static java.lang.System.getLogger;
/**
@@ -27,6 +27,8 @@
*/
public class MonauralInputFilter implements InputFilter {
+ private static final Logger logger = getLogger(MonauralInputFilter.class.getName());
+
@Override
public AudioInputStream doFilter(AudioInputStream sourceAis) throws IOException, UnsupportedAudioFileException {
AudioFormat inAudioFormat = sourceAis.getFormat();
@@ -42,8 +44,8 @@ public AudioInputStream doFilter(AudioInputStream sourceAis) throws IOException,
inAudioFormat.getFrameSize(),
inAudioFormat.getFrameRate(),
inAudioFormat.isBigEndian());
-Debug.println(Level.FINE, "OUT: " + outAudioFormat);
-Debug.println(Level.FINE, "OK: " + AudioSystem.isConversionSupported(outAudioFormat, inAudioFormat));
+logger.log(Level.DEBUG, "OUT: " + outAudioFormat);
+logger.log(Level.DEBUG, "OK: " + AudioSystem.isConversionSupported(outAudioFormat, inAudioFormat));
return AudioSystem.getAudioInputStream(outAudioFormat, sourceAis);
}
diff --git a/src/main/java/vavi/sound/sampled/Pcm16BitMonauralWaveDivider.java b/src/main/java/vavi/sound/sampled/Pcm16BitMonauralWaveDivider.java
index 35c8797..aeed46d 100644
--- a/src/main/java/vavi/sound/sampled/Pcm16BitMonauralWaveDivider.java
+++ b/src/main/java/vavi/sound/sampled/Pcm16BitMonauralWaveDivider.java
@@ -8,12 +8,9 @@
import java.io.EOFException;
import java.io.IOException;
-import java.util.logging.Level;
-
+import java.lang.System.Logger.Level;
import javax.sound.sampled.AudioInputStream;
-import vavi.util.Debug;
-
/**
* Pcm16BitMonauralWaveDivider.
@@ -48,25 +45,25 @@ class Pcm16BitMonauralWaveDivider implements WaveDivider {
public void divide(float seconds, Event event) throws IOException {
int numberChannels = targetAis.getFormat().getChannels();
-Debug.println(Level.FINE, "numberChannels: " + numberChannels);
+logger.log(Level.DEBUG, "numberChannels: " + numberChannels);
int samplingRate = (int) targetAis.getFormat().getSampleRate();
-Debug.println(Level.FINE, "samplingRate: " + samplingRate);
+logger.log(Level.DEBUG, "samplingRate: " + samplingRate);
int samplingBytes = targetAis.getFormat().getSampleSizeInBits() / 8;
-Debug.println(Level.FINE, "samplingBytes: " + samplingBytes);
+logger.log(Level.DEBUG, "samplingBytes: " + samplingBytes);
int bytesPerSecond = samplingRate * samplingBytes;
-Debug.println(Level.FINE, "bytesPerSecond: " + bytesPerSecond);
-Debug.println(Level.FINE, "header.bytesPerSecond: " + targetAis.getFormat().getFrameSize() * targetAis.getFormat().getFrameRate());
+logger.log(Level.DEBUG, "bytesPerSecond: " + bytesPerSecond);
+logger.log(Level.DEBUG, "header.bytesPerSecond: " + targetAis.getFormat().getFrameSize() * targetAis.getFormat().getFrameRate());
long totalTime = (long) (targetAis.available() / (targetAis.getFormat().getFrameSize() * targetAis.getFormat().getFrameRate()) * 1000);
-Debug.println(Level.FINE, "totalTime= " + (totalTime / (60 * 1000)) + ":" + ((totalTime % (60 * 1000)) / 1000) + "." + ((totalTime % (60 * 1000)) % 1000));
+logger.log(Level.DEBUG, "totalTime= " + (totalTime / (60 * 1000)) + ":" + ((totalTime % (60 * 1000)) / 1000) + "." + ((totalTime % (60 * 1000)) % 1000));
// all channel, per second
int blockSize = samplingRate * numberChannels * samplingBytes;
-Debug.println(Level.FINE, "blockSize: " + blockSize);
+logger.log(Level.DEBUG, "blockSize: " + blockSize);
int numberOfChunks = targetAis.available() / (int) (blockSize * seconds);
int moduloOfChunks = targetAis.available() % (int) (blockSize * seconds);
-Debug.println(Level.FINE, "numberOfChunks: " + numberOfChunks + ", moduloOfChunks: " + moduloOfChunks);
+logger.log(Level.DEBUG, "numberOfChunks: " + numberOfChunks + ", moduloOfChunks: " + moduloOfChunks);
for (int i = 0; i < numberOfChunks; i++) {
byte[] buffer = new byte[(int) (blockSize * seconds)];
@@ -78,7 +75,7 @@ public void divide(float seconds, Event event) throws IOException {
}
l += r;
}
-Debug.println(Level.FINE, "CHUNK[" + i + "] " + buffer.length + " bytes");
+logger.log(Level.DEBUG, "CHUNK[" + i + "] " + buffer.length + " bytes");
event.exec(new Chunk(i, buffer, samplingRate, samplingBytes * 8, numberChannels));
}
if (moduloOfChunks >= 0) {
@@ -92,7 +89,7 @@ public void divide(float seconds, Event event) throws IOException {
l += r;
}
event.exec(new Chunk(numberOfChunks, buffer, samplingRate, samplingBytes * 8, numberChannels));
-Debug.println(Level.FINE, "modulo bytes: " + buffer.length + ", " + (((totalTime / 1000) % seconds) + 1) + " [s]");
+logger.log(Level.DEBUG, "modulo bytes: " + buffer.length + ", " + (((totalTime / 1000) % seconds) + 1) + " [s]");
}
}
}
diff --git a/src/main/java/vavi/sound/sampled/SimpleResamplingInputFilter.java b/src/main/java/vavi/sound/sampled/SimpleResamplingInputFilter.java
index 7c72627..0aba2fd 100644
--- a/src/main/java/vavi/sound/sampled/SimpleResamplingInputFilter.java
+++ b/src/main/java/vavi/sound/sampled/SimpleResamplingInputFilter.java
@@ -7,14 +7,14 @@
package vavi.sound.sampled;
import java.io.IOException;
-import java.util.logging.Level;
-
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.UnsupportedAudioFileException;
-import vavi.util.Debug;
+import static java.lang.System.getLogger;
/**
@@ -27,8 +27,10 @@
*/
public class SimpleResamplingInputFilter implements InputFilter {
+ private static final Logger logger = getLogger(SimpleResamplingInputFilter.class.getName());
+
/** */
- protected int outSamplingRate;
+ protected final int outSamplingRate;
/** */
public SimpleResamplingInputFilter(int outSamplingRate) {
@@ -38,7 +40,7 @@ public SimpleResamplingInputFilter(int outSamplingRate) {
@Override
public AudioInputStream doFilter(AudioInputStream sourceAis) throws IOException, UnsupportedAudioFileException {
AudioFormat inAudioFormat = sourceAis.getFormat();
-Debug.println(Level.FINE, "IN: " + inAudioFormat);
+logger.log(Level.DEBUG, "IN: " + inAudioFormat);
// 1: PCM_SIGNED ? Hz, 16 bit, stereo, 2 bytes/frame, little-endian
AudioFormat outAudioFormat = new AudioFormat(
inAudioFormat.getEncoding(),
@@ -48,8 +50,8 @@ public AudioInputStream doFilter(AudioInputStream sourceAis) throws IOException,
inAudioFormat.getFrameSize(),
inAudioFormat.getFrameRate(),
inAudioFormat.isBigEndian());
-Debug.println(Level.FINE, "OUT: " + outAudioFormat);
-Debug.println(Level.FINE, "OK: " + AudioSystem.isConversionSupported(outAudioFormat, inAudioFormat));
+logger.log(Level.DEBUG, "OUT: " + outAudioFormat);
+logger.log(Level.DEBUG, "OK: " + AudioSystem.isConversionSupported(outAudioFormat, inAudioFormat));
return AudioSystem.getAudioInputStream(outAudioFormat, sourceAis);
}
diff --git a/src/main/java/vavi/sound/sampled/TemporaryFiledInputFilter.java b/src/main/java/vavi/sound/sampled/TemporaryFiledInputFilter.java
index 1642b4b..f34e6f1 100644
--- a/src/main/java/vavi/sound/sampled/TemporaryFiledInputFilter.java
+++ b/src/main/java/vavi/sound/sampled/TemporaryFiledInputFilter.java
@@ -8,14 +8,14 @@
import java.io.File;
import java.io.IOException;
-import java.util.logging.Level;
-
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
import javax.sound.sampled.AudioFileFormat;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.UnsupportedAudioFileException;
-import vavi.util.Debug;
+import static java.lang.System.getLogger;
/**
@@ -26,12 +26,14 @@
*/
public class TemporaryFiledInputFilter implements InputFilter {
+ private static final Logger logger = getLogger(TemporaryFiledInputFilter.class.getName());
+
@Override
public AudioInputStream doFilter(AudioInputStream sourceAis) throws IOException, UnsupportedAudioFileException {
// once write into temp
File tmpFile = File.createTempFile("temp", ".wav");
int r = AudioSystem.write(sourceAis, AudioFileFormat.Type.WAVE, tmpFile);
-Debug.println(Level.FINE, "RESULT: " + r);
+logger.log(Level.DEBUG, "RESULT: " + r);
return AudioSystem.getAudioInputStream(tmpFile);
}
diff --git a/src/main/java/vavi/sound/sampled/WaveDivider.java b/src/main/java/vavi/sound/sampled/WaveDivider.java
index 2f6bb1b..a20f504 100644
--- a/src/main/java/vavi/sound/sampled/WaveDivider.java
+++ b/src/main/java/vavi/sound/sampled/WaveDivider.java
@@ -7,13 +7,13 @@
package vavi.sound.sampled;
import java.io.IOException;
-import java.util.logging.Level;
-
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
+import javax.sound.sampled.AudioFormat.Encoding;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.UnsupportedAudioFileException;
-import javax.sound.sampled.AudioFormat.Encoding;
-import vavi.util.Debug;
+import static java.lang.System.getLogger;
/**
@@ -24,18 +24,20 @@
*/
public interface WaveDivider {
+ Logger logger = getLogger(WaveDivider.class.getName());
+
/** Represents divided PCM data */
class Chunk {
/** Sequence number */
- public int sequence;
+ public final int sequence;
/** sampling rate */
- public int samplingRate;
+ public final int samplingRate;
/** sampling bits */
- public int bits;
+ public final int bits;
/** channel number */
- public int channels;
+ public final int channels;
/** PCM dara */
- public byte[] buffer;
+ public final byte[] buffer;
/** */
Chunk(int sequence, byte[] buffer, int samplingRate, int bits, int channels) {
this.sequence = sequence;
@@ -57,7 +59,7 @@ public static WaveDivider getWaveDivider(AudioInputStream audioInputStream) thro
return new Pcm16BitMonauralWaveDivider(new MonauralInputFilter().doFilter(audioInputStream));
}
} else {
-Debug.println(Level.INFO, "unsupported type: " + audioInputStream.getFormat());
+logger.log(Level.INFO, "unsupported type: " + audioInputStream.getFormat());
throw new IllegalArgumentException("only pcm mono is supported.");
}
}
diff --git a/src/main/java/vavi/sound/sampled/adpcm/AdpcmWaveAudioFileReader.java b/src/main/java/vavi/sound/sampled/adpcm/AdpcmWaveAudioFileReader.java
index 068e1ca..a7efe78 100644
--- a/src/main/java/vavi/sound/sampled/adpcm/AdpcmWaveAudioFileReader.java
+++ b/src/main/java/vavi/sound/sampled/adpcm/AdpcmWaveAudioFileReader.java
@@ -10,11 +10,12 @@
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
import java.net.URL;
import java.nio.file.Files;
import java.util.HashMap;
import java.util.Map;
-import java.util.logging.Level;
import javax.sound.sampled.AudioFileFormat;
import javax.sound.sampled.AudioFileFormat.Type;
import javax.sound.sampled.AudioFormat;
@@ -28,6 +29,8 @@
import vavi.util.win32.Chunk;
import vavi.util.win32.WAVE;
+import static java.lang.System.getLogger;
+
/**
* Provider for some ADPCM audio files reading services. This implementation can parse
@@ -39,6 +42,8 @@
*/
public abstract class AdpcmWaveAudioFileReader extends AudioFileReader {
+ private static final Logger logger = getLogger(AdpcmWaveAudioFileReader.class.getName());
+
@Override
public AudioFileFormat getAudioFileFormat(File file) throws UnsupportedAudioFileException, IOException {
try (InputStream inputStream = Files.newInputStream(file.toPath())) {
@@ -86,7 +91,7 @@ protected int getBufferSize() {
* @throws IOException if an I/O exception occurs.
*/
protected AudioFileFormat getAudioFileFormat(InputStream bitStream, int mediaLength) throws UnsupportedAudioFileException, IOException {
-Debug.println(Level.FINER, "enter available: " + bitStream.available() + ", " + getClass().getSimpleName());
+logger.log(Level.TRACE, "enter available: " + bitStream.available() + ", " + getClass().getSimpleName());
float sampleRate;
int channels;
AudioFormat.Encoding encoding;
@@ -102,37 +107,37 @@ protected AudioFileFormat getAudioFileFormat(InputStream bitStream, int mediaLen
WAVE wave = Chunk.readFrom(is, WAVE.class, context);
WAVE.fmt fmt = wave.findChildOf(WAVE.fmt.class);
int formatCode = fmt.getFormatId();
- Debug.println(Level.FINER, "formatCode: " + formatCode);
+ logger.log(Level.TRACE, "formatCode: " + formatCode);
if (formatCode != getFormatCode()) {
- Debug.println(Level.FINER, "unsupported wave format code: " + formatCode);
+ logger.log(Level.TRACE, "unsupported wave format code: " + formatCode);
throw new UnsupportedAudioFileException("unsupported wave format code: " + formatCode);
}
sampleRate = fmt.getSamplingRate();
channels = fmt.getNumberChannels();
properties = toProperties(fmt);
- Debug.println(Level.FINER, "properties: " + properties);
+ logger.log(Level.TRACE, "properties: " + properties);
} catch (IOException e) {
if (e.getMessage().equals(LimitedInputStream.ERROR_MESSAGE_REACHED_TO_LIMIT)) {
-Debug.println(Level.FINER, e);
-Debug.printStackTrace(Level.FINEST, e);
+logger.log(Level.DEBUG, e);
+logger.log(Level.TRACE, e.getMessage(), e);
throw (UnsupportedAudioFileException) new UnsupportedAudioFileException(e.getMessage()).initCause(e);
} else {
throw e;
}
} catch (Exception e) {
-Debug.println(Level.FINER, e);
-Debug.printStackTrace(Level.FINEST, e);
+logger.log(Level.DEBUG, e);
+logger.log(Level.TRACE, e.getMessage(), e);
throw (UnsupportedAudioFileException) new UnsupportedAudioFileException(e.getMessage()).initCause(e);
} finally {
try {
bitStream.reset();
} catch (IOException e) {
- if (Debug.isLoggable(Level.FINEST))
-Debug.printStackTrace(e);
+ if (Debug.isLoggable(java.util.logging.Level.FINEST))
+logger.log(Level.ERROR, e.getMessage(), e);
else
-Debug.println(Level.FINE, e);
+logger.log(Level.DEBUG, e);
}
-Debug.println(Level.FINER, "finally available: " + bitStream.available());
+logger.log(Level.TRACE, "finally available: " + bitStream.available());
}
AudioFormat format;
if (properties == null) {
diff --git a/src/main/java/vavi/sound/sampled/mfi/DividedMfiWithVoiceMaker.java b/src/main/java/vavi/sound/sampled/mfi/DividedMfiWithVoiceMaker.java
index 1501242..1fb972a 100644
--- a/src/main/java/vavi/sound/sampled/mfi/DividedMfiWithVoiceMaker.java
+++ b/src/main/java/vavi/sound/sampled/mfi/DividedMfiWithVoiceMaker.java
@@ -8,8 +8,8 @@
import java.io.File;
import java.io.IOException;
-import java.util.logging.Level;
-
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.UnsupportedAudioFileException;
@@ -18,11 +18,11 @@
import org.klab.commons.cli.HelpOption;
import org.klab.commons.cli.Option;
import org.klab.commons.cli.Options;
-
import vavi.sound.mfi.InvalidMfiDataException;
import vavi.sound.sampled.FilterChain;
import vavi.sound.sampled.WaveDivider;
-import vavi.util.Debug;
+
+import static java.lang.System.getLogger;
/**
@@ -33,13 +33,15 @@
*/
class DividedMfiWithVoiceMaker extends MfiWithVoiceMaker {
+ private static final Logger logger = getLogger(DividedMfiWithVoiceMaker.class.getName());
+
/** source PCM */
- private AudioInputStream sourceAis;
+ private final AudioInputStream sourceAis;
/** output base directory */
- private String directory;
+ private final String directory;
/** output file template (use {@link String#format(String, Object...)}) */
- private String base;
+ private final String base;
/** */
private static int toReal(int base, int percent) {
@@ -78,7 +80,7 @@ public void exec(WaveDivider.Chunk chunk) throws IOException {
File file = new File(directory, String.format(base, chunk.sequence + 1));
r += createMFi(chunk.buffer, file);
} catch (InvalidMfiDataException e) {
- throw (IOException) new IOException(e);
+ throw new IOException(e);
}
}
}
@@ -96,10 +98,10 @@ public int create() throws IOException, UnsupportedAudioFileException, InvalidMf
// divide
Event event = new Event();
WaveDivider waveDivider = WaveDivider.Factory.getWaveDivider(sourceAis);
-Debug.println(Level.FINE, "1: " + (System.currentTimeMillis() - t));
+logger.log(Level.DEBUG, "1: " + (System.currentTimeMillis() - t));
t = System.currentTimeMillis();
waveDivider.divide(time, event);
-Debug.println(Level.FINE, "2: " + (System.currentTimeMillis() - t));
+logger.log(Level.DEBUG, "2: " + (System.currentTimeMillis() - t));
t = System.currentTimeMillis();
return event.r;
}
diff --git a/src/main/java/vavi/sound/sampled/mfi/MFi.java b/src/main/java/vavi/sound/sampled/mfi/MFi.java
index 9b605b9..2f5a30c 100644
--- a/src/main/java/vavi/sound/sampled/mfi/MFi.java
+++ b/src/main/java/vavi/sound/sampled/mfi/MFi.java
@@ -39,7 +39,7 @@ public MFi(Map properties) {
}
/** */
- private Map properties;
+ private final Map properties;
/** */
public Map properties() {
diff --git a/src/main/java/vavi/sound/sampled/mfi/MfiAudioFileWriter.java b/src/main/java/vavi/sound/sampled/mfi/MfiAudioFileWriter.java
index caf1446..327a228 100644
--- a/src/main/java/vavi/sound/sampled/mfi/MfiAudioFileWriter.java
+++ b/src/main/java/vavi/sound/sampled/mfi/MfiAudioFileWriter.java
@@ -9,15 +9,17 @@
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
import java.nio.file.Files;
-
import javax.sound.sampled.AudioFileFormat.Type;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.UnsupportedAudioFileException;
import javax.sound.sampled.spi.AudioFileWriter;
import vavi.sound.mfi.InvalidMfiDataException;
-import vavi.util.Debug;
+
+import static java.lang.System.getLogger;
/**
@@ -28,6 +30,8 @@
*/
public class MfiAudioFileWriter extends AudioFileWriter {
+ private static final Logger logger = getLogger(MfiAudioFileWriter.class.getName());
+
/** */
private static final Type[] outputTypes = new Type[] {
new MFi(null) // TODO null
@@ -90,9 +94,9 @@ public int write(AudioInputStream stream, Type fileType, OutputStream out) throw
return r;
}
} catch (UnsupportedAudioFileException | InvalidMfiDataException e) {
- throw (IOException) new IOException(e);
+ throw new IOException(e);
} catch (IllegalArgumentException e) {
-Debug.printStackTrace(e);
+logger.log(Level.ERROR, e.getMessage(), e);
throw e;
}
}
diff --git a/src/main/java/vavi/sound/sampled/mfi/MfiWithVoiceMaker.java b/src/main/java/vavi/sound/sampled/mfi/MfiWithVoiceMaker.java
index 85dd7ed..1dd6d23 100644
--- a/src/main/java/vavi/sound/sampled/mfi/MfiWithVoiceMaker.java
+++ b/src/main/java/vavi/sound/sampled/mfi/MfiWithVoiceMaker.java
@@ -8,9 +8,9 @@
import java.io.File;
import java.io.IOException;
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
import java.util.Properties;
-import java.util.logging.Level;
-
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.UnsupportedAudioFileException;
@@ -19,7 +19,6 @@
import org.klab.commons.cli.HelpOption;
import org.klab.commons.cli.Option;
import org.klab.commons.cli.Options;
-
import vavi.sound.mfi.InvalidMfiDataException;
import vavi.sound.mfi.MfiEvent;
import vavi.sound.mfi.MfiMessage;
@@ -33,7 +32,8 @@
import vavi.sound.mfi.vavi.header.VersMessage;
import vavi.sound.mfi.vavi.track.EndOfTrackMessage;
import vavi.sound.sampled.FilterChain;
-import vavi.util.Debug;
+
+import static java.lang.System.getLogger;
/**
@@ -44,6 +44,8 @@
*/
class MfiWithVoiceMaker {
+ private static final Logger logger = getLogger(MfiWithVoiceMaker.class.getName());
+
/** source PCM */
private AudioInputStream sourceAis;
@@ -116,7 +118,7 @@ protected MfiWithVoiceMaker(String model, float time, int samplingRate, int bits
public int create() throws IOException, UnsupportedAudioFileException, InvalidMfiDataException {
long t = System.currentTimeMillis();
// divide
-Debug.println(Level.FINE, "1: " + (System.currentTimeMillis() - t));
+logger.log(Level.DEBUG, "1: " + (System.currentTimeMillis() - t));
t = System.currentTimeMillis();
byte[] buffer = new byte[sourceAis.available()];
int l = 0;
@@ -125,7 +127,7 @@ public int create() throws IOException, UnsupportedAudioFileException, InvalidMf
l += r;
}
int result = createMFi(buffer, new File(filename));
-Debug.println(Level.FINE, "2: " + (System.currentTimeMillis() - t));
+logger.log(Level.DEBUG, "2: " + (System.currentTimeMillis() - t));
t = System.currentTimeMillis();
return result;
}
@@ -174,7 +176,7 @@ protected int createMFi(byte[] data, File file) throws InvalidMfiDataException,
}
int r = MfiSystem.write(sequence, VaviMfiFileFormat.FILE_TYPE, file);
-Debug.println(Level.FINE, "write: " + r);
+logger.log(Level.DEBUG, "write: " + r);
return r;
}
@@ -201,7 +203,7 @@ protected int createMFi(byte[] data, File file) throws InvalidMfiDataException,
sorc = Integer.parseInt(props.getProperty("sorc"));
defaultModel = props.getProperty("defaultModel");
} catch (Exception e) {
- Debug.printStackTrace(e);
+ logger.log(Level.ERROR, e.getMessage(), e);
}
}
diff --git a/src/main/java/vavi/sound/sampled/smaf/DividedSmafWithVoiceMaker.java b/src/main/java/vavi/sound/sampled/smaf/DividedSmafWithVoiceMaker.java
index bc7bed6..2354aa1 100644
--- a/src/main/java/vavi/sound/sampled/smaf/DividedSmafWithVoiceMaker.java
+++ b/src/main/java/vavi/sound/sampled/smaf/DividedSmafWithVoiceMaker.java
@@ -8,8 +8,8 @@
import java.io.File;
import java.io.IOException;
-import java.util.logging.Level;
-
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.UnsupportedAudioFileException;
@@ -18,11 +18,11 @@
import org.klab.commons.cli.HelpOption;
import org.klab.commons.cli.Option;
import org.klab.commons.cli.Options;
-
import vavi.sound.sampled.FilterChain;
import vavi.sound.sampled.WaveDivider;
import vavi.sound.smaf.InvalidSmafDataException;
-import vavi.util.Debug;
+
+import static java.lang.System.getLogger;
/**
@@ -33,13 +33,15 @@
*/
class DividedSmafWithVoiceMaker extends SmafWithVoiceMaker {
+ private static final Logger logger = getLogger(DividedSmafWithVoiceMaker.class.getName());
+
/** source PCM */
- private AudioInputStream sourceAis;
+ private final AudioInputStream sourceAis;
/** output base directory */
- private String directory;
+ private final String directory;
/** output file template (use {@link String#format(String, Object...)}) */
- private String base;
+ private final String base;
/**
*
@@ -70,10 +72,10 @@ private class Event implements WaveDivider.Event {
public void exec(WaveDivider.Chunk chunk) throws IOException {
try {
File file = new File(directory, String.format(base, chunk.sequence + 1));
-Debug.println(Level.FINE, "file: " + file + ", " + directory + ", " + base + ", " + (chunk.sequence + 1));
+logger.log(Level.DEBUG, "file: " + file + ", " + directory + ", " + base + ", " + (chunk.sequence + 1));
r += createSMAF(chunk.buffer, file);
} catch (InvalidSmafDataException e) {
- throw (IOException) new IOException(e);
+ throw new IOException(e);
}
}
}
@@ -91,10 +93,10 @@ public int create() throws IOException, UnsupportedAudioFileException, InvalidSm
// divide
Event event = new Event();
WaveDivider waveDivider = WaveDivider.Factory.getWaveDivider(sourceAis);
-Debug.println(Level.FINE, "1: " + (System.currentTimeMillis() - t));
+logger.log(Level.DEBUG, "1: " + (System.currentTimeMillis() - t));
t = System.currentTimeMillis();
waveDivider.divide(time, event);
-Debug.println(Level.FINE, "2: " + (System.currentTimeMillis() - t));
+logger.log(Level.DEBUG, "2: " + (System.currentTimeMillis() - t));
t = System.currentTimeMillis();
return event.r;
}
diff --git a/src/main/java/vavi/sound/sampled/smaf/SMAF.java b/src/main/java/vavi/sound/sampled/smaf/SMAF.java
index c24a113..bd24da2 100644
--- a/src/main/java/vavi/sound/sampled/smaf/SMAF.java
+++ b/src/main/java/vavi/sound/sampled/smaf/SMAF.java
@@ -38,7 +38,7 @@ public SMAF(Map properties) {
}
/** */
- private Map properties;
+ private final Map properties;
/** */
public Map properties() {
diff --git a/src/main/java/vavi/sound/sampled/smaf/SmafWithVoiceMaker.java b/src/main/java/vavi/sound/sampled/smaf/SmafWithVoiceMaker.java
index ade8619..c7cd73f 100644
--- a/src/main/java/vavi/sound/sampled/smaf/SmafWithVoiceMaker.java
+++ b/src/main/java/vavi/sound/sampled/smaf/SmafWithVoiceMaker.java
@@ -8,12 +8,12 @@
import java.io.File;
import java.io.IOException;
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
import java.nio.file.Files;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Properties;
-import java.util.logging.Level;
-
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.UnsupportedAudioFileException;
@@ -22,7 +22,6 @@
import org.klab.commons.cli.HelpOption;
import org.klab.commons.cli.Option;
import org.klab.commons.cli.Options;
-
import vavi.sound.mobile.AudioEngine;
import vavi.sound.sampled.FilterChain;
import vavi.sound.smaf.InvalidSmafDataException;
@@ -32,16 +31,17 @@
import vavi.sound.smaf.chunk.FileChunk;
import vavi.sound.smaf.chunk.PcmAudioTrackChunk;
import vavi.sound.smaf.chunk.SeekAndPhraseInfoChunk;
-import vavi.sound.smaf.chunk.WaveDataChunk;
-import vavi.sound.smaf.chunk.WaveType;
import vavi.sound.smaf.chunk.TrackChunk.FormatType;
import vavi.sound.smaf.chunk.TrackChunk.SequenceType;
+import vavi.sound.smaf.chunk.WaveDataChunk;
+import vavi.sound.smaf.chunk.WaveType;
import vavi.sound.smaf.message.EndOfSequenceMessage;
import vavi.sound.smaf.message.NopMessage;
import vavi.sound.smaf.message.VolumeMessage;
import vavi.sound.smaf.message.WaveMessage;
import vavi.sound.smaf.sequencer.WaveSequencer;
-import vavi.util.Debug;
+
+import static java.lang.System.getLogger;
/**
@@ -52,6 +52,8 @@
*/
class SmafWithVoiceMaker {
+ private static final Logger logger = getLogger(SmafWithVoiceMaker.class.getName());
+
/** source PCM */
private AudioInputStream sourceAis;
@@ -115,7 +117,7 @@ protected SmafWithVoiceMaker(float time, int samplingRate, int bits, int channel
public int create() throws IOException, UnsupportedAudioFileException, InvalidSmafDataException {
long t = System.currentTimeMillis();
// divide
-Debug.println(Level.FINE, "1: " + (System.currentTimeMillis() - t));
+logger.log(Level.DEBUG, "1: " + (System.currentTimeMillis() - t));
t = System.currentTimeMillis();
byte[] buffer = new byte[sourceAis.available()];
int l = 0;
@@ -124,7 +126,7 @@ public int create() throws IOException, UnsupportedAudioFileException, InvalidSm
l += r;
}
int result = createSMAF(buffer, new File(filename));
-Debug.println(Level.FINE, "2: " + (System.currentTimeMillis() - t));
+logger.log(Level.DEBUG, "2: " + (System.currentTimeMillis() - t));
t = System.currentTimeMillis();
return result;
}
@@ -160,11 +162,11 @@ protected int createSMAF(byte[] data, File file) throws InvalidSmafDataException
int timeBase = 4; // [ms]
-Debug.println(Level.FINE, "time: " + time + ", " + data.length);
+logger.log(Level.DEBUG, "time: " + time + ", " + data.length);
int numberOfChunks = (int) ((time * 1000) / (NopMessage.maxSteps * timeBase));
-Debug.println(Level.FINE, "numberOfChunks: " + numberOfChunks);
+logger.log(Level.DEBUG, "numberOfChunks: " + numberOfChunks);
int moduloOfChunks = (int) ((time * 1000) % (NopMessage.maxSteps * timeBase) / timeBase);
-Debug.println(Level.FINE, "moduloOfChunks: " + moduloOfChunks);
+logger.log(Level.DEBUG, "moduloOfChunks: " + moduloOfChunks);
int messageBytes = 0;
int streamNumber = 1;
@@ -173,41 +175,41 @@ protected int createSMAF(byte[] data, File file) throws InvalidSmafDataException
SmafMessage message = new VolumeMessage(0, 0, 127);
audioSequenceDataChunk.addSmafMessage(message);
messageBytes += message.getLength();
-//Debug.println("messageBytes: volume: " + messageBytes);
+//logger.log(Level.DEBUG, "messageBytes: volume: " + messageBytes);
for (int i = 0; i < numberOfChunks; i++) {
message = new WaveMessage(0, 0, streamNumber++, NopMessage.maxSteps);
audioSequenceDataChunk.addSmafMessage(message);
messageBytes += message.getLength();
-//Debug.println("messageBytes: wave: " + messageBytes);
+//logger.log(Level.DEBUG, "messageBytes: wave: " + messageBytes);
message = new NopMessage(NopMessage.maxSteps);
audioSequenceDataChunk.addSmafMessage(message);
messageBytes += message.getLength();
-//Debug.println("messageBytes: nop: " + messageBytes);
+//logger.log(Level.DEBUG, "messageBytes: nop: " + messageBytes);
}
if (moduloOfChunks != 0) {
message = new WaveMessage(0, 0, streamNumber++, moduloOfChunks);
audioSequenceDataChunk.addSmafMessage(message);
messageBytes += message.getLength();
-//Debug.println("messageBytes: wave: " + messageBytes);
+//logger.log(Level.DEBUG, "messageBytes: wave: " + messageBytes);
message = new NopMessage(moduloOfChunks);
audioSequenceDataChunk.addSmafMessage(message);
messageBytes += message.getLength();
-//Debug.println("messageBytes: nop: " + messageBytes);
+//logger.log(Level.DEBUG, "messageBytes: nop: " + messageBytes);
}
audioSequenceDataChunk.addSmafMessage(new EndOfSequenceMessage(0));
SeekAndPhraseInfoChunk seekAndPhraseInfoChunk = new SeekAndPhraseInfoChunk();
seekAndPhraseInfoChunk.setStartPoint(0);
seekAndPhraseInfoChunk.setStopPoint(messageBytes);
-Debug.println(Level.FINE, "sp: " + messageBytes);
+logger.log(Level.DEBUG, "sp: " + messageBytes);
AudioEngine audioEngine = WaveSequencer.Factory.getAudioEngine(ADPCM);
int chunkSize = numberOfChunks == 0 ? 0 : data.length / numberOfChunks;
-Debug.println(Level.FINE, "chunkSize: " + chunkSize);
+logger.log(Level.DEBUG, "chunkSize: " + chunkSize);
int moduloChunkSize = numberOfChunks == 0 ? data.length : data.length % chunkSize;
-Debug.println(Level.FINE, "moduloChunkSize: " + moduloChunkSize);
+logger.log(Level.DEBUG, "moduloChunkSize: " + moduloChunkSize);
streamNumber = 1;
PcmAudioTrackChunk pcmAudioTrackChunk = new PcmAudioTrackChunk();
@@ -246,18 +248,18 @@ protected int createSMAF(byte[] data, File file) throws InvalidSmafDataException
}
fileChunk.writeTo(Files.newOutputStream(file.toPath()));
int r = fileChunk.getSize();
-Debug.println(Level.FINE, "write: " + r);
+logger.log(Level.DEBUG, "write: " + r);
return r;
}
/** vendor */
- protected static String vn;
+ protected static final String vn;
/** copyright */
- protected static String cr;
+ protected static final String cr;
/** */
- protected static String defaultModel;
+ protected static final String defaultModel;
/* */
static {
@@ -281,18 +283,24 @@ public static class Arguments {
@Argument(index = 0)
File file;
@Option(argName = "filename", option = "f", args = 1, required = false, description = "output mmf filename")
+ final
String outFilename = "out.mmf";
@Option(argName = "model", option = "m", required = false, args = 1, description = "terminal model")
String model = defaultModel;
@Option(argName = "rate", option = "r", required = false, args = 1, description = "adpcm sampling rate [Hz]")
+ final
int samplingRate = 16000;
@Option(argName = "bits", option = "b", required = false, args = 1, description = "adpcm sampling bits")
+ final
int bits = 4;
@Option(argName = "channels", option = "c", required = false, args = 1, description = "adpcm channels")
+ final
int channels = 1;
@Option(argName = "masterVolume", option = "v", required = false, args = 1, description = "master volume in [%]")
+ final
int masterVolume = 100;
@Option(argName = "adpcmVolume", option = "a", required = false, args = 1, description = "adpcm volume in [%]")
+ final
int adpcmVolume = 100;
}
diff --git a/src/main/java/vavi/sound/smaf/MetaEventAdapter.java b/src/main/java/vavi/sound/smaf/MetaEventAdapter.java
index 7e18614..8a8c4f0 100644
--- a/src/main/java/vavi/sound/smaf/MetaEventAdapter.java
+++ b/src/main/java/vavi/sound/smaf/MetaEventAdapter.java
@@ -6,8 +6,8 @@
package vavi.sound.smaf;
-import java.util.logging.Level;
-
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
import javax.sound.midi.MetaEventListener;
import vavi.sound.midi.MidiConstants.MetaEvent;
@@ -18,7 +18,8 @@
import vavi.sound.smaf.sequencer.MachineDependentSequencer;
import vavi.sound.smaf.sequencer.SmafMessageStore;
import vavi.sound.smaf.sequencer.WaveSequencer;
-import vavi.util.Debug;
+
+import static java.lang.System.getLogger;
/**
@@ -29,6 +30,8 @@
*/
class MetaEventAdapter implements MetaEventListener, SmafDevice {
+ private static final Logger logger = getLogger(MetaEventAdapter.class.getName());
+
/** the device information */
private static final SmafDevice.Info info =
new SmafDevice.Info("Java SMAF WAVE Sequencer",
@@ -64,32 +67,32 @@ public void open() {
*/
@Override
public void meta(javax.sound.midi.MetaMessage message) {
-//Debug.println("type: " + message.getType());
+//logger.log(Level.DEBUG, "type: " + message.getType());
switch (MetaEvent.valueOf(message.getType())) {
case META_MACHINE_DEPEND: // sequencer specific meta event
try {
processSpecial(message);
} catch (InvalidSmafDataException e) {
- Debug.printStackTrace(e.getCause());
+ logger.log(Level.ERROR, e.getCause().getMessage(), e.getCause());
}
catch (RuntimeException e) {
-Debug.printStackTrace(e);
+logger.log(Level.ERROR, e.getMessage(), e);
} catch (Error e) {
-Debug.printStackTrace(e);
+logger.log(Level.ERROR, e.getMessage(), e);
throw e;
}
break;
case META_TEXT_EVENT: // text event
case META_COPYRIGHT: // show copyright
case META_NAME: // sequence name or track name
-Debug.println(Level.FINE, "meta " + message.getType() + ": " + MidiUtil.getDecodedMessage(message.getData()));
+logger.log(Level.DEBUG, "meta " + message.getType() + ": " + MidiUtil.getDecodedMessage(message.getData()));
break;
case META_END_OF_TRACK: // end of track
case META_TEMPO: // tempo was set
-Debug.println(Level.FINE, "this handler ignore meta: " + message.getType());
+logger.log(Level.DEBUG, "this handler ignore meta: " + message.getType());
break;
default:
-Debug.println(Level.FINE, "no meta sub handler: " + message.getType());
+logger.log(Level.DEBUG, "no meta sub handler: " + message.getType());
break;
}
}
@@ -107,13 +110,13 @@ private void processSpecial(javax.sound.midi.MetaMessage message)
int manufacturerId = data[0];
switch (manufacturerId) {
case 0: // 3 byte manufacturer id
-Debug.printf(Level.WARNING, "unhandled manufacturer: %02x %02x %02x\n", data[0], data[1], data[2]);
+logger.log(Level.WARNING, String.format("unhandled manufacturer: %02x %02x %02x", data[0], data[1], data[2]));
break;
case VaviMidiDeviceProvider.MANUFACTURER_ID: // 0x5f vavi
processSpecial_Vavi(message);
break;
default:
-Debug.printf(Level.WARNING, "unhandled manufacturer: %02x\n", manufacturerId);
+logger.log(Level.WARNING, String.format("unhandled manufacturer: %02x", manufacturerId));
break;
}
}
@@ -124,7 +127,7 @@ private void processSpecial(javax.sound.midi.MetaMessage message)
* 0x5f functionId
*
*/
- private void processSpecial_Vavi(javax.sound.midi.MetaMessage message)
+ private static void processSpecial_Vavi(javax.sound.midi.MetaMessage message)
throws InvalidSmafDataException {
byte[] data = message.getData();
@@ -137,7 +140,7 @@ private void processSpecial_Vavi(javax.sound.midi.MetaMessage message)
processSpecial_Vavi_Wave(message);
break;
default:
-Debug.printf(Level.WARNING, "unhandled function: %02x\n", functionId);
+logger.log(Level.WARNING, String.format("unhandled function: %02x", functionId));
break;
}
}
@@ -147,12 +150,12 @@ private void processSpecial_Vavi(javax.sound.midi.MetaMessage message)
* 0x5f 0x01
*
*/
- private void processSpecial_Vavi_MachineDependent(javax.sound.midi.MetaMessage message)
+ private static void processSpecial_Vavi_MachineDependent(javax.sound.midi.MetaMessage message)
throws InvalidSmafDataException {
byte[] data = message.getData();
int id = (data[2] & 0xff) * 0xff + (data[3] & 0xff);
-//Debug.println("message id: " + id);
+//logger.log(Level.DEBUG, "message id: " + id);
MachineDependentSequencer sequencer = (MachineDependentSequencer) SmafMessageStore.get(id);
sequencer.sequence();
}
@@ -163,12 +166,12 @@ private void processSpecial_Vavi_MachineDependent(javax.sound.midi.MetaMessage m
* 0x5f 0x03 id(H) id(L)
*
*/
- private void processSpecial_Vavi_Wave(javax.sound.midi.MetaMessage message)
+ private static void processSpecial_Vavi_Wave(javax.sound.midi.MetaMessage message)
throws InvalidSmafDataException {
byte[] data = message.getData();
int id = (data[2] & 0xff) * 0x100 + (data[3] & 0xff);
-//Debug.println("message id: " + id);
+//logger.log(Level.DEBUG, "message id: " + id);
WaveSequencer sequencer = (WaveSequencer) SmafMessageStore.get(id);
sequencer.sequence();
}
diff --git a/src/main/java/vavi/sound/smaf/MetaSupport.java b/src/main/java/vavi/sound/smaf/MetaSupport.java
index 8956587..aa24107 100644
--- a/src/main/java/vavi/sound/smaf/MetaSupport.java
+++ b/src/main/java/vavi/sound/smaf/MetaSupport.java
@@ -21,7 +21,7 @@
class MetaSupport implements Serializable {
/** The metaEvent listeners */
- private List listenerList = new ArrayList<>();
+ private final List listenerList = new ArrayList<>();
/** Adds {@link MetaEventListener}. */
public void addMetaEventListener(MetaEventListener l) {
diff --git a/src/main/java/vavi/sound/smaf/Sequence.java b/src/main/java/vavi/sound/smaf/Sequence.java
index 49f6be3..46a3ae8 100644
--- a/src/main/java/vavi/sound/smaf/Sequence.java
+++ b/src/main/java/vavi/sound/smaf/Sequence.java
@@ -22,7 +22,7 @@
public class Sequence {
/** */
- protected List