diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml
index 8f4fabb..a3fca81 100644
--- a/.github/workflows/maven.yml
+++ b/.github/workflows/maven.yml
@@ -12,7 +12,7 @@ on:
jobs:
build:
- runs-on: macos-latest
+ runs-on: macos-13
steps:
- name: Checkout repository
diff --git a/README.md b/README.md
index 373d562..7116030 100644
--- a/README.md
+++ b/README.md
@@ -70,6 +70,8 @@ A. yes you can, follow those steps
* on macos m2 ultra 1st pass is in a blink of an eye
* ~~`ima`, `ms` adpcm: wav reader~~
* ~~`tritonus:tritonus-remaining:org.tritonus.sampled.file.WaveAudioFileReader`~~
+ * use service provider for mfi, smaf sequencer
+ * service loader instead of vavi.properties
---
-images by melody, cellphone
\ No newline at end of file
+images by melody, cellphone
diff --git a/pom.xml b/pom.xml
index 473bae1..a0b41ff 100644
--- a/pom.xml
+++ b/pom.xml
@@ -8,7 +8,7 @@
vavi
vavi-sound
- 1.0.18
+ 1.0.19
Vavi Sound API
https://github.com/umjammer/vavi-sound
@@ -75,7 +75,7 @@ TODO
org.codehaus.mojo
properties-maven-plugin
- 1.1.0
+ 1.2.1
read-properties
@@ -164,9 +164,9 @@ TODO
-Djava.util.logging.config.file=${project.build.testOutputDirectory}/logging.properties
- -Dvavi.test.dev.null=${dev.null}
- -Dvavi.test.volume=${vavi.test.volume}
- -Dvavi.test.volume.midi=${vavi.test.volume.midi}
+ -Dvavi.test.dev.null=@{dev.null}
+ -Dvavi.test.volume=@{vavi.test.volume}
+ -Dvavi.test.volume.midi=@{vavi.test.volume.midi}
-Dvavi.test.version=${project.version}
false
@@ -202,7 +202,7 @@ TODO
com.github.umjammer
vavi-commons
- 1.1.12
+ 1.1.13
com.github.umjammer
@@ -223,7 +223,7 @@ TODO
vavi
vavi-sound-nda
- 1.0.13
+ 1.0.14
com.github.umjammer
diff --git a/src/main/java/readme.md b/src/main/java/readme.md
index db34d74..4ec4fef 100644
--- a/src/main/java/readme.md
+++ b/src/main/java/readme.md
@@ -25,9 +25,9 @@ packages
* `vavi.sound.adpcm.ma`
* `vavi.sound.adpcm.vox`
-着声に使用される ADPCM コーデックを取り扱うパッケージ群です。
-Java の標準 IO ({@link java.io.InputStream}/{@link java.io.OutputStream}) として実装されているため
-取り扱いが容易でストリーミングも楽に行えます。
+A group of packages that handle the ADPCM codec used for voice ringtone.
+Because it is implemented as Java standard IO ({@link java.io.InputStream}/{@link java.io.OutputStream})
+Easy to handle and stream easily.
### 2. MFi library
@@ -37,10 +37,10 @@ packages
* `vavi.sound.mfi.vavi`
* :
-着メロライブラリの核となる部分です。MFi のファイル構造を取り扱い、MIDI 構造に変換する事が出来ます。
-また MIDI から MFi への変換も可能です。基本的に {@link javax.sound.midi} パッケージと同じ構造をとっています。
-機種依存データを扱うパッケージとして {@link vavi.sound.mfi.vavi.mitsubishi D社} と
-{@link vavi.sound.mfi.vavi.nec N社} がサンプル実装されています。
+This is the core part of the ringtone library. It can handle MFi file structures and convert them to MIDI structures.
+It is also possible to convert from MIDI to MFi. It basically has the same structure as the {@link javax.sound.midi} package.
+{@link vavi.sound.mfi.vavi.mitsubishi Company D} as a package that handles model-dependent data
+{@link vavi.sound.mfi.vavi.nec Company N} has been implemented as a sample.
### 3. `javax.sound.midi.spi` implementation
@@ -49,10 +49,10 @@ packages
* `vavi.sound.midi`
* `vavi.sound.midi.mfi`
-`javax.sound.midi.spi` の一実装として機能させるためのパッケージです。
+This is a package to function as an implementation of `javax.sound.midi.spi`.
[SPI](http://java.sun.com/j2se/1.5.0/ja/docs/ja/guide/sound/programmer_guide/chapter1.html#111901)
-仕様に従い登録すれば midi の一ファイル形式として MFi ファイルを
-再生する事が可能になります。
+If you register according to the specifications, you can use MFi files as a midi file format.
+It will be possible to play it.
## How to
diff --git a/src/main/java/vavi/sound/adpcm/AdpcmInputStream.java b/src/main/java/vavi/sound/adpcm/AdpcmInputStream.java
index d1920b4..ff6254d 100644
--- a/src/main/java/vavi/sound/adpcm/AdpcmInputStream.java
+++ b/src/main/java/vavi/sound/adpcm/AdpcmInputStream.java
@@ -9,13 +9,15 @@
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.ByteOrder;
-
import javax.sound.sampled.AudioFormat;
import vavi.io.BitInputStream;
import vavi.io.BitOutputStream;
-import vavi.util.Debug;
+
+import static java.lang.System.getLogger;
/**
@@ -30,14 +32,16 @@
*/
public abstract class AdpcmInputStream extends FilterInputStream {
+ private static final Logger logger = getLogger(AdpcmInputStream.class.getName());
+
/** PCM format that #read() returns */
- protected AudioFormat.Encoding encoding = AudioFormat.Encoding.PCM_SIGNED;
+ protected final AudioFormat.Encoding encoding = AudioFormat.Encoding.PCM_SIGNED;
/** PCM byte order that #read() returns */
- protected ByteOrder byteOrder;
+ protected final ByteOrder byteOrder;
/** decoder */
- protected Codec decoder;
+ protected final Codec decoder;
/** */
protected abstract Codec getCodec();
@@ -52,13 +56,13 @@ public AdpcmInputStream(InputStream in, ByteOrder byteOrder, int bits, ByteOrder
super(new BitInputStream(in, bits, bitOrder));
this.byteOrder = byteOrder;
this.decoder = getCodec();
-//Debug.println(this.in);
+//logger.log(Level.DEBUG, this.in);
}
/** ADPCM (4bit) length */
@Override
public int available() throws IOException {
-//Debug.println("0: " + in.available() + ", " + ((in.available() * 2) + (rest ? 1 : 0)));
+//logger.log(Level.DEBUG, "0: " + in.available() + ", " + ((in.available() * 2) + (rest ? 1 : 0)));
// TODO "* 2" calc should be in bits?
return (in.available() * 2) + (rest ? 1 : 0);
}
@@ -73,10 +77,10 @@ public int available() throws IOException {
*/
@Override
public int read() throws IOException {
-//Debug.println(in);
+//logger.log(Level.DEBUG, in);
if (!rest) {
int adpcm = in.read();
-//System.err.println("0: " + StringUtil.toHex2(adpcm));
+//logger.log(Level.DEBUG, "0: " + StringUtil.toHex2(adpcm));
if (adpcm == -1) {
return -1;
}
@@ -84,7 +88,7 @@ public int read() throws IOException {
current = decoder.decode(adpcm);
rest = true;
-//System.err.println("1: " + StringUtil.toHex2(current & 0xff));
+//logger.log(Level.DEBUG, "1: " + StringUtil.toHex2(current & 0xff));
if (ByteOrder.BIG_ENDIAN.equals(byteOrder)) {
return (current & 0xff00) >> 8;
} else {
@@ -92,7 +96,7 @@ public int read() throws IOException {
}
} else {
rest = false;
-//System.err.println("2: " + StringUtil.toHex2((current & 0xff00) >> 8));
+//logger.log(Level.DEBUG, "2: " + StringUtil.toHex2((current & 0xff00) >> 8));
if (ByteOrder.BIG_ENDIAN.equals(byteOrder)) {
return current & 0xff;
} else {
@@ -130,7 +134,7 @@ public int read(byte[] b, int off, int len) throws IOException {
}
}
} catch (IOException e) {
- Debug.printStackTrace(e);
+ logger.log(Level.ERROR, e.getMessage(), e);
}
return i;
}
diff --git a/src/main/java/vavi/sound/adpcm/AdpcmOutputStream.java b/src/main/java/vavi/sound/adpcm/AdpcmOutputStream.java
index 08c7425..45e39bd 100644
--- a/src/main/java/vavi/sound/adpcm/AdpcmOutputStream.java
+++ b/src/main/java/vavi/sound/adpcm/AdpcmOutputStream.java
@@ -26,13 +26,13 @@
public abstract class AdpcmOutputStream extends FilterOutputStream {
/** PCM format for #write(int) */
- protected AudioFormat.Encoding encoding = AudioFormat.Encoding.PCM_SIGNED;
+ protected final AudioFormat.Encoding encoding = AudioFormat.Encoding.PCM_SIGNED;
/** PCM byte order for #write(int) */
- protected ByteOrder byteOrder;
+ protected final ByteOrder byteOrder;
/** encoder */
- protected Codec encoder;
+ protected final Codec encoder;
/** */
protected abstract Codec getCodec();
@@ -48,7 +48,7 @@ public AdpcmOutputStream(OutputStream out, ByteOrder byteOrder, int bits, ByteOr
super(new BitOutputStream(out, bits, bitOrder));
this.byteOrder = byteOrder;
this.encoder = getCodec();
-//Debug.println(this.out);
+//logger.log(Level.DEBUG, this.out);
}
/** remaining or not (having PCM L or H at least one side) */
@@ -74,7 +74,7 @@ public void write(int b) throws IOException {
current -= 0x10000;
}
}
-//System.err.println("current: " + StringUtil.toHex4(current));
+//logger.log(Level.DEBUG, "current: " + StringUtil.toHex4(current));
out.write(encoder.encode(current)); // BitOutputStream write 4bit
flushed = true;
diff --git a/src/main/java/vavi/sound/adpcm/ccitt/G711.java b/src/main/java/vavi/sound/adpcm/ccitt/G711.java
index 6a18727..08e4300 100644
--- a/src/main/java/vavi/sound/adpcm/ccitt/G711.java
+++ b/src/main/java/vavi/sound/adpcm/ccitt/G711.java
@@ -47,7 +47,7 @@
abstract class G711 implements Codec {
/** */
- protected State state = new State();
+ protected final State state = new State();
/** */
protected AudioFormat.Encoding encoding = AudioFormat.Encoding.PCM_SIGNED;
@@ -346,7 +346,7 @@ protected int reconstruct(boolean sign, int dqln, int y) {
int dql = dqln + (y >> 2); // ADDA
if (dql < 0) {
-// System.err.println("1: " + (sign ? -0x8000 : 0));
+// logger.log(Level.DEBUG, "1: " + (sign ? -0x8000 : 0));
return sign ? -0x8000 : 0;
} else { // ANTILOG
// Integer part of log
@@ -354,8 +354,8 @@ protected int reconstruct(boolean sign, int dqln, int y) {
int dqt = 128 + (dql & 127);
// Reconstructed difference signal sample
int dq = (dqt << 7) >> (14 - dex);
-// System.err.println("2: " + sign + ", " + dqln + ", " + y);
-// System.err.println("-: " + (sign ? dq - 0x8000 : dq) + ", " + (dq - 0x8000) + ", " + dq);
+// logger.log(Level.DEBUG, "2: " + sign + ", " + dqln + ", " + y);
+// logger.log(Level.DEBUG, "-: " + (sign ? dq - 0x8000 : dq) + ", " + (dq - 0x8000) + ", " + dq);
return sign ? dq - 0x8000 : dq;
}
}
@@ -380,11 +380,11 @@ protected int quantize(int d, int y, int[] table, int size) {
//
// Magnitude of 'd'
int dqm = Math.abs(d);
-// System.err.println("d:\t" + d);
-// System.err.println("dqm:\t" + dqm);
+// logger.log(Level.DEBUG, "d:\t" + d);
+// logger.log(Level.DEBUG, "dqm:\t" + dqm);
// Integer part of base 2 log of 'd'
int exp = State.quan(dqm >> 1);
-// System.err.println("exp:\t" + exp);
+// logger.log(Level.DEBUG, "exp:\t" + exp);
// Fractional part of base 2 log
int mant = ((dqm << 7) >> exp) & 0x7f; // Fractional portion.
// Log of magnitude of 'd'
@@ -509,7 +509,7 @@ protected int adjustUlawTandem(int sr, int se, int y, int i, int sign, int[] qta
}
}
- //-------------------------------------------------------------------------
+ // ----
/** */
public abstract int getEncodingBits();
diff --git a/src/main/java/vavi/sound/adpcm/ccitt/G721.java b/src/main/java/vavi/sound/adpcm/ccitt/G721.java
index 6aefb06..b07e16a 100644
--- a/src/main/java/vavi/sound/adpcm/ccitt/G721.java
+++ b/src/main/java/vavi/sound/adpcm/ccitt/G721.java
@@ -95,11 +95,11 @@ public int encode(int sl) {
} else if (AudioFormat.Encoding.ULAW.equals(encoding)) {
sl = ulaw2linear(sl) >> 2;
} else if (AudioFormat.Encoding.PCM_SIGNED.equals(encoding)) {
-//System.err.println("---- " + ccc + " ----");
+//logger.log(Level.DEBUG, "---- " + ccc + " ----");
//ccc++;
-//System.err.println("sl:B:\t" + sl);
+//logger.log(Level.DEBUG, "sl:B:\t" + sl);
sl >>= 2; // 14-bit dynamic range
-//System.err.println("sl:A:\t" + sl);
+//logger.log(Level.DEBUG, "sl:A:\t" + sl);
} else {
throw new IllegalArgumentException(encoding.toString());
}
@@ -109,8 +109,8 @@ public int encode(int sl) {
int sez = sezi >> 1;
int se = (sezi + state.getPolePredictor()) >> 1; // estimated signal
-//System.err.println("sl:\t" + sl);
-//System.err.println("se:\t" + se);
+//logger.log(Level.DEBUG, "sl:\t" + sl);
+//logger.log(Level.DEBUG, "se:\t" + se);
// SUBTA
int d = sl - se; // estimation difference
@@ -153,12 +153,12 @@ public int decode(int i) {
int sei = sezi + state.getPolePredictor();
int se = sei >> 1; // se = estimated signal
-//System.err.println("---- (" + (ccc++) + ")");
-//System.err.println("i:\t" + StringUtil.toHex2(i));
-//System.err.println("sezi:\t" + sezi);
-//System.err.println("sez:\t" + sez);
-//System.err.println("sei:\t" + sei);
-//System.err.println("se:\t" + se);
+//logger.log(Level.DEBUG, "---- (" + (ccc++) + ")");
+//logger.log(Level.DEBUG, "i:\t" + StringUtil.toHex2(i));
+//logger.log(Level.DEBUG, "sezi:\t" + sezi);
+//logger.log(Level.DEBUG, "sez:\t" + sez);
+//logger.log(Level.DEBUG, "sei:\t" + sei);
+//logger.log(Level.DEBUG, "se:\t" + se);
// MIX
int y = state.getStepSize(); // dynamic quantizer step size
diff --git a/src/main/java/vavi/sound/adpcm/ccitt/G723_16.java b/src/main/java/vavi/sound/adpcm/ccitt/G723_16.java
index a33fa80..ccd3749 100644
--- a/src/main/java/vavi/sound/adpcm/ccitt/G723_16.java
+++ b/src/main/java/vavi/sound/adpcm/ccitt/G723_16.java
@@ -72,7 +72,7 @@ class G723_16 extends G711 {
/**
* Comes from quantizer decision level tables (Table 7/G.726)
*/
- private static int[] qtab_723_16 = { 261 };
+ private static final int[] qtab_723_16 = { 261 };
/**
* Encodes a linear PCM, A-law or u-law input sample and returns its 2-bit
diff --git a/src/main/java/vavi/sound/adpcm/ccitt/G723_16InputStream.java b/src/main/java/vavi/sound/adpcm/ccitt/G723_16InputStream.java
index 20ec08c..d3be8c2 100644
--- a/src/main/java/vavi/sound/adpcm/ccitt/G723_16InputStream.java
+++ b/src/main/java/vavi/sound/adpcm/ccitt/G723_16InputStream.java
@@ -35,13 +35,13 @@ protected Codec getCodec() {
public G723_16InputStream(InputStream in, ByteOrder byteOrder) {
super(in, byteOrder, 2, ByteOrder.LITTLE_ENDIAN);
((G723_16) decoder).setEncoding(encoding);
-//Debug.println(this.in);
+//logger.log(Level.DEBUG, this.in);
}
/** ADPCM (4bit) length */
@Override
public int available() throws IOException {
-//Debug.println("0: " + in.available() + ", " + ((in.available() * 2) + (rest ? 1 : 0)));
+//logger.log(Level.DEBUG, "0: " + in.available() + ", " + ((in.available() * 2) + (rest ? 1 : 0)));
return (in.available() * 4) + (rest ? 1 : 0); // TODO check * 4 ???
}
}
diff --git a/src/main/java/vavi/sound/adpcm/ccitt/G723_24.java b/src/main/java/vavi/sound/adpcm/ccitt/G723_24.java
index 148d684..9c5b61c 100644
--- a/src/main/java/vavi/sound/adpcm/ccitt/G723_24.java
+++ b/src/main/java/vavi/sound/adpcm/ccitt/G723_24.java
@@ -45,12 +45,12 @@ class G723_24 extends G711 {
* Maps G.723_24 code word to reconstructed scale factor normalized log
* magnitude values.
*/
- private static int[] _dqlntab = {
+ private static final int[] _dqlntab = {
-2048, 135, 273, 373, 373, 273, 135, -2048
};
/** Maps G.723_24 code word to log of scale factor multiplier. */
- private static int[] _witab = {
+ private static final int[] _witab = {
-128, 960, 4384, 18624, 18624, 4384, 960, -128
};
@@ -59,12 +59,12 @@ class G723_24 extends G711 {
* term averages are computed and then compared to give an indication
* how stationary (steady state) the signal is.
*/
- private static int[] _fitab = {
+ private static final int[] _fitab = {
0, 0x200, 0x400, 0xE00, 0xE00, 0x400, 0x200, 0
};
/** */
- private static int[] qtab_723_24 = { 8, 218, 331 };
+ private static final int[] qtab_723_24 = { 8, 218, 331 };
/**
* Encodes a linear PCM, A-law or u-law input sample and returns its 3-bit
diff --git a/src/main/java/vavi/sound/adpcm/ccitt/State.java b/src/main/java/vavi/sound/adpcm/ccitt/State.java
index c0928c4..c35450f 100644
--- a/src/main/java/vavi/sound/adpcm/ccitt/State.java
+++ b/src/main/java/vavi/sound/adpcm/ccitt/State.java
@@ -81,26 +81,26 @@ class State {
private int ap;
/** Coefficients of pole portion of prediction filter. */
- private int[] a = new int[2];
+ private final int[] a = new int[2];
/** Coefficients of zero portion of prediction filter. */
- private int[] b = new int[6];
+ private final int[] b = new int[6];
/**
* Signs of previous two samples of a partially
* reconstructed signal.
*/
- private int[] pk = new int[2];
+ private final int[] pk = new int[2];
/**
* Previous 6 samples of the quantized difference
* signal represented in an internal floating point
* format.
*/
- private int[] dq = new int[6];
+ private final int[] dq = new int[6];
/**
* Previous 2 samples of the quantized difference
* signal represented in an internal floating point
* format.
*/
- private int[] sr = new int[2];
+ private final int[] sr = new int[2];
/** delayed tone detect, new in 1988 version */
private int td;
@@ -147,7 +147,7 @@ private static int fmult(int an, int srn) {
int retval = (wanexp >= 0) ? ((wanmant << wanexp) & 0x7fff) :
(wanmant >> -wanexp);
-// System.err.println(an + ", " + srn + ": " + ((an ^ srn) < 0 ? -retval : retval));
+//logger.log(Level.DEBUG, an + ", " + srn + ": " + ((an ^ srn) < 0 ? -retval : retval));
return (an ^ srn) < 0 ? -retval : retval;
}
@@ -208,10 +208,10 @@ public int getStepSize() {
*/
public void update(int code_size, int y, int wi, int fi, int _dq, int _sr, int dqsez) {
-//System.err.println("y:\t" + y);
-//System.err.println("dq:\t" + _dq);
-//System.err.println("sr:\t" + _sr);
-//System.err.println("dqsez:\t" + dqsez);
+//logger.log(Level.DEBUG, "y:\t" + y);
+//logger.log(Level.DEBUG, "dq:\t" + _dq);
+//logger.log(Level.DEBUG, "sr:\t" + _sr);
+//logger.log(Level.DEBUG, "dqsez:\t" + dqsez);
// needed in updating predictor poles
int pk0 = (dqsez < 0) ? 1 : 0;
@@ -346,33 +346,33 @@ public void update(int code_size, int y, int wi, int fi, int _dq, int _sr, int d
// FLOAT A : convert dq[0] to 4-bit exp, 6-bit mantissa f.p.
if (mag == 0) {
dq[0] = (_dq >= 0) ? 0x20 : -992;
-//System.err.println("dq[0]:1: " + dq[0]);
+//logger.log(Level.DEBUG, "dq[0]:1: " + dq[0]);
} else {
exp = quan(mag);
dq[0] = (_dq >= 0) ?
(exp << 6) + ((mag << 6) >> exp) :
(exp << 6) + ((mag << 6) >> exp) - 0x400;
-//System.err.println("dq[0]:2: " + dq[0] + ", " + _dq + ", " + exp + ", " + mag);
-//System.err.println("dq[0]:-: " + (exp << 6) + ", " + ((mag << 6) >> exp));
+//logger.log(Level.DEBUG, "dq[0]:2: " + dq[0] + ", " + _dq + ", " + exp + ", " + mag);
+//logger.log(Level.DEBUG, "dq[0]:-: " + (exp << 6) + ", " + ((mag << 6) >> exp));
}
sr[1] = sr[0];
// FLOAT B : convert sr to 4-bit exp., 6-bit mantissa f.p.
if (_sr == 0) {
sr[0] = 0x20;
-//System.err.println("sr[0]:1: " + sr[0]);
+//logger.log(Level.DEBUG, "sr[0]:1: " + sr[0]);
} else if (_sr > 0) {
exp = quan(_sr);
sr[0] = (exp << 6) + ((_sr << 6) >> exp);
-//System.err.println("sr[0]:2: " + sr[0]);
+//logger.log(Level.DEBUG, "sr[0]:2: " + sr[0]);
} else if (_sr > -32768) {
mag = -_sr;
exp = quan(mag);
sr[0] = (exp << 6) + ((mag << 6) >> exp) - 0x400;
-//System.err.println("sr[0]:3: " + sr[0]);
+//logger.log(Level.DEBUG, "sr[0]:3: " + sr[0]);
} else {
sr[0] = -992;
-//System.err.println("sr[0]:4: " + sr[0]);
+//logger.log(Level.DEBUG, "sr[0]:4: " + sr[0]);
}
// DELAY A
diff --git a/src/main/java/vavi/sound/adpcm/dvi/Dvi.java b/src/main/java/vavi/sound/adpcm/dvi/Dvi.java
index f57cdda..bbd9be2 100644
--- a/src/main/java/vavi/sound/adpcm/dvi/Dvi.java
+++ b/src/main/java/vavi/sound/adpcm/dvi/Dvi.java
@@ -81,7 +81,7 @@ private static class State {
}
/** */
- private State state = new State();
+ private final State state = new State();
/** */
public State getState() {
@@ -180,7 +180,7 @@ public int decode(int input) {
//
int valPrev = state.valPrev;
-//System.err.printf("%d\n", valPrev);
+//logger.log(Level.DEBUG, "{}", valPrev);
// Current step change index
int index = state.index;
diff --git a/src/main/java/vavi/sound/adpcm/ima/Ima.java b/src/main/java/vavi/sound/adpcm/ima/Ima.java
index a14bb72..b0caee0 100644
--- a/src/main/java/vavi/sound/adpcm/ima/Ima.java
+++ b/src/main/java/vavi/sound/adpcm/ima/Ima.java
@@ -18,9 +18,10 @@
package vavi.sound.adpcm.ima;
-import java.util.logging.Level;
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
-import vavi.util.Debug;
+import static java.lang.System.getLogger;
/**
@@ -32,6 +33,8 @@
*/
class Ima {
+ private static final Logger logger = getLogger(Ima.class.getName());
+
/** */
public static final int ISSTMAX = 88;
@@ -60,7 +63,7 @@ private static int adjustState(int c) {
}
/** */
- private static int[][] stateAdjustTable = new int[ISSTMAX + 1][8];
+ private static final int[][] stateAdjustTable = new int[ISSTMAX + 1][8];
/* */
static {
@@ -87,13 +90,13 @@ private static int adjustState(int c) {
* @param length samples to decode PER channel, REQUIRE n % 8 == 1
* @param outIncrement index difference between successive output samples
*/
- private void decode(int channel,
- int channels,
- byte[] inBuffer,
- int[] outBuffer,
- int op,
- int length,
- int outIncrement) {
+ private static void decode(int channel,
+ int channels,
+ byte[] inBuffer,
+ int[] outBuffer,
+ int op,
+ int length,
+ int outIncrement) {
// input pointer to 4-byte block state-initializer
int ip = 4 * channel;
@@ -106,7 +109,7 @@ private void decode(int channel,
}
int state = inBuffer[ip + 2] & 0xff;
if (state > ISSTMAX) {
-Debug.println(Level.FINE, "IMA_ADPCM block ch" + channel + " initial-state (" + state + ") out of range");
+logger.log(Level.DEBUG, "IMA_ADPCM block ch" + channel + " initial-state (" + state + ") out of range");
state = 0;
}
// specs say to ignore ip[3] , but write it as 0
@@ -150,13 +153,13 @@ private void decode(int channel,
if (c != cm) {
val -= dp;
if (val < -0x8000) {
-//Debug.println(StringUtil.toHex4(val) + " -> " + (-0x8000));
+//logger.log(Level.DEBUG, String.format("%04x -> %d", val, -0x8000));
val = -0x8000;
}
} else {
val += dp;
if (val > 0x7fff) {
-//Debug.println(StringUtil.toHex4(val) + " -> " + (0x7fff));
+//logger.log(Level.DEBUG, String.format("%04x -> %d", val, 0x7fff));
val = 0x7fff;
}
}
@@ -173,7 +176,7 @@ private void decode(int channel,
* @param outBuffer output samples, n*chans
* @param length samples to decode PER channel, REQUIRE n % 8 == 1
*/
- public void decodeBlock(int channels, byte[] inBuffer, int[] outBuffer, int length) {
+ public static void decodeBlock(int channels, byte[] inBuffer, int[] outBuffer, int length) {
for (int ch = 0; ch < channels; ch++) {
decode(ch, channels, inBuffer, outBuffer, ch, length, channels);
}
@@ -187,7 +190,7 @@ public void decodeBlock(int channels, byte[] inBuffer, int[] outBuffer, int leng
* @param outBuffers chan output sample buffers, each takes n samples
* @param length samples to decode PER channel, REQUIRE n % 8 == 1
*/
- public void decodeBlocks(int channels, byte[] inBuffer, int[][] outBuffers, int length) {
+ public static void decodeBlocks(int channels, byte[] inBuffer, int[][] outBuffers, int length) {
for (int ch = 0; ch < channels; ch++) {
decode(ch, channels, inBuffer, outBuffers[ch], 0, length, 1);
}
@@ -202,7 +205,7 @@ public void decodeBlocks(int channels, byte[] inBuffer, int[][] outBuffers, int
* @param st input/output state, REQUIRE 0 <= *st <= ISSTMAX
* @param obuff output buffer[blockAlign], or null for no output
*/
- private int encode(int ch, int chans, int v0, int[] ibuff, int n, int[] st, int stp, byte[] obuff) {
+ private static int encode(int ch, int chans, int v0, int[] ibuff, int n, int[] st, int stp, byte[] obuff) {
// set 0 only to shut up gcc's 'might be uninitialized'
int o_inc = 0;
@@ -261,7 +264,7 @@ private int encode(int ch, int chans, int v0, int[] ibuff, int n, int[] st, int
op += o_inc; // skip op for next group
}
} else {
-//System.err.println("op: " + op);
+//logger.log(Level.DEBUG, "op: " + op);
obuff[op] = (byte) cm;
}
i = (i + 1) & 0x07;
@@ -409,10 +412,10 @@ public void encodeBlock(int channels, int[] inBuffer, int length, int[] steps, b
*/
public static int getSamplesIn(int dataLength, int channels, int blockAlign, int samplesPerBlock) {
int m, n;
-// Debug.println("dataLength: " + dataLength);
-// Debug.println("channels: " + channels);
-// Debug.println("blockAlign: " + blockAlign);
-// Debug.println("samplesPerBlock: " + samplesPerBlock);
+//logger.log(Level.DEBUG, "dataLength: " + dataLength);
+//logger.log(Level.DEBUG, "channels: " + channels);
+//logger.log(Level.DEBUG, "blockAlign: " + blockAlign);
+//logger.log(Level.DEBUG, "samplesPerBlock: " + samplesPerBlock);
if (samplesPerBlock != 0) {
n = (dataLength / blockAlign) * samplesPerBlock;
@@ -421,8 +424,8 @@ public static int getSamplesIn(int dataLength, int channels, int blockAlign, int
n = 0;
m = blockAlign;
}
-//Debug.println("n: " + n);
-//Debug.println("m: " + m);
+//logger.log(Level.DEBUG, "n: " + n);
+//logger.log(Level.DEBUG, "m: " + m);
if (m >= 4 * channels) {
m -= 4 * channels; // number of bytes beyond block-header
m /= 4 * channels; // number of 4-byte blocks/channel beyond header
diff --git a/src/main/java/vavi/sound/adpcm/ima/ImaInputEngine.java b/src/main/java/vavi/sound/adpcm/ima/ImaInputEngine.java
index 2c4b423..b6a9335 100644
--- a/src/main/java/vavi/sound/adpcm/ima/ImaInputEngine.java
+++ b/src/main/java/vavi/sound/adpcm/ima/ImaInputEngine.java
@@ -10,15 +10,16 @@
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 vavi.io.InputEngine;
import vavi.io.LittleEndianDataInputStream;
-import vavi.util.Debug;
-
import vavix.io.IOStreamInputEngine;
+import static java.lang.System.getLogger;
+
/**
* ImaInputEngine.
@@ -28,7 +29,9 @@
*/
class ImaInputEngine implements InputEngine {
- private OutputStream out;
+ private static final Logger logger = getLogger(ImaInputEngine.class.getName());
+
+ private final OutputStream out;
private final Ima encoder = new Ima();
@@ -47,7 +50,7 @@ public ImaInputEngine(OutputStream out,
this.samplesPerBlock = samplesPerBlock;
this.channels = channels;
this.byteOrder = byteOrder;
-Debug.println(Level.FINE, "byteOrder: " + this.byteOrder);
+logger.log(Level.DEBUG, "byteOrder: " + this.byteOrder);
}
@Override
@@ -73,7 +76,7 @@ public void execute() throws IOException {
throw new IOException("Not yet initialized");
} else {
int bytesPerBlock = Ima.getBytesPerBlock(channels, samplesPerBlock);
-//System.err.println("bytesPerBlock: " + bytesPerBlock + ", samplesPerBlock: " + samplesPerBlock);
+//logger.log(Level.DEBUG, "bytesPerBlock: " + bytesPerBlock + ", samplesPerBlock: " + samplesPerBlock);
byte[] buffer = new byte[samplesPerBlock * 2];
int l = 0;
while (l < buffer.length) {
@@ -86,7 +89,7 @@ public void execute() throws IOException {
if (l > 0) {
byte[] adpcm = new byte[bytesPerBlock];
int[] pcm = new int[l / 2];
-//Debug.println("adpcm: " + bytesPerBlock + ", pcm: " + pcm.length + ", " + l);
+//logger.log(Level.DEBUG, "adpcm: " + bytesPerBlock + ", pcm: " + pcm.length + ", " + l);
LittleEndianDataInputStream ledis = new LittleEndianDataInputStream(new ByteArrayInputStream(buffer));
for (int i = 0; i < pcm.length; i++) {
pcm[i] = ledis.readShort();
@@ -94,7 +97,7 @@ public void execute() throws IOException {
ledis.close();
encoder.encodeBlock(1, pcm, pcm.length, steps, adpcm, 9);
-//Debug.println("adpcm: " + adpcm.length);
+//logger.log(Level.DEBUG, "adpcm: " + adpcm.length);
out.write(adpcm);
}
}
diff --git a/src/main/java/vavi/sound/adpcm/ima/ImaInputStream.java b/src/main/java/vavi/sound/adpcm/ima/ImaInputStream.java
index 7f3e533..69723ed 100644
--- a/src/main/java/vavi/sound/adpcm/ima/ImaInputStream.java
+++ b/src/main/java/vavi/sound/adpcm/ima/ImaInputStream.java
@@ -9,10 +9,13 @@
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.ByteOrder;
import vavi.io.OutputEngineInputStream;
-import vavi.util.Debug;
+
+import static java.lang.System.getLogger;
/**
@@ -23,6 +26,8 @@
*/
public class ImaInputStream extends FilterInputStream {
+ private static final Logger logger = getLogger(ImaInputStream.class.getName());
+
/**
* byte order is little endian
*/
@@ -107,7 +112,7 @@ public int read(byte[] b, int off, int len) throws IOException {
}
}
} catch (IOException e) {
- Debug.printStackTrace(e);
+ logger.log(Level.ERROR, e.getMessage(), e);
}
return i;
}
diff --git a/src/main/java/vavi/sound/adpcm/ima/ImaOutputEngine.java b/src/main/java/vavi/sound/adpcm/ima/ImaOutputEngine.java
index 8250cfd..41a7b6a 100644
--- a/src/main/java/vavi/sound/adpcm/ima/ImaOutputEngine.java
+++ b/src/main/java/vavi/sound/adpcm/ima/ImaOutputEngine.java
@@ -24,18 +24,18 @@
class ImaOutputEngine implements OutputEngine {
/** */
- private InputStream in;
+ private final InputStream in;
/** */
- private Ima decoder = new Ima();
+ private final Ima decoder = new Ima();
/** */
private DataOutputStream out;
- private int samplesPerBlock;
- private int channels;
- private int blockSize;
- private ByteOrder byteOrder;
+ private final int samplesPerBlock;
+ private final int channels;
+ private final int blockSize;
+ private final ByteOrder byteOrder;
private byte[] packet;
private int[] samples;
diff --git a/src/main/java/vavi/sound/adpcm/ms/Ms.java b/src/main/java/vavi/sound/adpcm/ms/Ms.java
index 5a9f3c4..170c92c 100644
--- a/src/main/java/vavi/sound/adpcm/ms/Ms.java
+++ b/src/main/java/vavi/sound/adpcm/ms/Ms.java
@@ -18,9 +18,10 @@
package vavi.sound.adpcm.ms;
-import java.util.logging.Level;
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
-import vavi.util.Debug;
+import static java.lang.System.getLogger;
/**
@@ -45,11 +46,13 @@
*/
class Ms {
+ private static final Logger logger = getLogger(Ms.class.getName());
+
/** */
private static class State {
/** step size */
int step;
- int[] iCoef = new int[2];
+ final int[] iCoef = new int[2];
}
/**
@@ -82,22 +85,22 @@ private static class State {
/**
* @param sp state pointer
*/
- private int decode(int code,
- State[] state,
- int sp,
- int sample1,
- int sample2) {
+ private static int decode(int code,
+ State[] state,
+ int sp,
+ int sample1,
+ int sample2) {
// Compute next step value
int step = state[sp].step;
int nstep = (stepAdjustTable[code] * step) >> 8;
- state[sp].step = (nstep < 16) ? 16 : nstep;
+ state[sp].step = Math.max(nstep, 16);
// make linear prediction for next sample
int vlin = ((sample1 * state[sp].iCoef[0]) +
(sample2 * state[sp].iCoef[1])) >> 8;
-//System.err.println(vlin);
+//logger.log(Level.DEBUG, vlin);
// then add the code * step adjustment
code -= (code & 0x08) << 1;
int sample = (code * step) + vlin;
@@ -135,7 +138,7 @@ public void decodeBlock(int channels,
for (int channel = 0; channel < channels; channel++) {
int bpred = inBuffer[ip++] & 0xff;
if (bpred >= nCoef) {
-Debug.println(Level.FINE, "MSADPCM bpred >= nCoef, arbitrarily using 0");
+logger.log(Level.DEBUG, "MSADPCM bpred >= nCoef, arbitrarily using 0");
bpred = 0;
}
state[channel] = new State();
@@ -148,7 +151,7 @@ public void decodeBlock(int channels,
if ((value & 0x8000) != 0) {
value -= 0x10000;
}
-//System.err.println("1: " + value);
+//logger.log(Level.DEBUG, "1: " + value);
state[channel].step = value;
ip += 2;
}
@@ -159,7 +162,7 @@ public void decodeBlock(int channels,
if ((value & 0x8000) != 0) {
value -= 0x10000;
}
-//System.err.println("2: " + value);
+//logger.log(Level.DEBUG, "2: " + value);
outBuffer[channels + channel] = value;
ip += 2;
}
@@ -170,7 +173,7 @@ public void decodeBlock(int channels,
if ((value & 0x8000) != 0) {
value -= 0x10000;
}
-//System.err.println("3: " + value);
+//logger.log(Level.DEBUG, "3: " + value);
outBuffer[channel] = value;
ip += 2;
}
@@ -208,15 +211,15 @@ public void decodeBlock(int channels,
* @param outBuffer output buffer[blockAlign], or NULL for no output
* @return ???
*/
- private int encode(int channel,
- int channels,
- int[] v,
- int[] iCoef,
- int[] inBuffer,
- int length,
- int[] steps,
- int sp,
- byte[] outBuffer) {
+ private static int encode(int channel,
+ int channels,
+ int[] v,
+ int[] iCoef,
+ int[] inBuffer,
+ int length,
+ int[] steps,
+ int sp,
+ byte[] outBuffer) {
int ox = 0; //
@@ -259,7 +262,7 @@ private int encode(int channel,
// difference between linear prediction and current sample
d = inBuffer[ip] - vlin;
int dp = d + (step << 3) + (step >> 1);
-//System.err.println("vlin: " + vlin + ", d: " + d + ", dp: " + dp + ", in: " + inBuffer[ip] + ", coef: " + iCoef[0] + ", " + iCoef[1]);
+//logger.log(Level.DEBUG, "vlin: " + vlin + ", d: " + d + ", dp: " + dp + ", in: " + inBuffer[ip] + ", coef: " + iCoef[0] + ", " + iCoef[1]);
int c = 0;
if (dp > 0) {
c = dp / step;
@@ -286,7 +289,7 @@ private int encode(int channel,
// FIXME does c << 0 work properly ?
outBuffer[op + (ox >> 3)] |= (byte) ((ox & 4) != 0 ? c : (c << 4));
ox += 4 * channels;
-//System.err.printf("%1x\n", c);
+//logger.log(Level.DEBUG, String.format("%1x", c));
}
// Update the step for the next sample
@@ -296,9 +299,9 @@ private int encode(int channel,
}
}
//if (outBuffer != null)
-// System.err.print("\n");
+// logger.log(Level.DEBUG, "");
d2 /= length; // be sure it's non-negative
-//System.err.printf("ch%d: st %d->%d, d %.1f\n", channel, steps[sp], step, Math.sqrt(d2));
+//logger.log(Level.DEBUG, String.format("ch%d: st %d->%d, d %.1f", channel, steps[sp], step, Math.sqrt(d2)));
steps[sp] = step;
return (int) Math.sqrt(d2);
@@ -315,13 +318,13 @@ private int encode(int channel,
* @param sp steps pointer
* @param outBuffer output buffer[blockAlign]
*/
- private void encodeChannel(int channel,
- int channels,
- int[] inBuffer,
- int length,
- int[] steps,
- int sp,
- byte[] outBuffer) {
+ private static void encodeChannel(int channel,
+ int channels,
+ int[] inBuffer,
+ int length,
+ int[] steps,
+ int sp,
+ byte[] outBuffer) {
int[] v = new int[2];
int[] ss = new int[1];
@@ -351,7 +354,7 @@ private void encodeChannel(int channel,
s1[0] = s0;
encode(channel, channels, v, _iCoef[k], inBuffer, n0, s1, 0, null);
-//System.err.printf(" s32 %d\n", s1[0]);
+//logger.log(Level.DEBUG, String.format(" s32 %d", s1[0]));
ss[0] = (3 * s0 + s1[0]) / 4;
s1[0] = ss[0];
@@ -369,7 +372,7 @@ private void encodeChannel(int channel,
}
}
steps[sp] = smin;
-//System.err.printf("kmin %d, smin %5d, \n", kmin, smin);
+//logger.log(Level.DEBUG, String.format("kmin %d, smin %5d, ", kmin, smin));
encode(channel, channels, v, _iCoef[kmin], inBuffer, length, steps, sp, outBuffer);
outBuffer[channel] = (byte) kmin;
}
@@ -419,8 +422,8 @@ public static int getSamplesIn(int dataLength,
n = 0;
m = blockAlign;
}
-//Debug.println("n: " + n);
-//Debug.println("m: " + m);
+//logger.log(Level.DEBUG, "n: " + n);
+//logger.log(Level.DEBUG, "m: " + m);
if (m >= 7 * channels) {
m -= 7 * channels; // bytes beyond block-header
m = (2 * m) / channels + 2; // nibbles / channels + 2 in header
diff --git a/src/main/java/vavi/sound/adpcm/ms/MsInputEngine.java b/src/main/java/vavi/sound/adpcm/ms/MsInputEngine.java
index dbfb4b1..b9fc2f0 100644
--- a/src/main/java/vavi/sound/adpcm/ms/MsInputEngine.java
+++ b/src/main/java/vavi/sound/adpcm/ms/MsInputEngine.java
@@ -10,15 +10,16 @@
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 vavi.io.InputEngine;
import vavi.io.LittleEndianDataInputStream;
-import vavi.util.Debug;
-
import vavix.io.IOStreamInputEngine;
+import static java.lang.System.getLogger;
+
/**
* MsInputEngine.
@@ -28,15 +29,17 @@
*/
class MsInputEngine implements InputEngine {
- private OutputStream out;
+ private static final Logger logger = getLogger(MsInputEngine.class.getName());
+
+ private final OutputStream out;
- private Ms encoder = new Ms();
+ private final Ms encoder = new Ms();
private InputStream in;
- private int samplesPerBlock;
- private int channels;
- private ByteOrder byteOrder;
+ private final int samplesPerBlock;
+ private final int channels;
+ private final ByteOrder byteOrder;
/** */
public MsInputEngine(OutputStream out,
@@ -47,7 +50,7 @@ public MsInputEngine(OutputStream out,
this.samplesPerBlock = samplesPerBlock;
this.channels = channels;
this.byteOrder = byteOrder;
-Debug.println(Level.FINE, "byteOrder: " + this.byteOrder);
+logger.log(Level.DEBUG, "byteOrder: " + this.byteOrder);
}
@Override
@@ -60,7 +63,7 @@ public void initialize(InputStream in) throws IOException {
}
/** */
- private int[] steps = new int[16];
+ private final int[] steps = new int[16];
/**
* because {@link #in} reads only {@link #samplesPerBlock} * 2 bytes, bufferSize for
@@ -73,7 +76,7 @@ public void execute() throws IOException {
throw new IOException("Not yet initialized");
} else {
int bytesPerBlock = Ms.getBytesPerBlock(channels, samplesPerBlock);
-//System.err.println("bytesPerBlock: " + bytesPerBlock + ", samplesPerBlock: " + samplesPerBlock);
+//logger.log(Level.DEBUG, "bytesPerBlock: " + bytesPerBlock + ", samplesPerBlock: " + samplesPerBlock);
byte[] buffer = new byte[samplesPerBlock * 2];
int l = 0;
while (l < buffer.length) {
@@ -83,18 +86,18 @@ public void execute() throws IOException {
}
l += r;
}
-//System.err.println(StringUtil.getDump(buffer, 128));
+//logger.log(Level.DEBUG, StringUtil.getDump(buffer, 128));
if (l > 0) {
byte[] adpcm = new byte[bytesPerBlock];
int[] pcm = new int[l / 2];
-//Debug.println("adpcm: " + bytesPerBlock + ", pcm: " + pcm.length + ", " + l);
+//logger.log(Level.DEBUG, "adpcm: " + bytesPerBlock + ", pcm: " + pcm.length + ", " + l);
LittleEndianDataInputStream ledis = new LittleEndianDataInputStream(new ByteArrayInputStream(buffer));
for (int i = 0; i < pcm.length; i++) {
pcm[i] = ledis.readShort();
}
ledis.close();
encoder.encodeBlock(1, pcm, pcm.length, steps, adpcm, bytesPerBlock);
-//System.err.println(StringUtil.getDump(adpcm, 128));
+//logger.log(Level.DEBUG, StringUtil.getDump(adpcm, 128));
out.write(adpcm);
}
diff --git a/src/main/java/vavi/sound/adpcm/ms/MsInputStream.java b/src/main/java/vavi/sound/adpcm/ms/MsInputStream.java
index f840581..d9c16ba 100644
--- a/src/main/java/vavi/sound/adpcm/ms/MsInputStream.java
+++ b/src/main/java/vavi/sound/adpcm/ms/MsInputStream.java
@@ -9,11 +9,13 @@
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.ByteOrder;
-import java.util.logging.Level;
import vavi.io.OutputEngineInputStream;
-import vavi.util.Debug;
+
+import static java.lang.System.getLogger;
/**
@@ -24,6 +26,8 @@
*/
public class MsInputStream extends FilterInputStream {
+ private static final Logger logger = getLogger(MsInputStream.class.getName());
+
/**
* byte order little endian
*/
@@ -61,9 +65,9 @@ public MsInputStream(InputStream in,
channels,
blockSize,
samplesPerBlock);
-Debug.println(Level.FINER, "numSamples: " + numSamples);
+logger.log(Level.TRACE, "numSamples: " + numSamples);
this.available = numSamples * channels * bytesPerSample;
-Debug.println(Level.FINER, "available: " + available);
+logger.log(Level.TRACE, "available: " + available);
}
/** */
@@ -109,7 +113,7 @@ public int read(byte[] b, int off, int len) throws IOException {
}
}
} catch (IOException e) {
-e.printStackTrace(System.err);
+logger.log(Level.ERROR, e.getMessage(), e);
}
return i;
}
diff --git a/src/main/java/vavi/sound/adpcm/ms/MsOutputEngine.java b/src/main/java/vavi/sound/adpcm/ms/MsOutputEngine.java
index 63fbf0f..46880e9 100644
--- a/src/main/java/vavi/sound/adpcm/ms/MsOutputEngine.java
+++ b/src/main/java/vavi/sound/adpcm/ms/MsOutputEngine.java
@@ -24,20 +24,20 @@
class MsOutputEngine implements OutputEngine {
/** */
- private InputStream in;
+ private final InputStream in;
/** */
- private Ms decoder = new Ms();
+ private final Ms decoder = new Ms();
/** */
private DataOutputStream out;
- private int samplesPerBlock;
- private int nCoefs;
- private int[][] iCoefs;
- private int channels;
- private int blockSize;
- private ByteOrder byteOrder;
+ private final int samplesPerBlock;
+ private final int nCoefs;
+ private final int[][] iCoefs;
+ private final int channels;
+ private final int blockSize;
+ private final ByteOrder byteOrder;
private byte[] packet;
private int[] samples;
diff --git a/src/main/java/vavi/sound/adpcm/oki/OkiInputStream.java b/src/main/java/vavi/sound/adpcm/oki/OkiInputStream.java
index 648403e..33d4a4e 100644
--- a/src/main/java/vavi/sound/adpcm/oki/OkiInputStream.java
+++ b/src/main/java/vavi/sound/adpcm/oki/OkiInputStream.java
@@ -7,12 +7,14 @@
package vavi.sound.adpcm.oki;
import java.io.InputStream;
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
import java.nio.ByteOrder;
-import java.util.logging.Level;
import vavi.sound.adpcm.AdpcmInputStream;
import vavi.sound.adpcm.Codec;
-import vavi.util.Debug;
+
+import static java.lang.System.getLogger;
/**
@@ -23,6 +25,8 @@
*/
public class OkiInputStream extends AdpcmInputStream {
+ private static final Logger logger = getLogger(OkiInputStream.class.getName());
+
@Override
protected Codec getCodec() {
return new Oki();
@@ -34,6 +38,6 @@ protected Codec getCodec() {
*/
public OkiInputStream(InputStream in, ByteOrder byteOrder) {
super(in, byteOrder, 4, ByteOrder.LITTLE_ENDIAN); // oki adpcm is little endian fixed
-Debug.println(Level.FINE, this.in);
+logger.log(Level.DEBUG, this.in);
}
}
diff --git a/src/main/java/vavi/sound/adpcm/vox/Vox.java b/src/main/java/vavi/sound/adpcm/vox/Vox.java
index 35768e0..d52c12e 100644
--- a/src/main/java/vavi/sound/adpcm/vox/Vox.java
+++ b/src/main/java/vavi/sound/adpcm/vox/Vox.java
@@ -33,7 +33,7 @@ private static class State {
};
/** */
- private State state = new State();
+ private final State state = new State();
@Override
public int encode(int samp) {
@@ -58,7 +58,7 @@ public int encode(int samp) {
}
state.last = decode(code);
-//System.err.printf("%04X -> %02X\n", samp, code);
+//logger.log(Level.DEBUG, String.format("%04X -> %02X", samp, code));
return code;
}
@@ -103,7 +103,7 @@ public int decode(int code) {
}
/** */
- private int adjust(int code) {
+ private static int adjust(int code) {
int c = code & 0x07;
if (c < 4) {
return -1;
diff --git a/src/main/java/vavi/sound/adpcm/vox/VoxInputStream.java b/src/main/java/vavi/sound/adpcm/vox/VoxInputStream.java
index 9330967..f4b6801 100644
--- a/src/main/java/vavi/sound/adpcm/vox/VoxInputStream.java
+++ b/src/main/java/vavi/sound/adpcm/vox/VoxInputStream.java
@@ -37,7 +37,7 @@ public VoxInputStream(InputStream in, ByteOrder byteOrder) {
@Override
public int available() throws IOException {
-//Debug.println("0: " + in.available() + ", " + ((in.available() * 2) + (rest ? 1 : 0)));
+//logger.log(Level.DEBUG, "0: " + in.available() + ", " + ((in.available() * 2) + (rest ? 1 : 0)));
return (in.available() * 2) + (rest ? 1 : 0);
}
@@ -46,7 +46,7 @@ public int available() throws IOException {
*/
@Override
public int read() throws IOException {
-//Debug.println(in);
+//logger.log(Level.DEBUG, in);
if (!rest) {
int adpcm = in.read();
if (adpcm == -1) {
@@ -56,7 +56,7 @@ public int read() throws IOException {
current = decoder.decode(adpcm) * 16; // TODO check!!!
rest = true;
-//Debug.println("1: " + StringUtil.toHex2(current & 0xff));
+//logger.log(Level.DEBUG, "1: " + StringUtil.toHex2(current & 0xff));
if (ByteOrder.BIG_ENDIAN.equals(byteOrder)) {
return (current & 0xff00) >> 8;
} else {
@@ -64,7 +64,7 @@ public int read() throws IOException {
}
} else {
rest = false;
-//Debug.println("2: " + StringUtil.toHex2((current & 0xff00) >> 8));
+//logger.log(Level.DEBUG, "2: " + StringUtil.toHex2((current & 0xff00) >> 8));
if (ByteOrder.BIG_ENDIAN.equals(byteOrder)) {
return current & 0xff;
} else {
diff --git a/src/main/java/vavi/sound/adpcm/vox/VoxOutputStream.java b/src/main/java/vavi/sound/adpcm/vox/VoxOutputStream.java
index 730ea38..192e8a3 100644
--- a/src/main/java/vavi/sound/adpcm/vox/VoxOutputStream.java
+++ b/src/main/java/vavi/sound/adpcm/vox/VoxOutputStream.java
@@ -55,7 +55,7 @@ public void write(int b) throws IOException {
}
}
-// System.err.println("current: " + StringUtil.toHex4(current));
+//logger.log(Level.DEBUG, "current: " + StringUtil.toHex4(current));
out.write(encoder.encode(current / 16)); // BitOutputStream write 4bit
flushed = true;
diff --git a/src/main/java/vavi/sound/adpcm/yamaha/Yamaha.java b/src/main/java/vavi/sound/adpcm/yamaha/Yamaha.java
index 728bbb5..bec747a 100644
--- a/src/main/java/vavi/sound/adpcm/yamaha/Yamaha.java
+++ b/src/main/java/vavi/sound/adpcm/yamaha/Yamaha.java
@@ -24,14 +24,14 @@ private static class Status {
}
/** You need initialize before reuse methods! */
- private Status stat = new Status();
+ private final Status stat = new Status();
/**
* @param code ADPCM (LSB 4bit available)
* @param ss ?
* @return adjusted ss
*/
- private int adjust(int code, int ss) {
+ private static int adjust(int code, int ss) {
switch (code & 0x07) {
case 0x00:
case 0x01:
@@ -123,7 +123,7 @@ public int encode(int samp) {
}
stat.last = decode(code);
-//System.err.printf("%04X -> %02X\n", samp, code);
+//logger.log(Level.DEBUG, String.format("%04X -> %02X", samp, code));
return code;
}
}
diff --git a/src/main/java/vavi/sound/adpcm/ym2608/Ym2608.java b/src/main/java/vavi/sound/adpcm/ym2608/Ym2608.java
index e5ed2b2..d725a91 100644
--- a/src/main/java/vavi/sound/adpcm/ym2608/Ym2608.java
+++ b/src/main/java/vavi/sound/adpcm/ym2608/Ym2608.java
@@ -31,7 +31,7 @@ void next() {
}
/** */
- private State state = new State();
+ private final State state = new State();
/** */
private static final int[] stepsizeTable = {
@@ -48,12 +48,12 @@ public int encode(int pcm) {
// encoding process 2
long dn = pcm - state.xn;
-//System.err.printf("%05d: %d, %d, %d\n", ccc, dn, pcm, state.xn); // OK
+//logger.log(Level.DEBUG, String.format("%05d: %d, %d, %d", ccc, dn, pcm, state.xn)); // OK
// encoding process 3, 4
// calc An from "I = | dn | / Sn"
// calc using integer part of production.
long i = (int) (((Math.abs(dn)) << 16) / ((state.stepSize) << 14));
-//System.err.printf("%05d: %d\n", ccc, i); // OK
+//logger.log(Level.DEBUG, String.format("%05d: %d", ccc, i)); // OK
if (i > 7) {
i = 7;
}
@@ -62,7 +62,7 @@ public int encode(int pcm) {
// encoding process 5
// L3 + L2 / 2 + L1 / 4 + 1 / 8 * stepSize multiply 8 times and calc as integer
i = (adpcm * 2L + 1) * state.stepSize / 8;
-//System.err.printf("%05d: %d, %d, %d\n", ccc, i, adpcm, state.stepSize); // OK
+//logger.log(Level.DEBUG, String.format("%05d: %d, %d, %d", ccc, i, adpcm, state.stepSize)); // OK
// if "1 - 2 * L4 -> L4" is 1 equals multiply -1
if (dn < 0) {
@@ -74,12 +74,12 @@ public int encode(int pcm) {
} else {
state.xn += i;
}
-//System.err.printf("%05d: %d, %d\n", ccc, state.xn, i);
+//logger.log(Level.DEBUG, String.format("%05d: %d, %d", ccc, state.xn, i));
// encode process 6
// update step size
state.stepSize = (stepsizeTable[adpcm] * state.stepSize) / 64;
-//System.err.printf("%05d: %d, %d, %d\n", ccc, i, adpcm, state.stepSize); // OK
+//logger.log(Level.DEBUG, String.format("%05d: %d, %d, %d", ccc, i, adpcm, state.stepSize)); // OK
// encode process 7
if (state.stepSize < 127) {
@@ -108,7 +108,7 @@ public int decode(int adpcm) {
} else {
state.xn += i;
}
-//System.err.printf("%05d: %d, %d, %d\n", state.count, state.xn, state.stepSize, adpcm); // OK
+//logger.log(Level.DEBUG, String.format("%05d: %d, %d, %d", state.count, state.xn, state.stepSize, adpcm)); // OK
// decode process 4
if (state.xn > 32767) {
@@ -125,7 +125,7 @@ public int decode(int adpcm) {
} else if (state.stepSize > 24576) {
state.stepSize = 24576;
}
-// System.err.printf("%05d: %d, %d, %d\n", state.count, state.xn, state.stepSize, adpcm); // OK
+//logger.log(Level.DEBUG, String.format("%05d: %d, %d, %d", state.count, state.xn, state.stepSize, adpcm)); // OK
// store PCM
int pcm = (int) state.xn;
diff --git a/src/main/java/vavi/sound/mfi/MfiDevice.java b/src/main/java/vavi/sound/mfi/MfiDevice.java
index d46f486..dbd3665 100644
--- a/src/main/java/vavi/sound/mfi/MfiDevice.java
+++ b/src/main/java/vavi/sound/mfi/MfiDevice.java
@@ -19,13 +19,13 @@ public interface MfiDevice {
class Info {
/** */
- String name;
+ final String name;
/** */
- String vendor;
+ final String vendor;
/** */
- String description;
+ final String description;
/** */
- String version;
+ final String version;
/** */
protected Info(String name,
diff --git a/src/main/java/vavi/sound/mfi/MfiEvent.java b/src/main/java/vavi/sound/mfi/MfiEvent.java
index 5552a27..3e8b6d6 100644
--- a/src/main/java/vavi/sound/mfi/MfiEvent.java
+++ b/src/main/java/vavi/sound/mfi/MfiEvent.java
@@ -18,7 +18,7 @@
public class MfiEvent {
/** */
- private MfiMessage message;
+ private final MfiMessage message;
/** */
private long tick;
diff --git a/src/main/java/vavi/sound/mfi/MfiFileFormat.java b/src/main/java/vavi/sound/mfi/MfiFileFormat.java
index 16c955d..da9cfc2 100644
--- a/src/main/java/vavi/sound/mfi/MfiFileFormat.java
+++ b/src/main/java/vavi/sound/mfi/MfiFileFormat.java
@@ -19,7 +19,7 @@ public class MfiFileFormat {
protected int byteLength;
/** */
- protected int type;
+ protected final int type;
/** */
public MfiFileFormat(int type, int bytes) {
diff --git a/src/main/java/vavi/sound/mfi/MfiSystem.java b/src/main/java/vavi/sound/mfi/MfiSystem.java
index 683270d..e8f5342 100644
--- a/src/main/java/vavi/sound/mfi/MfiSystem.java
+++ b/src/main/java/vavi/sound/mfi/MfiSystem.java
@@ -12,13 +12,14 @@
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.net.URL;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import java.util.ServiceLoader;
-import java.util.logging.Level;
import java.util.stream.StreamSupport;
import javax.sound.midi.InvalidMidiDataException;
@@ -26,7 +27,8 @@
import vavi.sound.mfi.spi.MfiDeviceProvider;
import vavi.sound.mfi.spi.MfiFileReader;
import vavi.sound.mfi.spi.MfiFileWriter;
-import vavi.util.Debug;
+
+import static java.lang.System.getLogger;
/**
@@ -41,6 +43,8 @@
*/
public final class MfiSystem {
+ private static final Logger logger = getLogger(MfiSystem.class.getName());
+
/** cannot be access */
private MfiSystem() {
}
@@ -138,7 +142,7 @@ public static javax.sound.midi.Sequence toMidiSequence(Sequence sequence)
throws InvalidMfiDataException, MfiUnavailableException {
MidiConverter converter = MfiSystem.getMidiConverter();
-//Debug.println(converter);
+//logger.log(Level.DEBUG, converter);
return converter.toMidiSequence(sequence);
}
@@ -146,14 +150,14 @@ public static javax.sound.midi.Sequence toMidiSequence(Sequence sequence)
public static MfiFileFormat getMfiFileFormat(InputStream stream)
throws InvalidMfiDataException, IOException {
-//Debug.println("readers: " + readers.length);
+//logger.log(Level.DEBUG, "readers: " + readers.length);
for (MfiFileReader reader : readers) {
try {
MfiFileFormat mff = reader.getMfiFileFormat(stream);
-//Debug.println(StringUtil.paramString(mff));
+//logger.log(Level.DEBUG, StringUtil.paramString(mff));
return mff;
} catch (Exception e) {
-Debug.println(Level.WARNING, e);
+logger.log(Level.WARNING, e.getMessage(), e);
}
}
@@ -175,15 +179,14 @@ public static MfiFileFormat getMfiFileFormat(URL url) throws InvalidMfiDataExcep
/** Gets a MFi sequence. */
public static Sequence getSequence(InputStream stream) throws InvalidMfiDataException, IOException {
-//Debug.println("readers: " + readers.length);
+//logger.log(Level.DEBUG, "readers: " + readers.length);
for (MfiFileReader reader : readers) {
try {
Sequence sequence = reader.getSequence(stream);
-//Debug.println(StringUtil.paramString(sequence));
+//logger.log(Level.DEBUG, StringUtil.paramString(sequence));
return sequence;
} catch (InvalidMfiDataException e) {
-Debug.println(Level.FINE, e);
- continue;
+logger.log(Level.DEBUG, e);
}
}
@@ -256,7 +259,7 @@ public static int write(Sequence in, int fileType, OutputStream out) throws IOEx
return writer.write(in, fileType, out);
}
}
-Debug.println(Level.WARNING, "no writer found for: " + fileType);
+logger.log(Level.WARNING, "no writer found for: " + fileType);
return 0;
}
@@ -269,14 +272,14 @@ public static int write(Sequence in, int fileType, File out) throws IOException
//----
/** all providers */
- private static ServiceLoader providers;
+ private static final ServiceLoader providers;
/** all readers */
- private static ServiceLoader readers;
+ private static final ServiceLoader readers;
/** all writers */
- private static ServiceLoader writers;
+ private static final ServiceLoader writers;
/** default provider */
- private static MfiDeviceProvider provider;
+ private static final MfiDeviceProvider provider;
/*
* default is specified by MfiSystem.properties.
@@ -294,7 +297,7 @@ public static int write(Sequence in, int fileType, File out) throws IOException
providers = ServiceLoader.load(vavi.sound.mfi.spi.MfiDeviceProvider.class);
providers.forEach(System.err::println);
provider = StreamSupport.stream(providers.spliterator(), false).filter(p -> p.getClass().getName().equals(defaultProvider)).findFirst().get();
-Debug.println(Level.FINE, "default provider: " + provider.getClass().getName());
+logger.log(Level.DEBUG, "default provider: " + provider.getClass().getName());
readers = ServiceLoader.load(vavi.sound.mfi.spi.MfiFileReader.class);
providers.forEach(System.err::println);
@@ -302,7 +305,7 @@ public static int write(Sequence in, int fileType, File out) throws IOException
writers = ServiceLoader.load(vavi.sound.mfi.spi.MfiFileWriter.class);
providers.forEach(System.err::println);
} catch (Exception e) {
-Debug.println(Level.SEVERE, e);
+logger.log(Level.ERROR, e.getMessage(), e);
throw new IllegalStateException(e);
}
}
diff --git a/src/main/java/vavi/sound/mfi/NoteMessage.java b/src/main/java/vavi/sound/mfi/NoteMessage.java
index 5cb89e2..cfdc4f8 100644
--- a/src/main/java/vavi/sound/mfi/NoteMessage.java
+++ b/src/main/java/vavi/sound/mfi/NoteMessage.java
@@ -107,18 +107,17 @@ protected NoteMessage() {
* @return note
*/
public int getNote() {
- switch (shift) {
- case 1: // 01
- return note + 12;
- case 0: // 00
- return note;
- case 3: // 11
- return note - 12;
- case 2: // 10
- return note - 24;
- default:
- throw new IllegalArgumentException("shift: " + shift);
- }
+ return switch (shift) {
+ case 1 -> // 01
+ note + 12;
+ case 0 -> // 00
+ note;
+ case 3 -> // 11
+ note - 12;
+ case 2 -> // 10
+ note - 24;
+ default -> throw new IllegalArgumentException("shift: " + shift);
+ };
}
/**
diff --git a/src/main/java/vavi/sound/mfi/Sequence.java b/src/main/java/vavi/sound/mfi/Sequence.java
index 5f838fd..9cbc39c 100644
--- a/src/main/java/vavi/sound/mfi/Sequence.java
+++ b/src/main/java/vavi/sound/mfi/Sequence.java
@@ -23,7 +23,7 @@
public class Sequence {
/** */
- protected List
+ * system property
+ *
+ * - vavi.sound.mobile.AudioEngine.volume ... adpcm volume
+ *
* @author Naohide Sano (nsano)
* @version 0.00 051116 nsano initial version
*/
public interface AudioEngine {
+ // TODO interlock midi volume
double volume = Double.parseDouble(System.getProperty("vavi.sound.mobile.AudioEngine.volume", "0.2"));
/**
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/mobile/readme.md b/src/main/java/vavi/sound/mobile/readme.md
index 985dd71..9b7581b 100644
--- a/src/main/java/vavi/sound/mobile/readme.md
+++ b/src/main/java/vavi/sound/mobile/readme.md
@@ -1,7 +1,7 @@
# vavi.sound.mobile
-mobile 用の wave シーケンサのクラスを提供します。
+Provides a wave sequencer class for mobile.
## TODO
- * continued がおかしい
+ * something is wrong with `continued`
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 tracks;
+ protected final List tracks;
/** Creates a sequence. */
public Sequence() {
diff --git a/src/main/java/vavi/sound/smaf/SmafDevice.java b/src/main/java/vavi/sound/smaf/SmafDevice.java
index 515fcc9..fa483d3 100644
--- a/src/main/java/vavi/sound/smaf/SmafDevice.java
+++ b/src/main/java/vavi/sound/smaf/SmafDevice.java
@@ -19,13 +19,13 @@ public interface SmafDevice {
class Info {
/** */
- String name;
+ final String name;
/** */
- String vendor;
+ final String vendor;
/** */
- String description;
+ final String description;
/** */
- String version;
+ final String version;
/** */
protected Info(String name,
diff --git a/src/main/java/vavi/sound/smaf/SmafDeviceProvider.java b/src/main/java/vavi/sound/smaf/SmafDeviceProvider.java
index 9d96556..c5ec568 100644
--- a/src/main/java/vavi/sound/smaf/SmafDeviceProvider.java
+++ b/src/main/java/vavi/sound/smaf/SmafDeviceProvider.java
@@ -6,13 +6,15 @@
package vavi.sound.smaf;
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
-import vavi.util.Debug;
+import static java.lang.System.getLogger;
/**
@@ -23,11 +25,13 @@
*/
public class SmafDeviceProvider {
+ private static final Logger logger = getLogger(SmafDeviceProvider.class.getName());
+
/** */
public static final String version = "1.0.10";
/** */
- private SmafDevice.Info[] smafDeviceInfos;
+ private final SmafDevice.Info[] smafDeviceInfos;
/** */
public SmafDeviceProvider() {
@@ -73,7 +77,7 @@ public static SmafDevice getSmafDevice(SmafDevice.Info smafDeviceInfo) {
try {
return deviceMap.get(smafDeviceInfo).getDeclaredConstructor().newInstance();
} catch (Exception e) {
-Debug.printStackTrace(e);
+logger.log(Level.ERROR, e.getMessage(), e);
}
}
@@ -81,7 +85,7 @@ public static SmafDevice getSmafDevice(SmafDevice.Info smafDeviceInfo) {
}
/** */
- private static Map> deviceMap = new HashMap<>();
+ private static final Map> deviceMap = new HashMap<>();
/* */
static {
@@ -97,14 +101,14 @@ public static SmafDevice getSmafDevice(SmafDevice.Info smafDeviceInfo) {
if (key.startsWith("smaf.device.")) {
@SuppressWarnings("unchecked")
Class deviceClass = (Class) Class.forName(props.getProperty(key));
-//Debug.println("smaf device class: " + StringUtil.getClassName(clazz));
+//logger.log(Level.DEBUG, "smaf device class: " + StringUtil.getClassName(clazz));
SmafDevice.Info smafDeviceInfo = deviceClass.getDeclaredConstructor().newInstance().getDeviceInfo();
deviceMap.put(smafDeviceInfo, deviceClass);
}
}
} catch (Exception e) {
-Debug.printStackTrace(e);
+logger.log(Level.ERROR, e.getMessage(), e);
throw new IllegalStateException(e);
}
}
diff --git a/src/main/java/vavi/sound/smaf/SmafEvent.java b/src/main/java/vavi/sound/smaf/SmafEvent.java
index a3241b8..14f0167 100644
--- a/src/main/java/vavi/sound/smaf/SmafEvent.java
+++ b/src/main/java/vavi/sound/smaf/SmafEvent.java
@@ -16,10 +16,10 @@
public class SmafEvent {
/** */
- private long tick;
+ private final long tick;
/** */
- private SmafMessage smafMessage;
+ private final SmafMessage smafMessage;
/**
* @param smafMessage
diff --git a/src/main/java/vavi/sound/smaf/SmafFileWriter.java b/src/main/java/vavi/sound/smaf/SmafFileWriter.java
index c472a5a..9f448bb 100644
--- a/src/main/java/vavi/sound/smaf/SmafFileWriter.java
+++ b/src/main/java/vavi/sound/smaf/SmafFileWriter.java
@@ -10,10 +10,11 @@
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 java.util.logging.Level;
-import vavi.util.Debug;
+import static java.lang.System.getLogger;
/**
@@ -24,8 +25,10 @@
*/
class SmafFileWriter {
+ private static final Logger logger = getLogger(SmafFileWriter.class.getName());
+
/** smaf file types */
- private static int[] types = { SmafFileFormat.FILE_TYPE };
+ private static final int[] types = { SmafFileFormat.FILE_TYPE };
/** */
public int[] getSmafFileTypes() {
@@ -64,7 +67,7 @@ public int write(Sequence in, int fileType, OutputStream out)
throws IOException {
if (!isFileTypeSupported(fileType)) {
-Debug.println(Level.WARNING, "unsupported fileType: " + fileType);
+logger.log(Level.WARNING, "unsupported fileType: " + fileType);
return 0;
}
@@ -81,7 +84,7 @@ public int write(Sequence in, int fileType, OutputStream out)
try {
ff.writeTo(out);
} catch (InvalidSmafDataException e) {
-Debug.printStackTrace(e);
+logger.log(Level.ERROR, e.getMessage(), e);
return 0;
}
diff --git a/src/main/java/vavi/sound/smaf/SmafMidiConverter.java b/src/main/java/vavi/sound/smaf/SmafMidiConverter.java
index de462ae..5aba5bf 100644
--- a/src/main/java/vavi/sound/smaf/SmafMidiConverter.java
+++ b/src/main/java/vavi/sound/smaf/SmafMidiConverter.java
@@ -7,11 +7,11 @@
package vavi.sound.smaf;
import java.io.IOException;
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
-import java.util.logging.Level;
-
import javax.sound.midi.InvalidMidiDataException;
import javax.sound.midi.MidiEvent;
import javax.sound.midi.Sequence;
@@ -21,7 +21,8 @@
import vavi.sound.midi.smaf.SmafVaviSequence;
import vavi.sound.smaf.message.MidiContext;
import vavi.sound.smaf.message.MidiConvertible;
-import vavi.util.Debug;
+
+import static java.lang.System.getLogger;
/**
@@ -32,6 +33,8 @@
*/
class SmafMidiConverter implements SmafDevice {
+ private static final Logger logger = getLogger(SmafMidiConverter.class.getName());
+
/** the device information */
private static final SmafDevice.Info info =
new SmafDevice.Info("Java MIDI, SMAF Sequence Converter",
@@ -62,7 +65,7 @@ public void open() {
}
/** debug */
-private Set> uc = new HashSet<>();
+private final Set> uc = new HashSet<>();
/** Converts smaf sequence to midi sequence */
Sequence convert(vavi.sound.smaf.Sequence smafSequence)
@@ -75,7 +78,7 @@ Sequence convert(vavi.sound.smaf.Sequence smafSequence)
MidiContext midiContext = new MidiContext();
int resolution = midiContext.getResolution(smafTracks);
-Debug.println(Level.FINE, "resolution: " + resolution);
+logger.log(Level.DEBUG, "resolution: " + resolution);
Sequence midiSequence = new SmafVaviSequence(Sequence.PPQ, resolution, 1);
javax.sound.midi.Track midiTrack = midiSequence.getTracks()[0];
@@ -96,7 +99,7 @@ Sequence convert(vavi.sound.smaf.Sequence smafSequence)
SmafMessage smafMessage = smafEvent.getMessage();
midiContext.addCurrentTick(midiContext.getTicksOf(smafMessage.getDuration()));
-//Debug.println("■■■■■(" + i + ":" + j + ") ticks: " + midiContext.getCurrentTick() + "(" + midiContext.getTicksOf(smafMessage.getDuration()) + "," + smafMessage.getDuration() + "), " + smafMessage.getClass().getSimpleName());
+//logger.log(Level.DEBUG, "■■■■■(" + i + ":" + j + ") ticks: " + midiContext.getCurrentTick() + "(" + midiContext.getTicksOf(smafMessage.getDuration()) + "," + smafMessage.getDuration() + "), " + smafMessage.getClass().getSimpleName());
if (smafMessage instanceof MidiConvertible) {
if (!(smafMessage instanceof vavi.sound.smaf.message.NoteMessage) &&
@@ -104,12 +107,12 @@ Sequence convert(vavi.sound.smaf.Sequence smafSequence)
!(smafMessage instanceof vavi.sound.smaf.message.PitchBendMessage) &&
!(smafMessage instanceof vavi.sound.smaf.message.PanMessage) &&
!(smafMessage instanceof vavi.sound.smaf.message.ExpressionMessage)) {
- Debug.println(Level.FINE, "midi convertible(" + i + ":" + j + "): " + smafMessage);
+ logger.log(Level.DEBUG, "midi convertible(" + i + ":" + j + "): " + smafMessage);
}
//if (smafMessage instanceof vavi.sound.smaf.message.NoteMessage) {
// int gateTime = ((vavi.sound.smaf.message.NoteMessage) smafMessage).getGateTime();
// if (gateTime == 0) {
-// Debug.println(Level.WARNING, "★★★★★(" + i + ":" + j + ") gateTime == 0: " + smafMessage);
+// logger.log(Level.WARNING, "★★★★★(" + i + ":" + j + ") gateTime == 0: " + smafMessage);
// }
//}
MidiEvent[] midiEvents = ((MidiConvertible) smafMessage).getMidiEvents(midiContext);
@@ -120,13 +123,13 @@ Sequence convert(vavi.sound.smaf.Sequence smafSequence)
}
}
} else if (smafMessage instanceof MetaMessage) {
-Debug.println(Level.FINE, "meta: " + ((MetaMessage) smafMessage).getType());
+logger.log(Level.DEBUG, "meta: " + ((MetaMessage) smafMessage).getType());
for (Map.Entry entry : ((MetaMessage) smafMessage).data.entrySet()) {
-Debug.println(Level.FINE, entry.getKey() + "=" + entry.getValue());
+logger.log(Level.DEBUG, entry.getKey() + "=" + entry.getValue());
}
} else {
if (!uc.contains(smafMessage.getClass())) {
- Debug.println(Level.WARNING, "unhandled message: " + smafMessage);
+ logger.log(Level.WARNING, "unhandled message: " + smafMessage);
uc.add(smafMessage.getClass());
}
}
@@ -138,9 +141,9 @@ Sequence convert(vavi.sound.smaf.Sequence smafSequence)
/** Note may be entered before Control/Program */
@SuppressWarnings("unused")
- private void addSmafMessage(javax.sound.midi.Track midiTrack, MidiEvent midiEvent) {
-//Debug.println("★: " + midiEvent.getMessage());
-//Debug.println("★: " + (midiTrack.size() > 1 ? midiTrack.get(midiTrack.size() - 2).getMessage() : null));
+ private static void addSmafMessage(javax.sound.midi.Track midiTrack, MidiEvent midiEvent) {
+//logger.log(Level.DEBUG, "★: " + midiEvent.getMessage());
+//logger.log(Level.DEBUG, "★: " + (midiTrack.size() > 1 ? midiTrack.get(midiTrack.size() - 2).getMessage() : null));
if (midiEvent.getTick() == 0 &&
midiEvent.getMessage() instanceof ShortMessage &&
((ShortMessage) midiEvent.getMessage()).getCommand() == ShortMessage.PROGRAM_CHANGE &&
@@ -152,7 +155,7 @@ private void addSmafMessage(javax.sound.midi.Track midiTrack, MidiEvent midiEven
midiTrack.remove(removedMidiEvent);
midiTrack.add(midiEvent);
midiTrack.add(removedMidiEvent);
-Debug.println(Level.INFO, "★★★★★ : " + MidiUtil.paramString(midiEvent.getMessage()) + ", " + MidiUtil.paramString(removedMidiEvent.getMessage()));
+logger.log(Level.INFO, "★★★★★ : " + MidiUtil.paramString(midiEvent.getMessage()) + ", " + MidiUtil.paramString(removedMidiEvent.getMessage()));
} else {
midiTrack.add(midiEvent);
}
diff --git a/src/main/java/vavi/sound/smaf/SmafSequence.java b/src/main/java/vavi/sound/smaf/SmafSequence.java
index 238e096..12ca569 100644
--- a/src/main/java/vavi/sound/smaf/SmafSequence.java
+++ b/src/main/java/vavi/sound/smaf/SmafSequence.java
@@ -6,15 +6,17 @@
package vavi.sound.smaf;
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
import java.util.List;
-import java.util.logging.Level;
import vavi.sound.smaf.chunk.Chunk;
import vavi.sound.smaf.chunk.FileChunk;
import vavi.sound.smaf.chunk.TrackChunk;
import vavi.sound.smaf.message.STMessage;
import vavi.sound.smaf.message.VNMessage;
-import vavi.util.Debug;
+
+import static java.lang.System.getLogger;
/**
@@ -25,6 +27,8 @@
*/
class SmafSequence extends Sequence {
+ private static final Logger logger = getLogger(SmafSequence.class.getName());
+
/** TODO content should be moved to SmafFileFormat/FileChunk */
SmafSequence(FileChunk fileChunk) {
try {
@@ -52,7 +56,7 @@ class SmafSequence extends Sequence {
String prot = "vavi";
if (fileChunk.getOptionalDataChunk() != null) {
for (Chunk dataChunk : fileChunk.getOptionalDataChunk().getDataChunks()) {
-Debug.println(Level.FINE, dataChunk);
+logger.log(Level.DEBUG, dataChunk);
// TODO
}
} else if (fileChunk.getContentsInfoChunk() != null) { // TODO no need for if as it is required
@@ -80,11 +84,11 @@ private void createTrack(List events) {
/**
* hack of Track
*/
- private void insert(Track track, SmafEvent event, int index) {
+ private static void insert(Track track, SmafEvent event, int index) {
try {
Class extends Track> clazz = track.getClass();
//for (Field field : clazz.getDeclaredFields()) {
-// System.err.println("field: " + field);
+// logger.log(Level.DEBUG, "field: " + field);
//}
@SuppressWarnings("unchecked")
List events = (List) clazz.getDeclaredField("events").get(track);
diff --git a/src/main/java/vavi/sound/smaf/SmafSequencer.java b/src/main/java/vavi/sound/smaf/SmafSequencer.java
index c9c9f6b..8a23fc2 100644
--- a/src/main/java/vavi/sound/smaf/SmafSequencer.java
+++ b/src/main/java/vavi/sound/smaf/SmafSequencer.java
@@ -8,7 +8,8 @@
import java.io.IOException;
import java.io.InputStream;
-
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
import javax.sound.midi.Instrument;
import javax.sound.midi.InvalidMidiDataException;
import javax.sound.midi.MidiChannel;
@@ -18,7 +19,8 @@
import javax.sound.midi.Soundbank;
import vavi.sound.midi.MidiUtil;
-import vavi.util.Debug;
+
+import static java.lang.System.getLogger;
/**
@@ -33,6 +35,8 @@
*/
class SmafSequencer implements Sequencer, Synthesizer {
+ private static final Logger logger = getLogger(SmafSequencer.class.getName());
+
/** the device information */
private static final SmafDevice.Info info =
new SmafDevice.Info("Java SMAF Sound Sequencer",
@@ -73,7 +77,7 @@ public boolean isOpen() {
}
/** ADPCM sequencer, TODO should be {@link javax.sound.midi.Transmitter} */
- private javax.sound.midi.MetaEventListener mea = new MetaEventAdapter();
+ private final javax.sound.midi.MetaEventListener mea = new MetaEventAdapter();
@Override
public void open() throws SmafUnavailableException {
@@ -86,7 +90,7 @@ public void open() throws SmafUnavailableException {
midiSequencer.open();
midiSynthesizer.open();
} catch (MidiUnavailableException e) {
-Debug.printStackTrace(e);
+logger.log(Level.ERROR, e.getMessage(), e);
throw new SmafUnavailableException(e);
}
}
@@ -100,10 +104,10 @@ public void setSequence(Sequence sequence)
try {
midiSequencer.setSequence(SmafSystem.toMidiSequence(sequence));
} catch (InvalidMidiDataException e) {
-Debug.println(e);
+logger.log(Level.DEBUG, e);
throw new InvalidSmafDataException(e);
} catch (SmafUnavailableException e) {
-Debug.println(e);
+logger.log(Level.DEBUG, e);
throw new IllegalStateException(e);
}
}
@@ -160,7 +164,7 @@ private void off() {
//-------------------------------------------------------------------------
/** {@link MetaMessage MetaEvent} utility */
- private MetaSupport metaSupport = new MetaSupport();
+ private final MetaSupport metaSupport = new MetaSupport();
/* Adds a {@link MetaEventListener}. */
@Override
@@ -180,26 +184,23 @@ protected void fireMeta(MetaMessage meta) {
}
/** meta 0x2f listener */
- private javax.sound.midi.MetaEventListener mel = new javax.sound.midi.MetaEventListener() {
- @Override
- public void meta(javax.sound.midi.MetaMessage message) {
-//Debug.println("type: " + message.getType());
- switch (message.getType()) {
- case 0x2f: // added automatically at the end of the sequence
- try {
- MetaMessage metaMessage = new MetaMessage();
- metaMessage.setMessage(0x2f, null);
- fireMeta(metaMessage);
- off();
- } catch (InvalidSmafDataException e) {
-Debug.println(e);
- }
+ private final javax.sound.midi.MetaEventListener mel = message -> {
+//logger.log(Level.DEBUG, "type: " + message.getType());
+ switch (message.getType()) {
+ case 0x2f: // added automatically at the end of the sequence
+ try {
+ MetaMessage metaMessage = new MetaMessage();
+ metaMessage.setMessage(0x2f, null);
+ fireMeta(metaMessage);
+ off();
+ } catch (InvalidSmafDataException e) {
+logger.log(Level.DEBUG, e);
+ }
catch (RuntimeException | Error e) {
-Debug.printStackTrace(e);
- throw e;
+logger.log(Level.ERROR, e.getMessage(), e);
+throw e;
}
- break;
- }
+ break;
}
};
diff --git a/src/main/java/vavi/sound/smaf/SmafSystem.java b/src/main/java/vavi/sound/smaf/SmafSystem.java
index 7c0ec63..1b776e7 100644
--- a/src/main/java/vavi/sound/smaf/SmafSystem.java
+++ b/src/main/java/vavi/sound/smaf/SmafSystem.java
@@ -11,13 +11,14 @@
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.file.Files;
-
import javax.sound.midi.InvalidMidiDataException;
import javax.sound.midi.MetaEventListener;
import javax.sound.midi.Sequence;
-import vavi.util.Debug;
+import static java.lang.System.getLogger;
/**
@@ -28,16 +29,18 @@
*/
public final class SmafSystem {
+ private static final Logger logger = getLogger(SmafSystem.class.getName());
+
/** TODO SmafDeviceProvider */
- private static Sequencer sequencer;
+ private static final Sequencer sequencer;
/** TODO SmafDeviceProvider */
- private static SmafMidiConverter converter;
+ private static final SmafMidiConverter converter;
/** TODO SmafDeviceProvider */
- private static MetaEventListener waveSequencer;
+ private static final MetaEventListener waveSequencer;
/** */
- private static SmafFileReader reader;
+ private static final SmafFileReader reader;
/** */
- private static SmafFileWriter writer;
+ private static final SmafFileWriter writer;
/* */
static {
@@ -107,7 +110,7 @@ public static Sequence toMidiSequence(vavi.sound.smaf.Sequence sequence)
try {
return converter.convert(sequence);
} catch (IOException | InvalidMidiDataException e) {
-Debug.printStackTrace(e);
+logger.log(Level.ERROR, e.getMessage(), e);
throw new InvalidSmafDataException(e);
}
}
@@ -123,7 +126,7 @@ public static vavi.sound.smaf.Sequence toSmafSequence(Sequence in, int fileType)
try {
return converter.convert(in, fileType);
} catch (IOException | InvalidSmafDataException e) {
-Debug.printStackTrace(e);
+logger.log(Level.ERROR, e.getMessage(), e);
throw (InvalidMidiDataException) new InvalidMidiDataException().initCause(e);
}
}
diff --git a/src/main/java/vavi/sound/smaf/SysexMessage.java b/src/main/java/vavi/sound/smaf/SysexMessage.java
index 8b73f6c..39624f4 100644
--- a/src/main/java/vavi/sound/smaf/SysexMessage.java
+++ b/src/main/java/vavi/sound/smaf/SysexMessage.java
@@ -81,20 +81,15 @@ public static class Factory {
* @param data 0: maker id ...
*/
public static SysexMessage getSysexMessage(int duration, byte[] data) throws InvalidSmafDataException {
- SysexMessage sysexMessage;
- switch (data[0]) {
- case 0x43: // YAMAHA
- sysexMessage = new vavi.sound.smaf.message.yamaha.YamahaMessage();
- break;
- case 0x7e: // non realtime
- sysexMessage = new vavi.sound.smaf.message.NonRealtimeUniversalSysexMessage();
- break;
- case 0x7f: // realtime
- sysexMessage = new vavi.sound.smaf.message.RealtimeUniversalSysexMessage();
- break;
- default:
- throw new IllegalArgumentException("unknown vendor: " + data[0]);
- }
+ SysexMessage sysexMessage = switch (data[0]) {
+ case 0x43 -> // YAMAHA
+ new vavi.sound.smaf.message.yamaha.YamahaMessage();
+ case 0x7e -> // non realtime
+ new vavi.sound.smaf.message.NonRealtimeUniversalSysexMessage();
+ case 0x7f -> // realtime
+ new vavi.sound.smaf.message.RealtimeUniversalSysexMessage();
+ default -> throw new IllegalArgumentException("unknown vendor: " + data[0]);
+ };
sysexMessage.setDuration(duration);
sysexMessage.setMessage(0xf0, data, data.length);
return sysexMessage;
diff --git a/src/main/java/vavi/sound/smaf/Track.java b/src/main/java/vavi/sound/smaf/Track.java
index 40d0b7a..e43c183 100644
--- a/src/main/java/vavi/sound/smaf/Track.java
+++ b/src/main/java/vavi/sound/smaf/Track.java
@@ -19,7 +19,7 @@
public class Track {
/** */
- protected List events;
+ protected final List events;
/**
*
diff --git a/src/main/java/vavi/sound/smaf/chunk/AudioSequenceDataChunk.java b/src/main/java/vavi/sound/smaf/chunk/AudioSequenceDataChunk.java
index 95ff266..6da42d4 100644
--- a/src/main/java/vavi/sound/smaf/chunk/AudioSequenceDataChunk.java
+++ b/src/main/java/vavi/sound/smaf/chunk/AudioSequenceDataChunk.java
@@ -7,13 +7,15 @@
package vavi.sound.smaf.chunk;
import java.io.IOException;
-import java.util.logging.Level;
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
import vavi.sound.smaf.InvalidSmafDataException;
import vavi.sound.smaf.SmafMessage;
import vavi.sound.smaf.chunk.TrackChunk.FormatType;
import vavi.sound.smaf.message.WaveMessage;
-import vavi.util.Debug;
+
+import static java.lang.System.getLogger;
/**
@@ -26,10 +28,12 @@
*/
public class AudioSequenceDataChunk extends SequenceDataChunk {
+ private static final Logger logger = getLogger(AudioSequenceDataChunk.class.getName());
+
/** */
public AudioSequenceDataChunk(byte[] id, int size) {
super(id, size);
-Debug.println(Level.FINE, "AudioSequenceData: " + size + " bytes");
+logger.log(Level.DEBUG, "AudioSequenceData: " + size + " bytes");
}
/** */
@@ -42,7 +46,7 @@ public AudioSequenceDataChunk() {
@Override
protected void init(MyDataInputStream dis, Chunk parent)
throws InvalidSmafDataException, IOException {
-//Debug.println("available: " + is.available() + ", " + available());
+//logger.log(Level.DEBUG, "available: " + is.available() + ", " + available());
//skip(is, size); // TODO
FormatType formatType = ((TrackChunk) parent).getFormatType();
switch (formatType) {
@@ -52,7 +56,7 @@ protected void init(MyDataInputStream dis, Chunk parent)
default:
throw new InvalidSmafDataException("FormatType: " + formatType);
}
-Debug.println(Level.FINE, "messages: " + messages.size());
+logger.log(Level.DEBUG, "messages: " + messages.size());
}
/**
diff --git a/src/main/java/vavi/sound/smaf/chunk/BitmapChunk.java b/src/main/java/vavi/sound/smaf/chunk/BitmapChunk.java
index 3515e38..25507e0 100644
--- a/src/main/java/vavi/sound/smaf/chunk/BitmapChunk.java
+++ b/src/main/java/vavi/sound/smaf/chunk/BitmapChunk.java
@@ -8,10 +8,12 @@
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 vavi.sound.smaf.InvalidSmafDataException;
-import vavi.util.Debug;
+
+import static java.lang.System.getLogger;
/**
@@ -24,10 +26,12 @@
*/
public class BitmapChunk extends Chunk {
+ private static final Logger logger = getLogger(BitmapChunk.class.getName());
+
/** */
public BitmapChunk(byte[] id, int size) {
super(id, size);
-Debug.println(Level.FINE, "Bitmap: " + size + " bytes");
+logger.log(Level.DEBUG, "Bitmap: " + size + " bytes");
}
/** */
@@ -36,7 +40,7 @@ public BitmapChunk() {
this.size = 0;
}
- /** */
+ /** */
@Override
protected void init(MyDataInputStream dis, Chunk parent)
throws InvalidSmafDataException, IOException {
diff --git a/src/main/java/vavi/sound/smaf/chunk/ChannelStatus.java b/src/main/java/vavi/sound/smaf/chunk/ChannelStatus.java
index 756ed12..994db11 100644
--- a/src/main/java/vavi/sound/smaf/chunk/ChannelStatus.java
+++ b/src/main/java/vavi/sound/smaf/chunk/ChannelStatus.java
@@ -28,18 +28,18 @@ public enum Type {
}
/** smaf channel */
- private int channel;
+ private final int channel;
/** */
private ChannelStatus.Status keyControlStatus;
/** */
private ChannelStatus.Status led;
/** */
- private ChannelStatus.Status vibration;
+ private final ChannelStatus.Status vibration;
/** */
private ChannelStatus.Type type;
/** internal use */
- private FormatType formatType;
+ private final FormatType formatType;
/**
* For HandyPhoneStandard.
diff --git a/src/main/java/vavi/sound/smaf/chunk/Chunk.java b/src/main/java/vavi/sound/smaf/chunk/Chunk.java
index 62a30d5..5ae8c3c 100644
--- a/src/main/java/vavi/sound/smaf/chunk/Chunk.java
+++ b/src/main/java/vavi/sound/smaf/chunk/Chunk.java
@@ -11,15 +11,17 @@
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.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
-import java.util.logging.Level;
import vavi.sound.smaf.InvalidSmafDataException;
import vavi.util.ByteUtil;
-import vavi.util.Debug;
import vavi.util.properties.PrefixedPropertiesFactory;
+import static java.lang.System.getLogger;
+
/**
* Chunk.
@@ -30,6 +32,8 @@
*/
public abstract class Chunk {
+ private static final Logger logger = getLogger(Chunk.class.getName());
+
/** Chunk ID */
protected byte[] id = new byte[4];
@@ -87,8 +91,7 @@ public static Chunk readFrom(InputStream is, Chunk parent)
throws InvalidSmafDataException, IOException {
DataInputStream dis;
- if (is instanceof MyDataInputStream) {
- MyDataInputStream mdis = (MyDataInputStream) is;
+ if (is instanceof MyDataInputStream mdis) {
dis = new DataInputStream(mdis.is);
} else {
dis = new DataInputStream(is);
@@ -98,13 +101,13 @@ public static Chunk readFrom(InputStream is, Chunk parent)
dis.readFully(id); // not want to count down
int size = dis.readInt();
-Debug.printf(Level.FINE, "size: 0x%1$08x (%1$d)", size);
+logger.log(Level.DEBUG, String.format("size: 0x%1$08x (%1$d)", size));
Chunk chunk = newInstance(id, size);
-//Debug.println(chunk.getClass().getName() + "\n" + StringUtil.getDump(is, 0, 128));
-//Debug.printf(Level.FINE, "is: " + is + " / " + chunk.getClass().getName());
+//logger.log(Level.DEBUG, chunk.getClass().getName() + "\n" + StringUtil.getDump(is, 0, 128));
+//logger.log(Level.DEBUG, String.format("is: " + is + " / " + chunk.getClass().getName()));
MyDataInputStream mdis = new MyDataInputStream(is, id, size);
-//Debug.printf(Level.FINE, "mdis: " + mdis + " / " + chunk.getClass().getName());
+//logger.log(Level.DEBUG, String.format("mdis: " + mdis + " / " + chunk.getClass().getName()));
chunk.init(mdis, parent);
if (parent != null) {
@@ -116,10 +119,10 @@ public static Chunk readFrom(InputStream is, Chunk parent)
assert false : "is: " + is.getClass().getName();
}
} else {
-//Debug.printf(Level.FINE, "crc (calc): %04x, avail: %d, %s, %s", mdis.crc(), mdis.available(), mdis, chunk.getClass().getName());
+//logger.log(Level.DEBUG, String.format("crc (calc): %04x, avail: %d, %s, %s", mdis.crc(), mdis.available(), mdis, chunk.getClass().getName()));
if (chunk instanceof FileChunk fc) {
if (fc.getCrc() != mdis.crc()) {
-Debug.printf(Level.WARNING, "crc not match expected: %04x, actural: %04x", fc.getCrc(), mdis.crc());
+logger.log(Level.WARNING, String.format("crc not match expected: %04x, actual: %04x", fc.getCrc(), mdis.crc()));
}
}
}
@@ -134,10 +137,10 @@ public static Chunk readFrom(InputStream is, Chunk parent)
/** input stream with count down, crc */
protected static class MyDataInputStream extends InputStream implements DataInput {
- InputStream is;
- DataInputStream dis;
+ final InputStream is;
+ final DataInputStream dis;
int readSize;
- static ThreadLocal crc = new ThreadLocal<>();
+ static final ThreadLocal crc = new ThreadLocal<>();
protected MyDataInputStream(InputStream is, byte[] id, int size) {
if (is instanceof MyDataInputStream mdis) {
@@ -145,7 +148,7 @@ protected MyDataInputStream(InputStream is, byte[] id, int size) {
} else {
this.is = is;
}
-//Debug.printf(Level.FINE, "is: " + this.is);
+//logger.log(Level.DEBUG, String.format("is: " + this.is));
this.dis = new DataInputStream(this.is);
this.readSize = size;
@@ -156,7 +159,7 @@ protected MyDataInputStream(InputStream is, byte[] id, int size) {
crc.get().update(ByteUtil.getBeBytes(size));
}
public int crc() {
-//Debug.println("crc len: " + crc.get().getCount());
+//logger.log(Level.DEBUG, "crc len: " + crc.get().getCount());
return crc.get().getValue();
}
@Override
@@ -255,7 +258,7 @@ static class CRC16 {
static final int BYTE_BIT = 8;
/** maximum unsigned char value */
static final int UCHAR_MAX = 0xff;
- static int[] crcTable = new int[UCHAR_MAX + 1];
+ static final int[] crcTable = new int[UCHAR_MAX + 1];
static final int CRCPOLY1 = 0x1021;
static {
@@ -321,14 +324,14 @@ private static Chunk newInstance(byte[] id, int size)
try {
return chunkFactory.get(id).newInstance(id, size);
} catch (IllegalArgumentException e) {
-Debug.println(Level.FINE, e);
+logger.log(Level.DEBUG, e);
return new UndefinedChunk(id, size); // TODO out source
// throw new InvalidSmafDataException("unsupported chunk id: " + StringUtil.getDump(id));
} catch (Exception e) {
if (e instanceof InvocationTargetException) {
-Debug.printStackTrace(Level.SEVERE, e.getCause());
+logger.log(Level.ERROR, e.getCause().getMessage(), e.getCause());
} else {
-Debug.printStackTrace(Level.SEVERE, e);
+logger.log(Level.ERROR, e.getMessage(), e);
}
throw new IllegalStateException(e);
}
@@ -344,7 +347,7 @@ private static Chunk newInstance(byte[] id, int size)
@Override
public Constructor extends Chunk> get(byte[] id) {
String type = new String(id);
- Debug.printf(Level.FINE, "Chunk ID(read): %s+0x%02x", (Character.isLetterOrDigit(type.charAt(3)) ? type : new String(id, 0, 3)), (int) type.charAt(3));
+logger.log(Level.DEBUG, String.format("Chunk ID(read): %s+0x%02x", (Character.isLetterOrDigit(type.charAt(3)) ? type : new String(id, 0, 3)), (int) type.charAt(3)));
for (String key : instances.keySet()) {
if (key.charAt(3) == '*' && key.substring(0, 3).equals(type.substring(0, 3))) {
@@ -362,10 +365,10 @@ protected Constructor extends Chunk> getStoreValue(String value) {
try {
@SuppressWarnings("unchecked")
Class extends Chunk> clazz = (Class extends Chunk>) Class.forName(value);
-//Debug.println("chunk class: " + StringUtil.getClassName(clazz));
+//logger.log(Level.DEBUG, "chunk class: " + StringUtil.getClassName(clazz));
return clazz.getConstructor(byte[].class, Integer.TYPE);
} catch (Exception e) {
- Debug.printStackTrace(e);
+ logger.log(Level.ERROR, e.getMessage(), e);
throw new IllegalStateException(e);
}
}
diff --git a/src/main/java/vavi/sound/smaf/chunk/ColorPaletteDefinitionChunk.java b/src/main/java/vavi/sound/smaf/chunk/ColorPaletteDefinitionChunk.java
index 75e2acc..ff95cdb 100644
--- a/src/main/java/vavi/sound/smaf/chunk/ColorPaletteDefinitionChunk.java
+++ b/src/main/java/vavi/sound/smaf/chunk/ColorPaletteDefinitionChunk.java
@@ -26,7 +26,7 @@ public class ColorPaletteDefinitionChunk extends Chunk {
/** */
public ColorPaletteDefinitionChunk(byte[] id, int size) {
super(id, size);
-//Debug.println("ColorPaletteDefinition: " + size);
+//logger.log(Level.DEBUG, "ColorPaletteDefinition: " + size);
}
/** */
diff --git a/src/main/java/vavi/sound/smaf/chunk/ContentsInfoChunk.java b/src/main/java/vavi/sound/smaf/chunk/ContentsInfoChunk.java
index 003cd4e..f96bebc 100644
--- a/src/main/java/vavi/sound/smaf/chunk/ContentsInfoChunk.java
+++ b/src/main/java/vavi/sound/smaf/chunk/ContentsInfoChunk.java
@@ -10,14 +10,16 @@
import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
import java.util.Map;
import java.util.TreeMap;
-import java.util.logging.Level;
import vavi.sound.smaf.InvalidSmafDataException;
-import vavi.util.Debug;
import vavi.util.StringUtil;
+import static java.lang.System.getLogger;
+
/**
* ContentsInfo Chunk.
@@ -37,6 +39,8 @@
*/
public class ContentsInfoChunk extends Chunk {
+ private static final Logger logger = getLogger(ContentsInfoChunk.class.getName());
+
/** */
public ContentsInfoChunk(byte[] id, int size) {
super(id, size);
@@ -53,26 +57,26 @@ protected void init(MyDataInputStream dis, Chunk parent)
throws InvalidSmafDataException, IOException {
this.contentsClass = dis.readUnsignedByte();
-Debug.println(Level.FINE, "contentsClass: " + (contentsClass == 0 ? "YAMAHA" : "Vender ID(" + contentsClass + ")"));
+logger.log(Level.DEBUG, "contentsClass: " + (contentsClass == 0 ? "YAMAHA" : "Vender ID(" + contentsClass + ")"));
this.contentsType = dis.readUnsignedByte();
-Debug.printf(Level.FINE, "contentsType: 0x%02x\n", contentsType);
+logger.log(Level.DEBUG, String.format("contentsType: 0x%02x", contentsType));
this.contentsCodeType = dis.readUnsignedByte();
-Debug.printf(Level.FINE, "contentsCodeType: 0x%02x\n", contentsCodeType);
+logger.log(Level.DEBUG, String.format("contentsCodeType: 0x%02x", contentsCodeType));
this.copyStatus = dis.readUnsignedByte();
-Debug.println(Level.FINE, "copyStatus: " + StringUtil.toBits(copyStatus, 8));
+logger.log(Level.DEBUG, "copyStatus: " + StringUtil.toBits(copyStatus, 8));
this.copyCounts = dis.readUnsignedByte();
-Debug.println(Level.FINE, "copyCounts: " + copyCounts);
+logger.log(Level.DEBUG, "copyCounts: " + copyCounts);
byte[] option = new byte[size - 5];
dis.readFully(option);
-Debug.println(Level.FINE, "option: " + option.length + " bytes (subData)");
+logger.log(Level.DEBUG, "option: " + option.length + " bytes (subData)");
int i = 0;
while (i < option.length) {
-Debug.println(Level.FINER, i + " / " + option.length + "\n" + StringUtil.getDump(option, i, option.length - i));
+logger.log(Level.TRACE, i + " / " + option.length + "\n" + StringUtil.getDump(option, i, option.length - i));
SubData subDatum = new SubData(option, i, contentsCodeType);
subData.put(subDatum.getTag(), subDatum);
-Debug.println(Level.FINE, "ContentsInfo: subDatum: " + subDatum);
+logger.log(Level.DEBUG, "ContentsInfo: subDatum: " + subDatum);
i += 2 + 1 + subDatum.getData().length + 1; // tag ':' data ','
-Debug.println(Level.FINER, i + " / " + option.length + "\n" + StringUtil.getDump(option, i, option.length - i));
+logger.log(Level.TRACE, i + " / " + option.length + "\n" + StringUtil.getDump(option, i, option.length - i));
}
}
@@ -193,7 +197,7 @@ public void setCopyStatus(int copyStatus) {
}
/** */
- private Map subData = new TreeMap<>();
+ private final Map subData = new TreeMap<>();
/**
* @return null when specified sub chunk is not found
diff --git a/src/main/java/vavi/sound/smaf/chunk/DataChunk.java b/src/main/java/vavi/sound/smaf/chunk/DataChunk.java
index 94a534b..8cc2961 100644
--- a/src/main/java/vavi/sound/smaf/chunk/DataChunk.java
+++ b/src/main/java/vavi/sound/smaf/chunk/DataChunk.java
@@ -11,14 +11,16 @@
import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
import java.util.Map;
import java.util.TreeMap;
-import java.util.logging.Level;
import vavi.sound.smaf.InvalidSmafDataException;
-import vavi.util.Debug;
import vavi.util.StringUtil;
+import static java.lang.System.getLogger;
+
/**
* Data Chunk.
@@ -30,12 +32,14 @@
*/
public class DataChunk extends Chunk {
+ private static final Logger logger = getLogger(DataChunk.class.getName());
+
/** */
public DataChunk(byte[] id, int size) {
super(id, size);
this.languageCode = id[3] & 0xff;
-Debug.println(Level.FINE, "Data: lang: " + languageCode + ", size: " + size);
+logger.log(Level.DEBUG, "Data: lang: " + languageCode + ", size: " + size);
}
/** */
@@ -48,12 +52,12 @@ public DataChunk() {
protected void init(MyDataInputStream dis, Chunk parent)
throws InvalidSmafDataException, IOException {
-Debug.println(Level.FINER, "available: " + dis.available());
+logger.log(Level.TRACE, "available: " + dis.available());
while (dis.available() > 4) { // TODO normal files should be 0.
SubData subDatum = new SubData(dis);
-Debug.println(Level.FINE, subDatum);
+logger.log(Level.DEBUG, subDatum);
subData.put(subDatum.tag, subDatum);
-Debug.println(Level.FINER, "SubData: " + subDatum.tag + ", " + subDatum.data.length + ", " + dis.available());
+logger.log(Level.TRACE, "SubData: " + subDatum.tag + ", " + subDatum.data.length + ", " + dis.available());
}
dis.skipBytes(dis.available()); // TODO not necessary if the file is normal
}
@@ -74,7 +78,7 @@ public void writeTo(OutputStream os) throws IOException {
private static final String defaultEncoding = "Windows-31J";
/** */
- private Map subData = new TreeMap<>();
+ private final Map subData = new TreeMap<>();
/** */
String getSubDataByTag(String tag) {
@@ -160,10 +164,10 @@ public int getSize() {
}
/** tag */
- private String tag;
+ private final String tag;
/** Data */
- private byte[] data;
+ private final byte[] data;
/** */
public String toString() {
diff --git a/src/main/java/vavi/sound/smaf/chunk/DisplayParameterDefinitionChunk.java b/src/main/java/vavi/sound/smaf/chunk/DisplayParameterDefinitionChunk.java
index d4b2ecb..578a385 100644
--- a/src/main/java/vavi/sound/smaf/chunk/DisplayParameterDefinitionChunk.java
+++ b/src/main/java/vavi/sound/smaf/chunk/DisplayParameterDefinitionChunk.java
@@ -9,13 +9,15 @@
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
+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 vavi.sound.midi.MidiUtil;
import vavi.sound.smaf.InvalidSmafDataException;
-import vavi.util.Debug;
+
+import static java.lang.System.getLogger;
/**
@@ -28,10 +30,12 @@
*/
public class DisplayParameterDefinitionChunk extends Chunk {
+ private static final Logger logger = getLogger(DisplayParameterDefinitionChunk.class.getName());
+
/** */
public DisplayParameterDefinitionChunk(byte[] id, int size) {
super(id, size);
-//Debug.println("DisplayParameterDefinition: " + size);
+//logger.log(Level.DEBUG, "DisplayParameterDefinition: " + size);
}
/** */
@@ -50,7 +54,7 @@ protected void init(MyDataInputStream dis, Chunk parent)
int eventType = dis.readUnsignedByte();
Event event = new Event();
event.eventType = eventType;
-Debug.println(Level.FINE, "event: " + eventType);
+logger.log(Level.DEBUG, "event: " + eventType);
for (int j = 0; j < ((eventSize - 1) / 2); j++) {
int parameterId = dis.readUnsignedByte();
int parameterValue = dis.readUnsignedByte();
@@ -58,7 +62,7 @@ protected void init(MyDataInputStream dis, Chunk parent)
parameter.parameterID = ParameterID.valueOf(parameterId);
parameter.value = parameterValue;
event.parameters.add(parameter);
-Debug.println(Level.FINE, "parameters: " + parameter);
+logger.log(Level.DEBUG, "parameters: " + parameter);
}
i += (eventSize > 127 ? 2 : 1) + eventSize;
}
@@ -77,7 +81,7 @@ public void writeTo(OutputStream os) throws IOException {
}
/** */
- private List events = new ArrayList<>();
+ private final List events = new ArrayList<>();
/** */
static class Event {
@@ -87,7 +91,7 @@ static class Event {
*/
int eventType;
/** */
- List parameters = new ArrayList<>();
+ final List parameters = new ArrayList<>();
/** */
static class Parameter {
ParameterID parameterID;
diff --git a/src/main/java/vavi/sound/smaf/chunk/FileChunk.java b/src/main/java/vavi/sound/smaf/chunk/FileChunk.java
index c40bff4..cba3726 100644
--- a/src/main/java/vavi/sound/smaf/chunk/FileChunk.java
+++ b/src/main/java/vavi/sound/smaf/chunk/FileChunk.java
@@ -10,12 +10,14 @@
import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.OutputStream;
+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 vavi.sound.smaf.InvalidSmafDataException;
-import vavi.util.Debug;
+
+import static java.lang.System.getLogger;
/**
@@ -28,6 +30,8 @@
*/
public class FileChunk extends Chunk {
+ private static final Logger logger = getLogger(FileChunk.class.getName());
+
/** */
public FileChunk(byte[] id, int size) {
super(id, size);
@@ -50,7 +54,7 @@ protected void init(MyDataInputStream dis, Chunk parent)
} else if (chunk instanceof OptionalDataChunk) {
optionalDataChunk = chunk;
} else if (chunk instanceof ScoreTrackChunk) {
-Debug.println(Level.FINE, "TRACK: " + scoreTrackChunks.size());
+logger.log(Level.DEBUG, "TRACK: " + scoreTrackChunks.size());
scoreTrackChunks.add((TrackChunk) chunk);
} else if (chunk instanceof PcmAudioTrackChunk) {
pcmAudioTrackChunks.add((TrackChunk) chunk);
@@ -59,16 +63,16 @@ protected void init(MyDataInputStream dis, Chunk parent)
} else if (chunk instanceof MasterTrackChunk) {
masterTrackChunk = (TrackChunk) chunk;
} else {
-Debug.println(Level.WARNING, "unsupported chunk: " + chunk.getClass());
+logger.log(Level.WARNING, "unsupported chunk: " + chunk.getClass());
}
}
-//Debug.println("available: " + is.available());
+//logger.log(Level.DEBUG, "available: " + is.available());
this.crc = dis.readUnsignedShort();
-Debug.printf(Level.FINE, "crc (orig): %04x\n", crc);
+logger.log(Level.DEBUG, String.format("crc (orig): %04x", crc));
if (dis.available() > 4) {
int kddiCrc = dis.readUnsignedShort();
int kddiMark = dis.readUnsignedShort();
-Debug.printf(Level.FINE, "has kddi crc: %04x, %04x\n", kddiCrc, kddiMark);
+logger.log(Level.DEBUG, String.format("has kddi crc: %04x, %04x", kddiCrc, kddiMark));
}
}
@@ -104,7 +108,7 @@ public void writeTo(OutputStream os) throws IOException {
/** */
private static class Crc16OutputStream extends FilterOutputStream {
/** */
- private CRC16 crc16 = new CRC16();
+ private final CRC16 crc16 = new CRC16();
/** */
public Crc16OutputStream(OutputStream out) {
super(out);
@@ -155,7 +159,7 @@ public void setOptionalDataChunk(OptionalDataChunk optionalDataChunk) {
}
/** "MTR*" */
- private List scoreTrackChunks = new ArrayList<>();
+ private final List scoreTrackChunks = new ArrayList<>();
/** */
public List getScoreTrackChunks() {
@@ -169,7 +173,7 @@ public void addScoreTrackChunk(ScoreTrackChunk scoreTrackChunk) {
}
/** "ATR*" */
- private List pcmAudioTrackChunks = new ArrayList<>();
+ private final List pcmAudioTrackChunks = new ArrayList<>();
/** */
public List getPcmAudioTrackChunks() {
@@ -183,7 +187,7 @@ public void addPcmAudioTrackChunk(PcmAudioTrackChunk pcmAudioTrackChunk) {
}
/** "GTR*" */
- private List graphicsTrackChunks = new ArrayList<>();
+ private final List graphicsTrackChunks = new ArrayList<>();
/** */
public List getGraphicsTrackChunks() {
diff --git a/src/main/java/vavi/sound/smaf/chunk/GraphicsSetupDataChunk.java b/src/main/java/vavi/sound/smaf/chunk/GraphicsSetupDataChunk.java
index 21e8a6c..3568028 100644
--- a/src/main/java/vavi/sound/smaf/chunk/GraphicsSetupDataChunk.java
+++ b/src/main/java/vavi/sound/smaf/chunk/GraphicsSetupDataChunk.java
@@ -9,10 +9,12 @@
import java.io.DataOutputStream;
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 vavi.sound.smaf.InvalidSmafDataException;
-import vavi.util.Debug;
+
+import static java.lang.System.getLogger;
/**
@@ -25,10 +27,12 @@
*/
public class GraphicsSetupDataChunk extends Chunk {
+ private static final Logger logger = getLogger(GraphicsSetupDataChunk.class.getName());
+
/** */
public GraphicsSetupDataChunk(byte[] id, int size) {
super(id, size);
-Debug.println(Level.FINE, "GraphicsSetupData: " + size + " bytes");
+logger.log(Level.DEBUG, "GraphicsSetupData: " + size + " bytes");
}
/** */
@@ -46,7 +50,7 @@ protected void init(MyDataInputStream dis, Chunk parent) throws InvalidSmafDataE
} else if (chunk instanceof ColorPaletteDefinitionChunk) {
colorPaletteDefinitionChunk = chunk;
} else {
-Debug.println(Level.WARNING, "unknown chunk: " + chunk.getClass());
+logger.log(Level.WARNING, "unknown chunk: " + chunk.getClass());
}
}
diff --git a/src/main/java/vavi/sound/smaf/chunk/GraphicsTrackChunk.java b/src/main/java/vavi/sound/smaf/chunk/GraphicsTrackChunk.java
index 83f4cd2..3129b4c 100644
--- a/src/main/java/vavi/sound/smaf/chunk/GraphicsTrackChunk.java
+++ b/src/main/java/vavi/sound/smaf/chunk/GraphicsTrackChunk.java
@@ -9,17 +9,19 @@
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.logging.Level;
import vavi.sound.midi.MidiConstants.MetaEvent;
import vavi.sound.smaf.InvalidSmafDataException;
import vavi.sound.smaf.MetaMessage;
import vavi.sound.smaf.SmafEvent;
-import vavi.util.Debug;
+
+import static java.lang.System.getLogger;
/**
@@ -41,10 +43,12 @@
*/
public class GraphicsTrackChunk extends TrackChunk {
+ private static final Logger logger = getLogger(GraphicsTrackChunk.class.getName());
+
/** */
public GraphicsTrackChunk(byte[] id, int size) {
super(id, size);
-Debug.println(Level.FINE, "Graphics[" + trackNumber + "]: " + size);
+logger.log(Level.DEBUG, "Graphics[" + trackNumber + "]: " + size);
}
/** */
@@ -80,7 +84,7 @@ protected void init(MyDataInputStream dis, Chunk parent)
} else if (chunk instanceof ImageDataChunk) {
imageDataChunk = chunk;
} else {
-Debug.println(Level.WARNING, "unknown chunk: " + chunk.getClass());
+logger.log(Level.WARNING, "unknown chunk: " + chunk.getClass());
}
}
}
@@ -138,7 +142,7 @@ public void setSetupDataChunk(SetupDataChunk setupDataChunk) {
}
/** > 1 */
- private List sequenceDataChunks = new ArrayList<>();
+ private final List sequenceDataChunks = new ArrayList<>();
/** (option) */
private Chunk fontDataChunk;
diff --git a/src/main/java/vavi/sound/smaf/chunk/GraphicsTrackSequenceDataChunk.java b/src/main/java/vavi/sound/smaf/chunk/GraphicsTrackSequenceDataChunk.java
index 9f4d7aa..7438039 100644
--- a/src/main/java/vavi/sound/smaf/chunk/GraphicsTrackSequenceDataChunk.java
+++ b/src/main/java/vavi/sound/smaf/chunk/GraphicsTrackSequenceDataChunk.java
@@ -8,7 +8,8 @@
import java.io.DataInputStream;
import java.io.IOException;
-import java.util.logging.Level;
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
import vavi.sound.midi.MidiUtil;
import vavi.sound.smaf.InvalidSmafDataException;
@@ -21,7 +22,8 @@
import vavi.sound.smaf.message.graphics.OffsetOriginMessage;
import vavi.sound.smaf.message.graphics.ResetOrigneMessage;
import vavi.sound.smaf.message.graphics.UserMessage;
-import vavi.util.Debug;
+
+import static java.lang.System.getLogger;
/**
@@ -34,6 +36,8 @@
*/
public class GraphicsTrackSequenceDataChunk extends SequenceDataChunk {
+ private static final Logger logger = getLogger(GraphicsTrackSequenceDataChunk.class.getName());
+
/** */
private int sequenceNumber;
@@ -42,7 +46,7 @@ public GraphicsTrackSequenceDataChunk(byte[] id, int size) {
super(id, size);
this.sequenceNumber = id[3];
-Debug.println(Level.FINE, "GraphicsTrackSequenceData[" + sequenceNumber + "]: " + size + " bytes");
+logger.log(Level.DEBUG, "GraphicsTrackSequenceData[" + sequenceNumber + "]: " + size + " bytes");
}
/** */
@@ -63,7 +67,7 @@ protected void init(MyDataInputStream dis, Chunk parent)
default:
throw new InvalidSmafDataException("FormatType: " + formatType);
}
-Debug.println(Level.FINE, "messages: " + messages.size());
+logger.log(Level.DEBUG, "messages: " + messages.size());
}
/** formatType 0 */
@@ -75,7 +79,7 @@ protected void readHandyPhoneStandard(DataInputStream dis)
while (dis.available() > 0) {
// -------- duration --------
int duration = MidiUtil.readVariableLength(dis);
-//Debug.println("duration: " + duration + ", 0x" + StringUtil.toHex4(duration));
+//logger.log(Level.DEBUG, "duration: " + duration + ", 0x" + StringUtil.toHex4(duration));
// -------- event --------
int e1 = dis.readUnsignedByte();
switch (e1) {
@@ -114,12 +118,12 @@ protected void readHandyPhoneStandard(DataInputStream dis)
byte[] data = new byte[size];
dis.readFully(data);
smafMessage = new UndefinedMessage(duration);
-Debug.printf(Level.FINE, "reserved: %02x\n", e1);
+logger.log(Level.DEBUG, String.format("reserved: %02x", e1));
} break;
}
-//Debug.println(available() + ", " + smafMessage);
-Debug.println(Level.FINE, "message: " + smafMessage);
+//logger.log(Level.DEBUG, available() + ", " + smafMessage);
+logger.log(Level.DEBUG, "message: " + smafMessage);
messages.add(smafMessage);
}
}
diff --git a/src/main/java/vavi/sound/smaf/chunk/HuffmanDecodingInputStream.java b/src/main/java/vavi/sound/smaf/chunk/HuffmanDecodingInputStream.java
index 603e393..8f2ff47 100644
--- a/src/main/java/vavi/sound/smaf/chunk/HuffmanDecodingInputStream.java
+++ b/src/main/java/vavi/sound/smaf/chunk/HuffmanDecodingInputStream.java
@@ -9,9 +9,10 @@
import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.util.logging.Level;
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
-import vavi.util.Debug;
+import static java.lang.System.getLogger;
/**
@@ -25,6 +26,8 @@
*/
public class HuffmanDecodingInputStream extends FilterInputStream {
+ private static final Logger logger = getLogger(HuffmanDecodingInputStream.class.getName());
+
/** */
private int currentByte;
@@ -32,7 +35,7 @@ public class HuffmanDecodingInputStream extends FilterInputStream {
private int bitOffset = 8;
/** */
- private int root;
+ private final int root;
/** */
public HuffmanDecodingInputStream(InputStream is) throws IOException {
@@ -42,7 +45,7 @@ public HuffmanDecodingInputStream(InputStream is) throws IOException {
if ((root = readTree(true)) == -1) {
throw new IllegalStateException("can not initialize reading tree");
}
-Debug.println(Level.FINE, "root: " + root);
+logger.log(Level.DEBUG, "root: " + root);
}
/**
@@ -56,11 +59,11 @@ private int readBit() throws IOException {
}
bitOffset = 0;
currentByte = in.read();
-Debug.println(Level.FINE, "currentByte: " + currentByte);
+logger.log(Level.DEBUG, "currentByte: " + currentByte);
}
int bit = (currentByte >> (7 - bitOffset)) & 0x01;
-Debug.println(Level.FINE, "bit: " + bit + " (" + bitOffset + ")");
+logger.log(Level.DEBUG, "bit: " + bit + " (" + bitOffset + ")");
bitOffset++;
return bit;
@@ -88,9 +91,9 @@ private int readBits(int n) throws IOException {
private static final int N = 256;
/** */
- private int[] left = new int[2 * N - 1];
+ private final int[] left = new int[2 * N - 1];
/** */
- private int[] right = new int[2 * N - 1];
+ private final int[] right = new int[2 * N - 1];
/** */
private int available; // TODO thread safe?
@@ -106,7 +109,7 @@ private int readTree(boolean init) throws IOException {
}
int bit = readBit();
-Debug.println(Level.FINE, "bit: " + bit);
+logger.log(Level.DEBUG, "bit: " + bit);
if (bit == -1) {
return -1;
}
@@ -135,7 +138,7 @@ public int read() throws IOException {
if (r < 0) {
return -1;
} else {
- return buf[0];
+ return buf[0] & 0xff;
}
}
@@ -144,7 +147,7 @@ public int read(byte[] b, int offset, int length) throws IOException {
int position = 0;
while (position < length) {
int node = root;
-Debug.println(Level.FINE, "node: " + node);
+logger.log(Level.DEBUG, "node: " + node);
while (node >= N) {
int bit = readBit();
if (bit == -1) {
diff --git a/src/main/java/vavi/sound/smaf/chunk/ImageChunk.java b/src/main/java/vavi/sound/smaf/chunk/ImageChunk.java
index 6d7b6af..a00b766 100644
--- a/src/main/java/vavi/sound/smaf/chunk/ImageChunk.java
+++ b/src/main/java/vavi/sound/smaf/chunk/ImageChunk.java
@@ -10,12 +10,13 @@
import java.io.ByteArrayInputStream;
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.imageio.ImageIO;
import vavi.sound.smaf.InvalidSmafDataException;
-import vavi.util.Debug;
+
+import static java.lang.System.getLogger;
/**
@@ -28,6 +29,8 @@
*/
public class ImageChunk extends Chunk {
+ private static final Logger logger = getLogger(ImageChunk.class.getName());
+
/** */
private int imageNumer;
@@ -36,7 +39,7 @@ public ImageChunk(byte[] id, int size) {
super(id, size);
this.imageNumer = id[3];
-Debug.println(Level.FINE, "Image[" + imageNumer + "]: " + size + " bytes");
+logger.log(Level.DEBUG, "Image[" + imageNumer + "]: " + size + " bytes");
}
/** */
@@ -52,7 +55,7 @@ protected void init(MyDataInputStream dis, Chunk parent)
this.imageData = new byte[size];
dis.readFully(imageData);
-Debug.println(Level.FINE, "image: " + getImage());
+logger.log(Level.DEBUG, "image: " + getImage());
}
/** */
diff --git a/src/main/java/vavi/sound/smaf/chunk/ImageDataChunk.java b/src/main/java/vavi/sound/smaf/chunk/ImageDataChunk.java
index 5fa8242..509d8ff 100644
--- a/src/main/java/vavi/sound/smaf/chunk/ImageDataChunk.java
+++ b/src/main/java/vavi/sound/smaf/chunk/ImageDataChunk.java
@@ -8,12 +8,14 @@
import java.io.IOException;
import java.io.OutputStream;
+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 vavi.sound.smaf.InvalidSmafDataException;
-import vavi.util.Debug;
+
+import static java.lang.System.getLogger;
/**
@@ -26,10 +28,12 @@
*/
public class ImageDataChunk extends Chunk {
+ private static final Logger logger = getLogger(ImageDataChunk.class.getName());
+
/** */
public ImageDataChunk(byte[] id, int size) {
super(id, size);
-Debug.println(Level.FINE, "ImageData: " + size + " bytes");
+logger.log(Level.DEBUG, "ImageData: " + size + " bytes");
}
/** */
@@ -38,7 +42,7 @@ public ImageDataChunk() {
this.size = 0;
}
- /** */
+ /** */
@Override
protected void init(MyDataInputStream dis, Chunk parent)
throws InvalidSmafDataException, IOException {
@@ -52,14 +56,14 @@ protected void init(MyDataInputStream dis, Chunk parent)
} else if (chunk instanceof LinkChunk) { // ""
imageDataChunks.add(chunk);
} else {
- Debug.println(Level.WARNING, "unknown chunk: " + chunk.getClass());
+ logger.log(Level.WARNING, "unknown chunk: " + chunk.getClass());
}
}
-Debug.println(Level.FINE, "messages: " + imageDataChunks.size());
+logger.log(Level.DEBUG, "messages: " + imageDataChunks.size());
}
/** */
- private List imageDataChunks = new ArrayList<>();
+ private final List imageDataChunks = new ArrayList<>();
/** TODO */
@Override
diff --git a/src/main/java/vavi/sound/smaf/chunk/LinkChunk.java b/src/main/java/vavi/sound/smaf/chunk/LinkChunk.java
index d1b8526..d3b1b08 100644
--- a/src/main/java/vavi/sound/smaf/chunk/LinkChunk.java
+++ b/src/main/java/vavi/sound/smaf/chunk/LinkChunk.java
@@ -8,10 +8,12 @@
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 vavi.sound.smaf.InvalidSmafDataException;
-import vavi.util.Debug;
+
+import static java.lang.System.getLogger;
/**
@@ -24,10 +26,12 @@
*/
public class LinkChunk extends Chunk {
+ private static final Logger logger = getLogger(LinkChunk.class.getName());
+
/** */
public LinkChunk(byte[] id, int size) {
super(id, size);
-Debug.println(Level.FINE, "Link: " + size + " bytes");
+logger.log(Level.DEBUG, "Link: " + size + " bytes");
}
/** */
@@ -36,7 +40,7 @@ public LinkChunk() {
this.size = 0;
}
- /** */
+ /** */
@Override
protected void init(MyDataInputStream dis, Chunk parent)
throws InvalidSmafDataException, IOException {
diff --git a/src/main/java/vavi/sound/smaf/chunk/MasterTrackChunk.java b/src/main/java/vavi/sound/smaf/chunk/MasterTrackChunk.java
index 2fff0d5..486738f 100644
--- a/src/main/java/vavi/sound/smaf/chunk/MasterTrackChunk.java
+++ b/src/main/java/vavi/sound/smaf/chunk/MasterTrackChunk.java
@@ -8,12 +8,14 @@
import java.io.IOException;
import java.io.OutputStream;
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
import java.util.List;
-import java.util.logging.Level;
import vavi.sound.smaf.InvalidSmafDataException;
import vavi.sound.smaf.SmafEvent;
-import vavi.util.Debug;
+
+import static java.lang.System.getLogger;
/**
@@ -26,10 +28,12 @@
*/
public class MasterTrackChunk extends TrackChunk {
+ private static final Logger logger = getLogger(MasterTrackChunk.class.getName());
+
/** */
public MasterTrackChunk(byte[] id, int size) {
super(id, size);
-Debug.println(Level.FINE, "MasterTrack: " + size);
+logger.log(Level.DEBUG, "MasterTrack: " + size);
}
@Override
@@ -38,20 +42,20 @@ protected void init(MyDataInputStream dis, Chunk parent)
this.formatType = FormatType.values()[dis.readUnsignedByte()];
this.sequenceType = SequenceType.values()[dis.readUnsignedByte()];
-Debug.println(Level.FINE, "sequenceType: " + sequenceType);
+logger.log(Level.DEBUG, "sequenceType: " + sequenceType);
this.durationTimeBase = dis.readUnsignedByte();
-//Debug.println("durationTimeBase: " + StringUtil.toHex2(durationTimeBase));
+//logger.log(Level.DEBUG, "durationTimeBase: " + StringUtil.toHex2(durationTimeBase));
int optionSize = dis.readUnsignedByte();
this.optionData = new byte[optionSize];
dis.readFully(optionData);
while (dis.available() > 0) {
-//Debug.println("available: " + is.available() + ", " + available());
+//logger.log(Level.DEBUG, "available: " + is.available() + ", " + available());
Chunk chunk = readFrom(dis);
if (chunk instanceof MasterTrackSequenceDataChunk) { // "Mssq"
sequenceDataChunk = chunk;
} else {
-Debug.println(Level.WARNING, "unknown chunk: " + chunk.getClass());
+logger.log(Level.WARNING, "unknown chunk: " + chunk.getClass());
}
}
}
diff --git a/src/main/java/vavi/sound/smaf/chunk/MasterTrackSequenceDataChunk.java b/src/main/java/vavi/sound/smaf/chunk/MasterTrackSequenceDataChunk.java
index 7f69f2d..853cc1e 100644
--- a/src/main/java/vavi/sound/smaf/chunk/MasterTrackSequenceDataChunk.java
+++ b/src/main/java/vavi/sound/smaf/chunk/MasterTrackSequenceDataChunk.java
@@ -7,10 +7,12 @@
package vavi.sound.smaf.chunk;
import java.io.IOException;
-import java.util.logging.Level;
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
import vavi.sound.smaf.InvalidSmafDataException;
-import vavi.util.Debug;
+
+import static java.lang.System.getLogger;
/**
@@ -23,10 +25,12 @@
*/
public class MasterTrackSequenceDataChunk extends SequenceDataChunk {
+ private static final Logger logger = getLogger(MasterTrackSequenceDataChunk.class.getName());
+
/** */
public MasterTrackSequenceDataChunk(byte[] id, int size) {
super(id, size);
-Debug.println(Level.FINE, "MasterTrackSequenceData: " + size + " bytes");
+logger.log(Level.DEBUG, "MasterTrackSequenceData: " + size + " bytes");
}
/** TODO how to get formatType from parent chunk ??? */
diff --git a/src/main/java/vavi/sound/smaf/chunk/OptionalDataChunk.java b/src/main/java/vavi/sound/smaf/chunk/OptionalDataChunk.java
index 1a03281..dbe31c4 100644
--- a/src/main/java/vavi/sound/smaf/chunk/OptionalDataChunk.java
+++ b/src/main/java/vavi/sound/smaf/chunk/OptionalDataChunk.java
@@ -9,12 +9,14 @@
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
+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 vavi.sound.smaf.InvalidSmafDataException;
-import vavi.util.Debug;
+
+import static java.lang.System.getLogger;
/**
@@ -27,10 +29,12 @@
*/
public class OptionalDataChunk extends Chunk {
+ private static final Logger logger = getLogger(OptionalDataChunk.class.getName());
+
/** */
public OptionalDataChunk(byte[] id, int size) {
super(id, size);
-Debug.println(Level.FINE, "OptionalData: " + size + " bytes");
+logger.log(Level.DEBUG, "OptionalData: " + size + " bytes");
}
/** */
@@ -63,7 +67,7 @@ public void writeTo(OutputStream os) throws IOException {
}
/** DataChunk "Dch*", ... */
- private List dataChunks = new ArrayList<>();
+ private final List dataChunks = new ArrayList<>();
/**
* @return Returns the subChunks.
diff --git a/src/main/java/vavi/sound/smaf/chunk/PcmAudioTrackChunk.java b/src/main/java/vavi/sound/smaf/chunk/PcmAudioTrackChunk.java
index ba78cd1..f65ca3a 100644
--- a/src/main/java/vavi/sound/smaf/chunk/PcmAudioTrackChunk.java
+++ b/src/main/java/vavi/sound/smaf/chunk/PcmAudioTrackChunk.java
@@ -9,18 +9,20 @@
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.logging.Level;
import vavi.sound.midi.MidiConstants.MetaEvent;
import vavi.sound.smaf.InvalidSmafDataException;
import vavi.sound.smaf.MetaMessage;
import vavi.sound.smaf.SmafEvent;
import vavi.sound.smaf.SmafMessage;
-import vavi.util.Debug;
+
+import static java.lang.System.getLogger;
/**
@@ -35,10 +37,12 @@
*/
public class PcmAudioTrackChunk extends TrackChunk {
+ private static final Logger logger = getLogger(PcmAudioTrackChunk.class.getName());
+
/** */
public PcmAudioTrackChunk(byte[] id, int size) {
super(id, size);
-Debug.println(Level.FINE, "PcmAudioTrack[" + trackNumber + "]: " + size + " bytes");
+logger.log(Level.DEBUG, "PcmAudioTrack[" + trackNumber + "]: " + size + " bytes");
}
/** */
@@ -53,17 +57,17 @@ protected void init(MyDataInputStream dis, Chunk parent)
//skip(is, size);
this.formatType = FormatType.values()[dis.readUnsignedByte()];
-Debug.println(Level.FINE, "formatType: " + formatType);
+logger.log(Level.DEBUG, "formatType: " + formatType);
this.sequenceType = SequenceType.values()[dis.readUnsignedByte()];
-Debug.println(Level.FINE, "sequenceType: " + sequenceType);
+logger.log(Level.DEBUG, "sequenceType: " + sequenceType);
this.waveType = new WaveType(dis.readUnsignedShort());
-Debug.println(Level.FINE, "waveType: " + waveType);
+logger.log(Level.DEBUG, "waveType: " + waveType);
this.durationTimeBase = dis.readUnsignedByte();
-Debug.println(Level.FINE, "durationTimeBase: " + durationTimeBase + ", " + getDurationTimeBase() + " ms");
+logger.log(Level.DEBUG, "durationTimeBase: " + durationTimeBase + ", " + getDurationTimeBase() + " ms");
this.gateTimeTimeBase = dis.readUnsignedByte();
-Debug.println(Level.FINE, "gateTimeTimeBase: " + gateTimeTimeBase + ", " + getGateTimeTimeBase() + " ms");
+logger.log(Level.DEBUG, "gateTimeTimeBase: " + gateTimeTimeBase + ", " + getGateTimeTimeBase() + " ms");
while (dis.available() > 0) {
Chunk chunk = readFrom(dis);
@@ -76,7 +80,7 @@ protected void init(MyDataInputStream dis, Chunk parent)
} else if (chunk instanceof WaveDataChunk) {
waveDataChunks.add(chunk);
} else {
-Debug.println(Level.WARNING, "unknown chunk: " + chunk.getClass());
+logger.log(Level.WARNING, "unknown chunk: " + chunk.getClass());
}
}
}
@@ -141,7 +145,7 @@ public void setSetupDataChunk(SetupDataChunk setupDataChunk) {
}
/** */
- private List waveDataChunks = new ArrayList<>();
+ private final List waveDataChunks = new ArrayList<>();
/** "Awa*" TODO is there really more than one? */
public void addWaveDataChunk(Chunk waveDataChunk) {
diff --git a/src/main/java/vavi/sound/smaf/chunk/ScoreTrackChunk.java b/src/main/java/vavi/sound/smaf/chunk/ScoreTrackChunk.java
index 32ab130..53a6574 100644
--- a/src/main/java/vavi/sound/smaf/chunk/ScoreTrackChunk.java
+++ b/src/main/java/vavi/sound/smaf/chunk/ScoreTrackChunk.java
@@ -9,18 +9,20 @@
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.logging.Level;
import vavi.sound.midi.MidiConstants.MetaEvent;
import vavi.sound.smaf.InvalidSmafDataException;
import vavi.sound.smaf.MetaMessage;
import vavi.sound.smaf.SmafEvent;
import vavi.sound.smaf.SmafMessage;
-import vavi.util.Debug;
+
+import static java.lang.System.getLogger;
/**
@@ -43,10 +45,12 @@
*/
public class ScoreTrackChunk extends TrackChunk {
+ private static final Logger logger = getLogger(ScoreTrackChunk.class.getName());
+
/** */
public ScoreTrackChunk(byte[] id, int size) {
super(id, size);
-Debug.println(Level.FINE, "ScoreTrack[" + trackNumber + "]: " + size + " bytes");
+logger.log(Level.DEBUG, "ScoreTrack[" + trackNumber + "]: " + size + " bytes");
}
/** */
@@ -61,21 +65,21 @@ protected void init(MyDataInputStream dis, Chunk parent)
this.formatType = FormatType.values()[dis.readUnsignedByte()];
this.sequenceType = SequenceType.values()[dis.readUnsignedByte()];
-Debug.println(Level.FINE, "sequenceType: " + sequenceType);
+logger.log(Level.DEBUG, "sequenceType: " + sequenceType);
this.durationTimeBase = dis.readUnsignedByte();
-Debug.println(Level.FINE, "durationTimeBase: " + durationTimeBase + ", " + getDurationTimeBase() + " ms");
+logger.log(Level.DEBUG, "durationTimeBase: " + durationTimeBase + ", " + getDurationTimeBase() + " ms");
this.gateTimeTimeBase = dis.readUnsignedByte();
-Debug.println(Level.FINE, "gateTimeTimeBase: " + gateTimeTimeBase + ", " + getGateTimeTimeBase() + " ms");
+logger.log(Level.DEBUG, "gateTimeTimeBase: " + gateTimeTimeBase + ", " + getGateTimeTimeBase() + " ms");
switch (formatType) {
case HandyPhoneStandard: {
byte[] buffer = new byte[2];
dis.readFully(buffer);
-//Debug.println(StringUtil.getDump(channelStatus));
+//logger.log(Level.DEBUG, StringUtil.getDump(channelStatus));
this.channelStatuses = new ChannelStatus[4];
for (int i = 0; i < 4; i++) {
channelStatuses[i] = new ChannelStatus(i, (byte) ((buffer[i / 2] & (0xf0 >> (4 * (i % 2)))) >> (4 * ((i + 1) % 2))));
-//Debug.println(channelStatuses[i]);
+//logger.log(Level.DEBUG, channelStatuses[i]);
}
} break;
case MobileStandard_Compress:
@@ -85,7 +89,7 @@ protected void init(MyDataInputStream dis, Chunk parent)
this.channelStatuses = new ChannelStatus[16];
for (int i = 0; i < 16; i++) {
channelStatuses[i] = new ChannelStatus(i, (int) buffer[i]);
-//Debug.println(channelStatuses[i]);
+//logger.log(Level.DEBUG, channelStatuses[i]);
}
} break;
case Unknown3: {
@@ -94,10 +98,10 @@ protected void init(MyDataInputStream dis, Chunk parent)
// TODO implement
} break;
}
-Debug.println(Level.FINE, "formatType: " + formatType);
+logger.log(Level.DEBUG, "formatType: " + formatType);
while (dis.available() > 0) {
-//Debug.println("available: " + is.available() + ", " + available());
+//logger.log(Level.DEBUG, "available: " + is.available() + ", " + available());
Chunk chunk = readFrom(dis);
if (chunk instanceof SeekAndPhraseInfoChunk) {
seekAndPhraseInfoChunk = chunk;
@@ -108,7 +112,7 @@ protected void init(MyDataInputStream dis, Chunk parent)
} else if (chunk instanceof StreamPcmDataChunk) {
streamPcmDataChunk = chunk;
} else {
-Debug.println(Level.WARNING, "unsupported chunk: " + chunk.getClass());
+logger.log(Level.WARNING, "unsupported chunk: " + chunk.getClass());
}
}
}
@@ -202,7 +206,7 @@ public List getSmafEvents() throws InvalidSmafDataException {
List messages = ((SetupDataChunk) setupDataChunk).getSmafMessages();
for (SmafMessage message : messages) {
events.add(new SmafEvent(message, 0L));
-//Debug.println("SetupDataChunk: " + message);
+//logger.log(Level.DEBUG, "SetupDataChunk: " + message);
}
}
@@ -211,7 +215,7 @@ public List getSmafEvents() throws InvalidSmafDataException {
List messages = ((StreamPcmDataChunk) streamPcmDataChunk).getSmafMessages();
for (SmafMessage message : messages) {
events.add(new SmafEvent(message, 0L)); // TODO 0l
-//Debug.println("StreamPcmDataChunk: " + message);
+//logger.log(Level.DEBUG, "StreamPcmDataChunk: " + message);
}
}
@@ -219,7 +223,7 @@ public List getSmafEvents() throws InvalidSmafDataException {
List messages = ((SequenceDataChunk) sequenceDataChunk).getSmafMessages();
for (SmafMessage message : messages) {
events.add(new SmafEvent(message, 0L)); // TODO 0l
-//Debug.println("SequenceDataChunk: " + message);
+//logger.log(Level.DEBUG, "SequenceDataChunk: " + message);
}
return events;
diff --git a/src/main/java/vavi/sound/smaf/chunk/SeekAndPhraseInfoChunk.java b/src/main/java/vavi/sound/smaf/chunk/SeekAndPhraseInfoChunk.java
index 869cc36..ba4fc4f 100644
--- a/src/main/java/vavi/sound/smaf/chunk/SeekAndPhraseInfoChunk.java
+++ b/src/main/java/vavi/sound/smaf/chunk/SeekAndPhraseInfoChunk.java
@@ -9,14 +9,16 @@
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
import java.nio.ByteBuffer;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
-import java.util.logging.Level;
import vavi.sound.smaf.InvalidSmafDataException;
-import vavi.util.Debug;
+
+import static java.lang.System.getLogger;
/**
@@ -29,10 +31,12 @@
*/
public class SeekAndPhraseInfoChunk extends Chunk {
+ private static final Logger logger = getLogger(SeekAndPhraseInfoChunk.class.getName());
+
/** */
public SeekAndPhraseInfoChunk(byte[] id, int size) {
super(id, size);
-//Debug.println("SeekAndPhraseInfo: " + size);
+//logger.log(Level.DEBUG, "SeekAndPhraseInfo: " + size);
}
/** */
@@ -46,17 +50,17 @@ protected void init(MyDataInputStream dis, Chunk parent)
throws InvalidSmafDataException, IOException {
byte[] data = new byte[size];
-Debug.println(Level.FINE, "SeekAndPhraseInfo: " + size + " bytes (subData)");
+logger.log(Level.DEBUG, "SeekAndPhraseInfo: " + size + " bytes (subData)");
dis.readFully(data);
int i = 0;
while (i < size) {
-//Debug.println(i + " / " + option.length + "\n" + StringUtil.getDump(option, i, option.length - i));
+//logger.log(Level.DEBUG, i + " / " + option.length + "\n" + StringUtil.getDump(option, i, option.length - i));
SubData subDatum = new SubData(data, i);
subData.put(subDatum.getTag(), subDatum);
-Debug.println(Level.FINE, "SeekAndPhraseInfo: subData: " + subDatum);
+logger.log(Level.DEBUG, "SeekAndPhraseInfo: subData: " + subDatum);
i += 2 + 1 + subDatum.getData().length + 1; // tag ':' data ','
-//Debug.println(i + " / " + option.length + "\n" + StringUtil.getDump(option, i, option.length - i));
+//logger.log(Level.DEBUG, i + " / " + option.length + "\n" + StringUtil.getDump(option, i, option.length - i));
}
}
@@ -73,7 +77,7 @@ public void writeTo(OutputStream os) throws IOException {
}
/** */
- private Map subData = new TreeMap<>();
+ private final Map subData = new TreeMap<>();
/** */
private static final String TAG_StartPoint = "st";
diff --git a/src/main/java/vavi/sound/smaf/chunk/SequenceDataChunk.java b/src/main/java/vavi/sound/smaf/chunk/SequenceDataChunk.java
index dd362d3..f01ab71 100644
--- a/src/main/java/vavi/sound/smaf/chunk/SequenceDataChunk.java
+++ b/src/main/java/vavi/sound/smaf/chunk/SequenceDataChunk.java
@@ -11,11 +11,12 @@
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import java.util.logging.Level;
import vavi.sound.midi.MidiUtil;
import vavi.sound.smaf.InvalidSmafDataException;
@@ -34,10 +35,10 @@
import vavi.sound.smaf.message.ProgramChangeMessage;
import vavi.sound.smaf.message.UndefinedMessage;
import vavi.sound.smaf.message.VolumeMessage;
-import vavi.util.Debug;
-
import vavix.io.huffman.Huffman;
+import static java.lang.System.getLogger;
+
/**
* SequenceData Chunk.
@@ -49,10 +50,12 @@
*/
public class SequenceDataChunk extends Chunk {
+ private static final Logger logger = getLogger(SequenceDataChunk.class.getName());
+
/** */
public SequenceDataChunk(byte[] id, int size) {
super(id, size);
-Debug.println(Level.FINE, "SequenceData: " + size + " bytes");
+logger.log(Level.DEBUG, "SequenceData: " + size + " bytes");
}
/** */
@@ -65,7 +68,7 @@ public SequenceDataChunk() {
@Override
protected void init(MyDataInputStream dis, Chunk parent)
throws InvalidSmafDataException, IOException {
-//Debug.println("available: " + is.available() + ", " + available());
+//logger.log(Level.DEBUG, "available: " + is.available() + ", " + available());
//skip(is, size);
ScoreTrackChunk.FormatType formatType = ((TrackChunk) parent).getFormatType();
switch (formatType) {
@@ -81,14 +84,14 @@ protected void init(MyDataInputStream dis, Chunk parent)
//os1.write(baos.toByteArray());
//os1.flush();
//os1.close();
-//Debug.println("data.enc created");
+//logger.log(Level.DEBUG, "data.enc created");
byte[] decoded = new Huffman().decode(baos.toByteArray());
//OutputStream os2 = new FileOutputStream("/tmp/data.dec");
//os2.write(decoded);
//os2.flush();
//os2.close();
-//Debug.println("data.dec created");
-Debug.println(Level.FINE, "decode: " + size + " -> " + decoded.length);
+//logger.log(Level.DEBUG, "data.dec created");
+logger.log(Level.DEBUG, "decode: " + size + " -> " + decoded.length);
size = decoded.length;
readMobileStandard(new MyDataInputStream(new ByteArrayInputStream(decoded), id, decoded.length));
break;
@@ -97,7 +100,7 @@ protected void init(MyDataInputStream dis, Chunk parent)
readMobileStandard(dis);
break;
}
-Debug.println(Level.FINE, "messages: " + messages.size());
+logger.log(Level.DEBUG, "messages: " + messages.size());
}
/**
@@ -118,7 +121,7 @@ protected void readHandyPhoneStandard(MyDataInputStream dis)
while (dis.available() > 0) {
// -------- duration --------
int duration = MidiUtil.readVariableLength(dis);
-//Debug.println("duration: " + duration + ", 0x" + StringUtil.toHex4(duration));
+//logger.log(Level.DEBUG, "duration: " + duration + ", 0x" + StringUtil.toHex4(duration));
// -------- event --------
int e1 = dis.readUnsignedByte();
if (e1 == 0xff) { // exclusive, nop
@@ -136,12 +139,12 @@ protected void readHandyPhoneStandard(MyDataInputStream dis)
break;
default:
smafMessage = new UndefinedMessage(duration);
-Debug.printf(Level.WARNING, "unknown 0xff, 0x02x\n", e2);
+logger.log(Level.WARNING, String.format("unknown 0xff, 0x%02x", e2));
break;
}
} else if (e1 != 0x00) { // note
int gateTime = MidiUtil.readVariableLength(dis);
-//Debug.println("gateTime: " + gateTime + ", 0x" + StringUtil.toHex4(gateTime));
+//logger.log(Level.DEBUG, String.format("gateTime: %d, 0x%04x", gateTime, gateTime));
smafMessage = getHandyPhoneStandardMessage(duration, e1, gateTime);
} else { // e1 == 0x00 other event
int e2 = dis.readUnsignedByte();
@@ -151,7 +154,7 @@ protected void readHandyPhoneStandard(MyDataInputStream dis)
smafMessage = new EndOfSequenceMessage(duration);
} else {
smafMessage = new UndefinedMessage(duration);
-Debug.printf(Level.WARNING, "unknown 0x00, 0x00, 0x02x\n", e3);
+logger.log(Level.WARNING, String.format("unknown 0x00, 0x00, 0x%02x", e3));
}
} else {
int channel = (e2 & 0xc0) >> 6;
@@ -187,7 +190,7 @@ protected void readHandyPhoneStandard(MyDataInputStream dis)
break;
default:
smafMessage = new UndefinedMessage(duration);
-Debug.printf(Level.WARNING, "unknown 0x00, 0x02x, 3, %02x\n", e2, data);
+logger.log(Level.WARNING, String.format("unknown 0x00, 0x%02x, 3, %02x", e2, data));
break;
}
break;
@@ -203,9 +206,9 @@ protected void readHandyPhoneStandard(MyDataInputStream dis)
}
}
}
-//Debug.println(available() + ", " + smafMessage);
+//logger.log(Level.DEBUG, available() + ", " + smafMessage);
if (smafMessage != null) {
-//Debug.println("message: " + smafMessage);
+//logger.log(Level.DEBUG, "message: " + smafMessage);
messages.add(smafMessage);
} else {
assert false : "smafMessage is null";
@@ -220,7 +223,7 @@ protected void readHandyPhoneStandard(MyDataInputStream dis)
};
/** debug */
-private Set uc = new HashSet<>();
+private final Set uc = new HashSet<>();
/** debug */
private int cc = 0;
@@ -233,7 +236,7 @@ private void readMobileStandard(MyDataInputStream dis)
while (dis.available() > 0) {
// duration
int duration = MidiUtil.readVariableLength(dis);
-//Debug.println("duration: " + duration);
+//logger.log(Level.DEBUG, "duration: " + duration);
// event
int status = dis.readUnsignedByte();
if (status >= 0x80 && status <= 0x8f) { // note w/o velocity
@@ -251,7 +254,7 @@ private void readMobileStandard(MyDataInputStream dis)
int d1 = dis.readUnsignedByte();
int d2 = dis.readUnsignedByte();
smafMessage = null;
-Debug.printf(Level.WARNING, "reserved: 0xa_: %02x%02x\n", d1, d2);
+logger.log(Level.WARNING, String.format("reserved: 0xa_: %02x%02x", d1, d2));
} else if (status >= 0xb0 && status <= 0xbf) { // control change
int channel = status & 0x0f;
int control = dis.readUnsignedByte();
@@ -293,7 +296,7 @@ private void readMobileStandard(MyDataInputStream dis)
break;
default:
smafMessage = new UndefinedMessage(duration);
-Debug.printf(Level.WARNING, "undefined control: %02x, %02x\n", control, value);
+logger.log(Level.WARNING, String.format("undefined control: %02x, %02x", control, value));
break;
}
} else if (status >= 0xc0 && status <= 0xcf) { // program change
@@ -303,7 +306,7 @@ private void readMobileStandard(MyDataInputStream dis)
} else if (status >= 0xd0 && status <= 0xdf) { // reserved
int d1 = dis.readUnsignedByte();
smafMessage = new UndefinedMessage(duration);
-Debug.printf(Level.WARNING, "reserved: 0xd_: %02x\n", d1);
+logger.log(Level.WARNING, String.format("reserved: 0xd_: %02x", d1));
} else if (status >= 0xe0 && status <= 0xef) { // pitch vend message
int channel = status & 0x0f;
int lsb = dis.readUnsignedByte();
@@ -318,13 +321,13 @@ private void readMobileStandard(MyDataInputStream dis)
case 0x2f:
int d2 = dis.readUnsignedByte(); // must be 0
if (d2 != 0) {
-Debug.printf(Level.WARNING, "illegal state: %02x\n", d2);
+logger.log(Level.WARNING, String.format("illegal state: %02x", d2));
}
smafMessage = new EndOfSequenceMessage(duration);
break;
default:
smafMessage = new UndefinedMessage(duration);
-Debug.printf(Level.WARNING, "unknown: 0xff: %02x\n", d1);
+logger.log(Level.WARNING, String.format("unknown: 0xff: %02x", d1));
break;
}
} else if (status == 0xf0) { // exclusive
@@ -336,18 +339,18 @@ private void readMobileStandard(MyDataInputStream dis)
} else if (status < 0x80) { // data
smafMessage = null;
if (cc < 10) {
- Debug.printf(Level.WARNING, "data found, ignore: %02x\n", status);
+ logger.log(Level.WARNING, String.format("data found, ignore: %02x", status));
}
cc++;
} else /* 0xf1 ~ 0xfe */ { // reserved
smafMessage = new UndefinedMessage(duration);
if (!uc.contains(String.format("reserved: %02x", status))) {
- Debug.printf(Level.WARNING, "reserved: %02x\n", status);
+ logger.log(Level.WARNING, String.format("reserved: %02x", status));
uc.add(String.format("reserved: %02x", status));
}
}
-//Debug.println(available() + ", " + smafMessage);
+//logger.log(Level.DEBUG, available() + ", " + smafMessage);
if (smafMessage != null) {
messages.add(smafMessage);
} else {
@@ -369,7 +372,7 @@ public void writeTo(OutputStream os) throws IOException {
}
/** */
- protected List messages = new ArrayList<>();
+ protected final List messages = new ArrayList<>();
/**
* @return Returns the messages.
diff --git a/src/main/java/vavi/sound/smaf/chunk/SetupDataChunk.java b/src/main/java/vavi/sound/smaf/chunk/SetupDataChunk.java
index 0b22601..7c087a4 100644
--- a/src/main/java/vavi/sound/smaf/chunk/SetupDataChunk.java
+++ b/src/main/java/vavi/sound/smaf/chunk/SetupDataChunk.java
@@ -9,16 +9,18 @@
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
+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 vavi.sound.midi.MidiUtil;
import vavi.sound.smaf.InvalidSmafDataException;
import vavi.sound.smaf.SmafMessage;
import vavi.sound.smaf.SysexMessage;
import vavi.sound.smaf.message.UndefinedMessage;
-import vavi.util.Debug;
+
+import static java.lang.System.getLogger;
/**
@@ -31,10 +33,12 @@
*/
public class SetupDataChunk extends Chunk {
+ private static final Logger logger = getLogger(SetupDataChunk.class.getName());
+
/** */
public SetupDataChunk(byte[] id, int size) {
super(id, size);
-Debug.println(Level.FINE, "SetupData: " + size + " bytes");
+logger.log(Level.DEBUG, "SetupData: " + size + " bytes");
}
/** */
@@ -59,7 +63,7 @@ protected void init(MyDataInputStream dis, Chunk parent) throws InvalidSmafDataE
readMobileStandard(dis);
break;
}
-Debug.println(Level.FINE, "messages: " + messages.size());
+logger.log(Level.DEBUG, "messages: " + messages.size());
}
/**
@@ -92,12 +96,12 @@ private void readHandyPhoneStandard(MyDataInputStream dis) throws InvalidSmafDat
break;
default:
smafMessage = new UndefinedMessage(0);
-Debug.printf(Level.WARNING, "unknown 0xff, 0x%02x\n", e2);
+logger.log(Level.WARNING, String.format("unknown 0xff, 0x%02x", e2));
break;
}
} else {
smafMessage = new UndefinedMessage(0);
-Debug.printf(Level.WARNING, "unhandled: %02x\n", e1);
+logger.log(Level.WARNING, String.format("unhandled: %02x", e1));
}
if (smafMessage != null) {
@@ -124,7 +128,7 @@ private void readMobileStandard(MyDataInputStream dis) throws InvalidSmafDataExc
smafMessage = SysexMessage.Factory.getSysexMessage(0, data);
} else {
smafMessage = new UndefinedMessage(0);
-Debug.printf(Level.WARNING, "unhandled: %02x\n", status);
+logger.log(Level.WARNING, String.format("unhandled: %02x", status));
}
if (smafMessage != null) {
@@ -149,7 +153,7 @@ public void writeTo(OutputStream os) throws IOException {
}
/** SysEx messages */
- private List messages = new ArrayList<>();
+ private final List messages = new ArrayList<>();
/**
* @return Returns the messages.
diff --git a/src/main/java/vavi/sound/smaf/chunk/StreamPcmDataChunk.java b/src/main/java/vavi/sound/smaf/chunk/StreamPcmDataChunk.java
index 935a8d5..00ad30b 100644
--- a/src/main/java/vavi/sound/smaf/chunk/StreamPcmDataChunk.java
+++ b/src/main/java/vavi/sound/smaf/chunk/StreamPcmDataChunk.java
@@ -9,13 +9,15 @@
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
+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 vavi.sound.smaf.InvalidSmafDataException;
import vavi.sound.smaf.SmafMessage;
-import vavi.util.Debug;
+
+import static java.lang.System.getLogger;
/**
@@ -29,10 +31,12 @@
*/
public class StreamPcmDataChunk extends Chunk {
+ private static final Logger logger = getLogger(StreamPcmDataChunk.class.getName());
+
/** */
public StreamPcmDataChunk(byte[] id, int size) {
super(id, size);
-Debug.println(Level.FINE, "StreamPcmData: " + size);
+logger.log(Level.DEBUG, "StreamPcmData: " + size);
}
/** */
@@ -48,7 +52,7 @@ protected void init(MyDataInputStream dis, Chunk parent) throws InvalidSmafDataE
if (chunk instanceof StreamWaveDataChunk) {
streamWaveDataChunks.add(chunk);
} else {
-Debug.println(Level.WARNING, "unknown chunk: " + chunk.getClass());
+logger.log(Level.WARNING, "unknown chunk: " + chunk.getClass());
}
}
}
@@ -66,7 +70,7 @@ public void writeTo(OutputStream os) throws IOException {
}
/** */
- private List streamWaveDataChunks = new ArrayList<>();
+ private final List streamWaveDataChunks = new ArrayList<>();
/** "Mwa*" */
public void addWaveDataChunk(Chunk streamWaveDataChunk) {
diff --git a/src/main/java/vavi/sound/smaf/chunk/StreamWaveDataChunk.java b/src/main/java/vavi/sound/smaf/chunk/StreamWaveDataChunk.java
index 3019209..ad21770 100644
--- a/src/main/java/vavi/sound/smaf/chunk/StreamWaveDataChunk.java
+++ b/src/main/java/vavi/sound/smaf/chunk/StreamWaveDataChunk.java
@@ -7,12 +7,14 @@
package vavi.sound.smaf.chunk;
import java.io.IOException;
-import java.util.logging.Level;
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
import vavi.sound.smaf.InvalidSmafDataException;
import vavi.sound.smaf.SmafMessage;
import vavi.sound.smaf.message.WaveDataMessage;
-import vavi.util.Debug;
+
+import static java.lang.System.getLogger;
/**
@@ -25,10 +27,12 @@
*/
public class StreamWaveDataChunk extends WaveDataChunk {
+ private static final Logger logger = getLogger(StreamWaveDataChunk.class.getName());
+
/** */
public StreamWaveDataChunk(byte[] id, int size) {
super(id, size);
-Debug.println(Level.FINE, "StreamWaveData: " + size);
+logger.log(Level.DEBUG, "StreamWaveData: " + size);
}
/** */
diff --git a/src/main/java/vavi/sound/smaf/chunk/SubData.java b/src/main/java/vavi/sound/smaf/chunk/SubData.java
index ebf2592..bfe7553 100644
--- a/src/main/java/vavi/sound/smaf/chunk/SubData.java
+++ b/src/main/java/vavi/sound/smaf/chunk/SubData.java
@@ -89,7 +89,7 @@ public int getSize() {
}
/** */
- private String tag;
+ private final String tag;
/** tag */
public String getTag() {
@@ -97,7 +97,7 @@ public String getTag() {
}
/** */
- private byte[] data;
+ private final byte[] data;
/** Data */
public byte[] getData() {
diff --git a/src/main/java/vavi/sound/smaf/chunk/TrackChunk.java b/src/main/java/vavi/sound/smaf/chunk/TrackChunk.java
index 4251c75..a583627 100644
--- a/src/main/java/vavi/sound/smaf/chunk/TrackChunk.java
+++ b/src/main/java/vavi/sound/smaf/chunk/TrackChunk.java
@@ -139,7 +139,7 @@ public void setSequenceType(SequenceType sequenceType) {
* @param timeBase real timeBase [msec]
* @return index of timeBase
*/
- private int findTimeBase(int timeBase) {
+ private static int findTimeBase(int timeBase) {
for (int i = 0; i < timeBaseTable.length; i++) {
if (timeBase == timeBaseTable[i]) {
return i;
diff --git a/src/main/java/vavi/sound/smaf/chunk/UndefinedChunk.java b/src/main/java/vavi/sound/smaf/chunk/UndefinedChunk.java
index 4e802e4..f783a72 100644
--- a/src/main/java/vavi/sound/smaf/chunk/UndefinedChunk.java
+++ b/src/main/java/vavi/sound/smaf/chunk/UndefinedChunk.java
@@ -8,12 +8,14 @@
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 vavi.sound.smaf.InvalidSmafDataException;
-import vavi.util.Debug;
import vavi.util.StringUtil;
+import static java.lang.System.getLogger;
+
/**
* Undefined Chunk.
@@ -23,6 +25,8 @@
*/
public class UndefinedChunk extends Chunk {
+ private static final Logger logger = getLogger(UndefinedChunk.class.getName());
+
/** */
public UndefinedChunk(byte[] id, int size) {
super(id, size);
@@ -34,18 +38,18 @@ protected void init(MyDataInputStream dis, Chunk parent)
throws InvalidSmafDataException, IOException {
if (size > dis.available()) {
-Debug.println(Level.WARNING, "read size is larger than available stream");
+logger.log(Level.WARNING, "read size is larger than available stream");
//new Exception("*** DUMMY ***").printStackTrace(System.err);
throw new InvalidSmafDataException("read size is larger than available stream");
}
byte[] data = new byte[size];
dis.readFully(data);
-Debug.println(Level.WARNING, "Undefined: size: " + size + "\n" + StringUtil.getDump(data, 64));
+logger.log(Level.WARNING, "Undefined: size: " + size + "\n" + StringUtil.getDump(data, 64));
}
@Override
public void writeTo(OutputStream os) throws IOException {
// TODO
-Debug.println(Level.WARNING, "not implemented skip");
+logger.log(Level.WARNING, "not implemented skip");
}
}
diff --git a/src/main/java/vavi/sound/smaf/chunk/WaveDataChunk.java b/src/main/java/vavi/sound/smaf/chunk/WaveDataChunk.java
index c7aabe6..94c5e8a 100644
--- a/src/main/java/vavi/sound/smaf/chunk/WaveDataChunk.java
+++ b/src/main/java/vavi/sound/smaf/chunk/WaveDataChunk.java
@@ -9,12 +9,14 @@
import java.io.DataOutputStream;
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 vavi.sound.smaf.InvalidSmafDataException;
import vavi.sound.smaf.SmafMessage;
import vavi.sound.smaf.message.WaveDataMessage;
-import vavi.util.Debug;
+
+import static java.lang.System.getLogger;
/**
@@ -27,12 +29,14 @@
*/
public class WaveDataChunk extends Chunk {
+ private static final Logger logger = getLogger(WaveDataChunk.class.getName());
+
/** */
public WaveDataChunk(byte[] id, int size) {
super(id, size);
waveNumber = id[3] & 0xff;
-Debug.println(Level.FINE, "WaveData[" + waveNumber + "]: " + size + " bytes");
+logger.log(Level.DEBUG, "WaveData[" + waveNumber + "]: " + size + " bytes");
}
/** */
diff --git a/src/main/java/vavi/sound/smaf/chunk/WaveType.java b/src/main/java/vavi/sound/smaf/chunk/WaveType.java
index b7fb891..c8068e2 100644
--- a/src/main/java/vavi/sound/smaf/chunk/WaveType.java
+++ b/src/main/java/vavi/sound/smaf/chunk/WaveType.java
@@ -7,9 +7,10 @@
package vavi.sound.smaf.chunk;
import java.io.IOException;
-import java.util.logging.Level;
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
-import vavi.util.Debug;
+import static java.lang.System.getLogger;
/**
@@ -33,8 +34,10 @@
*/
public class WaveType {
+ private static final Logger logger = getLogger(WaveType.class.getName());
+
/** 1, 2 */
- private int waveChannels;
+ private final int waveChannels;
/**
* TODO different numbers in chunks, can it be solved with enum?
@@ -61,16 +64,16 @@ public class WaveType {
* 5 Offset Binary PCM (unsigned PCM?)
*
*/
- private int waveFormat;
+ private final int waveFormat;
/** */
private static final int[] samplingFreqs = { 4000, 8000, 11000, 22050, 44100 };
/** 4000, 8000, 11000, 22050, 44100 */
- private int waveSamplingFreq;
+ private final int waveSamplingFreq;
/** 4, 8, 12, 16 */
- private int waveBaseBit;
+ private final int waveBaseBit;
/** */
private static final int[] tableForMwq = { 4, 5, 1 };
@@ -88,12 +91,12 @@ public class WaveType {
*
*/
WaveType(int waveType) throws IOException {
-//Debug.println("waveType: " + StringUtil.toHex4(waveType));
+//logger.log(Level.DEBUG, "waveType: " + StringUtil.toHex4(waveType));
this.waveChannels = (waveType & 0x8000) != 0 ? 2 : 1;
this.waveFormat = (waveType & 0x7000) >> 12;
this.waveSamplingFreq = samplingFreqs[(waveType & 0x0f00) >> 8];
this.waveBaseBit = 4 * (((waveType & 0x00f0) >> 4) + 1);
-Debug.println(Level.FINE, "waveType: " + this);
+logger.log(Level.DEBUG, "waveType: " + this);
}
/**
@@ -108,12 +111,12 @@ public class WaveType {
*
*/
WaveType(byte[] waveType) throws IOException {
-Debug.printf(Level.FINE, "waveType: %02x %02x %02x\n", waveType[0], waveType[1], waveType[2]);
+logger.log(Level.DEBUG, String.format("waveType: %02x %02x %02x", waveType[0], waveType[1], waveType[2]));
this.waveChannels = (waveType[0] & 0x80) != 0 ? 2 : 1;
this.waveFormat = tableForMwq[(waveType[0] & 0x70) >> 4];
this.waveBaseBit = 4 * ((waveType[0] & 0x0f) + 1);
this.waveSamplingFreq = ((waveType[1] & 0xff) << 8) | waveType[2] & 0xff;
-Debug.println(Level.FINE, "waveType: " + this);
+logger.log(Level.DEBUG, "waveType: " + this);
}
/**
@@ -135,25 +138,13 @@ int intValue() {
int waveType = 0;
waveType |= waveChannels == 2 ? 0x8000: 0;
waveType |= waveFormat << 12; // TODO 5, 6
- int v;
- switch (waveSamplingFreq) {
- case 4000:
- v = 0;
- break;
- case 8000:
- default:
- v = 1;
- break;
- case 11000:
- v = 2;
- break;
- case 22050:
- v = 3;
- break;
- case 44100:
- v = 4;
- break;
- }
+ int v = switch (waveSamplingFreq) {
+ case 4000 -> 0;
+ default -> 1;
+ case 11000 -> 2;
+ case 22050 -> 3;
+ case 44100 -> 4;
+ };
waveType |= v << 8;
waveType |= (waveBaseBit / 4 - 1) << 4;
return waveType;
diff --git a/src/main/java/vavi/sound/smaf/chunk/readme.md b/src/main/java/vavi/sound/smaf/chunk/readme.md
index a053586..48a575f 100644
--- a/src/main/java/vavi/sound/smaf/chunk/readme.md
+++ b/src/main/java/vavi/sound/smaf/chunk/readme.md
@@ -1,10 +1,10 @@
# vavi.sound.smaf.chunk
-SMAF サウンド関連のファイル構造を表すクラスを提供します.
+Provides a class that represents the file structure related to SMAF sound.
## Abstract
-SMAF ファイルの読み込み時に使用されます。
+Used when reading SMAF files.
## Structure
diff --git a/src/main/java/vavi/sound/smaf/message/BankSelectMessage.java b/src/main/java/vavi/sound/smaf/message/BankSelectMessage.java
index 270ef4b..4c47534 100644
--- a/src/main/java/vavi/sound/smaf/message/BankSelectMessage.java
+++ b/src/main/java/vavi/sound/smaf/message/BankSelectMessage.java
@@ -6,7 +6,8 @@
package vavi.sound.smaf.message;
-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.MidiEvent;
import javax.sound.midi.ShortMessage;
@@ -14,7 +15,8 @@
import vavi.sound.smaf.InvalidSmafDataException;
import vavi.sound.smaf.SmafEvent;
import vavi.sound.smaf.chunk.TrackChunk.FormatType;
-import vavi.util.Debug;
+
+import static java.lang.System.getLogger;
/**
@@ -26,6 +28,8 @@
public class BankSelectMessage extends vavi.sound.smaf.ShortMessage
implements MidiConvertible, SmafConvertible {
+ private static final Logger logger = getLogger(BankSelectMessage.class.getName());
+
/** smaf channel */
private int channel;
@@ -125,7 +129,7 @@ public MidiEvent[] getMidiEvents(MidiContext context)
throws InvalidMidiDataException {
if (significant == null) { // HandyPhoneStandard
-Debug.printf(Level.FINE, "BankSelect: [%d] %dch, 0x%02x", duration, channel, bank);
+logger.log(Level.DEBUG, String.format("BankSelect: [%d] %dch, 0x%02x", duration, channel, bank));
int data2;
if ((bank & 0x80) != 0) {
context.setDrum(channel, MidiContext.ChannelConfiguration.PERCUSSION);
@@ -161,7 +165,7 @@ public MidiEvent[] getMidiEvents(MidiContext context)
} else { // MobileStandard
int midiChannel = context.retrieveChannel(this.channel);
-Debug.println(Level.FINE, "BankSelect(" + significant + "): [" + duration + "] " + midiChannel + "ch, " + bank);
+logger.log(Level.DEBUG, "BankSelect(" + significant + "): [" + duration + "] " + midiChannel + "ch, " + bank);
ShortMessage shortMessage = new ShortMessage();
shortMessage.setMessage(ShortMessage.CONTROL_CHANGE,
midiChannel,
@@ -190,7 +194,7 @@ public SmafEvent[] getSmafEvents(MidiEvent midiEvent, SmafContext context)
changeBankMessage.setBank(data1);
context.setBeforeTick(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 SmafEvent[] {
new SmafEvent(changeBankMessage, midiEvent.getTick()),
diff --git a/src/main/java/vavi/sound/smaf/message/EndOfSequenceMessage.java b/src/main/java/vavi/sound/smaf/message/EndOfSequenceMessage.java
index dc8ffa9..0a9166a 100644
--- a/src/main/java/vavi/sound/smaf/message/EndOfSequenceMessage.java
+++ b/src/main/java/vavi/sound/smaf/message/EndOfSequenceMessage.java
@@ -9,14 +9,15 @@
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
-import java.util.logging.Level;
-
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
import javax.sound.midi.MidiEvent;
import vavi.sound.midi.MidiUtil;
import vavi.sound.smaf.SmafEvent;
import vavi.sound.smaf.chunk.TrackChunk.FormatType;
-import vavi.util.Debug;
+
+import static java.lang.System.getLogger;
/**
@@ -34,6 +35,8 @@
public class EndOfSequenceMessage extends vavi.sound.smaf.ShortMessage
implements MidiConvertible, SmafConvertible {
+ private static final Logger logger = getLogger(EndOfSequenceMessage.class.getName());
+
/** for SmafConvertible */
public EndOfSequenceMessage() {
}
@@ -87,7 +90,7 @@ public MidiEvent[] getMidiEvents(MidiContext context) {
javax.sound.midi.Track midiTrack = context.getMidiTrack();
MidiEvent midiEvent = midiTrack.get(midiTrack.size() - 1); // should be EoT
midiEvent.setTick(context.getCurrentTick());
-Debug.println(Level.FINE, "EOT: " + midiEvent.getMessage().getClass().getName());
+logger.log(Level.DEBUG, "EOT: " + midiEvent.getMessage().getClass().getName());
return null;
}
diff --git a/src/main/java/vavi/sound/smaf/message/ExpressionMessage.java b/src/main/java/vavi/sound/smaf/message/ExpressionMessage.java
index 09f77ac..a7e06d2 100644
--- a/src/main/java/vavi/sound/smaf/message/ExpressionMessage.java
+++ b/src/main/java/vavi/sound/smaf/message/ExpressionMessage.java
@@ -95,7 +95,7 @@ public MidiEvent[] getMidiEvents(MidiContext context)
MidiEvent[] events = new MidiEvent[1];
ShortMessage shortMessage = new ShortMessage();
-//Debug.println("Expression: [" + duration + "] " + channel + "ch, " + volume);
+//logger.log(Level.DEBUG, "Expression: [" + duration + "] " + channel + "ch, " + volume);
shortMessage.setMessage(ShortMessage.CONTROL_CHANGE,
midiChannel,
11, // expression MSB
diff --git a/src/main/java/vavi/sound/smaf/message/MidiContext.java b/src/main/java/vavi/sound/smaf/message/MidiContext.java
index 5d432a5..ae6712f 100644
--- a/src/main/java/vavi/sound/smaf/message/MidiContext.java
+++ b/src/main/java/vavi/sound/smaf/message/MidiContext.java
@@ -6,8 +6,9 @@
package vavi.sound.smaf.message;
+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.MetaMessage;
import javax.sound.midi.MidiEvent;
@@ -20,7 +21,8 @@
import vavi.sound.smaf.chunk.ChannelStatus;
import vavi.sound.smaf.chunk.ScoreTrackChunk;
import vavi.sound.smaf.chunk.TrackChunk.FormatType;
-import vavi.util.Debug;
+
+import static java.lang.System.getLogger;
/**
@@ -31,6 +33,8 @@
*/
public class MidiContext {
+ private static final Logger logger = getLogger(MidiContext.class.getName());
+
/** Max MIDI channels */
public static final int MAX_MIDI_CHANNELS = 16;
@@ -73,7 +77,7 @@ public void setTrack(Track smafTrack) {
if (metaMessage.getType() == MetaEvent.META_MACHINE_DEPEND.number()) {
//
this.formatType = (FormatType) metaMessage.getData().get("formatType"); // [ms]
-Debug.println(Level.FINE, "formatType: " + formatType);
+logger.log(Level.DEBUG, "formatType: " + formatType);
for (int i = 0; i < MAX_MIDI_CHANNELS; i++) {
if (formatType == FormatType.HandyPhoneStandard) {
velocities[i] = 0x7f;
@@ -83,7 +87,7 @@ public void setTrack(Track smafTrack) {
}
//
ChannelStatus[] channelStatuses = (ChannelStatus[]) metaMessage.getData().get("channelStatuses");
-Debug.println(Level.FINE, "channelStatuses: " + (channelStatuses != null ? channelStatuses.length : null));
+logger.log(Level.DEBUG, "channelStatuses: " + (channelStatuses != null ? channelStatuses.length : null));
if (channelStatuses != null) {
for (int i = 0; i < channelStatuses.length; i++) {
setDrum(i, toChannelConfiguration(getMidiChannel(i), channelStatuses[i].getType()));
@@ -113,18 +117,14 @@ public javax.sound.midi.Track getMidiTrack() {
}
/** convert types */
- private ChannelConfiguration toChannelConfiguration(int midiChannel, ChannelStatus.Type type) {
- switch (type) {
- case Melody:
- return ChannelConfiguration.SOUND_SET;
- case NoCare:
- return midiChannel == CHANNEL_DRUM ? ChannelConfiguration.PERCUSSION : ChannelConfiguration.SOUND_SET;
- case NoMelody:
- default:
- return ChannelConfiguration.UNUSED;
- case Rhythm:
- return ChannelConfiguration.PERCUSSION;
- }
+ private static ChannelConfiguration toChannelConfiguration(int midiChannel, ChannelStatus.Type type) {
+ return switch (type) {
+ case Melody -> ChannelConfiguration.SOUND_SET;
+ case NoCare ->
+ midiChannel == CHANNEL_DRUM ? ChannelConfiguration.PERCUSSION : ChannelConfiguration.SOUND_SET;
+ default -> ChannelConfiguration.UNUSED;
+ case Rhythm -> ChannelConfiguration.PERCUSSION;
+ };
}
/** current track no. */
@@ -141,7 +141,7 @@ public void setSmafTrackNumber(int smafTrackNumber) {
}
/** current ticks, index is smafTrackNumber */
- private long[] currentTicks = new long[4];
+ private final long[] currentTicks = new long[4];
/**
* smafTrackNumber must be set
@@ -168,10 +168,10 @@ public void addCurrentTick(long ticks) {
}
/** whether channel is for rhythm, index is pseudo MIDI channel */
- private ChannelConfiguration[] drums = new ChannelConfiguration[MAX_MIDI_CHANNELS];
+ private final ChannelConfiguration[] drums = new ChannelConfiguration[MAX_MIDI_CHANNELS];
/** index is pseudo MIDI channel */
- private int[] velocities = new int[MAX_MIDI_CHANNELS];
+ private final int[] velocities = new int[MAX_MIDI_CHANNELS];
/* init */ {
Arrays.fill(drums, ChannelConfiguration.UNUSED);
@@ -199,10 +199,10 @@ public void setDrum(int smafChannel, ChannelConfiguration value) {
int midiChannel = getMidiChannel(smafChannel);
if (drumSwapChannel != CHANNEL_UNUSED && midiChannel == drumSwapChannel) {
-Debug.println(Level.FINE, "already swapped: " + midiChannel + ", " + value);
+logger.log(Level.DEBUG, "already swapped: " + midiChannel + ", " + value);
} else {
drums[midiChannel] = value;
-//Debug.println("temporary: " + midiChannel + ", " + value);
+//logger.log(Level.DEBUG, "temporary: " + midiChannel + ", " + value);
}
// if DRUM_CHANNEL is not a rhythm, replace it with an empty channel.
@@ -210,14 +210,14 @@ public void setDrum(int smafChannel, ChannelConfiguration value) {
for (int k = MAX_MIDI_CHANNELS - 1; k >= 0; k--) {
if (k != CHANNEL_DRUM && drums[k] == ChannelConfiguration.UNUSED) {
drumSwapChannel = k;
-Debug.println(Level.FINE, "channel 9 -> " + k);
+logger.log(Level.DEBUG, "channel 9 -> " + k);
break;
}
}
if (drumSwapChannel == CHANNEL_UNUSED) {
- Debug.println(Level.FINE, "cannot swap: " + midiChannel + ", " + value);
+ logger.log(Level.DEBUG, "cannot swap: " + midiChannel + ", " + value);
}
-Debug.println(Level.FINE, "channel configuration: " + midiChannel + "ch, " + drums[midiChannel]);
+logger.log(Level.DEBUG, "channel configuration: " + midiChannel + "ch, " + drums[midiChannel]);
}
if (value != ChannelConfiguration.UNUSED) {
StringBuilder sb1 = new StringBuilder(16);
@@ -228,12 +228,12 @@ public void setDrum(int smafChannel, ChannelConfiguration value) {
sb2.append(midiChannel == i ? "*" : " ");
sb3.append(drums[i].name().charAt(0));
}
-Debug.println(Level.FINE, "drums: " + midiChannel + "ch, " + value + "\n" + sb1 + "\n" + sb2 + "\n" + sb3);
+logger.log(Level.DEBUG, "drums: " + midiChannel + "ch, " + value + "\n" + sb1 + "\n" + sb2 + "\n" + sb3);
}
}
/** program no, index is pseudo MIDI channel assigned to channel */
- private int[] programs = new int[MAX_MIDI_CHANNELS];
+ private final int[] programs = new int[MAX_MIDI_CHANNELS];
/**
* @param smafChannel SMAF channel
@@ -244,7 +244,7 @@ private int getMidiChannel(int smafChannel) {
return smafTrackNumber * 4 + smafChannel;
} else {
if (smafTrackNumber > 0) {
- Debug.println(Level.FINE, "track > 0: " + smafTrackNumber);
+ logger.log(Level.DEBUG, "track > 0: " + smafTrackNumber);
}
return smafTrackNumber * 16 + smafChannel;
}
@@ -259,7 +259,7 @@ public int setProgram(int smafChannel, int program) {
if (formatType != FormatType.HandyPhoneStandard) {
if (midiChannel != drumSwapChannel && drums[midiChannel] == ChannelConfiguration.PERCUSSION) {
-Debug.println(Level.FINE, "drum always zero:[" + midiChannel + "]: " + program);
+logger.log(Level.DEBUG, "drum always zero:[" + midiChannel + "]: " + program);
program = 0;
}
}
@@ -290,7 +290,7 @@ public int retrieveChannel(int smafChannel) {
int midiChannel = getMidiChannel(smafChannel);
// if (midiChannel == drumSwapChannel) {
-//Debug.println("used swapped channel: " + midiChannel);
+//logger.log(Level.DEBUG, "used swapped channel: " + midiChannel);
// }
// drum channel is used as sound
@@ -317,31 +317,21 @@ public int retrievePitch(int smafChannel, int pitch) {
if (formatType == ScoreTrackChunk.FormatType.HandyPhoneStandard) {
int midiChannel = getMidiChannel(smafChannel);
if (drums[midiChannel] == ChannelConfiguration.PERCUSSION) {
-//Debug.println("drum pitch: " + (programs[midiChannel] & 0x7f) + ", " + pitch);
+//logger.log(Level.DEBUG, "drum pitch: " + (programs[midiChannel] & 0x7f) + ", " + pitch);
return programs[midiChannel] & 0x7f;
} else {
pitch += 36;
- switch (octaveShifts[midiChannel]) {
- default:
- case 0:
- return pitch;
- case 1:
- return pitch + 12;
- case 2:
- return pitch + 24;
- case 3:
- return pitch + 36;
- case 4:
- return pitch + 48;
- case 0x81:
- return pitch - 12;
- case 0x82:
- return pitch - 24;
- case 0x83:
- return pitch - 36;
- case 0x84:
- return pitch - 48;
- }
+ return switch (octaveShifts[midiChannel]) {
+ default -> pitch;
+ case 1 -> pitch + 12;
+ case 2 -> pitch + 24;
+ case 3 -> pitch + 36;
+ case 4 -> pitch + 48;
+ case 0x81 -> pitch - 12;
+ case 0x82 -> pitch - 24;
+ case 0x83 -> pitch - 36;
+ case 0x84 -> pitch - 48;
+ };
}
} else {
return pitch;
@@ -368,7 +358,7 @@ public int retrievePitch(int smafChannel, int pitch) {
*
* @see OctaveShiftMessage
*/
- private int[] octaveShifts = new int[MAX_MIDI_CHANNELS];
+ private final int[] octaveShifts = new int[MAX_MIDI_CHANNELS];
/**
* @param smafChannel channel
@@ -379,7 +369,7 @@ public int retrievePitch(int smafChannel, int pitch) {
public void setOctaveShift(int smafChannel, int octaveShift) {
int midiChannel = getMidiChannel(smafChannel);
octaveShifts[midiChannel] = octaveShift;
-//Debug.println("octaveShifts[" + midiChannel + "]: " + octaveShift);
+//logger.log(Level.DEBUG, "octaveShifts[" + midiChannel + "]: " + octaveShift);
}
/**
@@ -391,7 +381,7 @@ public void setOctaveShift(int smafChannel, int octaveShift) {
public int setVelocity(int smafChannel, int velocity) {
int midiChannel = getMidiChannel(smafChannel);
velocities[midiChannel] = velocity;
-//Debug.println("velocities[" + mididChannel + "]: " + octaveShift);
+//logger.log(Level.DEBUG, "velocities[" + mididChannel + "]: " + octaveShift);
return velocity; // TODO mhh...
}
@@ -481,7 +471,7 @@ public int getVelocity(int smafChannel) {
/* */
static {
-Debug.println(Level.FINE, "tempoTable: " + tempoTable.length);
+logger.log(Level.DEBUG, "tempoTable: " + tempoTable.length);
}
/** if no tempo is specified, SSD will treat it as a quarter note = 120 */
@@ -537,7 +527,7 @@ public int getResolution(Track[] smafTracks)
if (message instanceof vavi.sound.smaf.MetaMessage metaMessage) {
if (metaMessage.getType() == MetaEvent.META_MACHINE_DEPEND.number()) {
this.timeBase = (Integer) metaMessage.getData().get("durationTimeBase"); // [ms]
-Debug.println(Level.FINE, "timebase: " + timeBase + ", (" + t + ":" + i + ")");
+logger.log(Level.DEBUG, "timebase: " + timeBase + ", (" + t + ":" + i + ")");
return tempo * timeBase;
}
}
@@ -545,7 +535,7 @@ public int getResolution(Track[] smafTracks)
t++;
}
-Debug.println(Level.FINE, "no tempo message in track 0");
+logger.log(Level.DEBUG, "no tempo message in track 0");
return 120;
}
}
diff --git a/src/main/java/vavi/sound/smaf/message/MidiConvertibleMessage.java b/src/main/java/vavi/sound/smaf/message/MidiConvertibleMessage.java
index 92559cb..71e8396 100644
--- a/src/main/java/vavi/sound/smaf/message/MidiConvertibleMessage.java
+++ b/src/main/java/vavi/sound/smaf/message/MidiConvertibleMessage.java
@@ -24,13 +24,13 @@ public class MidiConvertibleMessage extends vavi.sound.smaf.ShortMessage
implements MidiConvertible {
/** smaf channel */
- private int channel;
+ private final int channel;
/** */
- private int command;
+ private final int command;
/** */
- private int value;
+ private final int value;
/**
* @param duration duration
@@ -93,7 +93,7 @@ public MidiEvent[] getMidiEvents(MidiContext context) throws InvalidMidiDataExce
MidiEvent[] events = new MidiEvent[1];
ShortMessage shortMessage = new ShortMessage();
-//Debug.println("(" + StringUtil.toHex2(command) + "): " + channel + "ch, " + StringUtil.toHex2(value));
+//logger.log(Level.DEBUG, "(" + StringUtil.toHex2(command) + "): " + channel + "ch, " + StringUtil.toHex2(value));
shortMessage.setMessage(ShortMessage.CONTROL_CHANGE,
midiChannel,
command,
diff --git a/src/main/java/vavi/sound/smaf/message/NoteMessage.java b/src/main/java/vavi/sound/smaf/message/NoteMessage.java
index ebdeb61..5738c8c 100644
--- a/src/main/java/vavi/sound/smaf/message/NoteMessage.java
+++ b/src/main/java/vavi/sound/smaf/message/NoteMessage.java
@@ -6,9 +6,9 @@
package vavi.sound.smaf.message;
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
import java.util.NoSuchElementException;
-import java.util.logging.Level;
-
import javax.sound.midi.InvalidMidiDataException;
import javax.sound.midi.MidiEvent;
import javax.sound.midi.ShortMessage;
@@ -16,7 +16,8 @@
import vavi.sound.smaf.InvalidSmafDataException;
import vavi.sound.smaf.SmafEvent;
import vavi.sound.smaf.SmafMessage;
-import vavi.util.Debug;
+
+import static java.lang.System.getLogger;
/**
@@ -28,6 +29,8 @@
public class NoteMessage extends SmafMessage
implements MidiConvertible {
+ private static final Logger logger = getLogger(NoteMessage.class.getName());
+
/** note */
private int note;
@@ -71,7 +74,7 @@ public NoteMessage(int duration, int status, int gateTime) {
this.note = status & 0x0f;
this.gateTime = gateTime;
//if (gateTime == 0) {
-// Debug.println(Level.WARNING, "★★★★★ gateTime == 0: " + channel + "ch, note: " + note);
+// logger.log(Level.WARNING, "★★★★★ gateTime == 0: " + channel + "ch, note: " + note);
//}
this.velocity = -1;
}
@@ -105,18 +108,17 @@ protected NoteMessage() {
* @return note
*/
public int getNote() {
- switch (octave) {
- case 0: // 00
- return note;
- case 1: // 01
- return note + 12;
- case 2: // 10
- return note + 24;
- case 3: // 11
- return note + 36;
- default:
- return note;
- }
+ return switch (octave) {
+ case 0 -> // 00
+ note;
+ case 1 -> // 01
+ note + 12;
+ case 2 -> // 10
+ note + 24;
+ case 3 -> // 11
+ note + 36;
+ default -> note;
+ };
}
/**
@@ -216,7 +218,7 @@ public MidiEvent[] getMidiEvents(MidiContext context)
if (gateTime == 0) {
if (uc < 10) {
- Debug.println(Level.WARNING, "★★★★★ gateTime == 0 ignored: " + this);
+ logger.log(Level.WARNING, "★★★★★ gateTime == 0 ignored: " + this);
}
uc++;
return null;
@@ -232,7 +234,7 @@ public MidiEvent[] getMidiEvents(MidiContext context)
midiChannel,
pitch,
velocity);
-//Debug.println("note: " + channel + ": " + pitch);
+//logger.log(Level.DEBUG, "note: " + channel + ": " + pitch);
events[0] = new MidiEvent(shortMessage, context.getCurrentTick());
shortMessage = new ShortMessage();
@@ -258,14 +260,14 @@ public SmafEvent[] getSmafEvents(MidiEvent midiEvent, SmafContext context)
int command = shortMessage.getCommand();
int data1 = shortMessage.getData1();
int data2 = shortMessage.getData2();
-//Debug.println(midiEvent.getTick() + ", " + channel + ", " + command + ", " + (context.retrievePitch(channel, data1) + 45) + ", " + (data2 / 2));
+//logger.log(Level.DEBUG, midiEvent.getTick() + ", " + channel + ", " + command + ", " + (context.retrievePitch(channel, data1) + 45) + ", " + (data2 / 2));
if (command == ShortMessage.NOTE_OFF ||
// note on with velocity 0
(command == ShortMessage.NOTE_ON && data2 == 0)) {
if (!context.isNoteOffEventUsed()) {
-Debug.println(Level.FINE, "[" + context.getMidiEventIndex() + "] no pair of ON for: " + channel + "ch, " + data1);
+logger.log(Level.DEBUG, "[" + context.getMidiEventIndex() + "] no pair of ON for: " + channel + "ch, " + data1);
}
return null;
@@ -276,7 +278,7 @@ public SmafEvent[] getSmafEvents(MidiEvent midiEvent, SmafContext context)
try {
noteOffEvent = context.getNoteOffMidiEvent();
} catch (NoSuchElementException e) {
-Debug.println(Level.WARNING, "[" + context.getMidiEventIndex() + "] no pair of OFF for: " + channel + "ch, " + data1);
+logger.log(Level.WARNING, "[" + context.getMidiEventIndex() + "] no pair of OFF for: " + channel + "ch, " + data1);
return null;
}
@@ -301,12 +303,12 @@ public SmafEvent[] getSmafEvents(MidiEvent midiEvent, SmafContext context)
smafMessage.setNote(context.retrievePitch(channel, data1));
smafMessage.setGateTime(i == onLength - 1 ? length % 255 : 255);
if (length >= 255) {
- Debug.println(Level.FINE, channel + "ch, " + smafMessage.getNote() + ", " + smafMessage.getDuration() + ":[" + i + "]:" + (i == onLength - 1 ? length % 255 : 255) + "/" + length);
+ logger.log(Level.DEBUG, channel + "ch, " + smafMessage.getNote() + ", " + smafMessage.getDuration() + ":[" + i + "]:" + (i == onLength - 1 ? length % 255 : 255) + "/" + length);
}
-//Debug.println(channel + ", " + smafMessage.getVoice() + ", " + ((smafMessage.getMessage()[1] & 0xc0) >> 6));
+//logger.log(Level.DEBUG, channel + ", " + smafMessage.getVoice() + ", " + ((smafMessage.getMessage()[1] & 0xc0) >> 6));
smafEvents[i] = new SmafEvent(smafMessage, 0L); // TODO 0l
if (smafEvents[i] == null) {
- Debug.println(Level.FINE, "[" + i + "]: " + smafEvents[i]);
+ logger.log(Level.DEBUG, "[" + i + "]: " + smafEvents[i]);
}
if (i == 0) {
context.setBeforeTick(track, midiEvent.getTick());
diff --git a/src/main/java/vavi/sound/smaf/message/OctaveShiftMessage.java b/src/main/java/vavi/sound/smaf/message/OctaveShiftMessage.java
index 28fcac6..b6a0f68 100644
--- a/src/main/java/vavi/sound/smaf/message/OctaveShiftMessage.java
+++ b/src/main/java/vavi/sound/smaf/message/OctaveShiftMessage.java
@@ -39,7 +39,7 @@ public class OctaveShiftMessage extends vavi.sound.smaf.ShortMessage
* 0x85 ~ 0xff Reserved
*
*/
- private int octaveShift;
+ private final int octaveShift;
/**
* Creates OctaveShiftMessage.
diff --git a/src/main/java/vavi/sound/smaf/message/PitchBendMessage.java b/src/main/java/vavi/sound/smaf/message/PitchBendMessage.java
index ea322ea..3e7254d 100644
--- a/src/main/java/vavi/sound/smaf/message/PitchBendMessage.java
+++ b/src/main/java/vavi/sound/smaf/message/PitchBendMessage.java
@@ -39,7 +39,7 @@ public PitchBendMessage(int duration, int channel, int value) {
this.duration = duration;
this.channel = channel;
this.pitchBend = value;
-//Debug.println("pitchBend: " + value);
+//logger.log(Level.DEBUG, "pitchBend: " + value);
}
/** for SmafConvertible */
diff --git a/src/main/java/vavi/sound/smaf/message/ProgramChangeMessage.java b/src/main/java/vavi/sound/smaf/message/ProgramChangeMessage.java
index d3a2082..370df6d 100644
--- a/src/main/java/vavi/sound/smaf/message/ProgramChangeMessage.java
+++ b/src/main/java/vavi/sound/smaf/message/ProgramChangeMessage.java
@@ -96,7 +96,7 @@ public MidiEvent[] getMidiEvents(MidiContext context)
int midiChannel = context.setProgram(this.channel, this.program);
int program = midiChannel == MidiContext.CHANNEL_DRUM ? 0 : context.getProgram(this.channel);
-//Debug.println("ProgramChange: [" + duration + "] " + channel + "ch, " + context.getProgram(channel));
+//logger.log(Level.DEBUG, "ProgramChange: [" + duration + "] " + channel + "ch, " + context.getProgram(channel));
if (context.getFormatType() == FormatType.HandyPhoneStandard &&
context.getDrum(this.channel) == ChannelConfiguration.PERCUSSION &&
context.getSmafTrackNumber() * 4 + this.channel != MidiContext.CHANNEL_DRUM) {
diff --git a/src/main/java/vavi/sound/smaf/message/STMessage.java b/src/main/java/vavi/sound/smaf/message/STMessage.java
index 683761f..8c12b7b 100644
--- a/src/main/java/vavi/sound/smaf/message/STMessage.java
+++ b/src/main/java/vavi/sound/smaf/message/STMessage.java
@@ -7,14 +7,16 @@
package vavi.sound.smaf.message;
import java.io.UnsupportedEncodingException;
-
+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;
import vavi.sound.midi.MidiConstants.MetaEvent;
import vavi.sound.smaf.SmafMessage;
-import vavi.util.Debug;
+
+import static java.lang.System.getLogger;
/**
@@ -27,6 +29,8 @@
public class STMessage extends SmafMessage
implements MidiConvertible {
+ private static final Logger logger = getLogger(STMessage.class.getName());
+
/** */
private String songTitle;
@@ -77,7 +81,7 @@ public MidiEvent[] getMidiEvents(MidiContext context) throws InvalidMidiDataExce
try {
data = songTitle.getBytes("Windows-31J");
} catch (UnsupportedEncodingException e) {
-Debug.println(e);
+logger.log(Level.DEBUG, e);
data = songTitle.getBytes();
}
MetaMessage metaMessage = new MetaMessage();
diff --git a/src/main/java/vavi/sound/smaf/message/SmafContext.java b/src/main/java/vavi/sound/smaf/message/SmafContext.java
index bfec4c5..1758901 100644
--- a/src/main/java/vavi/sound/smaf/message/SmafContext.java
+++ b/src/main/java/vavi/sound/smaf/message/SmafContext.java
@@ -6,11 +6,11 @@
package vavi.sound.smaf.message;
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
import java.util.Arrays;
import java.util.BitSet;
import java.util.NoSuchElementException;
-import java.util.logging.Level;
-
import javax.sound.midi.MetaMessage;
import javax.sound.midi.MidiEvent;
import javax.sound.midi.MidiFileFormat;
@@ -21,7 +21,8 @@
import vavi.sound.smaf.InvalidSmafDataException;
import vavi.sound.smaf.SmafEvent;
-import vavi.util.Debug;
+
+import static java.lang.System.getLogger;
/**
@@ -32,6 +33,8 @@
*/
public class SmafContext implements SmafConvertible {
+ private static final Logger logger = getLogger(SmafContext.class.getName());
+
/** max SMAF track number */
public static final int MAX_SMAF_TRACKS = 4;
@@ -66,7 +69,7 @@ public void setTimeBase(int timeBase) {
//----
/** index is SMAF Track No., true if used */
- private boolean[] trackUsed = new boolean[MAX_SMAF_TRACKS];
+ private final boolean[] trackUsed = new boolean[MAX_SMAF_TRACKS];
/**
* @param smafTrackNumber smaf track number
@@ -96,14 +99,14 @@ public double getScale() {
/** */
public void setScale(float scale) {
-Debug.println(Level.FINE, "scale: " + scale);
+logger.log(Level.DEBUG, "scale: " + scale);
this.scale = scale;
}
//----
/** the previous tick, index is SMAF Track No. */
- private long[] beforeTicks = new long[MAX_SMAF_TRACKS];
+ private final long[] beforeTicks = new long[MAX_SMAF_TRACKS];
/* init */ {
Arrays.fill(beforeTicks, 0);
@@ -144,7 +147,7 @@ private int retrieveDelta(int smafTrackNumber, long currentTick) {
}
/** error rounded with Math#round() */
- private double[] roundedSum = new double[MAX_SMAF_TRACKS];
+ private final double[] roundedSum = new double[MAX_SMAF_TRACKS];
/** correction when the sum of rounding errors with Math#round() is larger than 1 */
private int getAdjustedDelta(int smafTrackNumber, double floatDelta) {
@@ -152,11 +155,11 @@ private int getAdjustedDelta(int smafTrackNumber, double floatDelta) {
double rounded = floatDelta - delta;
roundedSum[smafTrackNumber] += rounded;
if (roundedSum[smafTrackNumber] >= 1f) {
-Debug.println(Level.FINE, "rounded over 1, plus 1: " + roundedSum[smafTrackNumber] + "[" + smafTrackNumber + "]");
+logger.log(Level.DEBUG, "rounded over 1, plus 1: " + roundedSum[smafTrackNumber] + "[" + smafTrackNumber + "]");
delta += 1;
roundedSum[smafTrackNumber] -= 1;
} else if (roundedSum[smafTrackNumber] <= -1f) {
-Debug.println(Level.FINE, "rounded under -1, minus 1: " + roundedSum[smafTrackNumber] + "[" + smafTrackNumber + "]");
+logger.log(Level.DEBUG, "rounded under -1, minus 1: " + roundedSum[smafTrackNumber] + "[" + smafTrackNumber + "]");
delta -= 1;
roundedSum[smafTrackNumber] += 1;
}
@@ -204,24 +207,24 @@ public SmafEvent[] getIntervalSmafEvents() {
// tempo
track = smafTrackNumber;
interval = retrieveDelta(track, midiEvent.getTick());
-Debug.println(Level.FINE, "interval for tempo[" + smafTrackNumber + "]: " + interval);
+logger.log(Level.DEBUG, "interval for tempo[" + smafTrackNumber + "]: " + interval);
} else if (midiMessage instanceof MetaMessage && ((MetaMessage) midiMessage).getType() == 47) {
// eot
track = smafTrackNumber;
interval = retrieveDelta(track, midiEvent.getTick());
-Debug.println(Level.FINE, "interval for EOT[" + smafTrackNumber + "]: " + interval);
+logger.log(Level.DEBUG, "interval for EOT[" + smafTrackNumber + "]: " + interval);
} else if (midiMessage instanceof SysexMessage) {
return null;
} else {
-Debug.println(Level.WARNING, "not supported message: " + midiMessage);
+logger.log(Level.WARNING, "not supported message: " + midiMessage);
return null;
}
//if (interval > 255) {
-// Debug.println("interval: " + interval + ", " + (interval - 256));
+// logger.log(Level.DEBUG, "interval: " + interval + ", " + (interval - 256));
//}
if (interval < 0) {
// it shouldn't be possible
- Debug.println(Level.WARNING, "interval: " + interval);
+ logger.log(Level.WARNING, "interval: " + interval);
interval = 0;
}
int nopLength = interval / 255;
@@ -236,7 +239,7 @@ public SmafEvent[] getIntervalSmafEvents() {
incrementBeforeTick(track, 255);
}
-//Debug.println(nopLength + " nops inserted");
+//logger.log(Level.DEBUG, nopLength + " nops inserted");
return smafEvents;
}
@@ -258,14 +261,14 @@ public int getDuration() {
} else if (midiMessage instanceof MetaMessage && ((MetaMessage) midiMessage).getType() == 81) {
// tempo
delta = retrieveAdjustedDelta(smafTrackNumber, midiEvent.getTick()); // TODO is smafTrackNumber ok?
-Debug.println(Level.FINE, "delta for tempo[" + smafTrackNumber + "]: " + delta);
+logger.log(Level.DEBUG, "delta for tempo[" + smafTrackNumber + "]: " + delta);
} else {
-Debug.println(Level.FINE, "no delta defined for: " + midiMessage);
+logger.log(Level.DEBUG, "no delta defined for: " + midiMessage);
}
if (delta > 255) {
// this is impossible because it should be handled by getIntervalSmafEvents
- Debug.println(Level.WARNING, "Δ: " + delta + ", " + (delta % 256));
+ logger.log(Level.WARNING, "Δ: " + delta + ", " + (delta % 256));
}
return delta % 256;
}
@@ -367,7 +370,7 @@ public MidiEvent getNextMidiEvent() throws NoSuchElementException {
if (shortMessage.getChannel() == channel &&
shortMessage.getCommand() == ShortMessage.NOTE_ON &&
shortMessage.getData1() != data1) {
-Debug.println(Level.FINE, "next: " + shortMessage.getChannel() + "ch, " + shortMessage.getData1());
+logger.log(Level.DEBUG, "next: " + shortMessage.getChannel() + "ch, " + shortMessage.getData1());
return midiEvent;
}
}
@@ -485,7 +488,7 @@ public SmafEvent[] getSmafEvents(MidiEvent midiEvent, SmafContext context)
rpnMSB[channel] = data2;
break;
default:
-//Debug.println("not implemented: " + data1);
+//logger.log(Level.DEBUG, "not implemented: " + data1);
break;
}
diff --git a/src/main/java/vavi/sound/smaf/message/TrackMessage.java b/src/main/java/vavi/sound/smaf/message/TrackMessage.java
index c98bea4..88e2fa2 100644
--- a/src/main/java/vavi/sound/smaf/message/TrackMessage.java
+++ b/src/main/java/vavi/sound/smaf/message/TrackMessage.java
@@ -9,13 +9,15 @@
import java.io.DataOutputStream;
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 vavi.sound.smaf.SmafEvent;
import vavi.sound.smaf.SmafFileFormat;
import vavi.sound.smaf.SmafMessage;
import vavi.sound.smaf.Track;
-import vavi.util.Debug;
+
+import static java.lang.System.getLogger;
/**
@@ -26,11 +28,13 @@
*/
public class TrackMessage {
+ private static final Logger logger = getLogger(TrackMessage.class.getName());
+
/** */
- private int trackNumber;
+ private final int trackNumber;
/** */
- private Track track;
+ private final Track track;
/** */
public TrackMessage(int trackNumber, Track track) {
@@ -45,7 +49,7 @@ public void writeTo(OutputStream out) throws IOException {
dos.writeBytes(getType());
dos.writeInt(getDataLength());
-Debug.println(Level.FINE, "track: " + trackNumber + ": " + getDataLength());
+logger.log(Level.DEBUG, "track: " + trackNumber + ": " + getDataLength());
for (int j = 0; j < track.size(); j++) {
SmafEvent event = track.get(j);
SmafMessage message = event.getMessage();
diff --git a/src/main/java/vavi/sound/smaf/message/UndefinedMessage.java b/src/main/java/vavi/sound/smaf/message/UndefinedMessage.java
index a4a1400..028abe2 100644
--- a/src/main/java/vavi/sound/smaf/message/UndefinedMessage.java
+++ b/src/main/java/vavi/sound/smaf/message/UndefinedMessage.java
@@ -23,7 +23,7 @@ public class UndefinedMessage extends SmafMessage {
*/
public UndefinedMessage(int duration) {
this.duration = duration;
-//Debug.println("UndefinedMessage: ★★★★★★★★★★★★★★★★");
+//logger.log(Level.DEBUG, "UndefinedMessage: ★★★★★★★★★★★★★★★★");
}
/** */
diff --git a/src/main/java/vavi/sound/smaf/message/VNMessage.java b/src/main/java/vavi/sound/smaf/message/VNMessage.java
index 2a24253..b06f3c6 100644
--- a/src/main/java/vavi/sound/smaf/message/VNMessage.java
+++ b/src/main/java/vavi/sound/smaf/message/VNMessage.java
@@ -7,14 +7,16 @@
package vavi.sound.smaf.message;
import java.io.UnsupportedEncodingException;
-
+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;
import vavi.sound.midi.MidiConstants.MetaEvent;
import vavi.sound.smaf.SmafMessage;
-import vavi.util.Debug;
+
+import static java.lang.System.getLogger;
/**
@@ -27,6 +29,8 @@
public class VNMessage extends SmafMessage
implements MidiConvertible {
+ private static final Logger logger = getLogger(VNMessage.class.getName());
+
/** */
private String venderName;
@@ -77,7 +81,7 @@ public MidiEvent[] getMidiEvents(MidiContext context) throws InvalidMidiDataExce
try {
data = venderName.getBytes("Windows-31J");
} catch (UnsupportedEncodingException e) {
-Debug.println(e);
+logger.log(Level.DEBUG, e);
data = venderName.getBytes();
}
MetaMessage metaMessage = new MetaMessage();
diff --git a/src/main/java/vavi/sound/smaf/message/VolumeMessage.java b/src/main/java/vavi/sound/smaf/message/VolumeMessage.java
index 12ec329..f3f0c76 100644
--- a/src/main/java/vavi/sound/smaf/message/VolumeMessage.java
+++ b/src/main/java/vavi/sound/smaf/message/VolumeMessage.java
@@ -9,8 +9,8 @@
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
-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.MidiEvent;
import javax.sound.midi.ShortMessage;
@@ -20,7 +20,8 @@
import vavi.sound.smaf.SmafEvent;
import vavi.sound.smaf.chunk.TrackChunk.FormatType;
import vavi.sound.smaf.message.MidiContext.ChannelConfiguration;
-import vavi.util.Debug;
+
+import static java.lang.System.getLogger;
/**
@@ -38,6 +39,8 @@
public class VolumeMessage extends vavi.sound.smaf.ShortMessage
implements MidiConvertible, SmafConvertible {
+ private static final Logger logger = getLogger(VolumeMessage.class.getName());
+
/** smaf channel */
private int channel;
@@ -129,7 +132,7 @@ public MidiEvent[] getMidiEvents(MidiContext context)
context.getSmafTrackNumber() * 4 + this.channel != MidiContext.CHANNEL_DRUM) {
// TODO psm sets the last(maximum?)? volume
-Debug.println(Level.FINE, "volume: " + volume);
+logger.log(Level.DEBUG, "volume: " + volume);
context.setVelocity(this.channel, volume);
return null;
@@ -162,7 +165,7 @@ public SmafEvent[] getSmafEvents(MidiEvent midiEvent, SmafContext context)
smafMessage.setDuration(context.getDuration());
smafMessage.setChannel(voice);
smafMessage.setVolume(data2);
-Debug.println(Level.FINE, "voice: " + voice + ", volume: " + data2);
+logger.log(Level.DEBUG, "voice: " + voice + ", volume: " + data2);
context.setBeforeTick(track, midiEvent.getTick());
diff --git a/src/main/java/vavi/sound/smaf/message/WaveDataMessage.java b/src/main/java/vavi/sound/smaf/message/WaveDataMessage.java
index 85391d2..9d1d147 100644
--- a/src/main/java/vavi/sound/smaf/message/WaveDataMessage.java
+++ b/src/main/java/vavi/sound/smaf/message/WaveDataMessage.java
@@ -7,9 +7,9 @@
package vavi.sound.smaf.message;
import java.io.Serializable;
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
import java.nio.ByteBuffer;
-import java.util.logging.Level;
-
import javax.sound.midi.InvalidMidiDataException;
import javax.sound.midi.MetaMessage;
import javax.sound.midi.MidiEvent;
@@ -20,7 +20,8 @@
import vavi.sound.smaf.SmafMessage;
import vavi.sound.smaf.sequencer.SmafMessageStore;
import vavi.sound.smaf.sequencer.WaveSequencer;
-import vavi.util.Debug;
+
+import static java.lang.System.getLogger;
/**
@@ -35,18 +36,20 @@
public class WaveDataMessage extends SmafMessage
implements WaveSequencer, MidiConvertible, Serializable {
+ private static final Logger logger = getLogger(WaveDataMessage.class.getName());
+
/** */
- private int number;
+ private final int number;
/** */
- private int format;
+ private final int format;
/** */
- private byte[] data;
+ private final byte[] data;
/** */
- private int samplingRate;
+ private final int samplingRate;
/** */
- private int samplingBits;
+ private final int samplingBits;
/** */
- private int channels;
+ private final int channels;
/**
*/
@@ -115,15 +118,15 @@ public MidiEvent[] getMidiEvents(MidiContext context)
/* */
@Override
public void sequence() throws InvalidSmafDataException {
-Debug.println(Level.FINE, "WAVE DATA[" + number + "]: " + this);
+logger.log(Level.DEBUG, "WAVE DATA[" + number + "]: " + this);
//try {
// java.io.OutputStream os = new java.io.FileOutputStream("out.pcm");
// os.write(data);
// os.flush();
// os.close();
-// Debug.println("WAVE DATA saved to out.pcm");
+// logger.log(Level.DEBUG, "WAVE DATA saved to out.pcm");
//} catch (java.io.IOException e) {
-// Debug.printStackTrace(e);
+// logger.log(Level.ERROR, e.getMessage(), e);
//}
AudioEngine engine = Factory.getAudioEngine(format);
engine.setData(number, -1, samplingRate, samplingBits, channels, data, false);
diff --git a/src/main/java/vavi/sound/smaf/message/WaveMessage.java b/src/main/java/vavi/sound/smaf/message/WaveMessage.java
index 471e683..83d7432 100644
--- a/src/main/java/vavi/sound/smaf/message/WaveMessage.java
+++ b/src/main/java/vavi/sound/smaf/message/WaveMessage.java
@@ -10,8 +10,8 @@
import java.io.DataOutputStream;
import java.io.IOException;
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;
@@ -24,7 +24,8 @@
import vavi.sound.smaf.chunk.TrackChunk.FormatType;
import vavi.sound.smaf.sequencer.SmafMessageStore;
import vavi.sound.smaf.sequencer.WaveSequencer;
-import vavi.util.Debug;
+
+import static java.lang.System.getLogger;
/**
@@ -47,14 +48,16 @@
public class WaveMessage extends SmafMessage
implements WaveSequencer, MidiConvertible, Serializable {
+ private static final Logger logger = getLogger(WaveMessage.class.getName());
+
/** smaf channel 0 ~ 3 */
- private int channel;
+ private final int channel;
/** */
- private int number;
+ private final int number;
/** */
- private int gateTime;
+ private final int gateTime;
/**
* for reading
@@ -210,7 +213,7 @@ public MidiEvent[] getMidiEvents(MidiContext context)
/* */
@Override
public void sequence() throws InvalidSmafDataException {
-Debug.println(Level.FINE, "WAVE PLAY: " + number);
+logger.log(Level.DEBUG, "WAVE PLAY: " + number);
AudioEngine engine = Factory.getAudioEngine();
engine.start(number);
}
diff --git a/src/main/java/vavi/sound/smaf/message/graphics/BackDropColorDefinitionMessage.java b/src/main/java/vavi/sound/smaf/message/graphics/BackDropColorDefinitionMessage.java
index 0bcd030..4fad5ac 100644
--- a/src/main/java/vavi/sound/smaf/message/graphics/BackDropColorDefinitionMessage.java
+++ b/src/main/java/vavi/sound/smaf/message/graphics/BackDropColorDefinitionMessage.java
@@ -31,7 +31,7 @@
public class BackDropColorDefinitionMessage extends ShortMessage {
/** */
- private int backDropColor;
+ private final int backDropColor;
/**
* @param duration
diff --git a/src/main/java/vavi/sound/smaf/message/graphics/UserMessage.java b/src/main/java/vavi/sound/smaf/message/graphics/UserMessage.java
index e17b8ce..ad1fbc1 100644
--- a/src/main/java/vavi/sound/smaf/message/graphics/UserMessage.java
+++ b/src/main/java/vavi/sound/smaf/message/graphics/UserMessage.java
@@ -31,7 +31,7 @@
public class UserMessage extends ShortMessage {
/** */
- private int userEventId;
+ private final int userEventId;
/**
* @param duration
diff --git a/src/main/java/vavi/sound/smaf/message/yamaha/YamahaMessage.java b/src/main/java/vavi/sound/smaf/message/yamaha/YamahaMessage.java
index a7c00d2..2cc6de8 100644
--- a/src/main/java/vavi/sound/smaf/message/yamaha/YamahaMessage.java
+++ b/src/main/java/vavi/sound/smaf/message/yamaha/YamahaMessage.java
@@ -6,7 +6,8 @@
package vavi.sound.smaf.message.yamaha;
-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;
@@ -20,9 +21,10 @@
import vavi.sound.smaf.sequencer.MachineDependentSequencer;
import vavi.sound.smaf.sequencer.SmafMessageStore;
import vavi.sound.smaf.sequencer.WaveSequencer;
-import vavi.util.Debug;
import vavi.util.StringUtil;
+import static java.lang.System.getLogger;
+
/**
* YamahaMessage.
@@ -33,6 +35,8 @@
public class YamahaMessage extends MachineDependentMessage
implements MachineDependentSequencer, MidiConvertible {
+ private static final Logger logger = getLogger(YamahaMessage.class.getName());
+
/**
*
* [MA-3] stream PCM pair
@@ -133,7 +137,7 @@ public MidiEvent[] getMidiEvents(MidiContext context) throws InvalidMidiDataExce
// MidiEvent[] events = new MidiEvent[1];
// javax.sound.midi.SysexMessage sysexMessage = new javax.sound.midi.SysexMessage();
-//Debug.println("(" + StringUtil.toHex2(command) + "): " + channel + "ch, " + StringUtil.toHex2(value));
+//logger.log(Level.DEBUG, "(" + StringUtil.toHex2(command) + "): " + channel + "ch, " + StringUtil.toHex2(value));
// byte[] temp = new byte[data.length + 1];
// temp[0] = (byte) 0xf0;
// System.arraycopy(data, 0, temp, 1, data.length);
@@ -162,20 +166,20 @@ public MidiEvent[] getMidiEvents(MidiContext context) throws InvalidMidiDataExce
/* TODO super appropriate right now */
@Override
public void sequence() throws InvalidSmafDataException {
-Debug.println(Level.INFO, "yamaha: " + data.length + "\n" + StringUtil.getDump(data, 64));
+logger.log(Level.INFO, "yamaha: " + data.length + "\n" + StringUtil.getDump(data, 64));
switch (data[1]) {
case 0x79:
switch (data[3]) {
case 0x7f:
switch (data[4]) {
case 0x20: { //
-Debug.println(Level.FINE, "YAMAHA UNKNOWN: ");
+logger.log(Level.DEBUG, "YAMAHA UNKNOWN: ");
AudioEngine engine = WaveSequencer.Factory.getAudioEngine();
engine.start(2);
break;
}
case 0x00: { // volume
-Debug.println(Level.FINE, "YAMAHA VOLUME: ");
+logger.log(Level.DEBUG, "YAMAHA VOLUME: ");
AudioEngine engine = WaveSequencer.Factory.getAudioEngine();
engine.start(1);
break;
diff --git a/src/main/java/vavi/sound/smaf/readme.md b/src/main/java/vavi/sound/smaf/readme.md
index 98498c7..37346c4 100644
--- a/src/main/java/vavi/sound/smaf/readme.md
+++ b/src/main/java/vavi/sound/smaf/readme.md
@@ -1,18 +1,18 @@
# vavi.sound.smaf
-SMAF サウンド関連のクラスを提供します.
+Provides classes related to SMAF sound.
## Abstract
-{@link javax.sound.midi} パッケージとほぼ同じ構造をしています。
-使用法は {@link javax.sound.midi} を参考にしてください。
+It has almost the same structure as the {@link javax.sound.midi} package.
+Please refer to {@link javax.sound.midi} for usage.
## TODO
- * ~~ datetime="080512" smaf -> midi がおかしい~~
- * ma# emu を使用したシーケンサーとか [mmftool](https://murachue.sytes.net/web/softlist.cgi?mode=desc&title=mmftool)
- * HV と VSQ の相互変換?
- * GraphicsTrackChunk でモバラジ
+ * ~~ 080512 Something is wrong with smaf -> midi~~
+ * sequencer using ma# emu? [mmftool](https://murachue.sytes.net/web/softlist.cgi?mode=desc&title=mmftool)
+ * Conversion between HV and VSQ?
+ * MobaRad with GraphicsTrackChunk
* gervill
## Reference
diff --git a/src/main/java/vavi/sound/smaf/sequencer/SmafMessageStore.java b/src/main/java/vavi/sound/smaf/sequencer/SmafMessageStore.java
index 641c5a3..268a85b 100644
--- a/src/main/java/vavi/sound/smaf/sequencer/SmafMessageStore.java
+++ b/src/main/java/vavi/sound/smaf/sequencer/SmafMessageStore.java
@@ -27,7 +27,7 @@ public class SmafMessageStore {
private static int currentId = 0;
/** */
- private static Map stores = new HashMap<>();
+ private static final Map stores = new HashMap<>();
private SmafMessageStore() {
}
diff --git a/src/main/java/vavi/sound/smaf/sequencer/WaveSequencer.java b/src/main/java/vavi/sound/smaf/sequencer/WaveSequencer.java
index 7d83f08..30e025d 100644
--- a/src/main/java/vavi/sound/smaf/sequencer/WaveSequencer.java
+++ b/src/main/java/vavi/sound/smaf/sequencer/WaveSequencer.java
@@ -33,7 +33,7 @@ public interface WaveSequencer {
class Factory extends PrefixedClassPropertiesFactory {
/** */
- private static ThreadLocal audioEngineStore = new ThreadLocal<>();
+ private static final ThreadLocal audioEngineStore = new ThreadLocal<>();
/**
* Second time or later.
@@ -54,7 +54,7 @@ public static AudioEngine getAudioEngine(int format) {
}
/** */
- private static Factory instance = new Factory();
+ private static final Factory instance = new Factory();
/** */
private Factory() {
diff --git a/src/main/java/vavi/util/readme.md b/src/main/java/vavi/util/readme.md
index a7acaa9..71cc4a2 100644
--- a/src/main/java/vavi/util/readme.md
+++ b/src/main/java/vavi/util/readme.md
@@ -1,11 +1,11 @@
# vavi.util
-FFT, Bessel 関連のクラスを提供します.
+Provides classes related to FFT and Bessel.
## TODO
- * ~~FFT がおかしい~~
- * FFT がバージョンアップしてる
+ * ~~FFT is wrong~~
+ * FFT has been updated
## License
diff --git a/src/main/resources/vavi/sound/mfi/MfiSystem.properties b/src/main/resources/vavi/sound/mfi/MfiSystem.properties
index e075858..95cd03c 100644
--- a/src/main/resources/vavi/sound/mfi/MfiSystem.properties
+++ b/src/main/resources/vavi/sound/mfi/MfiSystem.properties
@@ -10,10 +10,10 @@
#
##
-# MfiSystem がデフォルトで使用する MfiDeviceProvider
+# MfiDeviceProvider used by MfiSystem by default
#
-# @name "default.provider" キー
-# @value MfiDeviceProvider クラス名
+# @name "default.provider" key
+# @value MfiDeviceProvider class name
# @see vavi.sound.mfi.MfiSystem
#
#default.provider=vavi.sound.mfi.ittake.IttakeMfiDeviceProvider
diff --git a/src/main/resources/vavi/sound/mfi/vavi/mitsubishi/mitsubishi.properties b/src/main/resources/vavi/sound/mfi/vavi/mitsubishi/mitsubishi.properties
index 35d715f..3c9e47d 100644
--- a/src/main/resources/vavi/sound/mfi/vavi/mitsubishi/mitsubishi.properties
+++ b/src/main/resources/vavi/sound/mfi/vavi/mitsubishi/mitsubishi.properties
@@ -11,21 +11,21 @@
#
# MitsubishiSequencer
#
-# 0x01 Pitch Bend 設定
+# 0x01 Pitch Bend setting
function.1=vavi.sound.mfi.vavi.mitsubishi.Function1
-# 0x02 Pitch Bend Range 設定
+# 0x02 Pitch Bend Range setting
function.2=vavi.sound.mfi.vavi.mitsubishi.Function2
-# 0x03 Modulation 設定
+# 0x03 Modulation setting
function.3=vavi.sound.mfi.vavi.mitsubishi.Function3
-# 0x10 UCS Wave 設定
+# 0x10 UCS Wave setting
#function.16=vavi.sound.mfi.vavi.mitsubishi.Function16
-# 0x11 UCS Parameter 設定
+# 0x11 UCS Parameter setting
#function.17=vavi.sound.mfi.vavi.mitsubishi.Function17
-# 0x12 UCS 管理ステータス設定
+# 0x12 UCS Admin status setting
#function.18=vavi.sound.mfi.vavi.mitsubishi.Function18
-# 0x81 WAVE Channel Volume 設定
+# 0x81 WAVE Channel Volume setting
function.129=vavi.sound.mfi.vavi.mitsubishi.Function129
-# 0x82 WAVE Channel Panpot 設定
+# 0x82 WAVE Channel Panpot setting
function.130=vavi.sound.mfi.vavi.mitsubishi.Function130
# 0x83 WAVE Packet Data
function.131=vavi.sound.mfi.vavi.mitsubishi.Function131
diff --git a/src/main/resources/vavi/sound/mfi/vavi/nec/nec.properties b/src/main/resources/vavi/sound/mfi/vavi/nec/nec.properties
index 9b58a9f..4e5199a 100644
--- a/src/main/resources/vavi/sound/mfi/vavi/nec/nec.properties
+++ b/src/main/resources/vavi/sound/mfi/vavi/nec/nec.properties
@@ -28,13 +28,13 @@ function.242.4=vavi.sound.mfi.vavi.nec.Function242_4
# f2._5 LED
function.242.5=vavi.sound.mfi.vavi.nec.Function242_5
-# 01.f0._3 拡張 FM 基本波形
-# 01.f0._4 拡張 FM 音色指定
-# 01.f0._5 拡張 WT 音色指定
-# 01.f0._6 拡張 WT 波形指定
-# 01.f0._7 拡張ストリーム波形制御情報
+# 01.f0._3 Extended FM basic waveform
+# 01.f0._4 Extended FM tone specification
+# 01.f0._5 Extended WT tone specification
+# 01.f0._6 Extended WT waveform specification
+# 01.f0._7 Extended stream waveform control information
function.1.240.7=vavi.sound.mfi.vavi.nec.Function1_240_7
-# 01.f0._8 拡張 AL 音色指定
+# 01.f0._8 Extended AL tone specification
# 01.f1.x3 StreamOn
function.1.241.3=vavi.sound.mfi.vavi.nec.Function1_241_3
@@ -47,18 +47,18 @@ function.1.241.6=vavi.sound.mfi.vavi.nec.Function1_241_6
# 01.f1.x7 Hold1
# 01.f1.x8 MonoOn
# 01.f1.x9 PlayOn
-# 01.f1.xa フィルタレゾナンス
-# 01.f1.xb フィルタブライトネス
+# 01.f1.xa filter resonance
+# 01.f1.xb filter brightness
-# 01.f2._7 Channel Status 制御情報
+# 01.f2._7 Channel Status control information
-# 01.f3._1 FM モード設定
+# 01.f3._1 FM mode setting
#
# 01.f3._2 UserEvent
-# 01.f3._3 MaxGain 設定
+# 01.f3._3 MaxGain setting
function.1.243.3=vavi.sound.mfi.vavi.nec.Function1_243_3
-# 01.f3._4 ストリーム数指定
+# 01.f3._4 Specify number of streams
function.1.243.4=vavi.sound.mfi.vavi.nec.Function1_243_4
-# 01.f3._5 AL チャンネル指定
+# 01.f3._5 AL channel specification
##
diff --git a/src/main/resources/vavi/sound/mfi/vavi/sharp/sharp.properties b/src/main/resources/vavi/sound/mfi/vavi/sharp/sharp.properties
index a44cd0f..7059c55 100644
--- a/src/main/resources/vavi/sound/mfi/vavi/sharp/sharp.properties
+++ b/src/main/resources/vavi/sound/mfi/vavi/sharp/sharp.properties
@@ -11,9 +11,9 @@
#
# SharpSequencer
#
-# 0x81 Wave Channel Volume 設定
+# 0x81 Wave Channel Volume setting
function.129=vavi.sound.mfi.vavi.sharp.Function129
-# 0x82 Wave Channel Panpot 設定
+# 0x82 Wave Channel Panpot setting
function.130=vavi.sound.mfi.vavi.sharp.Function130
# 0x83 Wave Packet Data
function.131=vavi.sound.mfi.vavi.sharp.Function131
diff --git a/src/main/resources/vavi/sound/mfi/vavi/vavi.properties b/src/main/resources/vavi/sound/mfi/vavi/vavi.properties
index 3c6d07c..c16631f 100644
--- a/src/main/resources/vavi/sound/mfi/vavi/vavi.properties
+++ b/src/main/resources/vavi/sound/mfi/vavi/vavi.properties
@@ -13,7 +13,7 @@
#------------------------------------------------------------------------------
##
-# フォーマットのデフォルトの値
+# Default value for format
#
format.type.major=1
format.type.minor=1
@@ -24,9 +24,9 @@ format.header.vers=0400
#------------------------------------------------------------------------------
##
-# ベンダー番号に対応するシーケンサー
+# Sequencer corresponding to vendor number
#
-# @name "sequencer.vendor" + ベンダー番号 + キャリア番号
+# @name "sequencer.vendor" + Vendor number + Carrier number
# @see vavi.sound.mfi.vavi.MetaEventAdapter
#
# nec 16 | docomo 1
@@ -49,9 +49,9 @@ sequencer.vendor.113=vavi.sound.mfi.vavi.sharp.SharpSequencer
#------------------------------------------------------------------------------
##
-# フォーマットタイプに対応する AudioEngine
+# AudioEngine corresponding to the format type
#
-# @name "audioEngine.format" + フォーマットタイプ
+# @name "audioEngine.format" + format type
# @see vavi.sound.mobile.AudioDataMessage
#
# ADPCM Type1 0x80 ???
@@ -69,10 +69,9 @@ audioEngine.format.129=vavi.sound.mobile.FuetrekAudioEngine
#
##
-# 未定義メッセージを処理するクラス
+# Class to handle undefined messages
#
-# @value vavi.sound.mfi.MfiMessage を継承し
-# (int,int,int,[B), (int,int,int,int) コンストラクタを持つもの
+# @value Those that inherit vavi.sound.mfi.MfiMessage and have (int,int,int,[B), (int,int,int,int) constructors
#
mfi.track.unknown=vavi.sound.mfi.vavi.track.UndefinedMessage
@@ -81,51 +80,48 @@ mfi.track.unknown=vavi.sound.mfi.vavi.track.UndefinedMessage
#
##
-# ノートメッセージを処理するクラス
+# Class that handles note messages
#
-# @value vavi.sound.mfi.NoteMessage を継承し
-# (int,int,int), (int,int,int,int) コンストラクタを持つもの
+# @value Inherits from vavi.sound.mfi.NoteMessage (int,int,int) and has (int,int,int,int) constructor
#
mfi.track.note=vavi.sound.mfi.vavi.VaviNoteMessage
#
-# -------- Normal (拡張ステータス情報) --------
+# -------- Normal (Extended status information) --------
#
-# ---- 拡張ステータス A ----
+# ---- Extended status A ----
#
-# vavi.sound.mfi.LongMessage を継承し
-# (int,int,int,[B) コンストラクタを持つもの
+# Inherits from vavi.sound.mfi.LongMessage and has a (int,int,int,[B) constructor
#
-# すべて予約
+# All reserved
-# ---- 拡張ステータス B ----
+# ---- Extended status B ----
#
-# vavi.sound.mfi.ShortMessage を継承し
-# (int,int,int,int) コンストラクタを持つもの
+# Inherits from vavi.sound.mfi.ShortMessage and has a (int,int,int,int) constructor
#
#
-# 0xb# チャンネルナンバに依存しない音源制御情報
+# 0xb# Sound source control information independent of channel numbers
#
-# + 0xb0 マスタボリューム
+# + 0xb0 Master volume
mfi.track.255.b.176=vavi.sound.mfi.vavi.track.MasterVolumeMessage
-# + 0xb1 マスタバランス
+# + 0xb1 Master balance
#mfi.track.255.b.177=vavi.sound.mfi.vavi.track.MasterValanceMessage
-# + 0xbc テンポの相対変化
+# + 0xbc Relative change in tempo
#mfi.track.255.b.188=vavi.sound.mfi.vavi.track.RelativeTempoMessage
-# + 0xbd マスタボリュームの相対変化
+# + 0xbd Relative change in master volume
#mfi.track.255.b.189=vavi.sound.mfi.vavi.track.RelativeMasterVolumeMessage
-# + 0xbe ストップ・アンド・ミュート
+# + 0xbe Stop and mute
#mfi.track.255.b.190=vavi.sound.mfi.vavi.track.StopAndMuteMessage
-# + 0xbf 音源リセット
+# + 0xbf Sound source reset
#mfi.track.255.b.191=vavi.sound.mfi.vavi.track.ResetMessage
-# + 0xba チャンネルコンフィグレーション
+# + 0xba Channel configuration
mfi.track.255.b.186=vavi.sound.mfi.vavi.track.ChannelConfigurationMessage
#
-# 0xc# テンポメッセージ
+# 0xc# tempo message
#
# + 0xc0 6
mfi.track.255.b.192=vavi.sound.mfi.vavi.track.TempoMessage
@@ -141,7 +137,7 @@ mfi.track.255.b.196=vavi.sound.mfi.vavi.track.TempoMessage
mfi.track.255.b.197=vavi.sound.mfi.vavi.track.TempoMessage
# + 0xc6 384
mfi.track.255.b.198=vavi.sound.mfi.vavi.track.TempoMessage
-# + 0xc7 予約
+# + 0xc7 \u4E88\u7D04
mfi.track.255.b.199=vavi.sound.mfi.vavi.track.TempoMessage
# + 0xc8 15
mfi.track.255.b.200=vavi.sound.mfi.vavi.track.TempoMessage
@@ -157,17 +153,17 @@ mfi.track.255.b.204=vavi.sound.mfi.vavi.track.TempoMessage
mfi.track.255.b.205=vavi.sound.mfi.vavi.track.TempoMessage
# + 0xce 960
mfi.track.255.b.206=vavi.sound.mfi.vavi.track.TempoMessage
-# + 0xcf 予約
+# + 0xcf \u4E88\u7D04
mfi.track.255.b.207=vavi.sound.mfi.vavi.track.TempoMessage
#
-# 0xd# 演奏管理情報
+# 0xd# Performance management information
#
-# + 0xd0 演奏位置情報 (キューポイント)
+# + 0xd0 Performance position information (cue point)
mfi.track.255.b.208=vavi.sound.mfi.vavi.track.CuePointMessage
# + 0xdc NOP2 (No OPeration2)
mfi.track.255.b.220=vavi.sound.mfi.vavi.track.Nop2Message
-# + 0xdd ループポイント
+# + 0xdd Loop point
mfi.track.255.b.221=vavi.sound.mfi.vavi.track.LoopPointMessage
# + 0xde NOP (No OPeration)
mfi.track.255.b.222=vavi.sound.mfi.vavi.track.NopMessage
@@ -175,39 +171,39 @@ mfi.track.255.b.222=vavi.sound.mfi.vavi.track.NopMessage
mfi.track.255.b.223=vavi.sound.mfi.vavi.track.EndOfTrackMessage
#
-# 0xe# 音源制御情報
+# 0xe# Sound source control information
#
-# + 0xe0 音色番号変更
+# + 0xe0 Tone number change
mfi.track.255.b.224=vavi.sound.mfi.vavi.track.ChangeVoiceMessage
-# + 0xe1 音色バンク変更
+# + 0xe1 Change tone bank
mfi.track.255.b.225=vavi.sound.mfi.vavi.track.ChangeBankMessage
-# + 0xe2 ボリューム変更
+# + 0xe2 Volume change
mfi.track.255.b.226=vavi.sound.mfi.vavi.track.VolumeMessage
-# + 0xe3 パンポット
+# + 0xe3 Pan pot
mfi.track.255.b.227=vavi.sound.mfi.vavi.track.PanpotMessage
-# + 0xe4 ピッチベンド設定
+# + 0xe4 Pitch bend settings
mfi.track.255.b.228=vavi.sound.mfi.vavi.track.PitchBendMessage
-# + 0xe5 チャンネル割り当て
+# + 0xe5 Channel assignment
mfi.track.255.b.229=vavi.sound.mfi.vavi.track.ChannelChangeMessage
-# + 0xe6 ボリュームの相対変化
+# + 0xe6 Relative change in volume
mfi.track.255.b.230=vavi.sound.mfi.vavi.track.ExpressionMessage
-# + 0xe7 ピッチベンドレンジ設定
+# + 0xe7 Pitch bend range setting
mfi.track.255.b.231=vavi.sound.mfi.vavi.track.PitchBendRangeMessage
-# + 0xe8 ファインピッチベンド A 設定
+# + 0xe8 Fine pitch bend A setting
#mfi.track.255.b.232=vavi.sound.mfi.vavi.track.FinePitchBendAMessage
-# + 0xe9 ファインピッチベンド B 設定
+# + 0xe9 Fine pitch bend B setting
#mfi.track.255.b.233=vavi.sound.mfi.vavi.track.FinePitchBendBMessage
-# + 0xea モジュレーションデプス設定
+# + 0xea Modulation depth setting
mfi.track.255.b.234=vavi.sound.mfi.vavi.track.ModulationDepthMessage
-# ---- 拡張情報 ----
+# ---- Extended information ----
#
-# vavi.sound.mfi.SysexMessage を継承し
-# static SysexMessage readFrom(int,int,int,InputStream) メソッドシグネチャを持つもの
+# Those that inherit vavi.sound.mfi.SysexMessage and have the
+# static SysexMessage readFrom(int,int,int,InputStream) method signature
#
#
-# 0xf# 拡張情報
+# 0xf# Extended information
#
# + 0xf0
mfi.track.255.e.240=vavi.sound.mfi.vavi.track.VoiceEditMessage
@@ -217,11 +213,11 @@ mfi.track.255.e.241=vavi.sound.mfi.vavi.track.ExtendedEditMessage
#mfi.track.255.e.242=vavi.sound.mfi.vavi.track.CaraokeTextMessage
# + 0xf3
#mfi.track.255.e.243=vavi.sound.mfi.vavi.track.CaraokeImageMessage
-# + 0xfe ノン・レジスタード・メッセージ指定
+# + 0xfe Non-registered message specification
# length = dis.readShort()
# id = dis.read();
# data ...
-# 0: 拡張用情報識別 ID
+# 0: Extension information ID
# 7654 3210
# ~~~~ ~~~~
# | +- 0001: DoCoMo
@@ -229,138 +225,133 @@ mfi.track.255.e.241=vavi.sound.mfi.vavi.track.ExtendedEditMessage
# +- 0000: reserved
# :
# 1110: reserved
-# 1111: 海外向け拡張データ
-# 0xff なら次(1:)に拡張用情報識別 ID2 を指定できる
-# 1: data or 拡張用情報識別 ID2
+# 1111: Expanded data for overseas
+# If it is 0xff, you can specify the extension information identification ID2 next (1:).
+# 1: data or Extension information ID2
# 2: :
#mfi.track.255.e.254=NonRegisteredMessage
-# + 0xff 拡張用情報
+# + 0xff Expansion information
mfi.track.255.e.255=vavi.sound.mfi.vavi.track.MachineDependentMessage
#
-# -------- Class A (ノン・レジスタード・メッセージ) (0x3f) --------
+# -------- Class A (Non-registered message) (0x3f) --------
#
-# ---- 拡張ステータス A ----
+# ---- Extended status A ----
#
-# vavi.sound.mfi.LongMessage を継承し
-# (int,int,int,[B) コンストラクタを持つもの
+# Inherits from vavi.sound.mfi.LongMessage
+# with (int,int,int,[B) constructor
#
-# すべて予約
+# All reserved
-# ---- 拡張ステータス B ----
+# ---- Extended status B ----
#
-# vavi.sound.mfi.ShortMessage を継承し
-# (int,int,int,int) コンストラクタを持つもの
+# Inherits from vavi.sound.mfi.ShortMessage and has an (int,int,int,int) constructor
#
-# すべて予約
+# All reserved
-# ---- 拡張情報 ----
+# ---- Extended information ----
#
-# vavi.sound.mfi.SysexMessage を継承し
-# static SysexMessage readFrom(int,int,int,InputStream) メソッドシグネチャを持つもの
+# Those that inherit vavi.sound.mfi.SysexMessage and have the
+# static SysexMessage readFrom(int,int,int,InputStream) method signature
#
-# すべて予約
+# All reserved
#
# -------- Class B (0x7f) --------
#
-# ---- 拡張ステータス A ----
+# ---- Extended status A ----
-# + 0x00 オーディオプレイ
+# + 0x00 Audio play
mfi.track.127.a.0=vavi.sound.mfi.vavi.track.AudioPlayMessage
-# + 0x01 オーディオストップ
+# + 0x01 Audio Stop
mfi.track.127.a.1=vavi.sound.mfi.vavi.track.AudioStopMessage
-# ---- 拡張ステータス B ----
+# ---- Extended status B ----
-# + 0x80 オーディオチャネルボリューム
+# + 0x80 Audio channel volume
mfi.track.127.b.128=vavi.sound.mfi.vavi.track.AudioChannelVolumeMessage
-# + 0x81 オーディオチャネルパンポット
+# + 0x81 Audio channel pan pot
mfi.track.127.b.129=vavi.sound.mfi.vavi.track.AudioChannelPanpotMessage
#
# 0x9#
-# + 0x90 3D 定位機能利用情報
+# + 0x90 3D localization function usage information
#mfi.track.127.b.144=
-# ---- 拡張情報 ----
+# ---- Extended information ----
-# + 0xf0 3D 定位情報
+# + 0xf0 3D localization information
#mfi.track.127.e.240=
#
# -------- Class C (0xbf) --------
#
-# ---- 拡張ステータス A ----
+# ---- Extended status A ----
#
-# vavi.sound.mfi.LongMessage を継承し
-# (int,int,int,[B) コンストラクタを持つもの
+# Inherits from vavi.sound.mfi.LongMessage and has a (int,int,int,[B) constructor
#
-# すべて予約
+# All reserved
-# ---- 拡張ステータス B ----
+# ---- Extended status B ----
#
-# vavi.sound.mfi.ShortMessage を継承し
-# (int,int,int,int) コンストラクタを持つもの
+# Inherits from vavi.sound.mfi.ShortMessage and has a (int,int,int,int) constructor
#
-# すべて予約
+# All reserved
-# ---- 拡張情報 ----
+# ---- Extended information ----
#
-# vavi.sound.mfi.SysexMessage を継承し
-# static SysexMessage readFrom(int,int,int,InputStream) メソッドシグネチャを持つもの
+# Those that inherit vavi.sound.mfi.SysexMessage and have the
+# static SysexMessage readFrom(int,int,int,InputStream) method signature
#
-# すべて予約
+# All reserved
#------------------------------------------------------------------------------
#
# AudioDataChunk SubChunk
#
-# vavi.sound.mfi.vavi.SubMessage を継承し
-# (String,[B) コンストラクタを持つもの
+# Inherits from vavi.sound.mfi.vavi.SubMessage and has a (String,[B) constructor
#
-# + ADPCM 情報
+# + ADPCM information
mfi.audio.adpm=vavi.sound.mfi.vavi.audio.AdpmMessage
#
# HeaderChunk SubChunk
#
-# vavi.sound.mfi.vavi.SubMessage を継承し
-# (String,[B) コンストラクタを持つもの
+# Inherits from vavi.sound.mfi.vavi.SubMessage and has a (String,[B) constructor
#
-# + 再配布不可識別子
+# + Non-redistributable identifier
mfi.header.sorc=vavi.sound.mfi.vavi.header.SorcMessage
-# + タイトル情報
+# + Title information
mfi.header.titl=vavi.sound.mfi.vavi.header.TitlMessage
-# + バージョン情報
+# + Version information
mfi.header.vers=vavi.sound.mfi.vavi.header.VersMessage
-# + 日付情報
+# + Date information
mfi.header.date=vavi.sound.mfi.vavi.header.DateMessage
-# + Copyright 情報
+# + Copyright information
mfi.header.copy=vavi.sound.mfi.vavi.header.CopyMessage
-# + データ管理及び保護情報
+# + Data management and protection information
mfi.header.prot=vavi.sound.mfi.vavi.header.ProtMessage
-# + ノートメッセージ長情報
+# + Note message length information
mfi.header.note=vavi.sound.mfi.vavi.header.NoteMessage
-# + 拡張ステータス A メッセージ長情報
+# + Extended status A Message length information
mfi.header.exst=vavi.sound.mfi.vavi.header.ExstMessage
-# + 著作権管理情報
+# + Copyright management information
mfi.header.auth=vavi.sound.mfi.vavi.header.AuthMessage
-# + サポート情報
+# + Support information
mfi.header.supt=vavi.sound.mfi.vavi.header.SuptMessage
-# + オーディオチャンク情報
+# + Audio chunk information
mfi.header.ainf=vavi.sound.mfi.vavi.header.AinfMessage
-# + 3D 定位機能利用情報
+# + 3D localization function usage information
#mfi.header.thrd=vavi.sound.mfi.vavi.header.ThrdMessage
#
@@ -376,96 +367,96 @@ encoding.read=JISAutoDetect
#
#
-# メタイベント
+# Meta event
#
-# + 0x01 テキスト
+# + 0x01 Text
midi.meta.1=vavi.sound.mfi.vavi.header.ProtMessage
-# + 0x02 著作権表示
+# + 0x02 Copyright notice
midi.meta.2=vavi.sound.mfi.vavi.header.CopyMessage
-# + 0x03 シーケンス名/トラック名
+# + 0x03 Sequence name/track name
midi.meta.3=vavi.sound.mfi.vavi.header.TitlMessage
# + 0x2f
midi.meta.47=vavi.sound.mfi.vavi.track.EndOfTrackMessage
-# + 0x51 セットテンポ
+# + 0x51 Set tempo
midi.meta.81=vavi.sound.mfi.vavi.track.TempoMessage
-# + 0x58 拍子
+# + 0x58 Beat
#midi.meta.88=
-# + 0x59 調号
+# + 0x59 Key signature
#midi.meta.89=
-# + 0x7f シーケンサ固有
+# + 0x7f Sequencer specific
#midi.meta.127=
#
-# チャンネルメッセージ
+# Channel message
#
-# + 0x8_ ノートオフ
+# + 0x8_ Note off
midi.short.128=vavi.sound.mfi.vavi.VaviNoteMessage
-# + 0x9_ ノートオン
+# + 0x9_ Note on
midi.short.144=vavi.sound.mfi.vavi.VaviNoteMessage
-# + 0xa_ ポリフォニックキープレッシャー
+# + 0xa_ Polyphonic key pressure
-# + 0xb_ コントロールチェンジ
+# + 0xb_ Control change
#
-# + 0xb_ 0x00 バンクセレクト MSB
+# + 0xb_ 0x00 Bank select MSB
midi.short.176.0=vavi.sound.mfi.vavi.track.MfiConvertibleMessage
-# + 0xb_ 0x01 モジュレーションデプス MSB
+# + 0xb_ 0x01 Modulation depth MSB
midi.short.176.1=vavi.sound.mfi.vavi.track.ModulationDepthMessage
-# + 0xb_ 0x02 ブレスコントローラー MSB
-# + 0xb_ 0x04 フットコントローラー MSB
-# + 0xb_ 0x05 ポルタメントタイム MSB
+# + 0xb_ 0x02 Breath controller MSB
+# + 0xb_ 0x04 Foot controller MSB
+# + 0xb_ 0x05 Portamento time MSB
#midi.short.176.5=
-# + 0xb_ 0x06 データエントリー MSB
+# + 0xb_ 0x06 Data entry MSB
midi.short.176.6=vavi.sound.mfi.vavi.track.MfiConvertibleMessage
-# + 0xb_ 0x07 メインボリューム MSB
+# + 0xb_ 0x07 Main volume MSB
midi.short.176.7=vavi.sound.mfi.vavi.track.VolumeMessage
-# + 0xb_ 0x08 バランスコントロール MSB
-# + 0xb_ 0x0a パンポット MSB
+# + 0xb_ 0x08 Balance control MSB
+# + 0xb_ 0x0a Pan pot MSB
midi.short.176.10=vavi.sound.mfi.vavi.track.PanpotMessage
-# + 0xb_ 0x0b エクスプレッション MSB
+# + 0xb_ 0x0b Expression MSB
midi.short.176.11=vavi.sound.mfi.vavi.track.ExpressionMessage
-# + 0xb_ 0x20 バンクセレクト LSB
+# + 0xb_ 0x20 Bank select LSB
midi.short.176.32=vavi.sound.mfi.vavi.track.MfiConvertibleMessage
-# + 0xb_ 0x30 汎用汎用操作子-1
-# + 0xb_ 0x31 汎用汎用操作子-2
-# + 0xb_ 0x32 汎用汎用操作子-3
-# + 0xb_ 0x33 汎用汎用操作子-4
-# + 0xb_ 0x40 ホールド1 (ダンパー)
-# + 0xb_ 0x41 ポルタメント
+# + 0xb_ 0x30 General-purpose controller-1
+# + 0xb_ 0x31 General-purpose controller-2
+# + 0xb_ 0x32 General-purpose controller-3
+# + 0xb_ 0x33 General-purpose controller-4
+# + 0xb_ 0x40 Hold 1 (damper)
+# + 0xb_ 0x41 Portamento
#midi.short.176.65=
-# + 0xb_ 0x42 ソステヌート
-# + 0xb_ 0x43 ソフトペダル
-# + 0xb_ 0x44 レガートフットスイッチ
-# + 0xb_ 0x45 ホールド2 (フリーズ)
-# + 0xb_ 0x46 サウンドコントローラー1 (サウンドバリエーション)
-# + 0xb_ 0x47 レゾナンス
-# + 0xb_ 0x48 リリースタイム
-# + 0xb_ 0x49 アタックタイム
-# + 0xb_ 0x4a カットオフ
-# + 0xb_ 0x4b ディケイタイム
-# + 0xb_ 0x4c ビブラートレイト
-# + 0xb_ 0x4d ビブラートデプス
-# + 0xb_ 0x4e ビブラートディレイ
-# + 0xb_ 0x50 汎用汎用操作子-5
-# + 0xb_ 0x51 汎用汎用操作子-6
-# + 0xb_ 0x52 汎用汎用操作子-7
-# + 0xb_ 0x53 汎用汎用操作子-8
-# + 0xb_ 0x54 ポルタメントタイム LSB
-# + 0xb_ 0x5b 汎用エフェクト1(リバーブ)
+# + 0xb_ 0x42 Sostenuto
+# + 0xb_ 0x43 Soft pedal
+# + 0xb_ 0x44 Legato foot switch
+# + 0xb_ 0x45 Hold 2 (freeze)
+# + 0xb_ 0x46 Sound controller 1 (sound variation)
+# + 0xb_ 0x47 Resonance
+# + 0xb_ 0x48 Release time
+# + 0xb_ 0x49 Attack time
+# + 0xb_ 0x4a Cut off
+# + 0xb_ 0x4b Decay time
+# + 0xb_ 0x4c Vibrato trait
+# + 0xb_ 0x4d Vibrato depth
+# + 0xb_ 0x4e Vibrato delay
+# + 0xb_ 0x50 General-purpose controller-5
+# + 0xb_ 0x51 General-purpose controller-6
+# + 0xb_ 0x52 General-purpose controller-7
+# + 0xb_ 0x53 General-purpose controller-8
+# + 0xb_ 0x54 Portamento time LSB
+# + 0xb_ 0x5b General-purpose effect 1 (reverb)
#midi.short.176.91=
-# + 0xb_ 0x5c 汎用エフェクト2(トレモロ)
+# + 0xb_ 0x5c General-purpose effect 2 (tremolo)
#midi.short.176.92=
-# + 0xb_ 0x5d 汎用エフェクト3(コーラス)
+# + 0xb_ 0x5d General-purpose effect 3 (chorus)
#midi.short.176.93=
-# + 0xb_ 0x5e 汎用エフェクト4(セレステ)
+# + 0xb_ 0x5e General-purpose effect 4 (celeste)
#midi.short.176.94=
-# + 0xb_ 0x5f 汎用エフェクト5(フェイザ)
+# + 0xb_ 0x5f General-purpose effect 5 (phaser)
#midi.short.176.95=
-# + 0xb_ 0x60 データインクリメント
-# + 0xb_ 0x61 データデクリメント
+# + 0xb_ 0x60 Data increment
+# + 0xb_ 0x61 Data decrement
# + 0xb_ 0x62 NRPN LSB
midi.short.176.98=vavi.sound.mfi.vavi.track.MfiConvertibleMessage
# + 0xb_ 0x63 NRPN MSB
@@ -475,46 +466,46 @@ midi.short.176.100=vavi.sound.mfi.vavi.track.MfiConvertibleMessage
# + 0xb_ 0x65 RPN MSB
midi.short.176.101=vavi.sound.mfi.vavi.track.MfiConvertibleMessage
-# + 0xb_ チャンネルモードメッセージ
+# + 0xb_ Channel mode message
#
-# + 0xb_ 0x78 (120) オールサウンドオフ
-# + 0xb_ 0x79 (121) リセットオールコントローラー
+# + 0xb_ 0x78 (120) All sound off
+# + 0xb_ 0x79 (121) Rest all controller
#midi.short.176.121=
-# + 0xb_ 0x7a (122) ローカルコントロール
-# + 0xb_ 0x7b (123) オールノートオフ
-# + 0xb_ 0x7c (124) オムニオフ
-# + 0xb_ 0x7d (125) オムニオン
-# + 0xb_ 0x7e (126) モノオン
+# + 0xb_ 0x7a (122) Local control
+# + 0xb_ 0x7b (123) All note off
+# + 0xb_ 0x7c (124) Omni off
+# + 0xb_ 0x7d (125) Omni on
+# + 0xb_ 0x7e (126) Mono on
#midi.short.176.126=
-# + 0xb_ 0x7f (127) ポリオン
+# + 0xb_ 0x7f (127) Poly on
#midi.short.176.127=
-# + 0xc_ プログラムチェンジ
+# + 0xc_ Program change
midi.short.192=vavi.sound.mfi.vavi.track.ChangeVoiceMessage
-# + 0xd_ チャンネルプレッシャー
+# + 0xd_ Channel pressure
-# + 0xe_ ピッチベンドチェンジ
+# + 0xe_ Pitch bend change
midi.short.224=vavi.sound.mfi.vavi.track.PitchBendMessage
-# + 0xf0 システムエクスクルーシブメッセージ
+# + 0xf0 System exclusive message
-# + 0xf_ システムコモンメッセージ
+# + 0xf_ System common message
#
-# + 0xf1 MTC クォーターフレーム
-# + 0xf2 ソングポジションポインタ
-# + 0xf3 ソングセレクト
-# + 0xf6 チューンリクエスト
-# + 0xf7 エンドオブエクスクルーシブ (EOX)
+# + 0xf1 MTC Quarter frame
+# + 0xf2 Song position pointer
+# + 0xf3 Song selection
+# + 0xf6 Tune request
+# + 0xf7 End of exclusive (EOX)
-# + 0xf_ システムリアルタイムメッセージ
+# + 0xf_ System real-time messages
#
-# + 0xf8 タイミングクロック
-# + 0xfa スタート
-# + 0xfb コンティニュー
-# + 0xfc ストップ
-# + 0xfe アクティブセンシング
-# + 0xff システムリセット
+# + 0xf8 Timing clock
+# + 0xfa Start
+# + 0xfb Continue
+# + 0xfc Stop
+# + 0xfe Active sensing
+# + 0xff System reset
#------------------------------------------------------------------------------
diff --git a/src/main/resources/vavi/sound/sampled/FilterChain.properties b/src/main/resources/vavi/sound/sampled/FilterChain.properties
index 1a01829..6ca31d0 100644
--- a/src/main/resources/vavi/sound/sampled/FilterChain.properties
+++ b/src/main/resources/vavi/sound/sampled/FilterChain.properties
@@ -10,7 +10,7 @@
#
##
-# 機種依存部作成クラス
+# Model dependent part creation class
#
#inputFilter.0=vavi.sound.sampled.SimpleResamplingInputFilter
#inputFilter.1=vavi.sound.sampled.MonauralInputFilter
diff --git a/src/main/resources/vavi/sound/sampled/mfi/MfiWithVoiceMaker.properties b/src/main/resources/vavi/sound/sampled/mfi/MfiWithVoiceMaker.properties
index 84d7a01..6de7c76 100644
--- a/src/main/resources/vavi/sound/sampled/mfi/MfiWithVoiceMaker.properties
+++ b/src/main/resources/vavi/sound/sampled/mfi/MfiWithVoiceMaker.properties
@@ -10,7 +10,7 @@
#
##
-# 機種依存部作成クラス
+# Model dependent part creation class
#
#class.d505=vavi.sound.sampled.mfi.type.d505
#class.n505=vavi.sound.sampled.mfi.type.n505
@@ -20,7 +20,7 @@ class.sh252=vavi.sound.sampled.mfi.type.sh252
class.sh900=vavi.sound.sampled.mfi.type.sh900
##
-# 作成者情報
+# Author information
#
prot=vavi
@@ -37,6 +37,6 @@ vers=0300
##
#
#
-defaultModle=sh900
+defaultModel=sh900
##
diff --git a/src/main/resources/vavi/sound/sampled/smaf/SmafWithVoiceMaker.properties b/src/main/resources/vavi/sound/sampled/smaf/SmafWithVoiceMaker.properties
index 059f077..b7fd542 100644
--- a/src/main/resources/vavi/sound/sampled/smaf/SmafWithVoiceMaker.properties
+++ b/src/main/resources/vavi/sound/sampled/smaf/SmafWithVoiceMaker.properties
@@ -10,7 +10,7 @@
#
##
-# コンテンツの情報 (',', '\' は '\' でエスケープすること)
+# Content information (',', '\' must be escaped with '\')
#
contentsInfo.subDatum.vn=vavi
contentsInfo.subDatum.cr=(c) 2008 Vavisoft Inc.
diff --git a/src/main/resources/vavi/sound/smaf/chunk/language.properties b/src/main/resources/vavi/sound/smaf/chunk/language.properties
index 04644de..2c8f2ce 100644
--- a/src/main/resources/vavi/sound/smaf/chunk/language.properties
+++ b/src/main/resources/vavi/sound/smaf/chunk/language.properties
@@ -6,22 +6,22 @@
# 0.00 050506 nsano initial version
#
-# 日本語
+# Japanese
0x00=Shift-JIS
-# 英語、フランス語、ドイツ イタリア語、スペイン語、ポルトガル語
+# English, French, German Italian, Spanish, Portuguese
0x01=ISO 8859-1(Latin-1)
-# 韓国語
+# Korean
0x02=EUC-KR(KS)
-# 中国語(簡体字)
+# Simplified Chinese
0x03=HZ-GB-2312
-# 中国語(繁体字)
+# Traditional Chinese
0x04=Big5
-# ロシア語など
+# Russian etc.
0x05=KOI8-R
-# ベトナム語
+# Vietnamese
0x06=TCVN-5773:1993
# Reserved
-# 0x07〜0x1F Reserved
+# 0x07\u301C0x1F Reserved
0x20=UCS-2 Unicode
0x21=UCS-4 Unicode
0x22=UTF-7 Unicode
@@ -29,6 +29,6 @@
0x24=UTF-16 Unicode
0x25=UTF-32 Unicode
# Reserved
-# 0x26〜0xFE Reserved
-# Binary 値
+# 0x26\u301C0xFE Reserved
+# Binary value
0xFF=Octet Stream
\ No newline at end of file
diff --git a/src/main/resources/vavi/sound/smaf/smaf.properties b/src/main/resources/vavi/sound/smaf/smaf.properties
index 582a8f3..a3b6858 100644
--- a/src/main/resources/vavi/sound/smaf/smaf.properties
+++ b/src/main/resources/vavi/sound/smaf/smaf.properties
@@ -12,10 +12,10 @@
#------------------------------------------------------------------------------
##
-# Chunk の ID に対応するクラスです。
+# This class corresponds to the Chunk ID.
#
-# @name "chunk." + ChunkID、'*' はワイルドカードになります
-# @value クラス名、Chunk を継承しシグネチャが (byte[],int) のコンストラクタを持つもの
+# @name "chunk." + ChunkID\u3001'*' is a wildcard
+# @value class name, Classes that inherits from Chunk and has a constructor with the signature (byte[],int)
# @see vavi.sound.smaf.Chunk
#
chunk.MMMD=vavi.sound.smaf.chunk.FileChunk
@@ -60,9 +60,9 @@ maker.43=vavi.sound.smaf.message.yamaha.YamahaMessage
#------------------------------------------------------------------------------
##
-# フォーマットタイプに対応する AudioEngine
+# AudioEngine corresponding to the format type
#
-# @name "audioEngine.format" + フォーマットタイプ
+# @name "audioEngine.format" + format type
# @see vavi.sound.smaf.chunk.WaveType
#
# WAVE Format 0 PCM Signed
diff --git a/src/test/java/PlayMFi.java b/src/test/java/PlayMFi.java
index 0ff33e6..ba3686e 100644
--- a/src/test/java/PlayMFi.java
+++ b/src/test/java/PlayMFi.java
@@ -5,14 +5,11 @@
*/
import java.io.File;
-import java.nio.file.Files;
-import java.nio.file.Paths;
import java.util.concurrent.CountDownLatch;
import javax.sound.midi.MidiSystem;
import javax.sound.midi.Soundbank;
-import org.junit.jupiter.api.BeforeEach;
import vavi.sound.mfi.MetaEventListener;
import vavi.sound.mfi.MfiSystem;
import vavi.sound.mfi.Sequence;
diff --git a/src/test/java/SoundFontTest.java b/src/test/java/SoundFontTest.java
index abc7714..9238c56 100644
--- a/src/test/java/SoundFontTest.java
+++ b/src/test/java/SoundFontTest.java
@@ -15,7 +15,6 @@
import javax.sound.midi.Soundbank;
import javax.sound.midi.Synthesizer;
-import vavi.sound.SoundUtil;
import vavi.sound.midi.MidiUtil;
import vavi.util.Debug;
import vavi.util.properties.annotation.Property;
diff --git a/src/test/java/vavi/sound/adpcm/ms/MsInputStreamTest.java b/src/test/java/vavi/sound/adpcm/ms/MsInputStreamTest.java
index 0dab566..b6d7a54 100644
--- a/src/test/java/vavi/sound/adpcm/ms/MsInputStreamTest.java
+++ b/src/test/java/vavi/sound/adpcm/ms/MsInputStreamTest.java
@@ -20,7 +20,6 @@
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.DataLine;
-import javax.sound.sampled.LineEvent;
import javax.sound.sampled.SourceDataLine;
import org.junit.jupiter.api.BeforeEach;
diff --git a/src/test/java/vavi/sound/mfi/MfiSystemTest.java b/src/test/java/vavi/sound/mfi/MfiSystemTest.java
index 3df491f..2e7aaab 100644
--- a/src/test/java/vavi/sound/mfi/MfiSystemTest.java
+++ b/src/test/java/vavi/sound/mfi/MfiSystemTest.java
@@ -15,7 +15,6 @@
import java.util.logging.Level;
import org.junit.jupiter.api.Test;
-
import vavi.util.Debug;
@@ -27,12 +26,18 @@
*/
public class MfiSystemTest {
+ static {
+ System.setProperty("vavi.sound.mobile.AudioEngine.volume", System.getProperty("vavi.test.volume", "0.02"));
+Debug.println("adpcm volume: " + System.getProperty("vavi.sound.mobile.AudioEngine.volume"));
+ }
+
@Test
public void test() throws Exception {
CountDownLatch cdl = new CountDownLatch(1);
Path inPath = Paths.get(MfiSystemTest.class.getResource("/test.mld").toURI());
Sequencer sequencer = MfiSystem.getSequencer();
sequencer.open();
+// volume(((Synthesizer) sequencer).getReceiver(), 0.2f); // TODO interlock mid adpcm volume
Sequence sequence = MfiSystem.getSequence(new BufferedInputStream(Files.newInputStream(inPath)));
sequencer.setSequence(sequence);
sequencer.addMetaEventListener(meta -> {
diff --git a/src/test/java/vavi/sound/mfi/vavi/VaviMfiFileWriterTest.java b/src/test/java/vavi/sound/mfi/vavi/VaviMfiFileWriterTest.java
index ed14d46..1ce6d4e 100644
--- a/src/test/java/vavi/sound/mfi/vavi/VaviMfiFileWriterTest.java
+++ b/src/test/java/vavi/sound/mfi/vavi/VaviMfiFileWriterTest.java
@@ -12,13 +12,8 @@
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Paths;
-import java.util.NoSuchElementException;
import java.util.logging.Level;
-import javax.sound.midi.MidiEvent;
-import javax.sound.midi.MidiMessage;
-import javax.sound.midi.ShortMessage;
-
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
@@ -32,7 +27,6 @@
import vavi.sound.mfi.vavi.track.CuePointMessage;
import vavi.sound.mfi.vavi.track.EndOfTrackMessage;
import vavi.sound.mfi.vavi.track.TempoMessage;
-import vavi.sound.midi.MidiUtil;
import vavi.util.Debug;
import vavi.util.win32.WAVE;
@@ -117,7 +111,7 @@ public void test1() throws Exception {
/**
* @param pcm wave, any sampling rate, 16bit, mono
*/
- private void d505i(Track track, byte[] pcm, int sampleRate, int delta)
+ private static void d505i(Track track, byte[] pcm, int sampleRate, int delta)
throws InvalidMfiDataException {
// adpcm vol
diff --git a/src/test/java/vavi/sound/mfi/vavi/VaviMidiConverterTest.java b/src/test/java/vavi/sound/mfi/vavi/VaviMidiConverterTest.java
index 669c087..6ed278b 100644
--- a/src/test/java/vavi/sound/mfi/vavi/VaviMidiConverterTest.java
+++ b/src/test/java/vavi/sound/mfi/vavi/VaviMidiConverterTest.java
@@ -32,6 +32,11 @@
*/
public class VaviMidiConverterTest {
+ static {
+ System.setProperty("vavi.sound.mobile.AudioEngine.volume", System.getProperty("vavi.test.volume", "0.02"));
+Debug.println("adpcm volume: " + System.getProperty("vavi.sound.mobile.AudioEngine.volume"));
+ }
+
@Test
public void test() throws Exception {
CountDownLatch cdl = new CountDownLatch(1);
diff --git a/src/test/java/vavi/sound/mfi/vavi/sequencer/MachineDependentSequencerTest.java b/src/test/java/vavi/sound/mfi/vavi/sequencer/MachineDependentSequencerTest.java
index 62b2a01..2d26a86 100644
--- a/src/test/java/vavi/sound/mfi/vavi/sequencer/MachineDependentSequencerTest.java
+++ b/src/test/java/vavi/sound/mfi/vavi/sequencer/MachineDependentSequencerTest.java
@@ -12,6 +12,7 @@
import vavi.util.properties.PrefixedClassPropertiesFactory;
import vavi.util.properties.PrefixedPropertiesFactory;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -30,21 +31,21 @@ public void test() {
MachineDependentSequencer mds = machineDependentSequencerFactory.get(97);
Debug.println(mds);
- assertTrue(mds instanceof vavi.sound.mfi.vavi.mitsubishi.MitsubishiSequencer);
+ assertInstanceOf(vavi.sound.mfi.vavi.mitsubishi.MitsubishiSequencer.class, mds);
mds = machineDependentSequencerFactory.get(17);
- assertTrue(mds instanceof vavi.sound.mfi.vavi.nec.NecSequencer);
+ assertInstanceOf(vavi.sound.mfi.vavi.nec.NecSequencer.class, mds);
mds = machineDependentSequencerFactory.get(33);
- assertTrue(mds instanceof vavi.sound.mfi.vavi.fujitsu.FujitsuSequencer);
+ assertInstanceOf(vavi.sound.mfi.vavi.fujitsu.FujitsuSequencer.class, mds);
mds = machineDependentSequencerFactory.get(49);
- assertTrue(mds instanceof vavi.sound.mfi.vavi.sony.SonySequencer);
+ assertInstanceOf(vavi.sound.mfi.vavi.sony.SonySequencer.class, mds);
mds = machineDependentSequencerFactory.get(65);
- assertTrue(mds instanceof vavi.sound.mfi.vavi.panasonic.PanasonicSequencer);
+ assertInstanceOf(vavi.sound.mfi.vavi.panasonic.PanasonicSequencer.class, mds);
mds = machineDependentSequencerFactory.get(113);
- assertTrue(mds instanceof vavi.sound.mfi.vavi.sharp.SharpSequencer);
+ assertInstanceOf(vavi.sound.mfi.vavi.sharp.SharpSequencer.class, mds);
}
}
diff --git a/src/test/java/vavi/sound/midi/mfi/MfiMidiFileReaderTest.java b/src/test/java/vavi/sound/midi/mfi/MfiMidiFileReaderTest.java
index caf59ce..d23bd64 100644
--- a/src/test/java/vavi/sound/midi/mfi/MfiMidiFileReaderTest.java
+++ b/src/test/java/vavi/sound/midi/mfi/MfiMidiFileReaderTest.java
@@ -25,6 +25,11 @@
*/
public class MfiMidiFileReaderTest {
+ static {
+ System.setProperty("vavi.sound.mobile.AudioEngine.volume", System.getProperty("vavi.test.volume", "0.02"));
+Debug.println("adpcm volume: " + System.getProperty("vavi.sound.mobile.AudioEngine.volume"));
+ }
+
@Test
public void test() throws Exception {
InputStream is = MfiVaviSequenceTest.class.getResourceAsStream("/test.mld");
diff --git a/src/test/java/vavi/sound/mobile/BasicAudioEngineTest.java b/src/test/java/vavi/sound/mobile/BasicAudioEngineTest.java
index a9a5201..8cda5c4 100644
--- a/src/test/java/vavi/sound/mobile/BasicAudioEngineTest.java
+++ b/src/test/java/vavi/sound/mobile/BasicAudioEngineTest.java
@@ -65,8 +65,8 @@ public void test() throws Exception {
/** */
public static class WrappedLineOutputStream extends OutputStream {
- SourceDataLine line;
- OutputStream out;
+ final SourceDataLine line;
+ final OutputStream out;
public WrappedLineOutputStream(SourceDataLine line, OutputStream out) {
this.out = out;
this.line = line;
diff --git a/src/test/java/vavi/sound/pcm/resampling/ssrc/SSRCTest.java b/src/test/java/vavi/sound/pcm/resampling/ssrc/SSRCTest.java
index f4d72e8..eb691e4 100644
--- a/src/test/java/vavi/sound/pcm/resampling/ssrc/SSRCTest.java
+++ b/src/test/java/vavi/sound/pcm/resampling/ssrc/SSRCTest.java
@@ -20,7 +20,6 @@
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import vavi.io.LittleEndianDataInputStream;
@@ -156,7 +155,7 @@ public void test2() throws Exception {
}
/** */
- private void writeDouble(byte[] buffer, int offset, double value) {
+ private static void writeDouble(byte[] buffer, int offset, double value) {
long l = Double.doubleToLongBits(value);
buffer[offset * 8 + 0] = (byte) (l & 0x00000000000000ffL);
buffer[offset * 8 + 1] = (byte) ((l & 0x000000000000ff00L) >> 8);
diff --git a/src/test/java/vavi/sound/pcm/resampling/ssrc/fftsgTest.java b/src/test/java/vavi/sound/pcm/resampling/ssrc/fftsgTest.java
index 921b7c0..aabd555 100644
--- a/src/test/java/vavi/sound/pcm/resampling/ssrc/fftsgTest.java
+++ b/src/test/java/vavi/sound/pcm/resampling/ssrc/fftsgTest.java
@@ -127,7 +127,7 @@ public void testDFST() throws Exception {
}
/** */
- private void putData(int nini, int nend, double[] a) {
+ private static void putData(int nini, int nend, double[] a) {
int[] seed = new int[] { 0 };
for (int j = nini; j <= nend; j++) {
diff --git a/src/test/java/vavi/sound/sampled/adpcm/ima/ImaWaveAudioFileReaderTest.java b/src/test/java/vavi/sound/sampled/adpcm/ima/ImaWaveAudioFileReaderTest.java
index 82f5599..0e30f94 100644
--- a/src/test/java/vavi/sound/sampled/adpcm/ima/ImaWaveAudioFileReaderTest.java
+++ b/src/test/java/vavi/sound/sampled/adpcm/ima/ImaWaveAudioFileReaderTest.java
@@ -20,7 +20,6 @@
import javax.sound.sampled.SourceDataLine;
import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import vavi.util.Debug;
diff --git a/src/test/java/vavi/sound/smaf/SmafSystemTest.java b/src/test/java/vavi/sound/smaf/SmafSystemTest.java
index fc010fb..49acb8e 100644
--- a/src/test/java/vavi/sound/smaf/SmafSystemTest.java
+++ b/src/test/java/vavi/sound/smaf/SmafSystemTest.java
@@ -27,6 +27,11 @@
*/
public class SmafSystemTest {
+ static {
+ System.setProperty("vavi.sound.mobile.AudioEngine.volume", System.getProperty("vavi.test.volume", "0.02"));
+Debug.println("adpcm volume: " + System.getProperty("vavi.sound.mobile.AudioEngine.volume"));
+ }
+
@Test
public void test() throws Exception {
CountDownLatch cdl = new CountDownLatch(1);
diff --git a/src/test/resources/logging.properties b/src/test/resources/logging.properties
index 3687257..b82ecda 100644
--- a/src/test/resources/logging.properties
+++ b/src/test/resources/logging.properties
@@ -4,4 +4,3 @@ java.util.logging.ConsoleHandler.level=ALL
java.util.logging.ConsoleHandler.formatter=vavi.util.logging.VaviFormatter
vavi.util.level=FINE
-