From 7519784b8d9dd8a126dbf58e6e57afcb1f6f78eb Mon Sep 17 00:00:00 2001 From: Naohide Sano Date: Sat, 16 Nov 2024 22:27:29 +0900 Subject: [PATCH 1/8] add deprecated --- .../java/vavi/sound/sampled/adpcm/ccitt/CcittFileFormatType.java | 1 + .../vavi/sound/sampled/adpcm/ccitt/G721RawAudioFileReader.java | 1 + .../java/vavi/sound/sampled/adpcm/dvi/DviFileFormatType.java | 1 + .../java/vavi/sound/sampled/adpcm/ima/ImaFileFormatType.java | 1 + src/main/java/vavi/sound/sampled/adpcm/ma/MaFileFormatType.java | 1 + src/main/java/vavi/sound/sampled/adpcm/ms/MsFileFormatType.java | 1 + .../java/vavi/sound/sampled/adpcm/oki/OkiFileFormatType.java | 1 + .../java/vavi/sound/sampled/adpcm/rohm/RohmFileFormatType.java | 1 + .../java/vavi/sound/sampled/adpcm/vox/VoxFileFormatType.java | 1 + .../vavi/sound/sampled/adpcm/yamaha/YamahaFileFormatType.java | 1 + 10 files changed, 10 insertions(+) diff --git a/src/main/java/vavi/sound/sampled/adpcm/ccitt/CcittFileFormatType.java b/src/main/java/vavi/sound/sampled/adpcm/ccitt/CcittFileFormatType.java index 52d0d12..3a30138 100644 --- a/src/main/java/vavi/sound/sampled/adpcm/ccitt/CcittFileFormatType.java +++ b/src/main/java/vavi/sound/sampled/adpcm/ccitt/CcittFileFormatType.java @@ -15,6 +15,7 @@ * @author Naohide Sano (nsano) * @version 0.00 050722 nsano initial version
*/ +@Deprecated public class CcittFileFormatType extends AudioFileFormat.Type { /** diff --git a/src/main/java/vavi/sound/sampled/adpcm/ccitt/G721RawAudioFileReader.java b/src/main/java/vavi/sound/sampled/adpcm/ccitt/G721RawAudioFileReader.java index d7ceac7..5c0e49f 100644 --- a/src/main/java/vavi/sound/sampled/adpcm/ccitt/G721RawAudioFileReader.java +++ b/src/main/java/vavi/sound/sampled/adpcm/ccitt/G721RawAudioFileReader.java @@ -30,6 +30,7 @@ * @author Naohide Sano (nsano) * @version 0.00 050722 nsano initial version
*/ +@Deprecated public class G721RawAudioFileReader extends AudioFileReader { @Override diff --git a/src/main/java/vavi/sound/sampled/adpcm/dvi/DviFileFormatType.java b/src/main/java/vavi/sound/sampled/adpcm/dvi/DviFileFormatType.java index 93b6fe3..a802f76 100644 --- a/src/main/java/vavi/sound/sampled/adpcm/dvi/DviFileFormatType.java +++ b/src/main/java/vavi/sound/sampled/adpcm/dvi/DviFileFormatType.java @@ -15,6 +15,7 @@ * @author Naohide Sano (nsano) * @version 0.00 201020 nsano initial version
*/ +@Deprecated public class DviFileFormatType extends AudioFileFormat.Type { /** diff --git a/src/main/java/vavi/sound/sampled/adpcm/ima/ImaFileFormatType.java b/src/main/java/vavi/sound/sampled/adpcm/ima/ImaFileFormatType.java index 8de889b..9a69595 100644 --- a/src/main/java/vavi/sound/sampled/adpcm/ima/ImaFileFormatType.java +++ b/src/main/java/vavi/sound/sampled/adpcm/ima/ImaFileFormatType.java @@ -15,6 +15,7 @@ * @author Naohide Sano (nsano) * @version 0.00 201020 nsano initial version
*/ +@Deprecated public class ImaFileFormatType extends AudioFileFormat.Type { /** diff --git a/src/main/java/vavi/sound/sampled/adpcm/ma/MaFileFormatType.java b/src/main/java/vavi/sound/sampled/adpcm/ma/MaFileFormatType.java index 9a74fce..9fb562c 100644 --- a/src/main/java/vavi/sound/sampled/adpcm/ma/MaFileFormatType.java +++ b/src/main/java/vavi/sound/sampled/adpcm/ma/MaFileFormatType.java @@ -15,6 +15,7 @@ * @author Naohide Sano (nsano) * @version 0.00 201020 nsano initial version
*/ +@Deprecated public class MaFileFormatType extends AudioFileFormat.Type { /** diff --git a/src/main/java/vavi/sound/sampled/adpcm/ms/MsFileFormatType.java b/src/main/java/vavi/sound/sampled/adpcm/ms/MsFileFormatType.java index a1394fd..af01200 100644 --- a/src/main/java/vavi/sound/sampled/adpcm/ms/MsFileFormatType.java +++ b/src/main/java/vavi/sound/sampled/adpcm/ms/MsFileFormatType.java @@ -15,6 +15,7 @@ * @author Naohide Sano (nsano) * @version 0.00 201020 nsano initial version
*/ +@Deprecated public class MsFileFormatType extends AudioFileFormat.Type { /** diff --git a/src/main/java/vavi/sound/sampled/adpcm/oki/OkiFileFormatType.java b/src/main/java/vavi/sound/sampled/adpcm/oki/OkiFileFormatType.java index 393ee5d..4879e23 100644 --- a/src/main/java/vavi/sound/sampled/adpcm/oki/OkiFileFormatType.java +++ b/src/main/java/vavi/sound/sampled/adpcm/oki/OkiFileFormatType.java @@ -15,6 +15,7 @@ * @author Naohide Sano (nsano) * @version 0.00 201020 nsano initial version
*/ +@Deprecated public class OkiFileFormatType extends AudioFileFormat.Type { /** diff --git a/src/main/java/vavi/sound/sampled/adpcm/rohm/RohmFileFormatType.java b/src/main/java/vavi/sound/sampled/adpcm/rohm/RohmFileFormatType.java index 5bc3073..31b605a 100644 --- a/src/main/java/vavi/sound/sampled/adpcm/rohm/RohmFileFormatType.java +++ b/src/main/java/vavi/sound/sampled/adpcm/rohm/RohmFileFormatType.java @@ -15,6 +15,7 @@ * @author Naohide Sano (nsano) * @version 0.00 201020 nsano initial version
*/ +@Deprecated public class RohmFileFormatType extends AudioFileFormat.Type { /** diff --git a/src/main/java/vavi/sound/sampled/adpcm/vox/VoxFileFormatType.java b/src/main/java/vavi/sound/sampled/adpcm/vox/VoxFileFormatType.java index 36f7f9a..0f64e89 100644 --- a/src/main/java/vavi/sound/sampled/adpcm/vox/VoxFileFormatType.java +++ b/src/main/java/vavi/sound/sampled/adpcm/vox/VoxFileFormatType.java @@ -15,6 +15,7 @@ * @author Naohide Sano (nsano) * @version 0.00 201020 nsano initial version
*/ +@Deprecated public class VoxFileFormatType extends AudioFileFormat.Type { /** diff --git a/src/main/java/vavi/sound/sampled/adpcm/yamaha/YamahaFileFormatType.java b/src/main/java/vavi/sound/sampled/adpcm/yamaha/YamahaFileFormatType.java index 588451f..b65700a 100644 --- a/src/main/java/vavi/sound/sampled/adpcm/yamaha/YamahaFileFormatType.java +++ b/src/main/java/vavi/sound/sampled/adpcm/yamaha/YamahaFileFormatType.java @@ -15,6 +15,7 @@ * @author Naohide Sano (nsano) * @version 0.00 201020 nsano initial version
*/ +@Deprecated public class YamahaFileFormatType extends AudioFileFormat.Type { /** From 30adf4cd3bdb978e3151200cbcffce93aac5dab9 Mon Sep 17 00:00:00 2001 From: Naohide Sano Date: Sat, 16 Nov 2024 22:27:43 +0900 Subject: [PATCH 2/8] clean up --- .../ssrc/SSRCSampleRateConversionProvider.java | 16 +++++++--------- .../sampled/adpcm/AdpcmWaveAudioFileReader.java | 3 +-- src/main/java/vavi/sound/sampled/mfi/MFi.java | 2 ++ 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/main/java/vavi/sound/pcm/resampling/ssrc/SSRCSampleRateConversionProvider.java b/src/main/java/vavi/sound/pcm/resampling/ssrc/SSRCSampleRateConversionProvider.java index 15db268..8b53b89 100755 --- a/src/main/java/vavi/sound/pcm/resampling/ssrc/SSRCSampleRateConversionProvider.java +++ b/src/main/java/vavi/sound/pcm/resampling/ssrc/SSRCSampleRateConversionProvider.java @@ -15,6 +15,8 @@ /** * SSRCSampleRateConversionProvider. * + * TODO not integrated as spi, see /META-INF/services/javax.sound.sampled.spi.FormatConversionProvider + * * @author Maksim Khadkevich */ public class SSRCSampleRateConversionProvider extends FormatConversionProvider { @@ -75,8 +77,8 @@ public AudioInputStream getAudioInputStream(AudioFormat.Encoding targetEncoding, return getAudioInputStream(targetFormat, sourceStream); } else { - throw new IllegalArgumentException("Unsupported conversion: " + sourceStream.getFormat().toString() + " to " - + targetEncoding.toString()); + throw new IllegalArgumentException("Unsupported conversion: " + sourceStream.getFormat() + " to " + + targetEncoding); } } @@ -91,7 +93,7 @@ public AudioInputStream getAudioInputStream(AudioFormat targetFormat, AudioInput SSRCInputStream resampler = new SSRCInputStream(inputFormat, outputFormat, sourceStream); return new AudioInputStream(resampler, outputFormat, AudioSystem.NOT_SPECIFIED); } else { - throw new IllegalArgumentException("Unsupported conversion: " + sourceStream.getFormat().toString() + " to " + throw new IllegalArgumentException("Unsupported conversion: " + sourceStream.getFormat() + " to " + targetFormat); } } catch (IOException e) { @@ -117,14 +119,10 @@ public boolean isConversionSupported(AudioFormat inputFormat, AudioFormat output return false; } - if (((inputSampleSize == 8) && (outputSampleSize == 8)) || ((inputSampleSize == 16) && (outputSampleSize == 16))) { + if (inputSampleSize == 8 && outputSampleSize == 8 || inputSampleSize == 16 && outputSampleSize == 16) { if ((inputEncoding == AudioFormat.Encoding.PCM_SIGNED)) { - if ((outputEncoding == AudioFormat.Encoding.PCM_SIGNED)) { - return true; - } else { - return false; - } + return outputEncoding == AudioFormat.Encoding.PCM_SIGNED; } else { return false; } diff --git a/src/main/java/vavi/sound/sampled/adpcm/AdpcmWaveAudioFileReader.java b/src/main/java/vavi/sound/sampled/adpcm/AdpcmWaveAudioFileReader.java index a7efe78..e888e91 100644 --- a/src/main/java/vavi/sound/sampled/adpcm/AdpcmWaveAudioFileReader.java +++ b/src/main/java/vavi/sound/sampled/adpcm/AdpcmWaveAudioFileReader.java @@ -25,7 +25,6 @@ import javax.sound.sampled.spi.AudioFileReader; import vavi.sound.LimitedInputStream; -import vavi.util.Debug; import vavi.util.win32.Chunk; import vavi.util.win32.WAVE; @@ -132,7 +131,7 @@ protected AudioFileFormat getAudioFileFormat(InputStream bitStream, int mediaLen try { bitStream.reset(); } catch (IOException e) { - if (Debug.isLoggable(java.util.logging.Level.FINEST)) + if (logger.isLoggable(Level.TRACE)) logger.log(Level.ERROR, e.getMessage(), e); else logger.log(Level.DEBUG, e); diff --git a/src/main/java/vavi/sound/sampled/mfi/MFi.java b/src/main/java/vavi/sound/sampled/mfi/MFi.java index 2f5a30c..f42bade 100644 --- a/src/main/java/vavi/sound/sampled/mfi/MFi.java +++ b/src/main/java/vavi/sound/sampled/mfi/MFi.java @@ -14,6 +14,8 @@ /** * MFi. * + * TODO props should be AudioFormat's props + * * @author Naohide Sano (nsano) * @version 0.00 060125 nsano initial version
*/ From 8ddc7b44158c1ae926def4b95431664beae8521c Mon Sep 17 00:00:00 2001 From: Naohide Sano Date: Sun, 24 Nov 2024 07:12:17 +0900 Subject: [PATCH 3/8] fix access level --- src/main/java/vavi/sound/sampled/adpcm/ccitt/CcittEncoding.java | 2 +- src/main/java/vavi/sound/sampled/adpcm/dvi/DviEncoding.java | 2 +- src/main/java/vavi/sound/sampled/adpcm/ima/ImaEncoding.java | 2 +- src/main/java/vavi/sound/sampled/adpcm/ma/MaEncoding.java | 2 +- src/main/java/vavi/sound/sampled/adpcm/ma/MaFileFormatType.java | 2 +- src/main/java/vavi/sound/sampled/adpcm/ms/MsEncoding.java | 2 +- src/main/java/vavi/sound/sampled/adpcm/ms/MsFileFormatType.java | 2 +- src/main/java/vavi/sound/sampled/adpcm/oki/OkiEncoding.java | 2 +- .../java/vavi/sound/sampled/adpcm/oki/OkiFileFormatType.java | 2 +- src/main/java/vavi/sound/sampled/adpcm/rohm/RohmEncoding.java | 2 +- .../java/vavi/sound/sampled/adpcm/rohm/RohmFileFormatType.java | 2 +- src/main/java/vavi/sound/sampled/adpcm/vox/VoxEncoding.java | 2 +- .../java/vavi/sound/sampled/adpcm/vox/VoxFileFormatType.java | 2 +- .../java/vavi/sound/sampled/adpcm/yamaha/YamahaEncoding.java | 2 +- .../vavi/sound/sampled/adpcm/yamaha/YamahaFileFormatType.java | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/main/java/vavi/sound/sampled/adpcm/ccitt/CcittEncoding.java b/src/main/java/vavi/sound/sampled/adpcm/ccitt/CcittEncoding.java index a776b63..ff69b9c 100644 --- a/src/main/java/vavi/sound/sampled/adpcm/ccitt/CcittEncoding.java +++ b/src/main/java/vavi/sound/sampled/adpcm/ccitt/CcittEncoding.java @@ -33,7 +33,7 @@ public class CcittEncoding extends AudioFormat.Encoding { * * @param name Name of the CCITT encoding. */ - public CcittEncoding(String name) { + private CcittEncoding(String name) { super(name); } } diff --git a/src/main/java/vavi/sound/sampled/adpcm/dvi/DviEncoding.java b/src/main/java/vavi/sound/sampled/adpcm/dvi/DviEncoding.java index 68920da..f89c2a7 100644 --- a/src/main/java/vavi/sound/sampled/adpcm/dvi/DviEncoding.java +++ b/src/main/java/vavi/sound/sampled/adpcm/dvi/DviEncoding.java @@ -25,7 +25,7 @@ public class DviEncoding extends AudioFormat.Encoding { * * @param name Name of the DVI encoding. */ - public DviEncoding(String name) { + private DviEncoding(String name) { super(name); } } diff --git a/src/main/java/vavi/sound/sampled/adpcm/ima/ImaEncoding.java b/src/main/java/vavi/sound/sampled/adpcm/ima/ImaEncoding.java index 9e4b172..58d83c2 100644 --- a/src/main/java/vavi/sound/sampled/adpcm/ima/ImaEncoding.java +++ b/src/main/java/vavi/sound/sampled/adpcm/ima/ImaEncoding.java @@ -25,7 +25,7 @@ public class ImaEncoding extends AudioFormat.Encoding { * * @param name Name of the IMA encoding. */ - public ImaEncoding(String name) { + private ImaEncoding(String name) { super(name); } } diff --git a/src/main/java/vavi/sound/sampled/adpcm/ma/MaEncoding.java b/src/main/java/vavi/sound/sampled/adpcm/ma/MaEncoding.java index 78fa76e..bfa012b 100644 --- a/src/main/java/vavi/sound/sampled/adpcm/ma/MaEncoding.java +++ b/src/main/java/vavi/sound/sampled/adpcm/ma/MaEncoding.java @@ -25,7 +25,7 @@ public class MaEncoding extends AudioFormat.Encoding { * * @param name Name of the MA encoding. */ - public MaEncoding(String name) { + private MaEncoding(String name) { super(name); } } diff --git a/src/main/java/vavi/sound/sampled/adpcm/ma/MaFileFormatType.java b/src/main/java/vavi/sound/sampled/adpcm/ma/MaFileFormatType.java index 9fb562c..966df5b 100644 --- a/src/main/java/vavi/sound/sampled/adpcm/ma/MaFileFormatType.java +++ b/src/main/java/vavi/sound/sampled/adpcm/ma/MaFileFormatType.java @@ -29,7 +29,7 @@ public class MaFileFormatType extends AudioFileFormat.Type { * @param name the name of the MA File Format. * @param extension the file extension for this MA File Format. */ - public MaFileFormatType(String name, String extension) { + private MaFileFormatType(String name, String extension) { super(name, extension); } } diff --git a/src/main/java/vavi/sound/sampled/adpcm/ms/MsEncoding.java b/src/main/java/vavi/sound/sampled/adpcm/ms/MsEncoding.java index e7c3186..f05fc9c 100644 --- a/src/main/java/vavi/sound/sampled/adpcm/ms/MsEncoding.java +++ b/src/main/java/vavi/sound/sampled/adpcm/ms/MsEncoding.java @@ -25,7 +25,7 @@ public class MsEncoding extends AudioFormat.Encoding { * * @param name Name of the MS encoding. */ - public MsEncoding(String name) { + private MsEncoding(String name) { super(name); } } diff --git a/src/main/java/vavi/sound/sampled/adpcm/ms/MsFileFormatType.java b/src/main/java/vavi/sound/sampled/adpcm/ms/MsFileFormatType.java index af01200..b8cceeb 100644 --- a/src/main/java/vavi/sound/sampled/adpcm/ms/MsFileFormatType.java +++ b/src/main/java/vavi/sound/sampled/adpcm/ms/MsFileFormatType.java @@ -29,7 +29,7 @@ public class MsFileFormatType extends AudioFileFormat.Type { * @param name the name of the MS File Format. * @param extension the file extension for this MS File Format. */ - public MsFileFormatType(String name, String extension) { + private MsFileFormatType(String name, String extension) { super(name, extension); } } diff --git a/src/main/java/vavi/sound/sampled/adpcm/oki/OkiEncoding.java b/src/main/java/vavi/sound/sampled/adpcm/oki/OkiEncoding.java index 9d2beb6..b164bb6 100644 --- a/src/main/java/vavi/sound/sampled/adpcm/oki/OkiEncoding.java +++ b/src/main/java/vavi/sound/sampled/adpcm/oki/OkiEncoding.java @@ -25,7 +25,7 @@ public class OkiEncoding extends AudioFormat.Encoding { * * @param name Name of the Oki encoding. */ - public OkiEncoding(String name) { + private OkiEncoding(String name) { super(name); } } diff --git a/src/main/java/vavi/sound/sampled/adpcm/oki/OkiFileFormatType.java b/src/main/java/vavi/sound/sampled/adpcm/oki/OkiFileFormatType.java index 4879e23..f8aa958 100644 --- a/src/main/java/vavi/sound/sampled/adpcm/oki/OkiFileFormatType.java +++ b/src/main/java/vavi/sound/sampled/adpcm/oki/OkiFileFormatType.java @@ -29,7 +29,7 @@ public class OkiFileFormatType extends AudioFileFormat.Type { * @param name the name of the Oki File Format. * @param extension the file extension for this Oki File Format. */ - public OkiFileFormatType(String name, String extension) { + private OkiFileFormatType(String name, String extension) { super(name, extension); } } diff --git a/src/main/java/vavi/sound/sampled/adpcm/rohm/RohmEncoding.java b/src/main/java/vavi/sound/sampled/adpcm/rohm/RohmEncoding.java index 0d57d47..d1aac66 100644 --- a/src/main/java/vavi/sound/sampled/adpcm/rohm/RohmEncoding.java +++ b/src/main/java/vavi/sound/sampled/adpcm/rohm/RohmEncoding.java @@ -25,7 +25,7 @@ public class RohmEncoding extends AudioFormat.Encoding { * * @param name Name of the Rohm encoding. */ - public RohmEncoding(String name) { + private RohmEncoding(String name) { super(name); } } diff --git a/src/main/java/vavi/sound/sampled/adpcm/rohm/RohmFileFormatType.java b/src/main/java/vavi/sound/sampled/adpcm/rohm/RohmFileFormatType.java index 31b605a..69334e8 100644 --- a/src/main/java/vavi/sound/sampled/adpcm/rohm/RohmFileFormatType.java +++ b/src/main/java/vavi/sound/sampled/adpcm/rohm/RohmFileFormatType.java @@ -29,7 +29,7 @@ public class RohmFileFormatType extends AudioFileFormat.Type { * @param name the name of the Rohm File Format. * @param extension the file extension for this Rohm File Format. */ - public RohmFileFormatType(String name, String extension) { + private RohmFileFormatType(String name, String extension) { super(name, extension); } } diff --git a/src/main/java/vavi/sound/sampled/adpcm/vox/VoxEncoding.java b/src/main/java/vavi/sound/sampled/adpcm/vox/VoxEncoding.java index c5bd5e6..7279142 100644 --- a/src/main/java/vavi/sound/sampled/adpcm/vox/VoxEncoding.java +++ b/src/main/java/vavi/sound/sampled/adpcm/vox/VoxEncoding.java @@ -25,7 +25,7 @@ public class VoxEncoding extends AudioFormat.Encoding { * * @param name Name of the VOX encoding. */ - public VoxEncoding(String name) { + private VoxEncoding(String name) { super(name); } } diff --git a/src/main/java/vavi/sound/sampled/adpcm/vox/VoxFileFormatType.java b/src/main/java/vavi/sound/sampled/adpcm/vox/VoxFileFormatType.java index 0f64e89..ca3a0a1 100644 --- a/src/main/java/vavi/sound/sampled/adpcm/vox/VoxFileFormatType.java +++ b/src/main/java/vavi/sound/sampled/adpcm/vox/VoxFileFormatType.java @@ -29,7 +29,7 @@ public class VoxFileFormatType extends AudioFileFormat.Type { * @param name the name of the VOX File Format. * @param extension the file extension for this VOX File Format. */ - public VoxFileFormatType(String name, String extension) { + private VoxFileFormatType(String name, String extension) { super(name, extension); } } diff --git a/src/main/java/vavi/sound/sampled/adpcm/yamaha/YamahaEncoding.java b/src/main/java/vavi/sound/sampled/adpcm/yamaha/YamahaEncoding.java index e3c652d..09d18ed 100644 --- a/src/main/java/vavi/sound/sampled/adpcm/yamaha/YamahaEncoding.java +++ b/src/main/java/vavi/sound/sampled/adpcm/yamaha/YamahaEncoding.java @@ -25,7 +25,7 @@ public class YamahaEncoding extends AudioFormat.Encoding { * * @param name Name of the Yamaha encoding. */ - public YamahaEncoding(String name) { + private YamahaEncoding(String name) { super(name); } } diff --git a/src/main/java/vavi/sound/sampled/adpcm/yamaha/YamahaFileFormatType.java b/src/main/java/vavi/sound/sampled/adpcm/yamaha/YamahaFileFormatType.java index b65700a..503e71a 100644 --- a/src/main/java/vavi/sound/sampled/adpcm/yamaha/YamahaFileFormatType.java +++ b/src/main/java/vavi/sound/sampled/adpcm/yamaha/YamahaFileFormatType.java @@ -29,7 +29,7 @@ public class YamahaFileFormatType extends AudioFileFormat.Type { * @param name the name of the Yamaha File Format. * @param extension the file extension for this Yamaha File Format. */ - public YamahaFileFormatType(String name, String extension) { + private YamahaFileFormatType(String name, String extension) { super(name, extension); } } From 66466f207b0a218a72ba94e4b4f28346090a2fca Mon Sep 17 00:00:00 2001 From: Naohide Sano Date: Mon, 25 Nov 2024 10:30:37 +0900 Subject: [PATCH 4/8] clean up --- .../vavi/sound/adpcm/AdpcmInputStream.java | 12 +- .../vavi/sound/adpcm/AdpcmOutputStream.java | 4 +- .../java/vavi/sound/adpcm/ccitt/G711.java | 2 +- .../java/vavi/sound/adpcm/ccitt/G721.java | 22 +- .../sound/adpcm/ccitt/G723_16InputStream.java | 4 +- .../java/vavi/sound/adpcm/ccitt/State.java | 26 +- src/main/java/vavi/sound/adpcm/dvi/Dvi.java | 2 +- src/main/java/vavi/sound/adpcm/ima/Ima.java | 18 +- .../vavi/sound/adpcm/ima/ImaInputEngine.java | 6 +- src/main/java/vavi/sound/adpcm/ms/Ms.java | 22 +- .../vavi/sound/adpcm/ms/MsInputEngine.java | 8 +- src/main/java/vavi/sound/adpcm/vox/Vox.java | 2 +- .../vavi/sound/adpcm/vox/VoxInputStream.java | 8 +- .../vavi/sound/adpcm/vox/VoxOutputStream.java | 2 +- .../java/vavi/sound/adpcm/yamaha/Yamaha.java | 2 +- .../java/vavi/sound/adpcm/ym2608/Ym2608.java | 14 +- src/main/java/vavi/sound/mfi/MfiSystem.java | 24 +- .../vavi/sound/mfi/vavi/AudioDataMessage.java | 2 +- .../java/vavi/sound/mfi/vavi/HeaderChunk.java | 4 +- .../vavi/sound/mfi/vavi/MetaEventAdapter.java | 6 +- .../java/vavi/sound/mfi/vavi/MfiContext.java | 26 +- .../java/vavi/sound/mfi/vavi/MidiContext.java | 8 +- .../java/vavi/sound/mfi/vavi/SubMessage.java | 6 +- .../vavi/sound/mfi/vavi/TrackMessage.java | 20 +- .../sound/mfi/vavi/VaviMfiDeviceProvider.java | 2 +- .../sound/mfi/vavi/VaviMfiFileFormat.java | 8 +- .../sound/mfi/vavi/VaviMidiConverter.java | 8 +- .../vavi/sound/mfi/vavi/VaviNoteMessage.java | 6 +- .../vavi/sound/mfi/vavi/VaviSequencer.java | 2 +- .../sound/mfi/vavi/header/NoteMessage.java | 2 +- .../sound/mfi/vavi/header/TitlMessage.java | 2 +- .../mfi/vavi/mitsubishi/Function131.java | 2 +- .../vavi/mitsubishi/MitsubishiSequencer.java | 4 +- .../sound/mfi/vavi/nec/Function1_240_7.java | 2 +- .../vavi/sound/mfi/vavi/nec/NecMessage.java | 4 +- .../vavi/sound/mfi/vavi/nec/NecSequencer.java | 4 +- .../sound/mfi/vavi/sharp/Function131.java | 2 +- .../sound/mfi/vavi/sharp/SharpSequencer.java | 4 +- .../vavi/track/AudioChannelPanpotMessage.java | 2 +- .../vavi/track/AudioChannelVolumeMessage.java | 2 +- .../mfi/vavi/track/AudioPlayMessage.java | 2 +- .../mfi/vavi/track/AudioStopMessage.java | 2 +- .../mfi/vavi/track/ChangeBankMessage.java | 6 +- .../mfi/vavi/track/ChangeVoiceMessage.java | 6 +- .../mfi/vavi/track/ChannelChangeMessage.java | 2 +- .../track/ChannelConfigurationMessage.java | 2 +- .../sound/mfi/vavi/track/CuePointMessage.java | 4 +- .../mfi/vavi/track/EndOfTrackMessage.java | 4 +- .../mfi/vavi/track/ExpressionMessage.java | 4 +- .../mfi/vavi/track/LoopPointMessage.java | 2 +- .../vavi/track/MachineDependentMessage.java | 14 +- .../mfi/vavi/track/MasterVolumeMessage.java | 2 +- .../mfi/vavi/track/MfiConvertibleMessage.java | 6 +- .../vavi/track/ModulationDepthMessage.java | 2 +- .../sound/mfi/vavi/track/Nop2Message.java | 4 +- .../vavi/sound/mfi/vavi/track/NopMessage.java | 8 +- .../sound/mfi/vavi/track/PanpotMessage.java | 2 +- .../mfi/vavi/track/PitchBendMessage.java | 2 +- .../mfi/vavi/track/PitchBendRangeMessage.java | 4 +- .../sound/mfi/vavi/track/TempoMessage.java | 16 +- .../mfi/vavi/track/UndefinedMessage.java | 2 +- .../sound/mfi/vavi/track/VolumeMessage.java | 6 +- .../vavi/sound/midi/BasicMidiFileReader.java | 4 +- .../java/vavi/sound/midi/MidiConstants.java | 6 +- src/main/java/vavi/sound/midi/MidiUtil.java | 24 +- .../sound/midi/mfi/MfiMidiFileReader.java | 2 +- .../sound/midi/mfi/MfiMidiFileWriter.java | 2 +- .../sound/midi/smaf/SmafMidiFileReader.java | 2 +- .../vavi/sound/mobile/BasicAudioEngine.java | 8 +- .../vavi/sound/mobile/FuetrekAudioEngine.java | 2 +- .../vavi/sound/mobile/PcmAudioEngine.java | 15 +- .../vavi/sound/mobile/RohmAudioEngine.java | 2 +- .../vavi/sound/mobile/YamahaAudioEngine.java | 2 +- .../vavi/sound/pcm/resampling/ssrc/SSRC.java | 34 +- .../sampled/mfi/DividedMfiWithVoiceMaker.java | 2 +- .../sound/sampled/mfi/MfiWithVoiceMaker.java | 2 +- .../smaf/DividedSmafWithVoiceMaker.java | 2 +- .../sampled/smaf/SmafWithVoiceMaker.java | 12 +- .../vavi/sound/smaf/MetaEventAdapter.java | 6 +- .../vavi/sound/smaf/SmafDeviceProvider.java | 2 +- .../java/vavi/sound/smaf/SmafFileFormat.java | 2 +- .../vavi/sound/smaf/SmafMidiConverter.java | 6 +- .../java/vavi/sound/smaf/SmafSequencer.java | 4 +- .../smaf/chunk/AudioSequenceDataChunk.java | 2 +- .../java/vavi/sound/smaf/chunk/Chunk.java | 24 +- .../chunk/ColorPaletteDefinitionChunk.java | 2 +- .../DisplayParameterDefinitionChunk.java | 2 +- .../java/vavi/sound/smaf/chunk/FileChunk.java | 4 +- .../chunk/GraphicsTrackSequenceDataChunk.java | 4 +- .../sound/smaf/chunk/MasterTrackChunk.java | 4 +- .../sound/smaf/chunk/ScoreTrackChunk.java | 14 +- .../smaf/chunk/SeekAndPhraseInfoChunk.java | 6 +- .../sound/smaf/chunk/SequenceDataChunk.java | 18 +- .../java/vavi/sound/smaf/chunk/WaveType.java | 2 +- .../sound/smaf/message/BankSelectMessage.java | 4 +- .../smaf/message/EndOfSequenceMessage.java | 2 +- .../sound/smaf/message/ExpressionMessage.java | 4 +- .../vavi/sound/smaf/message/MidiContext.java | 14 +- .../smaf/message/MidiConvertibleMessage.java | 4 +- .../sound/smaf/message/ModulationMessage.java | 2 +- .../vavi/sound/smaf/message/NopMessage.java | 2 +- .../vavi/sound/smaf/message/NoteMessage.java | 6 +- .../smaf/message/OctaveShiftMessage.java | 2 +- .../vavi/sound/smaf/message/PanMessage.java | 2 +- .../sound/smaf/message/PitchBendMessage.java | 4 +- .../smaf/message/ProgramChangeMessage.java | 4 +- .../vavi/sound/smaf/message/STMessage.java | 2 +- .../vavi/sound/smaf/message/SmafContext.java | 18 +- .../sound/smaf/message/UndefinedMessage.java | 4 +- .../vavi/sound/smaf/message/VNMessage.java | 2 +- .../sound/smaf/message/VolumeMessage.java | 2 +- .../sound/smaf/message/WaveDataMessage.java | 2 +- .../vavi/sound/smaf/message/WaveMessage.java | 2 +- .../BackDropColorDefinitionMessage.java | 2 +- .../GeneralPurposeDisplayMessage.java | 2 +- .../smaf/message/graphics/NopMessage.java | 2 +- .../message/graphics/OffsetOriginMessage.java | 2 +- .../message/graphics/ResetOrigneMessage.java | 2 +- .../smaf/message/graphics/UserMessage.java | 2 +- .../smaf/message/yamaha/YamahaMessage.java | 2 +- src/main/java/vavi/sound/smaf/readme.md | 14 +- src/test/java/ExtractWave.java | 3 +- src/test/java/PlayLine.java | 4 +- src/test/java/PlayPCM.java | 4 +- src/test/java/PlayPCM2.java | 8 +- src/test/java/PlaySMAF.java | 11 +- src/test/java/SoundFontTest.java | 4 +- .../adpcm/ccitt/G721InputStreamTest.java | 1 - .../adpcm/ccitt/G721OutputStreamTest.java | 1 - src/test/java/vavi/sound/adpcm/dvi/Adpcm.java | 534 ++++++++++-------- .../sound/adpcm/dvi/DviInputStreamTest.java | 1 - .../sound/adpcm/ima/ImaInputStreamTest.java | 2 +- .../sound/adpcm/ima/ImaOutputStreamTest.java | 2 - .../sound/adpcm/ma/MaInputStreamTest.java | 3 +- .../sound/adpcm/ma/MaOutputStreamTest.java | 1 - .../sound/adpcm/ms/MsInputStreamTest.java | 2 +- .../sound/adpcm/ms/MsOutputStreamTest.java | 6 +- .../sound/adpcm/oki/OkiInputStreamTest.java | 1 - .../sound/adpcm/oki/OkiOutputStreamTest.java | 1 - .../sound/adpcm/rohm/RohmInputStreamTest.java | 3 +- .../adpcm/rohm/RohmOutputStreamTest.java | 1 - .../sound/adpcm/vox/VoxInputStreamTest.java | 13 +- .../sound/adpcm/vox/VoxOutputStreamTest.java | 1 - .../adpcm/yamaha/YamahaInputStreamTest.java | 3 +- .../adpcm/yamaha/YamahaOutputStreamTest.java | 3 +- .../java/vavi/sound/mfi/MfiSystemTest.java | 2 +- .../vavi/sound/mfi/vavi/MfiContextTest.java | 2 +- .../sound/mfi/vavi/VaviMfiFileWriterTest.java | 2 +- .../sound/mfi/vavi/VaviMidiConverterTest.java | 2 +- .../java/vavi/sound/midi/MidiUtilTest.java | 38 +- .../sound/midi/mfi/MfiMidiFileReaderTest.java | 2 +- .../sound/midi/mfi/MfiVaviSequenceTest.java | 2 +- .../sound/midi/smaf/SmafVaviSequenceTest.java | 2 +- .../sound/mobile/BasicAudioEngineTest.java | 2 +- .../sampled/mfi/MfiAudioFileWriterTest.java | 2 +- .../sampled/smaf/SmafAudioFileWriterTest.java | 2 +- .../vavi/sound/smaf/SmafFileFormatTest.java | 4 +- .../java/vavi/sound/smaf/SmafSystemTest.java | 2 +- .../sound/smaf/message/SmafContextTest.java | 2 +- 159 files changed, 723 insertions(+), 697 deletions(-) diff --git a/src/main/java/vavi/sound/adpcm/AdpcmInputStream.java b/src/main/java/vavi/sound/adpcm/AdpcmInputStream.java index ff6254d..178171a 100644 --- a/src/main/java/vavi/sound/adpcm/AdpcmInputStream.java +++ b/src/main/java/vavi/sound/adpcm/AdpcmInputStream.java @@ -56,13 +56,13 @@ public AdpcmInputStream(InputStream in, ByteOrder byteOrder, int bits, ByteOrder super(new BitInputStream(in, bits, bitOrder)); this.byteOrder = byteOrder; this.decoder = getCodec(); -//logger.log(Level.DEBUG, this.in); +//logger.log(Level.TRACE, this.in); } /** ADPCM (4bit) length */ @Override public int available() throws IOException { -//logger.log(Level.DEBUG, "0: " + in.available() + ", " + ((in.available() * 2) + (rest ? 1 : 0))); +//logger.log(Level.TRACE, "0: " + in.available() + ", " + ((in.available() * 2) + (rest ? 1 : 0))); // TODO "* 2" calc should be in bits? return (in.available() * 2) + (rest ? 1 : 0); } @@ -77,10 +77,10 @@ public int available() throws IOException { */ @Override public int read() throws IOException { -//logger.log(Level.DEBUG, in); +//logger.log(Level.TRACE, in); if (!rest) { int adpcm = in.read(); -//logger.log(Level.DEBUG, "0: " + StringUtil.toHex2(adpcm)); +//logger.log(Level.TRACE, "0: " + StringUtil.toHex2(adpcm)); if (adpcm == -1) { return -1; } @@ -88,7 +88,7 @@ public int read() throws IOException { current = decoder.decode(adpcm); rest = true; -//logger.log(Level.DEBUG, "1: " + StringUtil.toHex2(current & 0xff)); +//logger.log(Level.TRACE, "1: " + StringUtil.toHex2(current & 0xff)); if (ByteOrder.BIG_ENDIAN.equals(byteOrder)) { return (current & 0xff00) >> 8; } else { @@ -96,7 +96,7 @@ public int read() throws IOException { } } else { rest = false; -//logger.log(Level.DEBUG, "2: " + StringUtil.toHex2((current & 0xff00) >> 8)); +//logger.log(Level.TRACE, "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/AdpcmOutputStream.java b/src/main/java/vavi/sound/adpcm/AdpcmOutputStream.java index 45e39bd..6c81d46 100644 --- a/src/main/java/vavi/sound/adpcm/AdpcmOutputStream.java +++ b/src/main/java/vavi/sound/adpcm/AdpcmOutputStream.java @@ -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(); -//logger.log(Level.DEBUG, this.out); +//logger.log(Level.TRACE, 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; } } -//logger.log(Level.DEBUG, "current: " + StringUtil.toHex4(current)); +//logger.log(Level.TRACE, "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 08e4300..b0f1c87 100644 --- a/src/main/java/vavi/sound/adpcm/ccitt/G711.java +++ b/src/main/java/vavi/sound/adpcm/ccitt/G711.java @@ -313,7 +313,7 @@ protected int ulaw2alaw(int uval) { 0x55 ^ (_u2a[0x7f ^ uval] - 1); } - //------------------------------------------------------------------------- + // ---- /** * Quantizes the input val against the table of size short integers. diff --git a/src/main/java/vavi/sound/adpcm/ccitt/G721.java b/src/main/java/vavi/sound/adpcm/ccitt/G721.java index b07e16a..0ac31dc 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)) { -//logger.log(Level.DEBUG, "---- " + ccc + " ----"); +//logger.log(Level.TRACE, "---- " + ccc + " ----"); //ccc++; -//logger.log(Level.DEBUG, "sl:B:\t" + sl); +//logger.log(Level.TRACE, "sl:B:\t" + sl); sl >>= 2; // 14-bit dynamic range -//logger.log(Level.DEBUG, "sl:A:\t" + sl); +//logger.log(Level.TRACE, "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 -//logger.log(Level.DEBUG, "sl:\t" + sl); -//logger.log(Level.DEBUG, "se:\t" + se); +//logger.log(Level.TRACE, "sl:\t" + sl); +//logger.log(Level.TRACE, "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 -//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); +//logger.log(Level.TRACE, "---- (" + (ccc++) + ")"); +//logger.log(Level.TRACE, "i:\t" + StringUtil.toHex2(i)); +//logger.log(Level.TRACE, "sezi:\t" + sezi); +//logger.log(Level.TRACE, "sez:\t" + sez); +//logger.log(Level.TRACE, "sei:\t" + sei); +//logger.log(Level.TRACE, "se:\t" + se); // MIX int y = state.getStepSize(); // dynamic quantizer step size 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 d3be8c2..cc13c60 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); -//logger.log(Level.DEBUG, this.in); +//logger.log(Level.TRACE, this.in); } /** ADPCM (4bit) length */ @Override public int available() throws IOException { -//logger.log(Level.DEBUG, "0: " + in.available() + ", " + ((in.available() * 2) + (rest ? 1 : 0))); +//logger.log(Level.TRACE, "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/State.java b/src/main/java/vavi/sound/adpcm/ccitt/State.java index c35450f..8b63bc6 100644 --- a/src/main/java/vavi/sound/adpcm/ccitt/State.java +++ b/src/main/java/vavi/sound/adpcm/ccitt/State.java @@ -104,7 +104,7 @@ class State { /** delayed tone detect, new in 1988 version */ private int td; - //---- + // ---- /** */ private static final int[] power2 = { @@ -147,7 +147,7 @@ private static int fmult(int an, int srn) { int retval = (wanexp >= 0) ? ((wanmant << wanexp) & 0x7fff) : (wanmant >> -wanexp); -//logger.log(Level.DEBUG, an + ", " + srn + ": " + ((an ^ srn) < 0 ? -retval : retval)); +//logger.log(Level.TRACE, 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) { -//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); +//logger.log(Level.TRACE, "y:\t" + y); +//logger.log(Level.TRACE, "dq:\t" + _dq); +//logger.log(Level.TRACE, "sr:\t" + _sr); +//logger.log(Level.TRACE, "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; -//logger.log(Level.DEBUG, "dq[0]:1: " + dq[0]); +//logger.log(Level.TRACE, "dq[0]:1: " + dq[0]); } else { exp = quan(mag); dq[0] = (_dq >= 0) ? (exp << 6) + ((mag << 6) >> exp) : (exp << 6) + ((mag << 6) >> exp) - 0x400; -//logger.log(Level.DEBUG, "dq[0]:2: " + dq[0] + ", " + _dq + ", " + exp + ", " + mag); -//logger.log(Level.DEBUG, "dq[0]:-: " + (exp << 6) + ", " + ((mag << 6) >> exp)); +//logger.log(Level.TRACE, "dq[0]:2: " + dq[0] + ", " + _dq + ", " + exp + ", " + mag); +//logger.log(Level.TRACE, "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; -//logger.log(Level.DEBUG, "sr[0]:1: " + sr[0]); +//logger.log(Level.TRACE, "sr[0]:1: " + sr[0]); } else if (_sr > 0) { exp = quan(_sr); sr[0] = (exp << 6) + ((_sr << 6) >> exp); -//logger.log(Level.DEBUG, "sr[0]:2: " + sr[0]); +//logger.log(Level.TRACE, "sr[0]:2: " + sr[0]); } else if (_sr > -32768) { mag = -_sr; exp = quan(mag); sr[0] = (exp << 6) + ((mag << 6) >> exp) - 0x400; -//logger.log(Level.DEBUG, "sr[0]:3: " + sr[0]); +//logger.log(Level.TRACE, "sr[0]:3: " + sr[0]); } else { sr[0] = -992; -//logger.log(Level.DEBUG, "sr[0]:4: " + sr[0]); +//logger.log(Level.TRACE, "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 bbd9be2..7c8e2ac 100644 --- a/src/main/java/vavi/sound/adpcm/dvi/Dvi.java +++ b/src/main/java/vavi/sound/adpcm/dvi/Dvi.java @@ -180,7 +180,7 @@ public int decode(int input) { // int valPrev = state.valPrev; -//logger.log(Level.DEBUG, "{}", valPrev); +//logger.log(Level.TRACE, "{}", 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 b0caee0..a9ac33a 100644 --- a/src/main/java/vavi/sound/adpcm/ima/Ima.java +++ b/src/main/java/vavi/sound/adpcm/ima/Ima.java @@ -153,13 +153,13 @@ private static void decode(int channel, if (c != cm) { val -= dp; if (val < -0x8000) { -//logger.log(Level.DEBUG, String.format("%04x -> %d", val, -0x8000)); +//logger.log(Level.TRACE, String.format("%04x -> %d", val, -0x8000)); val = -0x8000; } } else { val += dp; if (val > 0x7fff) { -//logger.log(Level.DEBUG, String.format("%04x -> %d", val, 0x7fff)); +//logger.log(Level.TRACE, String.format("%04x -> %d", val, 0x7fff)); val = 0x7fff; } } @@ -264,7 +264,7 @@ private static int encode(int ch, int chans, int v0, int[] ibuff, int n, int[] s op += o_inc; // skip op for next group } } else { -//logger.log(Level.DEBUG, "op: " + op); +//logger.log(Level.TRACE, "op: " + op); obuff[op] = (byte) cm; } i = (i + 1) & 0x07; @@ -412,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; -//logger.log(Level.DEBUG, "dataLength: " + dataLength); -//logger.log(Level.DEBUG, "channels: " + channels); -//logger.log(Level.DEBUG, "blockAlign: " + blockAlign); -//logger.log(Level.DEBUG, "samplesPerBlock: " + samplesPerBlock); +//logger.log(Level.TRACE, "dataLength: " + dataLength); +//logger.log(Level.TRACE, "channels: " + channels); +//logger.log(Level.TRACE, "blockAlign: " + blockAlign); +//logger.log(Level.TRACE, "samplesPerBlock: " + samplesPerBlock); if (samplesPerBlock != 0) { n = (dataLength / blockAlign) * samplesPerBlock; @@ -424,8 +424,8 @@ public static int getSamplesIn(int dataLength, int channels, int blockAlign, int n = 0; m = blockAlign; } -//logger.log(Level.DEBUG, "n: " + n); -//logger.log(Level.DEBUG, "m: " + m); +//logger.log(Level.TRACE, "n: " + n); +//logger.log(Level.TRACE, "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 b6a9335..b313114 100644 --- a/src/main/java/vavi/sound/adpcm/ima/ImaInputEngine.java +++ b/src/main/java/vavi/sound/adpcm/ima/ImaInputEngine.java @@ -76,7 +76,7 @@ public void execute() throws IOException { throw new IOException("Not yet initialized"); } else { int bytesPerBlock = Ima.getBytesPerBlock(channels, samplesPerBlock); -//logger.log(Level.DEBUG, "bytesPerBlock: " + bytesPerBlock + ", samplesPerBlock: " + samplesPerBlock); +//logger.log(Level.TRACE, "bytesPerBlock: " + bytesPerBlock + ", samplesPerBlock: " + samplesPerBlock); byte[] buffer = new byte[samplesPerBlock * 2]; int l = 0; while (l < buffer.length) { @@ -89,7 +89,7 @@ public void execute() throws IOException { if (l > 0) { byte[] adpcm = new byte[bytesPerBlock]; int[] pcm = new int[l / 2]; -//logger.log(Level.DEBUG, "adpcm: " + bytesPerBlock + ", pcm: " + pcm.length + ", " + l); +//logger.log(Level.TRACE, "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(); @@ -97,7 +97,7 @@ public void execute() throws IOException { ledis.close(); encoder.encodeBlock(1, pcm, pcm.length, steps, adpcm, 9); -//logger.log(Level.DEBUG, "adpcm: " + adpcm.length); +//logger.log(Level.TRACE, "adpcm: " + adpcm.length); out.write(adpcm); } } diff --git a/src/main/java/vavi/sound/adpcm/ms/Ms.java b/src/main/java/vavi/sound/adpcm/ms/Ms.java index 170c92c..01e7f12 100644 --- a/src/main/java/vavi/sound/adpcm/ms/Ms.java +++ b/src/main/java/vavi/sound/adpcm/ms/Ms.java @@ -100,7 +100,7 @@ private static int decode(int code, // make linear prediction for next sample int vlin = ((sample1 * state[sp].iCoef[0]) + (sample2 * state[sp].iCoef[1])) >> 8; -//logger.log(Level.DEBUG, vlin); +//logger.log(Level.TRACE, vlin); // then add the code * step adjustment code -= (code & 0x08) << 1; int sample = (code * step) + vlin; @@ -151,7 +151,7 @@ public void decodeBlock(int channels, if ((value & 0x8000) != 0) { value -= 0x10000; } -//logger.log(Level.DEBUG, "1: " + value); +//logger.log(Level.TRACE, "1: " + value); state[channel].step = value; ip += 2; } @@ -162,7 +162,7 @@ public void decodeBlock(int channels, if ((value & 0x8000) != 0) { value -= 0x10000; } -//logger.log(Level.DEBUG, "2: " + value); +//logger.log(Level.TRACE, "2: " + value); outBuffer[channels + channel] = value; ip += 2; } @@ -173,7 +173,7 @@ public void decodeBlock(int channels, if ((value & 0x8000) != 0) { value -= 0x10000; } -//logger.log(Level.DEBUG, "3: " + value); +//logger.log(Level.TRACE, "3: " + value); outBuffer[channel] = value; ip += 2; } @@ -262,7 +262,7 @@ private static int encode(int channel, // difference between linear prediction and current sample d = inBuffer[ip] - vlin; int dp = d + (step << 3) + (step >> 1); -//logger.log(Level.DEBUG, "vlin: " + vlin + ", d: " + d + ", dp: " + dp + ", in: " + inBuffer[ip] + ", coef: " + iCoef[0] + ", " + iCoef[1]); +//logger.log(Level.TRACE, "vlin: " + vlin + ", d: " + d + ", dp: " + dp + ", in: " + inBuffer[ip] + ", coef: " + iCoef[0] + ", " + iCoef[1]); int c = 0; if (dp > 0) { c = dp / step; @@ -289,7 +289,7 @@ private static int encode(int channel, // FIXME does c << 0 work properly ? outBuffer[op + (ox >> 3)] |= (byte) ((ox & 4) != 0 ? c : (c << 4)); ox += 4 * channels; -//logger.log(Level.DEBUG, String.format("%1x", c)); +//logger.log(Level.TRACE, String.format("%1x", c)); } // Update the step for the next sample @@ -301,7 +301,7 @@ private static int encode(int channel, //if (outBuffer != null) // logger.log(Level.DEBUG, ""); d2 /= length; // be sure it's non-negative -//logger.log(Level.DEBUG, String.format("ch%d: st %d->%d, d %.1f", channel, steps[sp], step, Math.sqrt(d2))); +//logger.log(Level.TRACE, String.format("ch%d: st %d->%d, d %.1f", channel, steps[sp], step, Math.sqrt(d2))); steps[sp] = step; return (int) Math.sqrt(d2); @@ -354,7 +354,7 @@ private static void encodeChannel(int channel, s1[0] = s0; encode(channel, channels, v, _iCoef[k], inBuffer, n0, s1, 0, null); -//logger.log(Level.DEBUG, String.format(" s32 %d", s1[0])); +//logger.log(Level.TRACE, String.format(" s32 %d", s1[0])); ss[0] = (3 * s0 + s1[0]) / 4; s1[0] = ss[0]; @@ -372,7 +372,7 @@ private static void encodeChannel(int channel, } } steps[sp] = smin; -//logger.log(Level.DEBUG, String.format("kmin %d, smin %5d, ", kmin, smin)); +//logger.log(Level.TRACE, String.format("kmin %d, smin %5d, ", kmin, smin)); encode(channel, channels, v, _iCoef[kmin], inBuffer, length, steps, sp, outBuffer); outBuffer[channel] = (byte) kmin; } @@ -422,8 +422,8 @@ public static int getSamplesIn(int dataLength, n = 0; m = blockAlign; } -//logger.log(Level.DEBUG, "n: " + n); -//logger.log(Level.DEBUG, "m: " + m); +//logger.log(Level.TRACE, "n: " + n); +//logger.log(Level.TRACE, "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 b9fc2f0..fc2449b 100644 --- a/src/main/java/vavi/sound/adpcm/ms/MsInputEngine.java +++ b/src/main/java/vavi/sound/adpcm/ms/MsInputEngine.java @@ -76,7 +76,7 @@ public void execute() throws IOException { throw new IOException("Not yet initialized"); } else { int bytesPerBlock = Ms.getBytesPerBlock(channels, samplesPerBlock); -//logger.log(Level.DEBUG, "bytesPerBlock: " + bytesPerBlock + ", samplesPerBlock: " + samplesPerBlock); +//logger.log(Level.TRACE, "bytesPerBlock: " + bytesPerBlock + ", samplesPerBlock: " + samplesPerBlock); byte[] buffer = new byte[samplesPerBlock * 2]; int l = 0; while (l < buffer.length) { @@ -86,18 +86,18 @@ public void execute() throws IOException { } l += r; } -//logger.log(Level.DEBUG, StringUtil.getDump(buffer, 128)); +//logger.log(Level.TRACE, StringUtil.getDump(buffer, 128)); if (l > 0) { byte[] adpcm = new byte[bytesPerBlock]; int[] pcm = new int[l / 2]; -//logger.log(Level.DEBUG, "adpcm: " + bytesPerBlock + ", pcm: " + pcm.length + ", " + l); +//logger.log(Level.TRACE, "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); -//logger.log(Level.DEBUG, StringUtil.getDump(adpcm, 128)); +//logger.log(Level.TRACE, StringUtil.getDump(adpcm, 128)); out.write(adpcm); } diff --git a/src/main/java/vavi/sound/adpcm/vox/Vox.java b/src/main/java/vavi/sound/adpcm/vox/Vox.java index d52c12e..9ef6465 100644 --- a/src/main/java/vavi/sound/adpcm/vox/Vox.java +++ b/src/main/java/vavi/sound/adpcm/vox/Vox.java @@ -58,7 +58,7 @@ public int encode(int samp) { } state.last = decode(code); -//logger.log(Level.DEBUG, String.format("%04X -> %02X", samp, code)); +//logger.log(Level.TRACE, String.format("%04X -> %02X", samp, code)); return code; } diff --git a/src/main/java/vavi/sound/adpcm/vox/VoxInputStream.java b/src/main/java/vavi/sound/adpcm/vox/VoxInputStream.java index f4b6801..6fcb56d 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 { -//logger.log(Level.DEBUG, "0: " + in.available() + ", " + ((in.available() * 2) + (rest ? 1 : 0))); +//logger.log(Level.TRACE, "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 { -//logger.log(Level.DEBUG, in); +//logger.log(Level.TRACE, 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; -//logger.log(Level.DEBUG, "1: " + StringUtil.toHex2(current & 0xff)); +//logger.log(Level.TRACE, "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; -//logger.log(Level.DEBUG, "2: " + StringUtil.toHex2((current & 0xff00) >> 8)); +//logger.log(Level.TRACE, "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 192e8a3..1c9a2a3 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 { } } -//logger.log(Level.DEBUG, "current: " + StringUtil.toHex4(current)); +//logger.log(Level.TRACE, "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 bec747a..c2ae345 100644 --- a/src/main/java/vavi/sound/adpcm/yamaha/Yamaha.java +++ b/src/main/java/vavi/sound/adpcm/yamaha/Yamaha.java @@ -123,7 +123,7 @@ public int encode(int samp) { } stat.last = decode(code); -//logger.log(Level.DEBUG, String.format("%04X -> %02X", samp, code)); +//logger.log(Level.TRACE, 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 d725a91..5f67f64 100644 --- a/src/main/java/vavi/sound/adpcm/ym2608/Ym2608.java +++ b/src/main/java/vavi/sound/adpcm/ym2608/Ym2608.java @@ -48,12 +48,12 @@ public int encode(int pcm) { // encoding process 2 long dn = pcm - state.xn; -//logger.log(Level.DEBUG, String.format("%05d: %d, %d, %d", ccc, dn, pcm, state.xn)); // OK +//logger.log(Level.TRACE, 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)); -//logger.log(Level.DEBUG, String.format("%05d: %d", ccc, i)); // OK +//logger.log(Level.TRACE, 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; -//logger.log(Level.DEBUG, String.format("%05d: %d, %d, %d", ccc, i, adpcm, state.stepSize)); // OK +//logger.log(Level.TRACE, 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; } -//logger.log(Level.DEBUG, String.format("%05d: %d, %d", ccc, state.xn, i)); +//logger.log(Level.TRACE, String.format("%05d: %d, %d", ccc, state.xn, i)); // encode process 6 // update step size state.stepSize = (stepsizeTable[adpcm] * state.stepSize) / 64; -//logger.log(Level.DEBUG, String.format("%05d: %d, %d, %d", ccc, i, adpcm, state.stepSize)); // OK +//logger.log(Level.TRACE, 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; } -//logger.log(Level.DEBUG, String.format("%05d: %d, %d, %d", state.count, state.xn, state.stepSize, adpcm)); // OK +//logger.log(Level.TRACE, 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; } -//logger.log(Level.DEBUG, String.format("%05d: %d, %d, %d", state.count, state.xn, state.stepSize, adpcm)); // OK +//logger.log(Level.TRACE, 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/MfiSystem.java b/src/main/java/vavi/sound/mfi/MfiSystem.java index e8f5342..00bb390 100644 --- a/src/main/java/vavi/sound/mfi/MfiSystem.java +++ b/src/main/java/vavi/sound/mfi/MfiSystem.java @@ -142,7 +142,7 @@ public static javax.sound.midi.Sequence toMidiSequence(Sequence sequence) throws InvalidMfiDataException, MfiUnavailableException { MidiConverter converter = MfiSystem.getMidiConverter(); -//logger.log(Level.DEBUG, converter); +//logger.log(Level.TRACE, converter); return converter.toMidiSequence(sequence); } @@ -150,11 +150,11 @@ public static javax.sound.midi.Sequence toMidiSequence(Sequence sequence) public static MfiFileFormat getMfiFileFormat(InputStream stream) throws InvalidMfiDataException, IOException { -//logger.log(Level.DEBUG, "readers: " + readers.length); +//logger.log(Level.TRACE, "readers: " + readers.length); for (MfiFileReader reader : readers) { try { MfiFileFormat mff = reader.getMfiFileFormat(stream); -//logger.log(Level.DEBUG, StringUtil.paramString(mff)); +//logger.log(Level.TRACE, StringUtil.paramString(mff)); return mff; } catch (Exception e) { logger.log(Level.WARNING, e.getMessage(), e); @@ -179,11 +179,11 @@ public static MfiFileFormat getMfiFileFormat(URL url) throws InvalidMfiDataExcep /** Gets a MFi sequence. */ public static Sequence getSequence(InputStream stream) throws InvalidMfiDataException, IOException { -//logger.log(Level.DEBUG, "readers: " + readers.length); +//logger.log(Level.TRACE, "readers: " + readers.length); for (MfiFileReader reader : readers) { try { Sequence sequence = reader.getSequence(stream); -//logger.log(Level.DEBUG, StringUtil.paramString(sequence)); +//logger.log(Level.TRACE, StringUtil.paramString(sequence)); return sequence; } catch (InvalidMfiDataException e) { logger.log(Level.DEBUG, e); @@ -269,7 +269,7 @@ public static int write(Sequence in, int fileType, File out) throws IOException return write(in, fileType, new BufferedOutputStream(Files.newOutputStream(out.toPath()))); } - //---- + // ---- /** all providers */ private static final ServiceLoader providers; @@ -295,15 +295,21 @@ public static int write(Sequence in, int fileType, File out) throws IOException String defaultProvider = mfiSystemProps.getProperty("default.provider"); providers = ServiceLoader.load(vavi.sound.mfi.spi.MfiDeviceProvider.class); -providers.forEach(System.err::println); +if (logger.isLoggable(Level.TRACE)) { + providers.forEach(System.err::println); +} provider = StreamSupport.stream(providers.spliterator(), false).filter(p -> p.getClass().getName().equals(defaultProvider)).findFirst().get(); logger.log(Level.DEBUG, "default provider: " + provider.getClass().getName()); readers = ServiceLoader.load(vavi.sound.mfi.spi.MfiFileReader.class); -providers.forEach(System.err::println); +if (logger.isLoggable(Level.TRACE)) { + providers.forEach(System.err::println); +} writers = ServiceLoader.load(vavi.sound.mfi.spi.MfiFileWriter.class); -providers.forEach(System.err::println); +if (logger.isLoggable(Level.TRACE)) { + providers.forEach(System.err::println); +} } catch (Exception e) { logger.log(Level.ERROR, e.getMessage(), e); throw new IllegalStateException(e); diff --git a/src/main/java/vavi/sound/mfi/vavi/AudioDataMessage.java b/src/main/java/vavi/sound/mfi/vavi/AudioDataMessage.java index 84686b7..b8d59b1 100644 --- a/src/main/java/vavi/sound/mfi/vavi/AudioDataMessage.java +++ b/src/main/java/vavi/sound/mfi/vavi/AudioDataMessage.java @@ -245,7 +245,7 @@ public byte[] getMessage() { throw new UnsupportedOperationException("no mean"); } - //---- + // ---- @Override public MidiEvent[] getMidiEvents(MidiContext context) throws InvalidMidiDataException { diff --git a/src/main/java/vavi/sound/mfi/vavi/HeaderChunk.java b/src/main/java/vavi/sound/mfi/vavi/HeaderChunk.java index 58f6ce9..5ac5152 100644 --- a/src/main/java/vavi/sound/mfi/vavi/HeaderChunk.java +++ b/src/main/java/vavi/sound/mfi/vavi/HeaderChunk.java @@ -159,7 +159,7 @@ public int getSubChunksLength() { int length = 0; for (SubMessage subChunk : subChunks.values()) { length += 4 + 2 + subChunk.getDataLength(); // type + length + ... -//logger.log(Level.DEBUG, subChunk + ": " + subChunks.getSubLength()); +//logger.log(Level.TRACE, subChunk + ": " + subChunks.getSubLength()); } return length; } @@ -267,7 +267,7 @@ public static HeaderChunk readFrom(InputStream is) SubMessage subChunk = SubMessage.readFrom(is); headerChunk.subChunks.put(subChunk.getSubType(), subChunk); l += 4 + 2 + subChunk.getDataLength(); // type + length + -//logger.log(Level.DEBUG, "header subchunk length sum: " + l + " / " + (headerLength - 3)); +//logger.log(Level.TRACE, "header subchunk length sum: " + l + " / " + (headerLength - 3)); } return headerChunk; diff --git a/src/main/java/vavi/sound/mfi/vavi/MetaEventAdapter.java b/src/main/java/vavi/sound/mfi/vavi/MetaEventAdapter.java index c230d87..20f91ca 100644 --- a/src/main/java/vavi/sound/mfi/vavi/MetaEventAdapter.java +++ b/src/main/java/vavi/sound/mfi/vavi/MetaEventAdapter.java @@ -70,7 +70,7 @@ public void open() { */ @Override public void meta(javax.sound.midi.MetaMessage message) { -//logger.log(Level.DEBUG, "type: " + message.getType()); +//logger.log(Level.TRACE, "type: " + message.getType()); switch (MetaEvent.valueOf(message.getType())) { case META_MACHINE_DEPEND: // sequencer specific meta event try { @@ -156,7 +156,7 @@ private static void processSpecial_Vavi_MachineDependent(javax.sound.midi.MetaMe byte[] data = message.getData(); int id = (data[2] & 0xff) * 0xff + (data[3] & 0xff); -//logger.log(Level.DEBUG, "message id: " + id); +//logger.log(Level.TRACE, "message id: " + id); MachineDependentMessage mdm = (MachineDependentMessage) MfiMessageStore.get(id); int vendor = mdm.getVendor() | mdm.getCarrier(); @@ -182,7 +182,7 @@ private static void processSpecial_Vavi_Mfi4(javax.sound.midi.MetaMessage messag byte[] data = message.getData(); int id = (data[2] & 0xff) * 0xff + (data[3] & 0xff); -//logger.log(Level.DEBUG, "message id: " + id); +//logger.log(Level.TRACE, "message id: " + id); AudioDataSequencer sequencer = (AudioDataSequencer) MfiMessageStore.get(id); sequencer.sequence(); diff --git a/src/main/java/vavi/sound/mfi/vavi/MfiContext.java b/src/main/java/vavi/sound/mfi/vavi/MfiContext.java index 87b8801..5a20aeb 100644 --- a/src/main/java/vavi/sound/mfi/vavi/MfiContext.java +++ b/src/main/java/vavi/sound/mfi/vavi/MfiContext.java @@ -48,7 +48,7 @@ public class MfiContext { /** max MFi track number */ public static final int MAX_MFI_TRACKS = 4; - //---- + // ---- /** @see MidiFileFormat#getType() 0: SMF Format 0, 1: SMF Format 1 */ private int type; @@ -72,7 +72,7 @@ public int getTimeBase() { return timeBase; } - //---- + // ---- /** index is MFi Track No., when that's used this returns true */ private final boolean[] trackUsed = new boolean[MAX_MFI_TRACKS]; @@ -109,7 +109,7 @@ public boolean isEofSet(int mfiTrackNumber) { return eofSet[mfiTrackNumber]; } - //---- + // ---- /** * magnification of tick @@ -132,7 +132,7 @@ public boolean isScaleChanged() { return scaleChanged; } - //---- + // ---- /** previous tick, index is MFi Track No. */ private final long[] previousTicks = new long[MAX_MFI_TRACKS]; @@ -176,18 +176,18 @@ private int getAdjustedDelta(int mfiTrackNumber, double doubleDelta) { double rounded = doubleDelta - delta; roundedSum[mfiTrackNumber] += rounded; if (roundedSum[mfiTrackNumber] >= 1d) { -//logger.log(Level.DEBUG, "rounded over 1, plus 1: " + roundedSum[mfiTrackNumber] + "[" + mfiTrackNumber + "]"); +//logger.log(Level.TRACE, "rounded over 1, plus 1: " + roundedSum[mfiTrackNumber] + "[" + mfiTrackNumber + "]"); delta += 1; roundedSum[mfiTrackNumber] -= 1; } else if (roundedSum[mfiTrackNumber] <= -1d) { -//logger.log(Level.DEBUG, "rounded under -1, minus 1: " + roundedSum[mfiTrackNumber] + "[" + mfiTrackNumber + "]"); +//logger.log(Level.TRACE, "rounded under -1, minus 1: " + roundedSum[mfiTrackNumber] + "[" + mfiTrackNumber + "]"); delta -= 1; roundedSum[mfiTrackNumber] += 1; } return delta; } - //---- + // ---- /** * Finds how many Δs(integer value, truncating too much) can be included in the time since the previous NoteOn @@ -229,7 +229,7 @@ public MfiEvent[] getIntervalMfiEvents(int mfiTrackNumber) { } else if (midiMessage instanceof MetaMessage && ((MetaMessage) midiMessage).getType() == 47) { // eot interval = retrieveAdjustedDelta(mfiTrackNumber, midiEvent.getTick()); -//logger.log(Level.DEBUG, "interval for EOT[" + mfiTrackNumber + "]: " + interval); +//logger.log(Level.TRACE, "interval for EOT[" + mfiTrackNumber + "]: " + interval); } else if (midiMessage instanceof MetaMessage) { return null; } else if (midiMessage instanceof SysexMessage) { @@ -255,7 +255,7 @@ public MfiEvent[] getIntervalMfiEvents(int mfiTrackNumber) { incrementPreviousTick(mfiTrackNumber, Math.round(255 * scale)); } -//logger.log(Level.DEBUG, nopLength + " nops inserted"); +//logger.log(Level.TRACE, nopLength + " nops inserted"); return mfiEvents; } @@ -275,7 +275,7 @@ public int getDelta(int mfiTrackNumber) { } else if (midiMessage instanceof MetaMessage && ((MetaMessage) midiMessage).getType() == 81) { // tempo delta = retrieveAdjustedDelta(mfiTrackNumber, midiEvent.getTick()); // TODO is 0 ok? -//logger.log(Level.DEBUG, "[" + midiEventIndex + "] delta for tempo, " + mfiTrackNumber + "ch: " + delta); +//logger.log(Level.TRACE, "[" + midiEventIndex + "] delta for tempo, " + mfiTrackNumber + "ch: " + delta); } else { logger.log(Level.WARNING, "no delta defined for: " + MidiUtil.paramString(midiMessage)); } @@ -287,7 +287,7 @@ public int getDelta(int mfiTrackNumber) { return delta % 256; } - //---- + // ---- /** * Gets the corrected MFi pitch. @@ -315,7 +315,7 @@ public int retrieveMfiTrack(int channel) { return channel / 4; } - //---- + // ---- /** a single sequence of MIDI events */ private final List midiEvents = new ArrayList<>(); @@ -440,7 +440,7 @@ public MidiEvent getNoteOffMidiEvent() throws NoSuchElementException { shortMessage.getData1() != data1 && shortMessage.getData2() == 0 && !noteOffEventUsed.get(i)) { -//logger.log(Level.DEBUG, "next: " + shortMessage.getChannel() + "ch, " + shortMessage.getData1()); +//logger.log(Level.TRACE, "next: " + shortMessage.getChannel() + "ch, " + shortMessage.getData1()); noteOffEventUsed.set(i); return midiEvent; } diff --git a/src/main/java/vavi/sound/mfi/vavi/MidiContext.java b/src/main/java/vavi/sound/mfi/vavi/MidiContext.java index 225138d..7ebde01 100644 --- a/src/main/java/vavi/sound/mfi/vavi/MidiContext.java +++ b/src/main/java/vavi/sound/mfi/vavi/MidiContext.java @@ -191,11 +191,11 @@ public int setBank(int channel, int bank) { * @param channel real MIDI channel */ public int getProgram(int channel) { -//logger.log(Level.DEBUG, "program[" + channel + "]: " + programs[channel] + " (0x" + StringUtil.toHex2(programs[channel]) + ")"); +//logger.log(Level.TRACE, "program[" + channel + "]: " + programs[channel] + " (0x" + StringUtil.toHex2(programs[channel]) + ")"); return programs[channel]; } - //---- note + // ---- note /** * @param channel pseudo MIDI channel (mfiTrackNumber * 4 + voice) @@ -228,7 +228,7 @@ public int retrievePitch(int channel, int pitch) { return pitch + 45; } - //---- + // ---- /** -32 ~ 31, index is pseudo MIDI channel */ private final int[] pitchBends = new int[MAX_MIDI_CHANNELS]; @@ -273,7 +273,7 @@ public int retrieveRealPitch(int channel) { return pitch; } - //---- + // ---- /** * use with PPQ diff --git a/src/main/java/vavi/sound/mfi/vavi/SubMessage.java b/src/main/java/vavi/sound/mfi/vavi/SubMessage.java index b615022..e25870d 100644 --- a/src/main/java/vavi/sound/mfi/vavi/SubMessage.java +++ b/src/main/java/vavi/sound/mfi/vavi/SubMessage.java @@ -169,7 +169,7 @@ public String toString() { return getSubType() + ": " + getDataLength() + ":\n" + StringUtil.getDump(getData()); } - //---- + // ---- /** */ public void writeTo(OutputStream os) throws IOException { @@ -237,7 +237,7 @@ public static SubMessage readFrom(InputStream is) return subChunk; } - //---- + // ---- /** {@link SubMessage} constructors */ private static final Map> subChunkConstructors = new HashMap<>(); @@ -255,7 +255,7 @@ public static SubMessage readFrom(InputStream is) if (key.matches("mfi\\.(header|audio)\\.\\w+")) { @SuppressWarnings("unchecked") Class clazz = (Class) Class.forName(props.getProperty(key)); -//logger.log(Level.DEBUG, "sub class: " + StringUtil.getClassName(clazz)); +//logger.log(Level.TRACE, "sub class: " + StringUtil.getClassName(clazz)); Constructor constructor = clazz.getConstructor(String.class, byte[].class); subChunkConstructors.put(key, constructor); diff --git a/src/main/java/vavi/sound/mfi/vavi/TrackMessage.java b/src/main/java/vavi/sound/mfi/vavi/TrackMessage.java index ba107d2..bd5cba1 100644 --- a/src/main/java/vavi/sound/mfi/vavi/TrackMessage.java +++ b/src/main/java/vavi/sound/mfi/vavi/TrackMessage.java @@ -136,7 +136,7 @@ public int getDataLength() { public void readFrom(InputStream is) throws InvalidMfiDataException, IOException { -//Debug.dump(is, 512); +//logger.log(Level.TRACE, "\n" + StringUtil.getDump(is, 512)); if (noteLength == -1 || exst == -1) { throw new IllegalStateException("noteLength and exst must be set."); @@ -149,7 +149,7 @@ public void readFrom(InputStream is) dis.readFully(bytes, 0, 4); String string = new String(bytes); if (!TYPE.equals(string)) { -//logger.log(Level.DEBUG, "dump:\n" + StringUtil.getDump(is, 64)); +//logger.log(Level.TRACE, "dump:\n" + StringUtil.getDump(is, 64)); throw new InvalidMfiDataException("invalid track: " + string); } @@ -164,7 +164,7 @@ public void readFrom(InputStream is) track.add(new MfiEvent(message, 0L)); l += message.getLength(); -//logger.log(Level.DEBUG, "track[" + trackNumber + "] event length sum: " + l + " / " + trackLlength); +//logger.log(Level.TRACE, "track[" + trackNumber + "] event length sum: " + l + " / " + trackLlength); } // @@ -224,7 +224,7 @@ public byte[] getMessage() { throw new UnsupportedOperationException("no mean"); } - //---- + // ---- /** note */ private static class NoteMessageFactory { @@ -286,7 +286,7 @@ public static MfiMessage getMessage(int delta, if (props.containsKey(key)) { @SuppressWarnings("unchecked") Class clazz = (Class) Class.forName(props.getProperty(key)); -//logger.log(Level.DEBUG, "note class: " + StringUtil.getClassName(clazz)); +//logger.log(Level.TRACE, "note class: " + StringUtil.getClassName(clazz)); noteMessageConstructor1 = clazz.getConstructor(Integer.TYPE, Integer.TYPE, Integer.TYPE); noteMessageConstructor2 = clazz.getConstructor(Integer.TYPE, Integer.TYPE, Integer.TYPE, Integer.TYPE); } @@ -313,7 +313,7 @@ public static MfiMessage getMessage(int delta, int status, int data1, DataInputStream dis) throws IOException { -//logger.log(Level.DEBUG, "delta: " + StringUtil.toHex2(delta)); +//logger.log(Level.TRACE, "delta: " + StringUtil.toHex2(delta)); String key = String.format("mfi.track.%d.%c.%d", status, 'e', data1); @@ -354,7 +354,7 @@ public static MfiMessage getMessage(int delta, String key = (String) o; if (key.matches("mfi\\.track\\.\\d+\\.e\\.\\d+")) { Class clazz = Class.forName(props.getProperty(key)); -//logger.log(Level.DEBUG, "sysex class: " + StringUtil.getClassName(clazz)); +//logger.log(Level.TRACE, "sysex class: " + StringUtil.getClassName(clazz)); Method method = clazz.getMethod("readFrom", Integer.TYPE, Integer.TYPE, Integer.TYPE, InputStream.class); sysexMessageInstantiators.put(key, method); @@ -421,7 +421,7 @@ public static MfiMessage getMessage(int delta, if (key.matches("mfi\\.track\\.\\d+\\.b\\.\\d+")) { @SuppressWarnings("unchecked") Class shortMessageClass = (Class) Class.forName(props.getProperty(key)); -//logger.log(Level.DEBUG, "short class: " + StringUtil.getClassName(shortMessageClass)); +//logger.log(Level.TRACE, "short class: " + StringUtil.getClassName(shortMessageClass)); Constructor constructor = shortMessageClass.getConstructor(Integer.TYPE, Integer.TYPE, Integer.TYPE, Integer.TYPE); shortMessageConstructors.put(key, constructor); @@ -492,7 +492,7 @@ public static MfiMessage getMessage(int delta, if (key.matches("mfi\\.track\\.\\d+\\.a\\.\\d+")) { @SuppressWarnings("unchecked") Class longMessageClass = (Class) Class.forName(props.getProperty(key)); -//logger.log(Level.DEBUG, "long class: " + StringUtil.getClassName(longMessageClass)); +//logger.log(Level.TRACE, "long class: " + StringUtil.getClassName(longMessageClass)); Constructor constructor = longMessageClass.getConstructor(Integer.TYPE, Integer.TYPE, Integer.TYPE, byte[].class); longMessageConstructors.put(key, constructor); @@ -551,7 +551,7 @@ public static MfiMessage getMessage(int delta, if (props.containsKey(key)) { @SuppressWarnings("unchecked") Class clazz = (Class) Class.forName(props.getProperty(key)); -//logger.log(Level.DEBUG, "unknown class: " + StringUtil.getClassName(clazz)); +//logger.log(Level.TRACE, "unknown class: " + StringUtil.getClassName(clazz)); unknownMessageConstructor1 = clazz.getConstructor(Integer.TYPE, Integer.TYPE, Integer.TYPE, Integer.TYPE); unknownMessageConstructor2 = clazz.getConstructor(Integer.TYPE, Integer.TYPE, Integer.TYPE, byte[].class); } diff --git a/src/main/java/vavi/sound/mfi/vavi/VaviMfiDeviceProvider.java b/src/main/java/vavi/sound/mfi/vavi/VaviMfiDeviceProvider.java index ddb77ba..18d6cf9 100644 --- a/src/main/java/vavi/sound/mfi/vavi/VaviMfiDeviceProvider.java +++ b/src/main/java/vavi/sound/mfi/vavi/VaviMfiDeviceProvider.java @@ -123,7 +123,7 @@ public static MfiDevice getMfiDevice(MfiDevice.Info mfiDeviceInfo) { if (key.startsWith("mfi.device.")) { @SuppressWarnings("unchecked") Class deviceClass = (Class) Class.forName(props.getProperty(key)); -//logger.log(Level.DEBUG, "mfi device class: " + StringUtil.getClassName(deviceClass)); +//logger.log(Level.TRACE, "mfi device class: " + StringUtil.getClassName(deviceClass)); MfiDevice.Info mfiDeviceInfo = deviceClass.getDeclaredConstructor().newInstance().getDeviceInfo(); deviceMap.put(mfiDeviceInfo, deviceClass); diff --git a/src/main/java/vavi/sound/mfi/vavi/VaviMfiFileFormat.java b/src/main/java/vavi/sound/mfi/vavi/VaviMfiFileFormat.java index bd5fb48..3753d80 100644 --- a/src/main/java/vavi/sound/mfi/vavi/VaviMfiFileFormat.java +++ b/src/main/java/vavi/sound/mfi/vavi/VaviMfiFileFormat.java @@ -123,7 +123,7 @@ public void init(Map subChunks) { MfiEvent event = track.get(j); MfiMessage message = event.getMessage(); if (message instanceof SubMessage subChunk) { - //logger.log(Level.DEBUG, infoMessage); + //logger.log(Level.TRACE, infoMessage); subChunks.put(subChunk.getSubType(), subChunk); } } @@ -384,7 +384,7 @@ public void setNoteLength(int noteLength) { /** * @return 0: not protected, 1: protected - * @throws NoSuchElementException + * @throws NoSuchElementException when the sorc chunk is not found * @see SorcMessage */ public int getSorc() { @@ -413,7 +413,7 @@ public void setSorc(int sorc) } /** - * @throws NoSuchElementException + * @throws NoSuchElementException when a title chunk is not found * @see TitlMessage */ public String getTitle() { @@ -440,7 +440,7 @@ public void setTitle(String title) } /** - * @throws NoSuchElementException + * @throws NoSuchElementException when a version chunk is not found * @see VersMessage */ public String getVersion() { diff --git a/src/main/java/vavi/sound/mfi/vavi/VaviMidiConverter.java b/src/main/java/vavi/sound/mfi/vavi/VaviMidiConverter.java index d534838..1520455 100644 --- a/src/main/java/vavi/sound/mfi/vavi/VaviMidiConverter.java +++ b/src/main/java/vavi/sound/mfi/vavi/VaviMidiConverter.java @@ -76,7 +76,7 @@ public boolean isOpen() { public void open() { } - //---- + // ---- /** * Converts midi sequence to mfi sequence. @@ -227,7 +227,7 @@ protected vavi.sound.mfi.Sequence convert(Sequence midiSequence, int fileType) mfiTracks[t].add(mfiEvents[t]); mfiContext.setEofSet(t, true); } else { -//logger.log(Level.DEBUG, "EOF already set[" + t + "]"); +//logger.log(Level.TRACE, "EOF already set[" + t + "]"); } } else { logger.log(Level.DEBUG, "message is null[" + mfiTracks[t].size() + "]: " + midiMessage); @@ -282,7 +282,7 @@ private void addEventToTrack(MfiContext mfiContext, long tick, Track mfiTrack, i mfiTrack.add(mfiEvent); } - //---- + // ---- /** Converts mfi sequence to midi sequence */ @Override @@ -326,7 +326,7 @@ protected Sequence convert(vavi.sound.mfi.Sequence mfiSequence) midiContext.addCurrent(mfiMessage.getDelta()); if (mfiMessage instanceof MidiConvertible) { -//logger.log(Level.DEBUG, "midi convertible: " + message); +//logger.log(Level.TRACE, "midi convertible: " + message); MidiEvent[] midiEvents = ((MidiConvertible) mfiMessage).getMidiEvents(midiContext); if (midiEvents != null) { for (MidiEvent midiEvent : midiEvents) { diff --git a/src/main/java/vavi/sound/mfi/vavi/VaviNoteMessage.java b/src/main/java/vavi/sound/mfi/vavi/VaviNoteMessage.java index 49576e4..d408bdd 100644 --- a/src/main/java/vavi/sound/mfi/vavi/VaviNoteMessage.java +++ b/src/main/java/vavi/sound/mfi/vavi/VaviNoteMessage.java @@ -67,7 +67,7 @@ public MidiEvent[] getMidiEvents(MidiContext context) channel, pitch, velocity); -//logger.log(Level.DEBUG, "note: " + channel + ": " + pitch); +//logger.log(Level.TRACE, "note: " + channel + ": " + pitch); events[0] = new MidiEvent(shortMessage, context.getCurrent()); shortMessage = new ShortMessage(); @@ -94,7 +94,7 @@ public MfiEvent[] getMfiEvents(MidiEvent midiEvent, MfiContext context) int command = shortMessage.getCommand(); int data1 = shortMessage.getData1(); int data2 = shortMessage.getData2(); -//logger.log(Level.DEBUG, midiEvent.getTick() + ", " + channel + ", " + command + ", " + (context.retrievePitch(channel, data1) + 45) + ", " + (data2 / 2)); +//logger.log(Level.TRACE, midiEvent.getTick() + ", " + channel + ", " + command + ", " + (context.retrievePitch(channel, data1) + 45) + ", " + (data2 / 2)); if (command == ShortMessage.NOTE_OFF || // note on with velocity 0 @@ -164,7 +164,7 @@ public MfiEvent[] getMfiEvents(MidiEvent midiEvent, MfiContext context) if (length >= 255) { logger.log(Level.INFO, channel + "ch, " + mfiMessage.getNote() + ", " + mfiMessage.getDelta() + ":[" + i + "]:" + (i == onLength - 1 ? length % 255 : 255) + "/" + length); } -//logger.log(Level.DEBUG, channel + ", " + mfiMessage.getVoice() + ", " + ((mfiMessage.getMessage()[1] & 0xc0) >> 6)); +//logger.log(Level.TRACE, channel + ", " + mfiMessage.getVoice() + ", " + ((mfiMessage.getMessage()[1] & 0xc0) >> 6)); mfiEvents[i] = new MfiEvent(mfiMessage, 0L); // TODO 0l //if (mfiEvents[i] == null) { // logger.log(Level.DEBUG, "[" + i + "]: " + mfiEvents[i]); diff --git a/src/main/java/vavi/sound/mfi/vavi/VaviSequencer.java b/src/main/java/vavi/sound/mfi/vavi/VaviSequencer.java index 3e8a074..7d6204a 100644 --- a/src/main/java/vavi/sound/mfi/vavi/VaviSequencer.java +++ b/src/main/java/vavi/sound/mfi/vavi/VaviSequencer.java @@ -184,7 +184,7 @@ private void off() { logger.log(Level.DEBUG, "★0 off: " + midiSequencer.hashCode()); } - //------------------------------------------------------------------------- + // ---- /** @see vavi.sound.mfi.MetaMessage MetaEvent */ private final MetaSupport metaSupport = new MetaSupport(); diff --git a/src/main/java/vavi/sound/mfi/vavi/header/NoteMessage.java b/src/main/java/vavi/sound/mfi/vavi/header/NoteMessage.java index 3d6a67f..11f7690 100644 --- a/src/main/java/vavi/sound/mfi/vavi/header/NoteMessage.java +++ b/src/main/java/vavi/sound/mfi/vavi/header/NoteMessage.java @@ -44,7 +44,7 @@ public NoteMessage(int data) { /** Length of {@link vavi.sound.mfi.NoteMessage} 1: 4byte */ public int getNoteLength() { byte[] data = getData(); -//logger.log(Level.DEBUG, data[0] * 0xff + data[1]); +//logger.log(Level.TRACE, data[0] * 0xff + data[1]); return data[0] * 0xff + data[1]; } diff --git a/src/main/java/vavi/sound/mfi/vavi/header/TitlMessage.java b/src/main/java/vavi/sound/mfi/vavi/header/TitlMessage.java index a3d1130..08cb9b8 100644 --- a/src/main/java/vavi/sound/mfi/vavi/header/TitlMessage.java +++ b/src/main/java/vavi/sound/mfi/vavi/header/TitlMessage.java @@ -84,7 +84,7 @@ public String toString() { ": \"" + getTitle() + "\""; } - //---- + // ---- /** Meta 0x03 */ @Override diff --git a/src/main/java/vavi/sound/mfi/vavi/mitsubishi/Function131.java b/src/main/java/vavi/sound/mfi/vavi/mitsubishi/Function131.java index b03a4a5..0484ef0 100644 --- a/src/main/java/vavi/sound/mfi/vavi/mitsubishi/Function131.java +++ b/src/main/java/vavi/sound/mfi/vavi/mitsubishi/Function131.java @@ -167,7 +167,7 @@ protected int getSamplingBitsInternal(int format2) { return bits; } - //---- + // ---- /** ADPCM channel */ public void setChannel(int channel) { diff --git a/src/main/java/vavi/sound/mfi/vavi/mitsubishi/MitsubishiSequencer.java b/src/main/java/vavi/sound/mfi/vavi/mitsubishi/MitsubishiSequencer.java index 936ac75..d86d27d 100644 --- a/src/main/java/vavi/sound/mfi/vavi/mitsubishi/MitsubishiSequencer.java +++ b/src/main/java/vavi/sound/mfi/vavi/mitsubishi/MitsubishiSequencer.java @@ -55,7 +55,7 @@ public void sequence(MachineDependentMessage message) } } - //------------------------------------------------------------------------- + // ---- /** */ private static final AudioEngine player = new FuetrekAudioEngine(); @@ -65,7 +65,7 @@ static AudioEngine getAudioEngine() { return player; } - //------------------------------------------------------------------------- + // ---- /** */ private static final MachineDependentFunction.Factory factory = diff --git a/src/main/java/vavi/sound/mfi/vavi/nec/Function1_240_7.java b/src/main/java/vavi/sound/mfi/vavi/nec/Function1_240_7.java index 66b11f3..d275d2c 100755 --- a/src/main/java/vavi/sound/mfi/vavi/nec/Function1_240_7.java +++ b/src/main/java/vavi/sound/mfi/vavi/nec/Function1_240_7.java @@ -84,7 +84,7 @@ public void process(MachineDependentMessage message) /** little endian */ private byte[] adpcm; - //------------------------------------------------------------------------- + // ---- /** ADPCM */ public void setAdpcm(byte[] adpcm) { diff --git a/src/main/java/vavi/sound/mfi/vavi/nec/NecMessage.java b/src/main/java/vavi/sound/mfi/vavi/nec/NecMessage.java index d79de79..bf9c381 100644 --- a/src/main/java/vavi/sound/mfi/vavi/nec/NecMessage.java +++ b/src/main/java/vavi/sound/mfi/vavi/nec/NecMessage.java @@ -310,7 +310,7 @@ public static MfiEvent getPanEvent(int channel, int streamNumber, int pan) throw return new MfiEvent(message, 0L); } - //---- + // ---- /** * Creates adpcm data message. (original pure stereo, TODO cannot play...) @@ -330,7 +330,7 @@ public static List getAdpcmEventsEx(byte[] pcm, float time, int sample byte[] adpcm = audioEngine.encode(4, channels, pcm); logger.log(Level.DEBUG, "adpcm length: " + adpcm.length); -//logger.log(Level.DEBUG, "pcm:\n" + StringUtil.getDump(pcm, 64) + "adpcm L:\n" + StringUtil.getDump(adpcm, 64) +"adpcm R:\n" + StringUtil.getDump(adpcm, adpcm.length / 2, 64)); +//logger.log(Level.TRACE, "pcm:\n" + StringUtil.getDump(pcm, 64) + "adpcm L:\n" + StringUtil.getDump(adpcm, 64) +"adpcm R:\n" + StringUtil.getDump(adpcm, adpcm.length / 2, 64)); int numberOfChunks = adpcm.length / MAX_BLOCK; int moduloOfChunks = adpcm.length % MAX_BLOCK; diff --git a/src/main/java/vavi/sound/mfi/vavi/nec/NecSequencer.java b/src/main/java/vavi/sound/mfi/vavi/nec/NecSequencer.java index 0cccfc5..34e61a4 100644 --- a/src/main/java/vavi/sound/mfi/vavi/nec/NecSequencer.java +++ b/src/main/java/vavi/sound/mfi/vavi/nec/NecSequencer.java @@ -80,7 +80,7 @@ public void sequence(MachineDependentMessage message) } } - //------------------------------------------------------------------------- + // ---- /** */ private static final AudioEngine player = new YamahaAudioEngine(); @@ -90,7 +90,7 @@ static AudioEngine getAudioEngine() { return player; } - //------------------------------------------------------------------------- + // ---- /** */ private static final MachineDependentFunction.Factory factory = diff --git a/src/main/java/vavi/sound/mfi/vavi/sharp/Function131.java b/src/main/java/vavi/sound/mfi/vavi/sharp/Function131.java index e15d905..4edd99b 100644 --- a/src/main/java/vavi/sound/mfi/vavi/sharp/Function131.java +++ b/src/main/java/vavi/sound/mfi/vavi/sharp/Function131.java @@ -162,7 +162,7 @@ protected int getSamplingBitsInternal(int format2) { return bits; } - //------------------------------------------------------------------------- + // ---- /** ADPCM channel */ public void setChannel(int channel) { diff --git a/src/main/java/vavi/sound/mfi/vavi/sharp/SharpSequencer.java b/src/main/java/vavi/sound/mfi/vavi/sharp/SharpSequencer.java index e46d42c..fbaf1eb 100644 --- a/src/main/java/vavi/sound/mfi/vavi/sharp/SharpSequencer.java +++ b/src/main/java/vavi/sound/mfi/vavi/sharp/SharpSequencer.java @@ -53,7 +53,7 @@ public void sequence(MachineDependentMessage message) } } - //------------------------------------------------------------------------- + // ---- /** */ private static final AudioEngine player = new FuetrekAudioEngine(); @@ -63,7 +63,7 @@ static AudioEngine getAudioEngine() { return player; } - //------------------------------------------------------------------------- + // ---- /** */ private static final MachineDependentFunction.Factory factory = diff --git a/src/main/java/vavi/sound/mfi/vavi/track/AudioChannelPanpotMessage.java b/src/main/java/vavi/sound/mfi/vavi/track/AudioChannelPanpotMessage.java index 091c940..319659c 100644 --- a/src/main/java/vavi/sound/mfi/vavi/track/AudioChannelPanpotMessage.java +++ b/src/main/java/vavi/sound/mfi/vavi/track/AudioChannelPanpotMessage.java @@ -87,7 +87,7 @@ public String toString() { " panpot=" + panpot; } - //---- + // ---- @Override public MidiEvent[] getMidiEvents(MidiContext context) diff --git a/src/main/java/vavi/sound/mfi/vavi/track/AudioChannelVolumeMessage.java b/src/main/java/vavi/sound/mfi/vavi/track/AudioChannelVolumeMessage.java index b145197..9cbeadd 100644 --- a/src/main/java/vavi/sound/mfi/vavi/track/AudioChannelVolumeMessage.java +++ b/src/main/java/vavi/sound/mfi/vavi/track/AudioChannelVolumeMessage.java @@ -85,7 +85,7 @@ public String toString() { " volume=" + volume; } - //---- + // ---- @Override public MidiEvent[] getMidiEvents(MidiContext context) diff --git a/src/main/java/vavi/sound/mfi/vavi/track/AudioPlayMessage.java b/src/main/java/vavi/sound/mfi/vavi/track/AudioPlayMessage.java index da00e71..a1be9cd 100644 --- a/src/main/java/vavi/sound/mfi/vavi/track/AudioPlayMessage.java +++ b/src/main/java/vavi/sound/mfi/vavi/track/AudioPlayMessage.java @@ -87,7 +87,7 @@ public String toString() { " velocity=" + velocity; } - //---- + // ---- /** * @throws InvalidMidiDataException diff --git a/src/main/java/vavi/sound/mfi/vavi/track/AudioStopMessage.java b/src/main/java/vavi/sound/mfi/vavi/track/AudioStopMessage.java index 0c1f6f4..c3ec332 100644 --- a/src/main/java/vavi/sound/mfi/vavi/track/AudioStopMessage.java +++ b/src/main/java/vavi/sound/mfi/vavi/track/AudioStopMessage.java @@ -78,7 +78,7 @@ public String toString() { " index=" + index; } - //---- + // ---- /** * @throws InvalidMidiDataException diff --git a/src/main/java/vavi/sound/mfi/vavi/track/ChangeBankMessage.java b/src/main/java/vavi/sound/mfi/vavi/track/ChangeBankMessage.java index 1968bce..288a95c 100644 --- a/src/main/java/vavi/sound/mfi/vavi/track/ChangeBankMessage.java +++ b/src/main/java/vavi/sound/mfi/vavi/track/ChangeBankMessage.java @@ -90,16 +90,16 @@ public String toString() { " bank=" + bank; } - //---- + // ---- @Override public MidiEvent[] getMidiEvents(MidiContext context) throws InvalidMidiDataException { int channel = getVoice() + 4 * context.getMfiTrackNumber(); -//logger.log(Level.DEBUG, "track: "+context.getTrackNumber()+", voice: "+getVoice()); +//logger.log(Level.TRACE, "track: "+context.getTrackNumber()+", voice: "+getVoice()); -//logger.log(Level.DEBUG, "bank[" + channel + "]: " + getBank()); +//logger.log(Level.TRACE, "bank[" + channel + "]: " + getBank()); channel = context.setBank(channel, getBank()); return null; diff --git a/src/main/java/vavi/sound/mfi/vavi/track/ChangeVoiceMessage.java b/src/main/java/vavi/sound/mfi/vavi/track/ChangeVoiceMessage.java index 05f41c3..2ebeed0 100644 --- a/src/main/java/vavi/sound/mfi/vavi/track/ChangeVoiceMessage.java +++ b/src/main/java/vavi/sound/mfi/vavi/track/ChangeVoiceMessage.java @@ -95,7 +95,7 @@ public String toString() { " program=" + program; } - //---- + // ---- @Override public MidiEvent[] getMidiEvents(MidiContext context) @@ -103,7 +103,7 @@ public MidiEvent[] getMidiEvents(MidiContext context) int channel = getVoice() + 4 * context.getMfiTrackNumber(); -//logger.log(Level.DEBUG, "program[" + channel + "]: " + StringUtil.toHex2(getProgram())); +//logger.log(Level.TRACE, "program[" + channel + "]: " + StringUtil.toHex2(getProgram())); channel = context.setProgram(channel, getProgram()); ShortMessage shortMessage = new ShortMessage(); @@ -137,7 +137,7 @@ public MfiEvent[] getMfiEvents(MidiEvent midiEvent, MfiContext context) changeBankMessage.setBank(((data1 & 0xc0) >> 6) + 2); // TODO 2 ??? context.setPreviousTick(track, midiEvent.getTick()); -//logger.log(Level.DEBUG, channel + ": " + StringUtil.toHex2(data1) + ", " + StringUtil.toHex2(changeVoiceMessage.getProgram()) + ", " + changeBankMessage.getBank()); +//logger.log(Level.TRACE, channel + ": " + StringUtil.toHex2(data1) + ", " + StringUtil.toHex2(changeVoiceMessage.getProgram()) + ", " + changeBankMessage.getBank()); return new MfiEvent[] { new MfiEvent(changeBankMessage, midiEvent.getTick()), diff --git a/src/main/java/vavi/sound/mfi/vavi/track/ChannelChangeMessage.java b/src/main/java/vavi/sound/mfi/vavi/track/ChannelChangeMessage.java index c694167..fd13bdf 100644 --- a/src/main/java/vavi/sound/mfi/vavi/track/ChannelChangeMessage.java +++ b/src/main/java/vavi/sound/mfi/vavi/track/ChannelChangeMessage.java @@ -85,7 +85,7 @@ public String toString() { " channel=" + channel; } - //---- + // ---- @Override public MidiEvent[] getMidiEvents(MidiContext context) { diff --git a/src/main/java/vavi/sound/mfi/vavi/track/ChannelConfigurationMessage.java b/src/main/java/vavi/sound/mfi/vavi/track/ChannelConfigurationMessage.java index 97fb526..1973823 100644 --- a/src/main/java/vavi/sound/mfi/vavi/track/ChannelConfigurationMessage.java +++ b/src/main/java/vavi/sound/mfi/vavi/track/ChannelConfigurationMessage.java @@ -73,7 +73,7 @@ public String toString() { " drum=" + drum; } - //---- + // ---- /** * Sets the context channel configuration. diff --git a/src/main/java/vavi/sound/mfi/vavi/track/CuePointMessage.java b/src/main/java/vavi/sound/mfi/vavi/track/CuePointMessage.java index 5d58ea0..0370f84 100644 --- a/src/main/java/vavi/sound/mfi/vavi/track/CuePointMessage.java +++ b/src/main/java/vavi/sound/mfi/vavi/track/CuePointMessage.java @@ -67,7 +67,7 @@ public String toString() { return "CuePoint:" + " start=" + start; } - //---- + // ---- /** * TODO {@link javax.sound.midi.MetaMessage} has 0x07 cue point @@ -92,7 +92,7 @@ public MidiEvent[] getMidiEvents(MidiContext context) throws InvalidMidiDataExce // new MidiEvent(sysexMessage, context.getCurrent()) // }; // } else { -//logger.log(Level.DEBUG, "ignore: " + this); +//logger.log(Level.TRACE, "ignore: " + this); // return null; // } MetaMessage metaMessage = new MetaMessage(); diff --git a/src/main/java/vavi/sound/mfi/vavi/track/EndOfTrackMessage.java b/src/main/java/vavi/sound/mfi/vavi/track/EndOfTrackMessage.java index 0a2f963..cd2aab0 100644 --- a/src/main/java/vavi/sound/mfi/vavi/track/EndOfTrackMessage.java +++ b/src/main/java/vavi/sound/mfi/vavi/track/EndOfTrackMessage.java @@ -62,7 +62,7 @@ public String toString() { return "EndOfTrack:"; } - //---- + // ---- @Override public MidiEvent[] getMidiEvents(MidiContext context) { @@ -75,7 +75,7 @@ public MidiEvent[] getMidiEvents(MidiContext context) { // new MidiEvent(metaMessage, context.getCurrent()) // }; -//logger.log(Level.DEBUG, "ignore: " + this); +//logger.log(Level.TRACE, "ignore: " + this); return null; } diff --git a/src/main/java/vavi/sound/mfi/vavi/track/ExpressionMessage.java b/src/main/java/vavi/sound/mfi/vavi/track/ExpressionMessage.java index 03b221e..4a52258 100644 --- a/src/main/java/vavi/sound/mfi/vavi/track/ExpressionMessage.java +++ b/src/main/java/vavi/sound/mfi/vavi/track/ExpressionMessage.java @@ -100,7 +100,7 @@ public String toString() { " volume=" + volume; } - //---- + // ---- /** TODO i considered it an expression, but is that okay? */ @Override @@ -109,7 +109,7 @@ public MidiEvent[] getMidiEvents(MidiContext context) int channel = getVoice() + 4 * context.getMfiTrackNumber(); -//logger.log(Level.DEBUG, "volume rel: " + channel + ": " + getVolume()); +//logger.log(Level.TRACE, "volume rel: " + channel + ": " + getVolume()); // context.addVolume(channel, getVolume()); // MidiEvent[] events = new MidiEvent[2]; diff --git a/src/main/java/vavi/sound/mfi/vavi/track/LoopPointMessage.java b/src/main/java/vavi/sound/mfi/vavi/track/LoopPointMessage.java index f6309e2..ce7be44 100644 --- a/src/main/java/vavi/sound/mfi/vavi/track/LoopPointMessage.java +++ b/src/main/java/vavi/sound/mfi/vavi/track/LoopPointMessage.java @@ -89,7 +89,7 @@ public String toString() { " start=" + start; } - //---- + // ---- @Override public MidiEvent[] getMidiEvents(MidiContext context) { diff --git a/src/main/java/vavi/sound/mfi/vavi/track/MachineDependentMessage.java b/src/main/java/vavi/sound/mfi/vavi/track/MachineDependentMessage.java index b9be66b..e304b7b 100644 --- a/src/main/java/vavi/sound/mfi/vavi/track/MachineDependentMessage.java +++ b/src/main/java/vavi/sound/mfi/vavi/track/MachineDependentMessage.java @@ -64,18 +64,18 @@ public void setMessage(int delta, byte[] message) throws InvalidMfiDataException { byte[] tmp = new byte[5 + message.length]; -//logger.log(Level.DEBUG, "data: " + message.length); +//logger.log(Level.TRACE, "data: " + message.length); tmp[0] = (byte) (delta & 0xff); tmp[1] = (byte) 0xff; tmp[2] = (byte) 0xff; tmp[3] = (byte) ((message.length / 0x100) & 0xff); tmp[4] = (byte) ((message.length % 0x100) & 0xff); -//Debug.dump(new ByteArrayInputStream(tmp, 0, 5)); +//logger.log(Level.TRACE, "\n" + StringUtil.getDump(new ByteArrayInputStream(tmp, 0, 5)); System.arraycopy(message, 0, tmp, 5, message.length); -//logger.log(Level.DEBUG, "message: " + tmp.length); +//logger.log(Level.TRACE, "message: " + tmp.length); super.setMessage(tmp, tmp.length); -//Debug.dump(new ByteArrayInputStream(this.data, 0, 10)); +//logger.log(Level.TRACE, "\n" + StringUtil.getDump(new ByteArrayInputStream(this.data, 0, 10)); } /** @@ -86,11 +86,11 @@ public static MachineDependentMessage readFrom(int delta, int status, int data1, throws InvalidMfiDataException, IOException { -//Debug.dump(is); +//logger.log(Level.TRACE, "\n" + StringUtil.getDump(is); DataInputStream dis = new DataInputStream(is); int length = dis.readUnsignedShort(); -//logger.log(Level.DEBUG, "length: " + length); +//logger.log(Level.TRACE, "length: " + length); byte[] data = new byte[length + 5]; @@ -126,7 +126,7 @@ public String toString() { return String.format("MachineDepend: vendor: %02x", data[5]); } - //---- + // ---- /** *

diff --git a/src/main/java/vavi/sound/mfi/vavi/track/MasterVolumeMessage.java b/src/main/java/vavi/sound/mfi/vavi/track/MasterVolumeMessage.java index 989ed42..bc6c5fd 100644 --- a/src/main/java/vavi/sound/mfi/vavi/track/MasterVolumeMessage.java +++ b/src/main/java/vavi/sound/mfi/vavi/track/MasterVolumeMessage.java @@ -56,7 +56,7 @@ public String toString() { " volume=" + volume; } - //---- + // ---- @Override public MidiEvent[] getMidiEvents(MidiContext context) diff --git a/src/main/java/vavi/sound/mfi/vavi/track/MfiConvertibleMessage.java b/src/main/java/vavi/sound/mfi/vavi/track/MfiConvertibleMessage.java index e72b8c8..cf0ba1b 100644 --- a/src/main/java/vavi/sound/mfi/vavi/track/MfiConvertibleMessage.java +++ b/src/main/java/vavi/sound/mfi/vavi/track/MfiConvertibleMessage.java @@ -90,13 +90,13 @@ public MfiEvent[] getMfiEvents(MidiEvent midiEvent, MfiContext context) // case RPN_PITCH_BEND_SENSITIVITY: // MfiConvertible converter = new vavi.sound.mfi.vavi.channel.PitchBendRangeMessage(); // return converter.getMfiEvents(midiEvent, context); -//logger.log(Level.DEBUG, "rpn: MSB:" + rpnMSB[channel] + ", LSB:" + rpnLSB[channel]); +//logger.log(Level.TRACE, "rpn: MSB:" + rpnMSB[channel] + ", LSB:" + rpnLSB[channel]); // default: -//logger.log(Level.DEBUG, "data entry: no handler for rpn: " + rpn[channel]); +//logger.log(Level.TRACE, "data entry: no handler for rpn: " + rpn[channel]); // break; // } default: -//logger.log(Level.DEBUG, "not implemented: " + data1); +//logger.log(Level.TRACE, "not implemented: " + data1); break; } diff --git a/src/main/java/vavi/sound/mfi/vavi/track/ModulationDepthMessage.java b/src/main/java/vavi/sound/mfi/vavi/track/ModulationDepthMessage.java index 3f79dc6..c995fb6 100644 --- a/src/main/java/vavi/sound/mfi/vavi/track/ModulationDepthMessage.java +++ b/src/main/java/vavi/sound/mfi/vavi/track/ModulationDepthMessage.java @@ -96,7 +96,7 @@ public String toString() { " modulationDepth=" + modulationDepth; } - //---- + // ---- @Override public MidiEvent[] getMidiEvents(MidiContext context) diff --git a/src/main/java/vavi/sound/mfi/vavi/track/Nop2Message.java b/src/main/java/vavi/sound/mfi/vavi/track/Nop2Message.java index 1dffa27..f0e4564 100644 --- a/src/main/java/vavi/sound/mfi/vavi/track/Nop2Message.java +++ b/src/main/java/vavi/sound/mfi/vavi/track/Nop2Message.java @@ -67,11 +67,11 @@ public String toString() { return "Nop2:" + (data[3] & 0xff); } - //---- + // ---- @Override public MidiEvent[] getMidiEvents(MidiContext context) { -//logger.log(Level.DEBUG, "ignore: " + this); +//logger.log(Level.TRACE, "ignore: " + this); return null; } } diff --git a/src/main/java/vavi/sound/mfi/vavi/track/NopMessage.java b/src/main/java/vavi/sound/mfi/vavi/track/NopMessage.java index 52db685..f521a77 100644 --- a/src/main/java/vavi/sound/mfi/vavi/track/NopMessage.java +++ b/src/main/java/vavi/sound/mfi/vavi/track/NopMessage.java @@ -36,7 +36,7 @@ public class NopMessage extends ShortMessage */ public NopMessage(int delta, int data2) { super(delta, 0xff, 0xde, data2); -//logger.log(Level.DEBUG, "NOP: delta: " + delta); +//logger.log(Level.TRACE, "NOP: delta: " + delta); } /** @@ -48,7 +48,7 @@ public NopMessage(int delta, int data2) { */ public NopMessage(int delta, int status, int data1, int data2) { super(delta, 0xff, 0xde, data2); -//logger.log(Level.DEBUG, "NOP: delta: " + delta); +//logger.log(Level.TRACE, "NOP: delta: " + delta); } /** */ @@ -56,11 +56,11 @@ public String toString() { return "Nop: delta=" + (data[3] & 0xff); } - //---- + // ---- @Override public MidiEvent[] getMidiEvents(MidiContext context) { -//logger.log(Level.DEBUG, "ignore: " + this); +//logger.log(Level.TRACE, "ignore: " + this); return null; } } diff --git a/src/main/java/vavi/sound/mfi/vavi/track/PanpotMessage.java b/src/main/java/vavi/sound/mfi/vavi/track/PanpotMessage.java index 2565ff7..1ea73b1 100644 --- a/src/main/java/vavi/sound/mfi/vavi/track/PanpotMessage.java +++ b/src/main/java/vavi/sound/mfi/vavi/track/PanpotMessage.java @@ -97,7 +97,7 @@ public String toString() { " panpot=" + panpot; } - //---- + // ---- @Override public MidiEvent[] getMidiEvents(MidiContext context) diff --git a/src/main/java/vavi/sound/mfi/vavi/track/PitchBendMessage.java b/src/main/java/vavi/sound/mfi/vavi/track/PitchBendMessage.java index 2070c8c..bd78eb0 100644 --- a/src/main/java/vavi/sound/mfi/vavi/track/PitchBendMessage.java +++ b/src/main/java/vavi/sound/mfi/vavi/track/PitchBendMessage.java @@ -102,7 +102,7 @@ public MidiEvent[] getMidiEvents(MidiContext context) throws InvalidMidiDataException { int channel = getVoice() + 4 * context.getMfiTrackNumber(); -//logger.log(Level.DEBUG, this); +//logger.log(Level.TRACE, this); // context.setPitchBend(channel, getPitchBend()); // int pitch = context.retrieveRealPitch(channel); diff --git a/src/main/java/vavi/sound/mfi/vavi/track/PitchBendRangeMessage.java b/src/main/java/vavi/sound/mfi/vavi/track/PitchBendRangeMessage.java index 92e41e9..a125273 100644 --- a/src/main/java/vavi/sound/mfi/vavi/track/PitchBendRangeMessage.java +++ b/src/main/java/vavi/sound/mfi/vavi/track/PitchBendRangeMessage.java @@ -96,14 +96,14 @@ public String toString() { " pitchBendRange=" + pitchBendRange; } - //---- + // ---- @Override public MidiEvent[] getMidiEvents(MidiContext context) throws InvalidMidiDataException { int channel = getVoice() + 4 * context.getMfiTrackNumber(); -//logger.log(Level.DEBUG, this); +//logger.log(Level.TRACE, this); // context.setPitchBendRange(channel, getPitchBendRange()); MidiEvent[] events = new MidiEvent[3]; diff --git a/src/main/java/vavi/sound/mfi/vavi/track/TempoMessage.java b/src/main/java/vavi/sound/mfi/vavi/track/TempoMessage.java index 37196b0..ca52e21 100644 --- a/src/main/java/vavi/sound/mfi/vavi/track/TempoMessage.java +++ b/src/main/java/vavi/sound/mfi/vavi/track/TempoMessage.java @@ -114,7 +114,7 @@ public String toString() { " tempo=" + tempo; } - //---- + // ---- @Override public MidiEvent[] getMidiEvents(MidiContext context) @@ -124,8 +124,8 @@ public MidiEvent[] getMidiEvents(MidiContext context) int timeBase = getTimeBase(); // quarter note length in μsec TODO is round OK?, TODO 48??? (actually 60 * 10^6 / tempo) int l = (int) Math.round(60d * 1000000d / ((48d / timeBase) * tempo)); -//logger.log(Level.DEBUG, this); -//logger.log(Level.DEBUG, l + " = " + +//logger.log(Level.TRACE, this); +//logger.log(Level.TRACE, l + " = " + // StringUtil.toHex2( ((l / 0x10000) & 0xff)) + ", " + // StringUtil.toHex2((((l % 0x10000) / 0x100) & 0xff)) + ", " + // StringUtil.toHex2( ((l % 0x100) & 0xff))); @@ -148,23 +148,23 @@ public MfiEvent[] getMfiEvents(MidiEvent midiEvent, MfiContext context) MetaMessage metaMessage = (MetaMessage) midiEvent.getMessage(); // int type = metaMessage.getType(); byte[] data = metaMessage.getData(); -//logger.log(Level.DEBUG, "data.length: " + data.length); +//logger.log(Level.TRACE, "data.length: " + data.length); int timeBase = getNearestTimeBase(context.getTimeBase()); int l = ((data[0] & 0xff) << 16) | ((data[1] & 0xff) << 8) | (data[2] & 0xff); -//logger.log(Level.DEBUG, "(CALC) timeBase: " + timeBase + ", tempo: " + tempo + ", l; " + l); +//logger.log(Level.TRACE, "(CALC) timeBase: " + timeBase + ", tempo: " + tempo + ", l; " + l); // TODO no more change if scale is changed once? if (context.isScaleChanged()) { timeBase = getNearestTimeBase((int) (context.getTimeBase() / context.getScale())); tempo = (int) Math.round(60d * 1000000d / ((48d / timeBase) * l)); -//logger.log(Level.DEBUG, "(SET) tempo > " + MAX_SCALELESS + ": timeBase: " + timeBase + ", tempo: " + tempo); +//logger.log(Level.TRACE, "(SET) tempo > " + MAX_SCALELESS + ": timeBase: " + timeBase + ", tempo: " + tempo); } else { timeBase = getNearestTimeBase(context.getTimeBase()); tempo = (int) Math.round(60d * 1000000d / ((48d / timeBase) * l)); -//logger.log(Level.DEBUG, "(SET) timeBase: " + timeBase + ", tempo: " + tempo); +//logger.log(Level.TRACE, "(SET) timeBase: " + timeBase + ", tempo: " + tempo); } TempoMessage mfiMessage = new TempoMessage(); @@ -209,7 +209,7 @@ public static int getNearestTimeBase(int timeBase) { //for (int i = 0; i < table.size(); i++) { // logger.log(Level.DEBUG, "(" + i + ") timeBaseTable[" + table.get(i).index + "], " + table.get(i).value); //} -//logger.log(Level.DEBUG, "(CHANGE) " + timeBase + " -> " + timeBaseTable[table.get(0).index]); +//logger.log(Level.TRACE, "(CHANGE) " + timeBase + " -> " + timeBaseTable[table.get(0).index]); return timeBaseTable[table.get(0).index]; } } diff --git a/src/main/java/vavi/sound/mfi/vavi/track/UndefinedMessage.java b/src/main/java/vavi/sound/mfi/vavi/track/UndefinedMessage.java index b42ced0..2cac990 100644 --- a/src/main/java/vavi/sound/mfi/vavi/track/UndefinedMessage.java +++ b/src/main/java/vavi/sound/mfi/vavi/track/UndefinedMessage.java @@ -62,7 +62,7 @@ public String toString() { return String.format("Undefined: %02x, %02x, %02x\n%s", data[0], data[1], data[2], StringUtil.getDump(data, 3, length - 3)); } - //---- + // ---- @Override public MidiEvent[] getMidiEvents(MidiContext context) { diff --git a/src/main/java/vavi/sound/mfi/vavi/track/VolumeMessage.java b/src/main/java/vavi/sound/mfi/vavi/track/VolumeMessage.java index ba0422c..d9229c1 100644 --- a/src/main/java/vavi/sound/mfi/vavi/track/VolumeMessage.java +++ b/src/main/java/vavi/sound/mfi/vavi/track/VolumeMessage.java @@ -94,7 +94,7 @@ public String toString() { " volume=" + volume; } - //---- + // ---- @Override public MidiEvent[] getMidiEvents(MidiContext context) @@ -102,7 +102,7 @@ public MidiEvent[] getMidiEvents(MidiContext context) int channel = getVoice() + 4 * context.getMfiTrackNumber(); -//logger.log(Level.DEBUG, "volume: " + channel + ": " + getVolume()); +//logger.log(Level.TRACE, "volume: " + channel + ": " + getVolume()); context.setVolume(channel, volume); MidiEvent[] events = new MidiEvent[1]; @@ -136,7 +136,7 @@ public MfiEvent[] getMfiEvents(MidiEvent midiEvent, MfiContext context) mfiMessage.setDelta(context.getDelta(context.retrieveMfiTrack(channel))); mfiMessage.setVoice(voice); mfiMessage.setVolume(data2 / 2); -//logger.log(Level.DEBUG, mfiMessage.getVoice() + ", " + ((mfiMessage.getMessage()[3] & 0xc0) >> 6)); +//logger.log(Level.TRACE, mfiMessage.getVoice() + ", " + ((mfiMessage.getMessage()[3] & 0xc0) >> 6)); context.setPreviousTick(track, midiEvent.getTick()); diff --git a/src/main/java/vavi/sound/midi/BasicMidiFileReader.java b/src/main/java/vavi/sound/midi/BasicMidiFileReader.java index 6325a41..d46fc28 100644 --- a/src/main/java/vavi/sound/midi/BasicMidiFileReader.java +++ b/src/main/java/vavi/sound/midi/BasicMidiFileReader.java @@ -46,12 +46,12 @@ public MidiFileFormat getMidiFileFormat(InputStream stream) throws InvalidMidiDataException, IOException { -//logger.log(Level.DEBUG, "here ★"); +//logger.log(Level.TRACE, "here ★"); Sequence midiSequence = getSequence(stream); ByteArrayOutputStream os = new ByteArrayOutputStream(); MidiSystem.write(midiSequence, 0, os); ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray()); -//logger.log(Level.DEBUG, "temporary midi:\n" + StringUtil.getDump(os.toByteArray(), 128)); +//logger.log(Level.TRACE, "temporary midi:\n" + StringUtil.getDump(os.toByteArray(), 128)); MidiFileFormat midiFF = MidiSystem.getMidiFileFormat(is); return midiFF; } diff --git a/src/main/java/vavi/sound/midi/MidiConstants.java b/src/main/java/vavi/sound/midi/MidiConstants.java index 3aef812..58d0f0d 100644 --- a/src/main/java/vavi/sound/midi/MidiConstants.java +++ b/src/main/java/vavi/sound/midi/MidiConstants.java @@ -37,7 +37,7 @@ public static String getInstrumentName(int index) { return props.getProperty("midi.inst.gm." + index); } - //------------------------------------------------------------------------- + // ---- // Meta Event // @@ -255,7 +255,7 @@ public String toString() { } } - //---- + // ---- /** * 01H ~ 1FH @@ -300,7 +300,7 @@ public String toString() { // it is used when exchanging data across manufacturers and models, and in 7FH it is used for data transfer // related to real time. - //---- + // ---- /* */ static { diff --git a/src/main/java/vavi/sound/midi/MidiUtil.java b/src/main/java/vavi/sound/midi/MidiUtil.java index 5518522..e74df13 100644 --- a/src/main/java/vavi/sound/midi/MidiUtil.java +++ b/src/main/java/vavi/sound/midi/MidiUtil.java @@ -25,8 +25,6 @@ import javax.sound.midi.SysexMessage; import javax.sound.midi.spi.MidiDeviceProvider; -import vavi.util.Debug; - import static java.lang.System.getLogger; @@ -145,19 +143,19 @@ public static void writeVarInt(DataOutput output, int value) throws IOException // // It's easier to just enumerate them than to make a loop. // - if ((value & 0xF0000000) != 0) { - output.write(0x80 | ((value >> 28) & 0x7F)); + if ((value & 0xf000_0000) != 0) { + output.write(0x80 | ((value >> 28) & 0x7f)); } - if ((value & 0xFFE00000) != 0) { - output.write(0x80 | ((value >> 21) & 0x7F)); + if ((value & 0xffe0_0000) != 0) { + output.write(0x80 | ((value >> 21) & 0x7f)); } - if ((value & 0xFFFFC000) != 0) { - output.write(0x80 | ((value >> 14) & 0x7F)); + if ((value & 0xffff_c000) != 0) { + output.write(0x80 | ((value >> 14) & 0x7f)); } - if ((value & 0xFFFFFF80) != 0) { - output.write(0x80 | ((value >> 7) & 0x7F)); + if ((value & 0xffff_ff80) != 0) { + output.write(0x80 | ((value >> 7) & 0x7f)); } - output.write(value & 0x7F); + output.write(value & 0x7f); } /** */ @@ -177,7 +175,7 @@ public static String getDecodedMessage(byte[] data, String encoding) { // 01 0x03 ? // 02 length try { -//logger.log(Level.DEBUG, "META: " + data[1] + ", " + data[2] + ", " + StringUtil.getDump(data, start, length)); +//logger.log(Level.TRACE, "META: " + data[1] + ", " + data[2] + ", " + StringUtil.getDump(data, start, length)); start = 3; length -= 3; return new String(data, start, length, encoding); @@ -372,7 +370,7 @@ public static Sequencer getDefaultSequencer(Class static { try { providers = ServiceLoader.load(javax.sound.midi.spi.MidiDeviceProvider.class); -if (Debug.isLoggable(java.util.logging.Level.FINE)) { +if (logger.isLoggable(Level.TRACE)) { providers.forEach(provider -> System.err.println(provider.getClass())); } } catch (Throwable t) { diff --git a/src/main/java/vavi/sound/midi/mfi/MfiMidiFileReader.java b/src/main/java/vavi/sound/midi/mfi/MfiMidiFileReader.java index 77c2aac..6e5ef7b 100644 --- a/src/main/java/vavi/sound/midi/mfi/MfiMidiFileReader.java +++ b/src/main/java/vavi/sound/midi/mfi/MfiMidiFileReader.java @@ -60,7 +60,7 @@ public Sequence getSequence(InputStream is) } vavi.sound.mfi.Sequence mfiSequence = MfiSystem.getSequence(is); -//logger.log(Level.DEBUG, mfiSequence); +//logger.log(Level.TRACE, mfiSequence); return MfiSystem.toMidiSequence(mfiSequence); } catch (InvalidMfiDataException e) { logger.log(Level.ERROR, e.getMessage(), e); diff --git a/src/main/java/vavi/sound/midi/mfi/MfiMidiFileWriter.java b/src/main/java/vavi/sound/midi/mfi/MfiMidiFileWriter.java index b9b92f2..44be1b2 100644 --- a/src/main/java/vavi/sound/midi/mfi/MfiMidiFileWriter.java +++ b/src/main/java/vavi/sound/midi/mfi/MfiMidiFileWriter.java @@ -60,7 +60,7 @@ public boolean isFileTypeSupported(int fileType) { @Override public boolean isFileTypeSupported(int fileType, Sequence sequence) { logger.log(Level.DEBUG, "(2): fileType: " + fileType); -//logger.log(Level.DEBUG, sequence); +//logger.log(Level.TRACE, sequence); return MfiSystem.isFileTypeSupported(fileType); } diff --git a/src/main/java/vavi/sound/midi/smaf/SmafMidiFileReader.java b/src/main/java/vavi/sound/midi/smaf/SmafMidiFileReader.java index 78385a2..234143d 100644 --- a/src/main/java/vavi/sound/midi/smaf/SmafMidiFileReader.java +++ b/src/main/java/vavi/sound/midi/smaf/SmafMidiFileReader.java @@ -59,7 +59,7 @@ public Sequence getSequence(InputStream is) } vavi.sound.smaf.Sequence sequence = SmafSystem.getSequence(is); -//logger.log(Level.DEBUG, sequence); +//logger.log(Level.TRACE, sequence); return SmafSystem.toMidiSequence(sequence); } catch (InvalidSmafDataException e) { logger.log(Level.INFO, e); diff --git a/src/main/java/vavi/sound/mobile/BasicAudioEngine.java b/src/main/java/vavi/sound/mobile/BasicAudioEngine.java index a207567..bd7bab9 100644 --- a/src/main/java/vavi/sound/mobile/BasicAudioEngine.java +++ b/src/main/java/vavi/sound/mobile/BasicAudioEngine.java @@ -100,10 +100,10 @@ public void start(int streamNumber) { try { -//logger.log(Level.DEBUG, data.length); +//logger.log(Level.TRACE, data.length); InputStream[] iss = getInputStreams(streamNumber, channels); -//logger.log(Level.DEBUG, "is: " + is.available()); +//logger.log(Level.TRACE, "is: " + is.available()); //OutputStream os = debug2(); DataLine.Info info = new DataLine.Info(SourceDataLine.class, audioFormat); @@ -121,7 +121,7 @@ public void start(int streamNumber) { } else { int lL = iss[0].read(buf, 0, 512); int lR = iss[1].read(buf, 512, 512); -//logger.log(Level.DEBUG, "l : " + lL + ", r: " + lR); +//logger.log(Level.TRACE, "l : " + lL + ", r: " + lR); for (int i = 0; i < lL / 2; i++) { byte[] temp = new byte[4]; temp[0] = buf[i * 2]; @@ -141,7 +141,7 @@ public void start(int streamNumber) { } } - //------------------------------------------------------------------------- + // ---- /** */ protected abstract OutputStream getOutputStream(OutputStream os); diff --git a/src/main/java/vavi/sound/mobile/FuetrekAudioEngine.java b/src/main/java/vavi/sound/mobile/FuetrekAudioEngine.java index a41aaa3..a7f16e8 100644 --- a/src/main/java/vavi/sound/mobile/FuetrekAudioEngine.java +++ b/src/main/java/vavi/sound/mobile/FuetrekAudioEngine.java @@ -104,7 +104,7 @@ protected InputStream[] getInputStreams(int streamNumber, int channels) { return iss; } - //------------------------------------------------------------------------- + // ---- @Override protected OutputStream getOutputStream(OutputStream os) { diff --git a/src/main/java/vavi/sound/mobile/PcmAudioEngine.java b/src/main/java/vavi/sound/mobile/PcmAudioEngine.java index 72f553d..c9fa510 100644 --- a/src/main/java/vavi/sound/mobile/PcmAudioEngine.java +++ b/src/main/java/vavi/sound/mobile/PcmAudioEngine.java @@ -107,7 +107,7 @@ protected InputStream[] getInputStreams(int streamNumber, int channels) { return iss; } - //------------------------------------------------------------------------- + // ---- @Override protected OutputStream getOutputStream(OutputStream os) { @@ -135,11 +135,10 @@ public void start(int streamNumber) { try { -//logger.log(Level.DEBUG, data.length); +//logger.log(Level.TRACE, data.length); InputStream[] iss = getInputStreams(streamNumber, channels); -//logger.log(Level.DEBUG, "is: " + is.available()); -// OutputStream os = debug2(); +//logger.log(Level.TRACE, "is: " + is.available()); DataLine.Info info = new DataLine.Info(SourceDataLine.class, audioFormat); SourceDataLine line = (SourceDataLine) AudioSystem.getLine(info); @@ -150,13 +149,12 @@ public void start(int streamNumber) { while (iss[0].available() > 0) { if (channels == 1) { int l = iss[0].read(buf, 0, 1024); -//Debug.dump(buf, 64); +//logger.log(Level.TRACE, "\n" + StringUtil.getDump(buf, 64)); line.write(buf, 0, l); -// debug3(os); } else { int lL = iss[0].read(buf, 0, 512); /*int lR = */iss[1].read(buf, 512, 512); -//logger.log(Level.DEBUG, "l : " + lL + ", r: " + lR); +//logger.log(Level.TRACE, "l : " + lL + ", r: " + lR); for (int i = 0; i < lL / 2; i++) { byte[] temp = new byte[4]; temp[0] = buf[i * 2]; @@ -170,10 +168,9 @@ public void start(int streamNumber) { line.drain(); line.stop(); line.close(); -// debug4(os); + } catch (IOException | LineUnavailableException e) { throw new IllegalStateException(e); } } - } diff --git a/src/main/java/vavi/sound/mobile/RohmAudioEngine.java b/src/main/java/vavi/sound/mobile/RohmAudioEngine.java index 7d57694..f44b0b6 100644 --- a/src/main/java/vavi/sound/mobile/RohmAudioEngine.java +++ b/src/main/java/vavi/sound/mobile/RohmAudioEngine.java @@ -80,7 +80,7 @@ protected InputStream[] getInputStreams(int streamNumber, int channels) { return iss; } - //------------------------------------------------------------------------- + // ---- @Override protected OutputStream getOutputStream(OutputStream os) { diff --git a/src/main/java/vavi/sound/mobile/YamahaAudioEngine.java b/src/main/java/vavi/sound/mobile/YamahaAudioEngine.java index 1ce01f8..12bee13 100644 --- a/src/main/java/vavi/sound/mobile/YamahaAudioEngine.java +++ b/src/main/java/vavi/sound/mobile/YamahaAudioEngine.java @@ -90,7 +90,7 @@ protected InputStream[] getInputStreams(int streamNumber, int channels) { return iss; } - //------------------------------------------------------------------------- + // ---- @Override protected OutputStream getOutputStream(OutputStream os) { 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 ef560b8..758ef55 100644 --- a/src/main/java/vavi/sound/pcm/resampling/ssrc/SSRC.java +++ b/src/main/java/vavi/sound/pcm/resampling/ssrc/SSRC.java @@ -550,7 +550,7 @@ int resample(ReadableByteChannel fpi, WritableByteChannel fpo) throws IOExceptio alp = alpha(aa); iza = I0Bessel.value(alp); -//logger.log(Level.DEBUG, String.format("iza = %g",iza)); +//logger.log(Level.TRACE, String.format("iza = %g",iza)); n1y = fs1 / sfrq; n1x = n1 / n1y + 1; @@ -843,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]; -//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)); +//logger.log(Level.TRACE, 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; @@ -1129,7 +1129,7 @@ int resample(ReadableByteChannel fpi, WritableByteChannel fpo) throws IOExceptio alp = alpha(aa); iza = I0Bessel.value(alp); -//logger.log(Level.DEBUG, String.format("iza %f, alp: %f", iza, alp)); // OK +//logger.log(Level.TRACE, String.format("iza %f, alp: %f", iza, alp)); // OK for (n1b = 1; n1b < n1; n1b *= 2) { } @@ -1139,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; -//logger.log(Level.DEBUG, String.format("1: %06d: %e", i + n1 / 2, stage1[i + n1 / 2])); // OK +//logger.log(Level.TRACE, String.format("1: %06d: %e", i + n1 / 2, stage1[i + n1 / 2])); // OK } ipsize = (int) (2 + Math.sqrt(n1b)); @@ -1197,7 +1197,7 @@ int resample(ReadableByteChannel fpi, WritableByteChannel fpo) throws IOExceptio alp = alpha(aa); iza = I0Bessel.value(alp); -//logger.log(Level.DEBUG, String.format("iza %f, alp: %f", iza, alp)); // OK +//logger.log(Level.TRACE, 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; @@ -1220,10 +1220,10 @@ int resample(ReadableByteChannel fpi, WritableByteChannel fpo) throws IOExceptio stage2 = new double[n2y][n2x]; -//logger.log(Level.DEBUG, String.format("n2y: %d, n2: %d", n2y, n2)); +//logger.log(Level.TRACE, 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; -//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 +//logger.log(Level.TRACE, 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 } } @@ -1268,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); -//logger.log(Level.DEBUG, (double) n1b2 * sfrq / dfrq + 1); +//logger.log(Level.TRACE, (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))]; @@ -1314,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; -//logger.log(Level.DEBUG, String.format("I: %f", inbuf[nch * inbuflen + i])); +//logger.log(Level.TRACE, String.format("I: %f", inbuf[nch * inbuflen + i])); } break; @@ -1420,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++) { -//logger.log(Level.DEBUG, String.format("%d (%d, %d)", i, bp2 / buf2[0].length, bp2 % buf2[0].length)); +//logger.log(Level.TRACE, 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; -//logger.log(Level.DEBUG, String.format("O: %06d: %f", op + p * nch + ch, tmp)); +//logger.log(Level.TRACE, String.format("O: %06d: %f", op + p * nch + ch, tmp)); } nsmplwrt2 = p; @@ -1439,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); -//logger.log(Level.DEBUG, "p: " + rawoutbuf.position() + ", l: " + rawoutbuf.limit()); +//logger.log(Level.TRACE, "p: " + rawoutbuf.position() + ", l: " + rawoutbuf.limit()); rawoutbuf.asDoubleBuffer().put(i, outbuf[i]); //if (i < 100) { // logger.log(Level.DEBUG, String.format("1: %06d: %f", i, outbuf[i])); //} -//logger.log(Level.DEBUG, "\n" + StringUtil.getDump(rawoutbuf, i, 8)); +//logger.log(Level.TRACE, "\n" + StringUtil.getDump(rawoutbuf, i, 8)); } } else { switch (dbps) { @@ -1811,7 +1811,7 @@ public void exec(String[] argv) throws IOException { switch (argv[i]) { case "--rate" -> { dfrq = Integer.parseInt(argv[++i]); -//logger.log(Level.DEBUG, String.format("dfrq: %d", dfrq)); +//logger.log(Level.TRACE, String.format("dfrq: %d", dfrq)); continue; } case "--att" -> { @@ -2113,7 +2113,7 @@ public void exec(String[] argv) throws IOException { try (FileOutputStream tfos= new FileOutputStream(ft)) { fpto = tfos.getChannel(); -//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)); +//logger.log(Level.TRACE, 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(); @@ -2174,7 +2174,7 @@ public void exec(String[] argv) throws IOException { setStartTime(); fptlen = (int) (ft.length() / 8); -//logger.log(Level.DEBUG, "tmp: " + fpt.getFilePointer()); +//logger.log(Level.TRACE, "tmp: " + fpt.getFilePointer()); try (FileInputStream fisf = new FileInputStream(ft)) { FileChannel fpti = fisf.getChannel(); @@ -2245,7 +2245,7 @@ public void exec(String[] argv) throws IOException { } fpti.close(); } - //logger.log(Level.DEBUG, "ft: " + ft); + //logger.log(Level.TRACE, "ft: " + ft); if (!ft.delete()) { System.err.printf("Failed to remove %s\n", ft); } diff --git a/src/main/java/vavi/sound/sampled/mfi/DividedMfiWithVoiceMaker.java b/src/main/java/vavi/sound/sampled/mfi/DividedMfiWithVoiceMaker.java index 1fb972a..3eb9510 100644 --- a/src/main/java/vavi/sound/sampled/mfi/DividedMfiWithVoiceMaker.java +++ b/src/main/java/vavi/sound/sampled/mfi/DividedMfiWithVoiceMaker.java @@ -106,7 +106,7 @@ public int create() throws IOException, UnsupportedAudioFileException, InvalidMf return event.r; } - //---- + // ---- @Options @HelpOption(argName = "help", option = "?", description = "print this help") diff --git a/src/main/java/vavi/sound/sampled/mfi/MfiWithVoiceMaker.java b/src/main/java/vavi/sound/sampled/mfi/MfiWithVoiceMaker.java index 1dd6d23..1479c7b 100644 --- a/src/main/java/vavi/sound/sampled/mfi/MfiWithVoiceMaker.java +++ b/src/main/java/vavi/sound/sampled/mfi/MfiWithVoiceMaker.java @@ -207,7 +207,7 @@ protected int createMFi(byte[] data, File file) throws InvalidMfiDataException, } } - //---- + // ---- @Options @HelpOption(argName = "help", option = "?", description = "print this help") diff --git a/src/main/java/vavi/sound/sampled/smaf/DividedSmafWithVoiceMaker.java b/src/main/java/vavi/sound/sampled/smaf/DividedSmafWithVoiceMaker.java index 2354aa1..6392a6a 100644 --- a/src/main/java/vavi/sound/sampled/smaf/DividedSmafWithVoiceMaker.java +++ b/src/main/java/vavi/sound/sampled/smaf/DividedSmafWithVoiceMaker.java @@ -101,7 +101,7 @@ public int create() throws IOException, UnsupportedAudioFileException, InvalidSm return event.r; } - //---- + // ---- @Options @HelpOption(argName = "help", option = "?", description = "print this help") diff --git a/src/main/java/vavi/sound/sampled/smaf/SmafWithVoiceMaker.java b/src/main/java/vavi/sound/sampled/smaf/SmafWithVoiceMaker.java index c7cd73f..b0ff80d 100644 --- a/src/main/java/vavi/sound/sampled/smaf/SmafWithVoiceMaker.java +++ b/src/main/java/vavi/sound/sampled/smaf/SmafWithVoiceMaker.java @@ -175,28 +175,28 @@ protected int createSMAF(byte[] data, File file) throws InvalidSmafDataException SmafMessage message = new VolumeMessage(0, 0, 127); audioSequenceDataChunk.addSmafMessage(message); messageBytes += message.getLength(); -//logger.log(Level.DEBUG, "messageBytes: volume: " + messageBytes); +//logger.log(Level.TRACE, "messageBytes: volume: " + messageBytes); for (int i = 0; i < numberOfChunks; i++) { message = new WaveMessage(0, 0, streamNumber++, NopMessage.maxSteps); audioSequenceDataChunk.addSmafMessage(message); messageBytes += message.getLength(); -//logger.log(Level.DEBUG, "messageBytes: wave: " + messageBytes); +//logger.log(Level.TRACE, "messageBytes: wave: " + messageBytes); message = new NopMessage(NopMessage.maxSteps); audioSequenceDataChunk.addSmafMessage(message); messageBytes += message.getLength(); -//logger.log(Level.DEBUG, "messageBytes: nop: " + messageBytes); +//logger.log(Level.TRACE, "messageBytes: nop: " + messageBytes); } if (moduloOfChunks != 0) { message = new WaveMessage(0, 0, streamNumber++, moduloOfChunks); audioSequenceDataChunk.addSmafMessage(message); messageBytes += message.getLength(); -//logger.log(Level.DEBUG, "messageBytes: wave: " + messageBytes); +//logger.log(Level.TRACE, "messageBytes: wave: " + messageBytes); message = new NopMessage(moduloOfChunks); audioSequenceDataChunk.addSmafMessage(message); messageBytes += message.getLength(); -//logger.log(Level.DEBUG, "messageBytes: nop: " + messageBytes); +//logger.log(Level.TRACE, "messageBytes: nop: " + messageBytes); } audioSequenceDataChunk.addSmafMessage(new EndOfSequenceMessage(0)); @@ -275,7 +275,7 @@ protected int createSMAF(byte[] data, File file) throws InvalidSmafDataException } } - //---- + // ---- @Options @HelpOption(argName = "help", option = "?", description = "print this help") diff --git a/src/main/java/vavi/sound/smaf/MetaEventAdapter.java b/src/main/java/vavi/sound/smaf/MetaEventAdapter.java index 8a8c4f0..62397b5 100644 --- a/src/main/java/vavi/sound/smaf/MetaEventAdapter.java +++ b/src/main/java/vavi/sound/smaf/MetaEventAdapter.java @@ -67,7 +67,7 @@ public void open() { */ @Override public void meta(javax.sound.midi.MetaMessage message) { -//logger.log(Level.DEBUG, "type: " + message.getType()); +//logger.log(Level.TRACE, "type: " + message.getType()); switch (MetaEvent.valueOf(message.getType())) { case META_MACHINE_DEPEND: // sequencer specific meta event try { @@ -155,7 +155,7 @@ private static void processSpecial_Vavi_MachineDependent(javax.sound.midi.MetaMe byte[] data = message.getData(); int id = (data[2] & 0xff) * 0xff + (data[3] & 0xff); -//logger.log(Level.DEBUG, "message id: " + id); +//logger.log(Level.TRACE, "message id: " + id); MachineDependentSequencer sequencer = (MachineDependentSequencer) SmafMessageStore.get(id); sequencer.sequence(); } @@ -171,7 +171,7 @@ private static void processSpecial_Vavi_Wave(javax.sound.midi.MetaMessage messag byte[] data = message.getData(); int id = (data[2] & 0xff) * 0x100 + (data[3] & 0xff); -//logger.log(Level.DEBUG, "message id: " + id); +//logger.log(Level.TRACE, "message id: " + id); WaveSequencer sequencer = (WaveSequencer) SmafMessageStore.get(id); sequencer.sequence(); } diff --git a/src/main/java/vavi/sound/smaf/SmafDeviceProvider.java b/src/main/java/vavi/sound/smaf/SmafDeviceProvider.java index c5ec568..721f5ed 100644 --- a/src/main/java/vavi/sound/smaf/SmafDeviceProvider.java +++ b/src/main/java/vavi/sound/smaf/SmafDeviceProvider.java @@ -101,7 +101,7 @@ public static SmafDevice getSmafDevice(SmafDevice.Info smafDeviceInfo) { if (key.startsWith("smaf.device.")) { @SuppressWarnings("unchecked") Class deviceClass = (Class) Class.forName(props.getProperty(key)); -//logger.log(Level.DEBUG, "smaf device class: " + StringUtil.getClassName(clazz)); +//logger.log(Level.TRACE, "smaf device class: " + StringUtil.getClassName(clazz)); SmafDevice.Info smafDeviceInfo = deviceClass.getDeclaredConstructor().newInstance().getDeviceInfo(); deviceMap.put(smafDeviceInfo, deviceClass); diff --git a/src/main/java/vavi/sound/smaf/SmafFileFormat.java b/src/main/java/vavi/sound/smaf/SmafFileFormat.java index 547e3d1..af55293 100644 --- a/src/main/java/vavi/sound/smaf/SmafFileFormat.java +++ b/src/main/java/vavi/sound/smaf/SmafFileFormat.java @@ -49,7 +49,7 @@ public int getByteLength() { return byteLength; } - //---- + // ---- /** SMAF Sequence */ private Sequence sequence; diff --git a/src/main/java/vavi/sound/smaf/SmafMidiConverter.java b/src/main/java/vavi/sound/smaf/SmafMidiConverter.java index 5aba5bf..775e1ed 100644 --- a/src/main/java/vavi/sound/smaf/SmafMidiConverter.java +++ b/src/main/java/vavi/sound/smaf/SmafMidiConverter.java @@ -99,7 +99,7 @@ Sequence convert(vavi.sound.smaf.Sequence smafSequence) SmafMessage smafMessage = smafEvent.getMessage(); midiContext.addCurrentTick(midiContext.getTicksOf(smafMessage.getDuration())); -//logger.log(Level.DEBUG, "■■■■■(" + i + ":" + j + ") ticks: " + midiContext.getCurrentTick() + "(" + midiContext.getTicksOf(smafMessage.getDuration()) + "," + smafMessage.getDuration() + "), " + smafMessage.getClass().getSimpleName()); +//logger.log(Level.TRACE, "■■■■■(" + 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) && @@ -142,8 +142,8 @@ Sequence convert(vavi.sound.smaf.Sequence smafSequence) /** Note may be entered before Control/Program */ @SuppressWarnings("unused") 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)); +//logger.log(Level.TRACE, "★: " + midiEvent.getMessage()); +//logger.log(Level.TRACE, "★: " + (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 && diff --git a/src/main/java/vavi/sound/smaf/SmafSequencer.java b/src/main/java/vavi/sound/smaf/SmafSequencer.java index 8a23fc2..0cc19fb 100644 --- a/src/main/java/vavi/sound/smaf/SmafSequencer.java +++ b/src/main/java/vavi/sound/smaf/SmafSequencer.java @@ -161,7 +161,7 @@ private void off() { midiSequencer.removeMetaEventListener(mea); } - //------------------------------------------------------------------------- + // ---- /** {@link MetaMessage MetaEvent} utility */ private final MetaSupport metaSupport = new MetaSupport(); @@ -185,7 +185,7 @@ protected void fireMeta(MetaMessage meta) { /** meta 0x2f listener */ private final javax.sound.midi.MetaEventListener mel = message -> { -//logger.log(Level.DEBUG, "type: " + message.getType()); +//logger.log(Level.TRACE, "type: " + message.getType()); switch (message.getType()) { case 0x2f: // added automatically at the end of the sequence try { diff --git a/src/main/java/vavi/sound/smaf/chunk/AudioSequenceDataChunk.java b/src/main/java/vavi/sound/smaf/chunk/AudioSequenceDataChunk.java index 6da42d4..faf3cef 100644 --- a/src/main/java/vavi/sound/smaf/chunk/AudioSequenceDataChunk.java +++ b/src/main/java/vavi/sound/smaf/chunk/AudioSequenceDataChunk.java @@ -46,7 +46,7 @@ public AudioSequenceDataChunk() { @Override protected void init(MyDataInputStream dis, Chunk parent) throws InvalidSmafDataException, IOException { -//logger.log(Level.DEBUG, "available: " + is.available() + ", " + available()); +//logger.log(Level.TRACE, "available: " + is.available() + ", " + available()); //skip(is, size); // TODO FormatType formatType = ((TrackChunk) parent).getFormatType(); switch (formatType) { diff --git a/src/main/java/vavi/sound/smaf/chunk/Chunk.java b/src/main/java/vavi/sound/smaf/chunk/Chunk.java index 5ae8c3c..922781d 100644 --- a/src/main/java/vavi/sound/smaf/chunk/Chunk.java +++ b/src/main/java/vavi/sound/smaf/chunk/Chunk.java @@ -53,8 +53,8 @@ protected Chunk(byte[] id, int size) { /** * @param dis chunk Header must be read - * @throws IOException - * @throws InvalidSmafDataException + * @throws IOException when an io error occurs + * @throws InvalidSmafDataException when input smaf is wrong * TODO Chunk -> constructor ??? * because of passing the parent */ @@ -73,7 +73,7 @@ public int getSize() { /** * For reading non-first parent (unmarked) - * @param is + * @param is source samf stream * @return Chunk object read */ protected Chunk readFrom(InputStream is) @@ -104,10 +104,10 @@ public static Chunk readFrom(InputStream is, Chunk parent) logger.log(Level.DEBUG, String.format("size: 0x%1$08x (%1$d)", size)); Chunk chunk = newInstance(id, size); -//logger.log(Level.DEBUG, chunk.getClass().getName() + "\n" + StringUtil.getDump(is, 0, 128)); -//logger.log(Level.DEBUG, String.format("is: " + is + " / " + chunk.getClass().getName())); +//logger.log(Level.TRACE, chunk.getClass().getName() + "\n" + StringUtil.getDump(is, 0, 128)); +//logger.log(Level.TRACE, String.format("is: " + is + " / " + chunk.getClass().getName())); MyDataInputStream mdis = new MyDataInputStream(is, id, size); -//logger.log(Level.DEBUG, String.format("mdis: " + mdis + " / " + chunk.getClass().getName())); +//logger.log(Level.TRACE, String.format("mdis: " + mdis + " / " + chunk.getClass().getName())); chunk.init(mdis, parent); if (parent != null) { @@ -119,7 +119,7 @@ public static Chunk readFrom(InputStream is, Chunk parent) assert false : "is: " + is.getClass().getName(); } } else { -//logger.log(Level.DEBUG, String.format("crc (calc): %04x, avail: %d, %s, %s", mdis.crc(), mdis.available(), mdis, chunk.getClass().getName())); +//logger.log(Level.TRACE, 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()) { logger.log(Level.WARNING, String.format("crc not match expected: %04x, actual: %04x", fc.getCrc(), mdis.crc())); @@ -133,7 +133,7 @@ public static Chunk readFrom(InputStream is, Chunk parent) /** */ public abstract void writeTo(OutputStream os) throws IOException; - //---- + // ---- /** input stream with count down, crc */ protected static class MyDataInputStream extends InputStream implements DataInput { @@ -148,7 +148,7 @@ protected MyDataInputStream(InputStream is, byte[] id, int size) { } else { this.is = is; } -//logger.log(Level.DEBUG, String.format("is: " + this.is)); +//logger.log(Level.TRACE, String.format("is: " + this.is)); this.dis = new DataInputStream(this.is); this.readSize = size; @@ -159,7 +159,7 @@ protected MyDataInputStream(InputStream is, byte[] id, int size) { crc.get().update(ByteUtil.getBeBytes(size)); } public int crc() { -//logger.log(Level.DEBUG, "crc len: " + crc.get().getCount()); +//logger.log(Level.TRACE, "crc len: " + crc.get().getCount()); return crc.get().getValue(); } @Override @@ -310,7 +310,7 @@ public int getCount() { return count; } } - //---- + // ---- /** * factory @@ -365,7 +365,7 @@ protected Constructor getStoreValue(String value) { try { @SuppressWarnings("unchecked") Class clazz = (Class) Class.forName(value); -//logger.log(Level.DEBUG, "chunk class: " + StringUtil.getClassName(clazz)); +//logger.log(Level.TRACE, "chunk class: " + StringUtil.getClassName(clazz)); return clazz.getConstructor(byte[].class, Integer.TYPE); } catch (Exception e) { logger.log(Level.ERROR, e.getMessage(), e); diff --git a/src/main/java/vavi/sound/smaf/chunk/ColorPaletteDefinitionChunk.java b/src/main/java/vavi/sound/smaf/chunk/ColorPaletteDefinitionChunk.java index ff95cdb..77d1dfd 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); -//logger.log(Level.DEBUG, "ColorPaletteDefinition: " + size); +//logger.log(Level.TRACE, "ColorPaletteDefinition: " + size); } /** */ diff --git a/src/main/java/vavi/sound/smaf/chunk/DisplayParameterDefinitionChunk.java b/src/main/java/vavi/sound/smaf/chunk/DisplayParameterDefinitionChunk.java index 578a385..89fbe1d 100644 --- a/src/main/java/vavi/sound/smaf/chunk/DisplayParameterDefinitionChunk.java +++ b/src/main/java/vavi/sound/smaf/chunk/DisplayParameterDefinitionChunk.java @@ -35,7 +35,7 @@ public class DisplayParameterDefinitionChunk extends Chunk { /** */ public DisplayParameterDefinitionChunk(byte[] id, int size) { super(id, size); -//logger.log(Level.DEBUG, "DisplayParameterDefinition: " + size); +//logger.log(Level.TRACE, "DisplayParameterDefinition: " + size); } /** */ diff --git a/src/main/java/vavi/sound/smaf/chunk/FileChunk.java b/src/main/java/vavi/sound/smaf/chunk/FileChunk.java index cba3726..c43ca8c 100644 --- a/src/main/java/vavi/sound/smaf/chunk/FileChunk.java +++ b/src/main/java/vavi/sound/smaf/chunk/FileChunk.java @@ -66,7 +66,7 @@ protected void init(MyDataInputStream dis, Chunk parent) logger.log(Level.WARNING, "unsupported chunk: " + chunk.getClass()); } } -//logger.log(Level.DEBUG, "available: " + is.available()); +//logger.log(Level.TRACE, "available: " + is.available()); this.crc = dis.readUnsignedShort(); logger.log(Level.DEBUG, String.format("crc (orig): %04x", crc)); if (dis.available() > 4) { @@ -124,7 +124,7 @@ public int getCrc() { } } - //---- + // ---- /** */ private Chunk contentsInfoChunk; diff --git a/src/main/java/vavi/sound/smaf/chunk/GraphicsTrackSequenceDataChunk.java b/src/main/java/vavi/sound/smaf/chunk/GraphicsTrackSequenceDataChunk.java index 7438039..a45ab4d 100644 --- a/src/main/java/vavi/sound/smaf/chunk/GraphicsTrackSequenceDataChunk.java +++ b/src/main/java/vavi/sound/smaf/chunk/GraphicsTrackSequenceDataChunk.java @@ -79,7 +79,7 @@ protected void readHandyPhoneStandard(DataInputStream dis) while (dis.available() > 0) { // -------- duration -------- int duration = MidiUtil.readVariableLength(dis); -//logger.log(Level.DEBUG, "duration: " + duration + ", 0x" + StringUtil.toHex4(duration)); +//logger.log(Level.TRACE, "duration: " + duration + ", 0x" + StringUtil.toHex4(duration)); // -------- event -------- int e1 = dis.readUnsignedByte(); switch (e1) { @@ -122,7 +122,7 @@ protected void readHandyPhoneStandard(DataInputStream dis) } break; } -//logger.log(Level.DEBUG, available() + ", " + smafMessage); +//logger.log(Level.TRACE, available() + ", " + smafMessage); logger.log(Level.DEBUG, "message: " + smafMessage); messages.add(smafMessage); } diff --git a/src/main/java/vavi/sound/smaf/chunk/MasterTrackChunk.java b/src/main/java/vavi/sound/smaf/chunk/MasterTrackChunk.java index 486738f..c878ee4 100644 --- a/src/main/java/vavi/sound/smaf/chunk/MasterTrackChunk.java +++ b/src/main/java/vavi/sound/smaf/chunk/MasterTrackChunk.java @@ -44,13 +44,13 @@ protected void init(MyDataInputStream dis, Chunk parent) this.sequenceType = SequenceType.values()[dis.readUnsignedByte()]; logger.log(Level.DEBUG, "sequenceType: " + sequenceType); this.durationTimeBase = dis.readUnsignedByte(); -//logger.log(Level.DEBUG, "durationTimeBase: " + StringUtil.toHex2(durationTimeBase)); +//logger.log(Level.TRACE, "durationTimeBase: " + StringUtil.toHex2(durationTimeBase)); int optionSize = dis.readUnsignedByte(); this.optionData = new byte[optionSize]; dis.readFully(optionData); while (dis.available() > 0) { -//logger.log(Level.DEBUG, "available: " + is.available() + ", " + available()); +//logger.log(Level.TRACE, "available: " + is.available() + ", " + available()); Chunk chunk = readFrom(dis); if (chunk instanceof MasterTrackSequenceDataChunk) { // "Mssq" sequenceDataChunk = chunk; diff --git a/src/main/java/vavi/sound/smaf/chunk/ScoreTrackChunk.java b/src/main/java/vavi/sound/smaf/chunk/ScoreTrackChunk.java index 53a6574..b567cbd 100644 --- a/src/main/java/vavi/sound/smaf/chunk/ScoreTrackChunk.java +++ b/src/main/java/vavi/sound/smaf/chunk/ScoreTrackChunk.java @@ -75,11 +75,11 @@ protected void init(MyDataInputStream dis, Chunk parent) case HandyPhoneStandard: { byte[] buffer = new byte[2]; dis.readFully(buffer); -//logger.log(Level.DEBUG, StringUtil.getDump(channelStatus)); +//logger.log(Level.TRACE, 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)))); -//logger.log(Level.DEBUG, channelStatuses[i]); +//logger.log(Level.TRACE, channelStatuses[i]); } } break; case MobileStandard_Compress: @@ -89,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]); -//logger.log(Level.DEBUG, channelStatuses[i]); +//logger.log(Level.TRACE, channelStatuses[i]); } } break; case Unknown3: { @@ -101,7 +101,7 @@ protected void init(MyDataInputStream dis, Chunk parent) logger.log(Level.DEBUG, "formatType: " + formatType); while (dis.available() > 0) { -//logger.log(Level.DEBUG, "available: " + is.available() + ", " + available()); +//logger.log(Level.TRACE, "available: " + is.available() + ", " + available()); Chunk chunk = readFrom(dis); if (chunk instanceof SeekAndPhraseInfoChunk) { seekAndPhraseInfoChunk = chunk; @@ -206,7 +206,7 @@ public List getSmafEvents() throws InvalidSmafDataException { List messages = ((SetupDataChunk) setupDataChunk).getSmafMessages(); for (SmafMessage message : messages) { events.add(new SmafEvent(message, 0L)); -//logger.log(Level.DEBUG, "SetupDataChunk: " + message); +//logger.log(Level.TRACE, "SetupDataChunk: " + message); } } @@ -215,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 -//logger.log(Level.DEBUG, "StreamPcmDataChunk: " + message); +//logger.log(Level.TRACE, "StreamPcmDataChunk: " + message); } } @@ -223,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 -//logger.log(Level.DEBUG, "SequenceDataChunk: " + message); +//logger.log(Level.TRACE, "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 ba4fc4f..1bdd482 100644 --- a/src/main/java/vavi/sound/smaf/chunk/SeekAndPhraseInfoChunk.java +++ b/src/main/java/vavi/sound/smaf/chunk/SeekAndPhraseInfoChunk.java @@ -36,7 +36,7 @@ public class SeekAndPhraseInfoChunk extends Chunk { /** */ public SeekAndPhraseInfoChunk(byte[] id, int size) { super(id, size); -//logger.log(Level.DEBUG, "SeekAndPhraseInfo: " + size); +//logger.log(Level.TRACE, "SeekAndPhraseInfo: " + size); } /** */ @@ -55,12 +55,12 @@ protected void init(MyDataInputStream dis, Chunk parent) int i = 0; while (i < size) { -//logger.log(Level.DEBUG, 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(data, i); subData.put(subDatum.getTag(), subDatum); logger.log(Level.DEBUG, "SeekAndPhraseInfo: subData: " + subDatum); i += 2 + 1 + subDatum.getData().length + 1; // tag ':' data ',' -//logger.log(Level.DEBUG, 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)); } } diff --git a/src/main/java/vavi/sound/smaf/chunk/SequenceDataChunk.java b/src/main/java/vavi/sound/smaf/chunk/SequenceDataChunk.java index f01ab71..27e15e1 100644 --- a/src/main/java/vavi/sound/smaf/chunk/SequenceDataChunk.java +++ b/src/main/java/vavi/sound/smaf/chunk/SequenceDataChunk.java @@ -68,7 +68,7 @@ public SequenceDataChunk() { @Override protected void init(MyDataInputStream dis, Chunk parent) throws InvalidSmafDataException, IOException { -//logger.log(Level.DEBUG, "available: " + is.available() + ", " + available()); +//logger.log(Level.TRACE, "available: " + is.available() + ", " + available()); //skip(is, size); ScoreTrackChunk.FormatType formatType = ((TrackChunk) parent).getFormatType(); switch (formatType) { @@ -84,13 +84,13 @@ protected void init(MyDataInputStream dis, Chunk parent) //os1.write(baos.toByteArray()); //os1.flush(); //os1.close(); -//logger.log(Level.DEBUG, "data.enc created"); +//logger.log(Level.TRACE, "data.enc created"); byte[] decoded = new Huffman().decode(baos.toByteArray()); //OutputStream os2 = new FileOutputStream("/tmp/data.dec"); //os2.write(decoded); //os2.flush(); //os2.close(); -//logger.log(Level.DEBUG, "data.dec created"); +//logger.log(Level.TRACE, "data.dec created"); logger.log(Level.DEBUG, "decode: " + size + " -> " + decoded.length); size = decoded.length; readMobileStandard(new MyDataInputStream(new ByteArrayInputStream(decoded), id, decoded.length)); @@ -121,7 +121,7 @@ protected void readHandyPhoneStandard(MyDataInputStream dis) while (dis.available() > 0) { // -------- duration -------- int duration = MidiUtil.readVariableLength(dis); -//logger.log(Level.DEBUG, "duration: " + duration + ", 0x" + StringUtil.toHex4(duration)); +//logger.log(Level.TRACE, "duration: " + duration + ", 0x" + StringUtil.toHex4(duration)); // -------- event -------- int e1 = dis.readUnsignedByte(); if (e1 == 0xff) { // exclusive, nop @@ -144,7 +144,7 @@ protected void readHandyPhoneStandard(MyDataInputStream dis) } } else if (e1 != 0x00) { // note int gateTime = MidiUtil.readVariableLength(dis); -//logger.log(Level.DEBUG, String.format("gateTime: %d, 0x%04x", gateTime, gateTime)); +//logger.log(Level.TRACE, String.format("gateTime: %d, 0x%04x", gateTime, gateTime)); smafMessage = getHandyPhoneStandardMessage(duration, e1, gateTime); } else { // e1 == 0x00 other event int e2 = dis.readUnsignedByte(); @@ -206,9 +206,9 @@ protected void readHandyPhoneStandard(MyDataInputStream dis) } } } -//logger.log(Level.DEBUG, available() + ", " + smafMessage); +//logger.log(Level.TRACE, available() + ", " + smafMessage); if (smafMessage != null) { -//logger.log(Level.DEBUG, "message: " + smafMessage); +//logger.log(Level.TRACE, "message: " + smafMessage); messages.add(smafMessage); } else { assert false : "smafMessage is null"; @@ -236,7 +236,7 @@ private void readMobileStandard(MyDataInputStream dis) while (dis.available() > 0) { // duration int duration = MidiUtil.readVariableLength(dis); -//logger.log(Level.DEBUG, "duration: " + duration); +//logger.log(Level.TRACE, "duration: " + duration); // event int status = dis.readUnsignedByte(); if (status >= 0x80 && status <= 0x8f) { // note w/o velocity @@ -350,7 +350,7 @@ private void readMobileStandard(MyDataInputStream dis) } } -//logger.log(Level.DEBUG, available() + ", " + smafMessage); +//logger.log(Level.TRACE, available() + ", " + smafMessage); if (smafMessage != null) { messages.add(smafMessage); } else { diff --git a/src/main/java/vavi/sound/smaf/chunk/WaveType.java b/src/main/java/vavi/sound/smaf/chunk/WaveType.java index c8068e2..34ddc6f 100644 --- a/src/main/java/vavi/sound/smaf/chunk/WaveType.java +++ b/src/main/java/vavi/sound/smaf/chunk/WaveType.java @@ -91,7 +91,7 @@ public class WaveType { * */ WaveType(int waveType) throws IOException { -//logger.log(Level.DEBUG, "waveType: " + StringUtil.toHex4(waveType)); +//logger.log(Level.TRACE, "waveType: " + StringUtil.toHex4(waveType)); this.waveChannels = (waveType & 0x8000) != 0 ? 2 : 1; this.waveFormat = (waveType & 0x7000) >> 12; this.waveSamplingFreq = samplingFreqs[(waveType & 0x0f00) >> 8]; diff --git a/src/main/java/vavi/sound/smaf/message/BankSelectMessage.java b/src/main/java/vavi/sound/smaf/message/BankSelectMessage.java index 4c47534..af842e8 100644 --- a/src/main/java/vavi/sound/smaf/message/BankSelectMessage.java +++ b/src/main/java/vavi/sound/smaf/message/BankSelectMessage.java @@ -110,7 +110,7 @@ public String toString() { " bank=" + bank; } - //---- + // ---- /* */ @Override @@ -194,7 +194,7 @@ public SmafEvent[] getSmafEvents(MidiEvent midiEvent, SmafContext context) changeBankMessage.setBank(data1); context.setBeforeTick(track, midiEvent.getTick()); -//logger.log(Level.DEBUG, channel + ": " + StringUtil.toHex2(data1) + ", " + StringUtil.toHex2(changeVoiceMessage.getProgram()) + ", " + changeBankMessage.getBank()); +//logger.log(Level.TRACE, 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 0a9166a..78cb056 100644 --- a/src/main/java/vavi/sound/smaf/message/EndOfSequenceMessage.java +++ b/src/main/java/vavi/sound/smaf/message/EndOfSequenceMessage.java @@ -51,7 +51,7 @@ public String toString() { return "EOS: duration=" + duration; } - //---- + // ---- /* */ @Override diff --git a/src/main/java/vavi/sound/smaf/message/ExpressionMessage.java b/src/main/java/vavi/sound/smaf/message/ExpressionMessage.java index a7e06d2..6edbf70 100644 --- a/src/main/java/vavi/sound/smaf/message/ExpressionMessage.java +++ b/src/main/java/vavi/sound/smaf/message/ExpressionMessage.java @@ -73,7 +73,7 @@ public String toString() { " volume=" + volume; } - //---- + // ---- /* */ @Override @@ -95,7 +95,7 @@ public MidiEvent[] getMidiEvents(MidiContext context) MidiEvent[] events = new MidiEvent[1]; ShortMessage shortMessage = new ShortMessage(); -//logger.log(Level.DEBUG, "Expression: [" + duration + "] " + channel + "ch, " + volume); +//logger.log(Level.TRACE, "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 ae6712f..5c1630b 100644 --- a/src/main/java/vavi/sound/smaf/message/MidiContext.java +++ b/src/main/java/vavi/sound/smaf/message/MidiContext.java @@ -202,7 +202,7 @@ public void setDrum(int smafChannel, ChannelConfiguration value) { logger.log(Level.DEBUG, "already swapped: " + midiChannel + ", " + value); } else { drums[midiChannel] = value; -//logger.log(Level.DEBUG, "temporary: " + midiChannel + ", " + value); +//logger.log(Level.TRACE, "temporary: " + midiChannel + ", " + value); } // if DRUM_CHANNEL is not a rhythm, replace it with an empty channel. @@ -279,7 +279,7 @@ public int getProgram(int smafChannel) { return programs[midiChannel]; } - //---- note + // ---- note /** * @param smafChannel SMAF channel @@ -290,7 +290,7 @@ public int retrieveChannel(int smafChannel) { int midiChannel = getMidiChannel(smafChannel); // if (midiChannel == drumSwapChannel) { -//logger.log(Level.DEBUG, "used swapped channel: " + midiChannel); +//logger.log(Level.TRACE, "used swapped channel: " + midiChannel); // } // drum channel is used as sound @@ -317,7 +317,7 @@ public int retrievePitch(int smafChannel, int pitch) { if (formatType == ScoreTrackChunk.FormatType.HandyPhoneStandard) { int midiChannel = getMidiChannel(smafChannel); if (drums[midiChannel] == ChannelConfiguration.PERCUSSION) { -//logger.log(Level.DEBUG, "drum pitch: " + (programs[midiChannel] & 0x7f) + ", " + pitch); +//logger.log(Level.TRACE, "drum pitch: " + (programs[midiChannel] & 0x7f) + ", " + pitch); return programs[midiChannel] & 0x7f; } else { pitch += 36; @@ -369,7 +369,7 @@ public int retrievePitch(int smafChannel, int pitch) { public void setOctaveShift(int smafChannel, int octaveShift) { int midiChannel = getMidiChannel(smafChannel); octaveShifts[midiChannel] = octaveShift; -//logger.log(Level.DEBUG, "octaveShifts[" + midiChannel + "]: " + octaveShift); +//logger.log(Level.TRACE, "octaveShifts[" + midiChannel + "]: " + octaveShift); } /** @@ -381,7 +381,7 @@ public void setOctaveShift(int smafChannel, int octaveShift) { public int setVelocity(int smafChannel, int velocity) { int midiChannel = getMidiChannel(smafChannel); velocities[midiChannel] = velocity; -//logger.log(Level.DEBUG, "velocities[" + mididChannel + "]: " + octaveShift); +//logger.log(Level.TRACE, "velocities[" + mididChannel + "]: " + octaveShift); return velocity; // TODO mhh... } @@ -395,7 +395,7 @@ public int getVelocity(int smafChannel) { return velocities[midiChannel]; } - //---- + // ---- /** * index is MA1 register value diff --git a/src/main/java/vavi/sound/smaf/message/MidiConvertibleMessage.java b/src/main/java/vavi/sound/smaf/message/MidiConvertibleMessage.java index 71e8396..6f779a6 100644 --- a/src/main/java/vavi/sound/smaf/message/MidiConvertibleMessage.java +++ b/src/main/java/vavi/sound/smaf/message/MidiConvertibleMessage.java @@ -75,7 +75,7 @@ public String toString() { " value=" + value; } - //---- + // ---- @Override public byte[] getMessage() { @@ -93,7 +93,7 @@ public MidiEvent[] getMidiEvents(MidiContext context) throws InvalidMidiDataExce MidiEvent[] events = new MidiEvent[1]; ShortMessage shortMessage = new ShortMessage(); -//logger.log(Level.DEBUG, "(" + StringUtil.toHex2(command) + "): " + channel + "ch, " + StringUtil.toHex2(value)); +//logger.log(Level.TRACE, "(" + 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/ModulationMessage.java b/src/main/java/vavi/sound/smaf/message/ModulationMessage.java index 77ee1d3..4c967ef 100644 --- a/src/main/java/vavi/sound/smaf/message/ModulationMessage.java +++ b/src/main/java/vavi/sound/smaf/message/ModulationMessage.java @@ -73,7 +73,7 @@ public String toString() { " modulation=" + modulation; } - //---- + // ---- /* */ @Override diff --git a/src/main/java/vavi/sound/smaf/message/NopMessage.java b/src/main/java/vavi/sound/smaf/message/NopMessage.java index 07e653c..4a9b270 100644 --- a/src/main/java/vavi/sound/smaf/message/NopMessage.java +++ b/src/main/java/vavi/sound/smaf/message/NopMessage.java @@ -48,7 +48,7 @@ public String toString() { " (" + String.format("%04x", duration) + ")"; } - //---- + // ---- /* */ @Override diff --git a/src/main/java/vavi/sound/smaf/message/NoteMessage.java b/src/main/java/vavi/sound/smaf/message/NoteMessage.java index 5738c8c..f1f2a03 100644 --- a/src/main/java/vavi/sound/smaf/message/NoteMessage.java +++ b/src/main/java/vavi/sound/smaf/message/NoteMessage.java @@ -234,7 +234,7 @@ public MidiEvent[] getMidiEvents(MidiContext context) midiChannel, pitch, velocity); -//logger.log(Level.DEBUG, "note: " + channel + ": " + pitch); +//logger.log(Level.TRACE, "note: " + channel + ": " + pitch); events[0] = new MidiEvent(shortMessage, context.getCurrentTick()); shortMessage = new ShortMessage(); @@ -260,7 +260,7 @@ public SmafEvent[] getSmafEvents(MidiEvent midiEvent, SmafContext context) int command = shortMessage.getCommand(); int data1 = shortMessage.getData1(); int data2 = shortMessage.getData2(); -//logger.log(Level.DEBUG, midiEvent.getTick() + ", " + channel + ", " + command + ", " + (context.retrievePitch(channel, data1) + 45) + ", " + (data2 / 2)); +//logger.log(Level.TRACE, midiEvent.getTick() + ", " + channel + ", " + command + ", " + (context.retrievePitch(channel, data1) + 45) + ", " + (data2 / 2)); if (command == ShortMessage.NOTE_OFF || // note on with velocity 0 @@ -305,7 +305,7 @@ public SmafEvent[] getSmafEvents(MidiEvent midiEvent, SmafContext context) if (length >= 255) { logger.log(Level.DEBUG, channel + "ch, " + smafMessage.getNote() + ", " + smafMessage.getDuration() + ":[" + i + "]:" + (i == onLength - 1 ? length % 255 : 255) + "/" + length); } -//logger.log(Level.DEBUG, channel + ", " + smafMessage.getVoice() + ", " + ((smafMessage.getMessage()[1] & 0xc0) >> 6)); +//logger.log(Level.TRACE, channel + ", " + smafMessage.getVoice() + ", " + ((smafMessage.getMessage()[1] & 0xc0) >> 6)); smafEvents[i] = new SmafEvent(smafMessage, 0L); // TODO 0l if (smafEvents[i] == null) { logger.log(Level.DEBUG, "[" + i + "]: " + smafEvents[i]); diff --git a/src/main/java/vavi/sound/smaf/message/OctaveShiftMessage.java b/src/main/java/vavi/sound/smaf/message/OctaveShiftMessage.java index b6a0f68..1209a83 100644 --- a/src/main/java/vavi/sound/smaf/message/OctaveShiftMessage.java +++ b/src/main/java/vavi/sound/smaf/message/OctaveShiftMessage.java @@ -71,7 +71,7 @@ public String toString() { " octaveShift=" + octaveShift; } - //---- + // ---- /* */ @Override diff --git a/src/main/java/vavi/sound/smaf/message/PanMessage.java b/src/main/java/vavi/sound/smaf/message/PanMessage.java index 5c40802..34a08a0 100644 --- a/src/main/java/vavi/sound/smaf/message/PanMessage.java +++ b/src/main/java/vavi/sound/smaf/message/PanMessage.java @@ -73,7 +73,7 @@ public String toString() { " panpot=" + panpot; } - //---- + // ---- /* */ @Override diff --git a/src/main/java/vavi/sound/smaf/message/PitchBendMessage.java b/src/main/java/vavi/sound/smaf/message/PitchBendMessage.java index 3e7254d..d5b281d 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; -//logger.log(Level.DEBUG, "pitchBend: " + value); +//logger.log(Level.TRACE, "pitchBend: " + value); } /** for SmafConvertible */ @@ -74,7 +74,7 @@ public String toString() { " pitchBend=" + pitchBend; } - //---- + // ---- /* */ @Override diff --git a/src/main/java/vavi/sound/smaf/message/ProgramChangeMessage.java b/src/main/java/vavi/sound/smaf/message/ProgramChangeMessage.java index 370df6d..6bf2293 100644 --- a/src/main/java/vavi/sound/smaf/message/ProgramChangeMessage.java +++ b/src/main/java/vavi/sound/smaf/message/ProgramChangeMessage.java @@ -75,7 +75,7 @@ public String toString() { " program=" + program; } - //---- + // ---- /* */ @Override @@ -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); -//logger.log(Level.DEBUG, "ProgramChange: [" + duration + "] " + channel + "ch, " + context.getProgram(channel)); +//logger.log(Level.TRACE, "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 8c12b7b..208dd19 100644 --- a/src/main/java/vavi/sound/smaf/message/STMessage.java +++ b/src/main/java/vavi/sound/smaf/message/STMessage.java @@ -58,7 +58,7 @@ public String toString() { " songTitle=" + songTitle; } - //---- + // ---- /* */ @Override diff --git a/src/main/java/vavi/sound/smaf/message/SmafContext.java b/src/main/java/vavi/sound/smaf/message/SmafContext.java index 1758901..d27f676 100644 --- a/src/main/java/vavi/sound/smaf/message/SmafContext.java +++ b/src/main/java/vavi/sound/smaf/message/SmafContext.java @@ -38,7 +38,7 @@ public class SmafContext implements SmafConvertible { /** max SMAF track number */ public static final int MAX_SMAF_TRACKS = 4; - //---- + // ---- /** @see MidiFileFormat#getType() 0: SMF Format 0, 1: SMF Format 1 */ private int type; @@ -66,7 +66,7 @@ public void setTimeBase(int timeBase) { this.timeBase = timeBase; } - //---- + // ---- /** index is SMAF Track No., true if used */ private final boolean[] trackUsed = new boolean[MAX_SMAF_TRACKS]; @@ -85,7 +85,7 @@ public boolean isTrackUsed(int smafTrackNumber) { return trackUsed[smafTrackNumber]; } - //---- + // ---- /** * tick magnification @@ -103,7 +103,7 @@ public void setScale(float scale) { this.scale = scale; } - //---- + // ---- /** the previous tick, index is SMAF Track No. */ private final long[] beforeTicks = new long[MAX_SMAF_TRACKS]; @@ -166,7 +166,7 @@ private int getAdjustedDelta(int smafTrackNumber, double floatDelta) { return delta; } - //---- + // ---- /** * Finds how many Δs(integer value, truncating too much) can be included in the time since the previous @@ -239,7 +239,7 @@ public SmafEvent[] getIntervalSmafEvents() { incrementBeforeTick(track, 255); } -//logger.log(Level.DEBUG, nopLength + " nops inserted"); +//logger.log(Level.TRACE, nopLength + " nops inserted"); return smafEvents; } @@ -273,7 +273,7 @@ public int getDuration() { return delta % 256; } - //---- + // ---- /** Gets the corrected SMAF Pitch. sound -45, percussion -35 */ public int retrievePitch(int channel, int pitch) { @@ -304,7 +304,7 @@ public int retrieveSmafTrack(int channel) { return channel / 4; } - //---- + // ---- /** current SMAF track No. */ private int smafTrackNumber; @@ -488,7 +488,7 @@ public SmafEvent[] getSmafEvents(MidiEvent midiEvent, SmafContext context) rpnMSB[channel] = data2; break; default: -//logger.log(Level.DEBUG, "not implemented: " + data1); +//logger.log(Level.TRACE, "not implemented: " + data1); break; } diff --git a/src/main/java/vavi/sound/smaf/message/UndefinedMessage.java b/src/main/java/vavi/sound/smaf/message/UndefinedMessage.java index 028abe2..8e269f9 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; -//logger.log(Level.DEBUG, "UndefinedMessage: ★★★★★★★★★★★★★★★★"); +//logger.log(Level.TRACE, "UndefinedMessage: ★★★★★★★★★★★★★★★★"); } /** */ @@ -32,7 +32,7 @@ public String toString() { " duration=" + duration; } - //---- + // ---- /* */ @Override diff --git a/src/main/java/vavi/sound/smaf/message/VNMessage.java b/src/main/java/vavi/sound/smaf/message/VNMessage.java index b06f3c6..20c608e 100644 --- a/src/main/java/vavi/sound/smaf/message/VNMessage.java +++ b/src/main/java/vavi/sound/smaf/message/VNMessage.java @@ -58,7 +58,7 @@ public String toString() { " venderName=" + venderName; } - //---- + // ---- /* */ @Override diff --git a/src/main/java/vavi/sound/smaf/message/VolumeMessage.java b/src/main/java/vavi/sound/smaf/message/VolumeMessage.java index f3f0c76..8a26ea0 100644 --- a/src/main/java/vavi/sound/smaf/message/VolumeMessage.java +++ b/src/main/java/vavi/sound/smaf/message/VolumeMessage.java @@ -90,7 +90,7 @@ public String toString() { " volume=" + volume; } - //---- + // ---- /* */ @Override diff --git a/src/main/java/vavi/sound/smaf/message/WaveDataMessage.java b/src/main/java/vavi/sound/smaf/message/WaveDataMessage.java index 9d1d147..0ba3cb6 100644 --- a/src/main/java/vavi/sound/smaf/message/WaveDataMessage.java +++ b/src/main/java/vavi/sound/smaf/message/WaveDataMessage.java @@ -72,7 +72,7 @@ public String toString() { " channels=" + channels; } - //---- + // ---- /* */ @Override diff --git a/src/main/java/vavi/sound/smaf/message/WaveMessage.java b/src/main/java/vavi/sound/smaf/message/WaveMessage.java index 83d7432..0e749da 100644 --- a/src/main/java/vavi/sound/smaf/message/WaveMessage.java +++ b/src/main/java/vavi/sound/smaf/message/WaveMessage.java @@ -112,7 +112,7 @@ public String toString() { " gateTime=" + String.format("%04x", gateTime); } - //---- + // ---- /* */ @Override 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 4fad5ac..70d91a2 100644 --- a/src/main/java/vavi/sound/smaf/message/graphics/BackDropColorDefinitionMessage.java +++ b/src/main/java/vavi/sound/smaf/message/graphics/BackDropColorDefinitionMessage.java @@ -48,7 +48,7 @@ public String toString() { " backDropColor = " + backDropColor; } - //---- + // ---- /* */ @Override diff --git a/src/main/java/vavi/sound/smaf/message/graphics/GeneralPurposeDisplayMessage.java b/src/main/java/vavi/sound/smaf/message/graphics/GeneralPurposeDisplayMessage.java index d679fec..d3653d2 100644 --- a/src/main/java/vavi/sound/smaf/message/graphics/GeneralPurposeDisplayMessage.java +++ b/src/main/java/vavi/sound/smaf/message/graphics/GeneralPurposeDisplayMessage.java @@ -64,7 +64,7 @@ enum SubBlockType { BitmapTile } - //---- + // ---- /* */ @Override diff --git a/src/main/java/vavi/sound/smaf/message/graphics/NopMessage.java b/src/main/java/vavi/sound/smaf/message/graphics/NopMessage.java index a543036..2158e22 100644 --- a/src/main/java/vavi/sound/smaf/message/graphics/NopMessage.java +++ b/src/main/java/vavi/sound/smaf/message/graphics/NopMessage.java @@ -42,7 +42,7 @@ public String toString() { " duration=" + duration; } - //---- + // ---- /* */ @Override diff --git a/src/main/java/vavi/sound/smaf/message/graphics/OffsetOriginMessage.java b/src/main/java/vavi/sound/smaf/message/graphics/OffsetOriginMessage.java index 45f826f..294e2cc 100644 --- a/src/main/java/vavi/sound/smaf/message/graphics/OffsetOriginMessage.java +++ b/src/main/java/vavi/sound/smaf/message/graphics/OffsetOriginMessage.java @@ -44,7 +44,7 @@ public String toString() { " duration=" + duration; } - //---- + // ---- /* */ @Override diff --git a/src/main/java/vavi/sound/smaf/message/graphics/ResetOrigneMessage.java b/src/main/java/vavi/sound/smaf/message/graphics/ResetOrigneMessage.java index 80e027a..64c5a9d 100644 --- a/src/main/java/vavi/sound/smaf/message/graphics/ResetOrigneMessage.java +++ b/src/main/java/vavi/sound/smaf/message/graphics/ResetOrigneMessage.java @@ -41,7 +41,7 @@ public String toString() { " duration=" + duration; } - //---- + // ---- /* */ @Override 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 ad1fbc1..8fe29d6 100644 --- a/src/main/java/vavi/sound/smaf/message/graphics/UserMessage.java +++ b/src/main/java/vavi/sound/smaf/message/graphics/UserMessage.java @@ -49,7 +49,7 @@ public String toString() { " userEventId=" + userEventId; } - //---- + // ---- /* */ @Override 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 2cc6de8..78d1733 100644 --- a/src/main/java/vavi/sound/smaf/message/yamaha/YamahaMessage.java +++ b/src/main/java/vavi/sound/smaf/message/yamaha/YamahaMessage.java @@ -137,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(); -//logger.log(Level.DEBUG, "(" + StringUtil.toHex2(command) + "): " + channel + "ch, " + StringUtil.toHex2(value)); +//logger.log(Level.TRACE, "(" + 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); diff --git a/src/main/java/vavi/sound/smaf/readme.md b/src/main/java/vavi/sound/smaf/readme.md index 37346c4..f47c569 100644 --- a/src/main/java/vavi/sound/smaf/readme.md +++ b/src/main/java/vavi/sound/smaf/readme.md @@ -4,17 +4,17 @@ Provides classes related to SMAF sound. ## Abstract -It has almost the same structure as the {@link javax.sound.midi} package. -Please refer to {@link javax.sound.midi} for usage. +It has almost the same structure as the `javax.sound.midi` package. +Please refer to `javax.sound.midi` for usage. + +## Reference + +* [MMFplay](http://mmfplay.sourceforge.net/) ## TODO - * ~~ 080512 Something is wrong with smaf -> midi~~ + * ~~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 - - * [MMFplay](http://mmfplay.sourceforge.net/) diff --git a/src/test/java/ExtractWave.java b/src/test/java/ExtractWave.java index b7da191..6f9db4d 100644 --- a/src/test/java/ExtractWave.java +++ b/src/test/java/ExtractWave.java @@ -24,6 +24,7 @@ * 0.02 030715 nsano fix
*/ public class ExtractWave { + /** * usage: java ExtractWave in_file out_file */ @@ -34,7 +35,7 @@ public static void main(String[] args) throws Exception { is.close(); OutputStream os = new BufferedOutputStream(Files.newOutputStream(Paths.get(args[1]))); -//System.err.println("wave.data: " + data.getWave().length); +//Debug.println("wave.data: " + data.getWave().length); is = new BufferedInputStream(new ByteArrayInputStream(data.getWave())); byte[] buf = new byte[1024]; diff --git a/src/test/java/PlayLine.java b/src/test/java/PlayLine.java index ead2d04..cdea9df 100644 --- a/src/test/java/PlayLine.java +++ b/src/test/java/PlayLine.java @@ -14,6 +14,8 @@ import javax.sound.sampled.LineEvent; import javax.sound.sampled.SourceDataLine; +import vavi.util.Debug; + import static vavi.sound.SoundUtil.volume; @@ -47,7 +49,7 @@ public static void main(String[] args) throws Exception { void play(String filename) throws Exception { AudioInputStream ais = AudioSystem.getAudioInputStream(new File(filename)); AudioFormat format = ais.getFormat(); -System.err.println(format); +Debug.println(format); DataLine.Info info = new DataLine.Info(SourceDataLine.class, format); SourceDataLine line = (SourceDataLine) AudioSystem.getLine(info); line.open(format); diff --git a/src/test/java/PlayPCM.java b/src/test/java/PlayPCM.java index 14c9fd4..4c65bfe 100644 --- a/src/test/java/PlayPCM.java +++ b/src/test/java/PlayPCM.java @@ -54,9 +54,7 @@ public static void main(String[] args) throws Exception { player.play(file, sampleRate, byteOrder); } - /** - * - */ + /** */ void play(File file, int sampleRate, ByteOrder byteOrder) throws Exception { AudioFormat format = new AudioFormat( AudioFormat.Encoding.PCM_SIGNED, diff --git a/src/test/java/PlayPCM2.java b/src/test/java/PlayPCM2.java index b4a9b52..0fabd17 100644 --- a/src/test/java/PlayPCM2.java +++ b/src/test/java/PlayPCM2.java @@ -15,6 +15,8 @@ import javax.sound.sampled.LineEvent; import javax.sound.sampled.SourceDataLine; +import vavi.util.Debug; + import static vavi.sound.SoundUtil.volume; @@ -50,9 +52,7 @@ public static void main(String[] args) throws Exception { player.play(file, sampleRate, byteOrder); } - /** - * - */ + /** */ void play(File file, int sampleRate, ByteOrder byteOrder) throws Exception { AudioFormat format = new AudioFormat( AudioFormat.Encoding.PCM_UNSIGNED, @@ -62,7 +62,7 @@ void play(File file, int sampleRate, ByteOrder byteOrder) throws Exception { 1, sampleRate, ByteOrder.BIG_ENDIAN.equals(byteOrder)); -System.err.println(format); +Debug.println(format); InputStream is = new BufferedInputStream(Files.newInputStream(file.toPath())); diff --git a/src/test/java/PlaySMAF.java b/src/test/java/PlaySMAF.java index 033cb07..c12a353 100644 --- a/src/test/java/PlaySMAF.java +++ b/src/test/java/PlaySMAF.java @@ -16,6 +16,7 @@ import vavi.sound.smaf.Sequencer; import vavi.sound.smaf.SmafSystem; import vavi.sound.smaf.Synthesizer; +import vavi.util.Debug; import vavi.util.properties.annotation.Property; import vavi.util.properties.annotation.PropsEntity; @@ -53,23 +54,23 @@ void exec(String[] args) throws Exception { // sf Soundbank soundbank = synthesizer.getDefaultSoundbank(); //Instrument[] instruments = synthesizer.getAvailableInstruments(); -System.err.println("---- " + soundbank.getDescription() + " ----"); +Debug.println("---- " + soundbank.getDescription() + " ----"); //Arrays.asList(instruments).forEach(System.err::println); synthesizer.unloadAllInstruments(soundbank); File file = new File(sf2); soundbank = MidiSystem.getSoundbank(file); synthesizer.loadAllInstruments(soundbank); //instruments = synthesizer.getAvailableInstruments(); -System.err.println("---- " + soundbank.getDescription() + " ----"); +Debug.println("---- " + soundbank.getDescription() + " ----"); //Arrays.asList(instruments).forEach(System.err::println); // volume (not work ???) MidiChannel[] channels = synthesizer.getChannels(); for (String arg : args) { -System.err.println("START: " + arg); +Debug.println("START: " + arg); CountDownLatch countDownLatch = new CountDownLatch(1); MetaEventListener mel = meta -> { -System.err.println("META: " + meta.getType()); +Debug.println("META: " + meta.getType()); if (meta.getType() == 47) { countDownLatch.countDown(); } @@ -80,7 +81,7 @@ void exec(String[] args) throws Exception { sequencer.start(); MidiUtil.volume(synthesizer.getReceiver(), volume); // TODO noise countDownLatch.await(); -System.err.println("END: " + arg); +Debug.println("END: " + arg); sequencer.removeMetaEventListener(mel); } sequencer.close(); diff --git a/src/test/java/SoundFontTest.java b/src/test/java/SoundFontTest.java index 9238c56..10e06a0 100644 --- a/src/test/java/SoundFontTest.java +++ b/src/test/java/SoundFontTest.java @@ -66,12 +66,12 @@ void exec(File file) throws Exception { soundbank = MidiSystem.getSoundbank(sf2); synthesizer.loadAllInstruments(soundbank); // instruments = synthesizer.getAvailableInstruments(); -System.err.println("---- " + soundbank.getDescription() + " ----"); +Debug.println("---- " + soundbank.getDescription() + " ----"); //Arrays.asList(instruments).forEach(System.err::println); CountDownLatch countDownLatch = new CountDownLatch(1); MetaEventListener mel = meta -> { -System.err.println("META: " + meta.getType()); +Debug.println("META: " + meta.getType()); if (meta.getType() == 47) { countDownLatch.countDown(); } diff --git a/src/test/java/vavi/sound/adpcm/ccitt/G721InputStreamTest.java b/src/test/java/vavi/sound/adpcm/ccitt/G721InputStreamTest.java index 4001c81..4dc430f 100644 --- a/src/test/java/vavi/sound/adpcm/ccitt/G721InputStreamTest.java +++ b/src/test/java/vavi/sound/adpcm/ccitt/G721InputStreamTest.java @@ -49,7 +49,6 @@ public void setup() throws IOException { Debug.println(Level.FINE, "outFile: " + outFile); } - /** */ @Test public void test1() throws Exception { diff --git a/src/test/java/vavi/sound/adpcm/ccitt/G721OutputStreamTest.java b/src/test/java/vavi/sound/adpcm/ccitt/G721OutputStreamTest.java index 7d4eaaa..cadb514 100644 --- a/src/test/java/vavi/sound/adpcm/ccitt/G721OutputStreamTest.java +++ b/src/test/java/vavi/sound/adpcm/ccitt/G721OutputStreamTest.java @@ -43,7 +43,6 @@ public void setup() throws IOException { Debug.println(Level.FINE, "outFile: " + outFile); } - /** */ @Test public void test1() throws Exception { OutputStream os = Files.newOutputStream(outFile.toPath()); diff --git a/src/test/java/vavi/sound/adpcm/dvi/Adpcm.java b/src/test/java/vavi/sound/adpcm/dvi/Adpcm.java index 1d8c4a2..876fa33 100644 --- a/src/test/java/vavi/sound/adpcm/dvi/Adpcm.java +++ b/src/test/java/vavi/sound/adpcm/dvi/Adpcm.java @@ -1,3 +1,26 @@ +/* + * Copyright 1992 by Stichting Mathematisch Centrum, Amsterdam, The + * Netherlands. + * + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the names of Stichting Mathematisch + * Centrum or CWI not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior permission. + * + * STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE + * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + package vavi.sound.adpcm.dvi; import java.io.BufferedInputStream; @@ -10,251 +33,272 @@ import vavi.util.ByteUtil; + +/* + * Intel/DVI ADPCM coder/decoder. + * + * The algorithm for this coder was taken from the IMA Compatibility Project + * proceedings, Vol 2, Number 2; May 1992. + * + * @version 1.2, 18-Dec-92. + * - Fixed a stupid bug, where the delta was computed as + * stepsize*code/4 in stead of stepsize*(code+0.5)/4.
+ * - There was an off-by-one error causing it to pick + * an incorrect delta once in a blue moon.
+ * - The NODIVMUL define has been removed. Computations are now always done + * using shifts, adds and subtracts. It turned out that, because the standard + * is defined using shift/add/subtract, you needed bits of fixup code + * (because the div/mul simulation using shift/add/sub made some rounding + * errors that real div/mul don't make) and all together the resultant code + * ran slower than just using the shifts all the time.
+ * - Changed some of the variable names to be more meaningful.
+ */ public class Adpcm { - public static final int RTP_PT = 5; - - public String codecName() { - return "DVI ADPCM"; - } - - public int getSampleRate() { - return 8000; - } - - private static final int[] indexTable = { - -1, -1, -1, -1, 2, 4, 6, 8, - -1, -1, -1, -1, 2, 4, 6, 8, - }; - - private static final int[] stepsizeTable = { - 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, - 19, 21, 23, 25, 28, 31, 34, 37, 41, 45, - 50, 55, 60, 66, 73, 80, 88, 97, 107, 118, - 130, 143, 157, 173, 190, 209, 230, 253, 279, 307, - 337, 371, 408, 449, 494, 544, 598, 658, 724, 796, - 876, 963, 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066, - 2272, 2499, 2749, 3024, 3327, 3660, 4026, 4428, 4871, 5358, - 5894, 6484, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899, - 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767 - }; - - public static class AdpcmState { - int valprev, index; - } - - public Object createState() { - return new AdpcmState(); - } - - public void initState(Object state) { - ((AdpcmState)state).valprev = 0; - ((AdpcmState)state).index = 0; - } - - public int code(Object state, short[] input, int inp, int len, byte[] output, int outp) { - int sign; - int delta; - int valprev = ((AdpcmState)state).valprev; - int vpdiff; - int index = ((AdpcmState)state).index; - int step = stepsizeTable[index]; - int outputbuffer = 0; - int bufferstep = 1; - - ByteUtil.writeBeShort((short)valprev, output, outp); - output[outp + 2] = (byte)index; - output[outp + 3] = (byte)0; - outp += 4; - - int count = len; - while (--count >= 0) { - - delta = input[inp++] - valprev; - sign = (delta < 0) ? 8 : 0; - if ( 0 != sign ) delta = (-delta); - - int tmp = 0; - vpdiff = step >> 3; - if ( delta > step ) { - tmp = 4; - delta -= step; - vpdiff += step; - } - step >>= 1; - if ( delta > step ) { - tmp |= 2; - delta -= step; - vpdiff += step; - } - step >>= 1; - if ( delta > step ) { - tmp |= 1; - vpdiff += step; - } - delta = tmp; - - if ( 0 != sign ) - valprev -= vpdiff; - else - valprev += vpdiff; - - if ( valprev > 32767 ) - valprev = 32767; - else if ( valprev < -32768 ) - valprev = -32768; - - delta |= sign; - - index += indexTable[delta]; - if ( index < 0 ) index = 0; - if ( index > 88 ) index = 88; - step = stepsizeTable[index]; - - if ( 0 != bufferstep ) { - outputbuffer = (delta << 4) & 0xf0; - } else { - output[outp++] = (byte)((delta & 0x0f) | outputbuffer); - } - bufferstep = (0 == bufferstep) ? 1 : 0; - } - - if ( 0 == bufferstep ) - output[outp++] = (byte)outputbuffer; - - ((AdpcmState)state).valprev = valprev; - ((AdpcmState)state).index = index; - return (len / 2) + 4; - } - - public int decode(Object state, byte[] input, int inp, int len, short[] output, int outp) { - int sign; - int delta; - int vpdiff; - int valprev = ByteUtil.readBeShort(input, inp); - int index = input[inp + 2]; - int inputbuffer = 0; - int bufferstep = 0; - - if ( index < 0 ) index = 0; - else if ( index > 88 ) index = 88; - - int step = stepsizeTable[index]; - - inp += 4; - - len = (len - 4) * 2; - - int count = len; - while(count-- > 0) { - - if ( 0 == bufferstep ) { - inputbuffer = input[inp++]; - delta = (inputbuffer >> 4) & 0xf; - bufferstep = 1; - } else { - delta = inputbuffer & 0xf; - bufferstep = 0; - } - - index += indexTable[delta]; - if ( index < 0 ) index = 0; - else if ( index > 88 ) index = 88; - - sign = delta & 8; - delta = delta & 7; - - vpdiff = step >> 1; - if ( (delta & 4) == 4 ) vpdiff += (step << 2); - if ( (delta & 2) == 2 ) vpdiff += (step << 1); - if ( (delta & 1) == 1 ) vpdiff += step; - vpdiff >>= 2; - - if ( 0 != sign ) - valprev -= vpdiff; - else - valprev += vpdiff; - - if ( valprev > 32767 ) - valprev = 32767; - else if ( valprev < -32768 ) - valprev = -32768; - - step = stepsizeTable[index]; - output[outp++] = (short) valprev; - } - - ((AdpcmState)state).valprev = valprev; - ((AdpcmState)state).index = index; - return len; - } - - /** */ - public static void main(String[] args) throws Exception { - if ("-e".equals(args[2])) { - encode(args); - } else { - decode(args); - } - } - - /** */ - static void encode(String[] args) throws Exception { - Adpcm adpcm = new Adpcm(); - AdpcmState state = new AdpcmState(); - InputStream is = new BufferedInputStream(Files.newInputStream(Paths.get(args[0]))); - OutputStream os = new BufferedOutputStream(Files.newOutputStream(Paths.get(args[1]))); - byte[] buf = new byte[1024]; - while (is.available() > 0) { - int l = 0; - while (l < buf.length) { - int r = is.read(buf, l, buf.length - l); - if (r == -1) { - break; - } - l += r; - } - short[] sbuf = new short[l / 2]; - for (int i = 0; i < sbuf.length; i++) { - sbuf[i] = buf[i * 2]; - sbuf[i] |= buf[i * 2 + 1] << 8; - } - byte[] abuf = new byte[sbuf.length / 2 + 4]; - adpcm.code(state, sbuf, 0, sbuf.length, abuf, 0); - for (int i = 0; i < sbuf.length / 2; i++) { - os.write(abuf[i]); - } - } - os.close(); - is.close(); - } - - /** */ - static void decode(String[] args) throws Exception { - Adpcm adpcm = new Adpcm(); - AdpcmState state = new AdpcmState(); - InputStream is = new BufferedInputStream(Files.newInputStream(Paths.get(args[0]))); - OutputStream os = new BufferedOutputStream(Files.newOutputStream(Paths.get(args[1]))); - byte[] buf = new byte[1024]; - while (is.available() > 0) { - int l = 0; - while (l < buf.length) { - int r = is.read(buf, l, buf.length - l); - if (r == -1) { - os.close(); - is.close(); - throw new EOFException(); - } - l += r; - } - short[] sbuf = new short[l * 2]; - adpcm.decode(state, buf, 0, l, sbuf, 0); - for (short value : sbuf) { - os.write(value & 0x00ff); - os.write((value & 0xff00) >> 8); - } - } - os.close(); - is.close(); - } + public static final int RTP_PT = 5; + + public String codecName() { + return "DVI ADPCM"; + } + + public int getSampleRate() { + return 8000; + } + + private static final int[] indexTable = { + -1, -1, -1, -1, 2, 4, 6, 8, + -1, -1, -1, -1, 2, 4, 6, 8, + }; + + private static final int[] stepsizeTable = { + 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, + 19, 21, 23, 25, 28, 31, 34, 37, 41, 45, + 50, 55, 60, 66, 73, 80, 88, 97, 107, 118, + 130, 143, 157, 173, 190, 209, 230, 253, 279, 307, + 337, 371, 408, 449, 494, 544, 598, 658, 724, 796, + 876, 963, 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066, + 2272, 2499, 2749, 3024, 3327, 3660, 4026, 4428, 4871, 5358, + 5894, 6484, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899, + 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767 + }; + + public static class AdpcmState { + + int valprev, index; + } + + public Object createState() { + return new AdpcmState(); + } + + public void initState(Object state) { + ((AdpcmState) state).valprev = 0; + ((AdpcmState) state).index = 0; + } + + public int code(Object state, short[] input, int inp, int len, byte[] output, int outp) { + int sign; + int delta; + int valprev = ((AdpcmState) state).valprev; + int vpdiff; + int index = ((AdpcmState) state).index; + int step = stepsizeTable[index]; + int outputbuffer = 0; + int bufferstep = 1; + + ByteUtil.writeBeShort((short) valprev, output, outp); + output[outp + 2] = (byte) index; + output[outp + 3] = (byte) 0; + outp += 4; + + int count = len; + while (--count >= 0) { + + delta = input[inp++] - valprev; + sign = (delta < 0) ? 8 : 0; + if (0 != sign) delta = (-delta); + + int tmp = 0; + vpdiff = step >> 3; + if (delta > step) { + tmp = 4; + delta -= step; + vpdiff += step; + } + step >>= 1; + if (delta > step) { + tmp |= 2; + delta -= step; + vpdiff += step; + } + step >>= 1; + if (delta > step) { + tmp |= 1; + vpdiff += step; + } + delta = tmp; + + if (0 != sign) + valprev -= vpdiff; + else + valprev += vpdiff; + + if (valprev > 32767) + valprev = 32767; + else if (valprev < -32768) + valprev = -32768; + + delta |= sign; + + index += indexTable[delta]; + if (index < 0) index = 0; + if (index > 88) index = 88; + step = stepsizeTable[index]; + + if (0 != bufferstep) { + outputbuffer = (delta << 4) & 0xf0; + } else { + output[outp++] = (byte) ((delta & 0x0f) | outputbuffer); + } + bufferstep = (0 == bufferstep) ? 1 : 0; + } + + if (0 == bufferstep) + output[outp++] = (byte) outputbuffer; + + ((AdpcmState) state).valprev = valprev; + ((AdpcmState) state).index = index; + return (len / 2) + 4; + } + + public int decode(Object state, byte[] input, int inp, int len, short[] output, int outp) { + int sign; + int delta; + int vpdiff; + int valprev = ByteUtil.readBeShort(input, inp); + int index = input[inp + 2]; + int inputbuffer = 0; + int bufferstep = 0; + + if (index < 0) index = 0; + else if (index > 88) index = 88; + + int step = stepsizeTable[index]; + + inp += 4; + + len = (len - 4) * 2; + + int count = len; + while (count-- > 0) { + + if (0 == bufferstep) { + inputbuffer = input[inp++]; + delta = (inputbuffer >> 4) & 0xf; + bufferstep = 1; + } else { + delta = inputbuffer & 0xf; + bufferstep = 0; + } + + index += indexTable[delta]; + if (index < 0) index = 0; + else if (index > 88) index = 88; + + sign = delta & 8; + delta = delta & 7; + + vpdiff = step >> 1; + if ((delta & 4) == 4) vpdiff += (step << 2); + if ((delta & 2) == 2) vpdiff += (step << 1); + if ((delta & 1) == 1) vpdiff += step; + vpdiff >>= 2; + + if (0 != sign) + valprev -= vpdiff; + else + valprev += vpdiff; + + if (valprev > 32767) + valprev = 32767; + else if (valprev < -32768) + valprev = -32768; + + step = stepsizeTable[index]; + output[outp++] = (short) valprev; + } + + ((AdpcmState) state).valprev = valprev; + ((AdpcmState) state).index = index; + return len; + } + + /** */ + public static void main(String[] args) throws Exception { + if ("-e".equals(args[2])) { + encode(args); + } else { + decode(args); + } + } + + /** */ + static void encode(String[] args) throws Exception { + Adpcm adpcm = new Adpcm(); + AdpcmState state = new AdpcmState(); + InputStream is = new BufferedInputStream(Files.newInputStream(Paths.get(args[0]))); + OutputStream os = new BufferedOutputStream(Files.newOutputStream(Paths.get(args[1]))); + byte[] buf = new byte[1024]; + while (is.available() > 0) { + int l = 0; + while (l < buf.length) { + int r = is.read(buf, l, buf.length - l); + if (r == -1) { + break; + } + l += r; + } + short[] sbuf = new short[l / 2]; + for (int i = 0; i < sbuf.length; i++) { + sbuf[i] = buf[i * 2]; + sbuf[i] |= buf[i * 2 + 1] << 8; + } + byte[] abuf = new byte[sbuf.length / 2 + 4]; + adpcm.code(state, sbuf, 0, sbuf.length, abuf, 0); + for (int i = 0; i < sbuf.length / 2; i++) { + os.write(abuf[i]); + } + } + os.close(); + is.close(); + } + + /** */ + static void decode(String[] args) throws Exception { + Adpcm adpcm = new Adpcm(); + AdpcmState state = new AdpcmState(); + InputStream is = new BufferedInputStream(Files.newInputStream(Paths.get(args[0]))); + OutputStream os = new BufferedOutputStream(Files.newOutputStream(Paths.get(args[1]))); + byte[] buf = new byte[1024]; + while (is.available() > 0) { + int l = 0; + while (l < buf.length) { + int r = is.read(buf, l, buf.length - l); + if (r == -1) { + os.close(); + is.close(); + throw new EOFException(); + } + l += r; + } + short[] sbuf = new short[l * 2]; + adpcm.decode(state, buf, 0, l, sbuf, 0); + for (short value : sbuf) { + os.write(value & 0x00ff); + os.write((value & 0xff00) >> 8); + } + } + os.close(); + is.close(); + } } diff --git a/src/test/java/vavi/sound/adpcm/dvi/DviInputStreamTest.java b/src/test/java/vavi/sound/adpcm/dvi/DviInputStreamTest.java index 90a7a7f..3e73338 100644 --- a/src/test/java/vavi/sound/adpcm/dvi/DviInputStreamTest.java +++ b/src/test/java/vavi/sound/adpcm/dvi/DviInputStreamTest.java @@ -49,7 +49,6 @@ public void setup() throws IOException { Debug.println(Level.FINE, "outFile: " + outFile); } - /** */ @Test public void test1() throws Exception { diff --git a/src/test/java/vavi/sound/adpcm/ima/ImaInputStreamTest.java b/src/test/java/vavi/sound/adpcm/ima/ImaInputStreamTest.java index b157f43..8291d1d 100644 --- a/src/test/java/vavi/sound/adpcm/ima/ImaInputStreamTest.java +++ b/src/test/java/vavi/sound/adpcm/ima/ImaInputStreamTest.java @@ -80,7 +80,7 @@ public void test1() throws Exception { in = new ByteArrayInputStream(data.getWave()); Debug.println(Level.FINE, "wave: " + in.available()); - //---- + // ---- int sampleRate = format.getSamplingRate(); ByteOrder byteOrder = ByteOrder.LITTLE_ENDIAN; diff --git a/src/test/java/vavi/sound/adpcm/ima/ImaOutputStreamTest.java b/src/test/java/vavi/sound/adpcm/ima/ImaOutputStreamTest.java index aecdec9..2b8f0d3 100644 --- a/src/test/java/vavi/sound/adpcm/ima/ImaOutputStreamTest.java +++ b/src/test/java/vavi/sound/adpcm/ima/ImaOutputStreamTest.java @@ -58,7 +58,6 @@ public void setup() throws IOException { Debug.println(Level.FINE, "outFile: " + outFile.getCanonicalPath()); } - /** */ @Test public void test1() throws Exception { OutputStream os = new BufferedOutputStream(Files.newOutputStream(outFile.toPath())); @@ -181,7 +180,6 @@ public void test2() throws Exception { assertEquals(Checksum.getChecksum(getClass().getResourceAsStream(inFile)), Checksum.getChecksum(outFile)); } - /** */ @Test public void test3() throws Exception { final String inFile = "out.pcm"; diff --git a/src/test/java/vavi/sound/adpcm/ma/MaInputStreamTest.java b/src/test/java/vavi/sound/adpcm/ma/MaInputStreamTest.java index 80778f4..cebe48f 100644 --- a/src/test/java/vavi/sound/adpcm/ma/MaInputStreamTest.java +++ b/src/test/java/vavi/sound/adpcm/ma/MaInputStreamTest.java @@ -51,13 +51,12 @@ public void setup() throws IOException { Debug.println(Level.FINE, "outFile: " + outFile); } - /** */ @Test public void test1() throws Exception { InputStream in = new BufferedInputStream(getClass().getResourceAsStream(inFile)); - //---- + // ---- int sampleRate = 8000; ByteOrder byteOrder = ByteOrder.LITTLE_ENDIAN; diff --git a/src/test/java/vavi/sound/adpcm/ma/MaOutputStreamTest.java b/src/test/java/vavi/sound/adpcm/ma/MaOutputStreamTest.java index 479c665..c1211cc 100644 --- a/src/test/java/vavi/sound/adpcm/ma/MaOutputStreamTest.java +++ b/src/test/java/vavi/sound/adpcm/ma/MaOutputStreamTest.java @@ -43,7 +43,6 @@ public void setup() throws IOException { Debug.println(Level.FINE, "outFile: " + outFile); } - /** */ @Test public void test1() throws Exception { OutputStream os = Files.newOutputStream(outFile.toPath()); diff --git a/src/test/java/vavi/sound/adpcm/ms/MsInputStreamTest.java b/src/test/java/vavi/sound/adpcm/ms/MsInputStreamTest.java index b6d7a54..26f0f05 100644 --- a/src/test/java/vavi/sound/adpcm/ms/MsInputStreamTest.java +++ b/src/test/java/vavi/sound/adpcm/ms/MsInputStreamTest.java @@ -91,7 +91,7 @@ public void test1() throws Exception { in = new ByteArrayInputStream(data.getWave()); Debug.println(Level.FINE, "wave: " + in.available()); - //---- + // ---- int sampleRate = format.getSamplingRate(); ByteOrder byteOrder = ByteOrder.LITTLE_ENDIAN; diff --git a/src/test/java/vavi/sound/adpcm/ms/MsOutputStreamTest.java b/src/test/java/vavi/sound/adpcm/ms/MsOutputStreamTest.java index 245b2ea..95d4f6c 100644 --- a/src/test/java/vavi/sound/adpcm/ms/MsOutputStreamTest.java +++ b/src/test/java/vavi/sound/adpcm/ms/MsOutputStreamTest.java @@ -54,7 +54,6 @@ public void setup() throws IOException { Debug.println(Level.FINE, "outFile: " + outFile); } - /** */ @Test public void test1() throws Exception { OutputStream os = Files.newOutputStream(outFile.toPath()); @@ -77,7 +76,6 @@ public void test1() throws Exception { assertEquals(Checksum.getChecksum(getClass().getResourceAsStream(correctFile)), Checksum.getChecksum(outFile)); } - /** */ @Test public void test2() throws Exception { InputStream is = new BufferedInputStream(getClass().getResourceAsStream(inFile)); @@ -86,7 +84,7 @@ public void test2() throws Exception { byte[] buffer = new byte[500 * 2]; while (true) { int amount = is.read(buffer); -//System.err.println("amount: " + amount); +//Debug.println("amount: " + amount); if (amount < 0) { break; } @@ -100,8 +98,6 @@ public void test2() throws Exception { assertEquals(Checksum.getChecksum(getClass().getResourceAsStream(correctFile)), Checksum.getChecksum(outFile)); } - /** - */ @Test public void test3() throws Exception { // final String inFile = "out.pcm"; diff --git a/src/test/java/vavi/sound/adpcm/oki/OkiInputStreamTest.java b/src/test/java/vavi/sound/adpcm/oki/OkiInputStreamTest.java index 1e42db1..9fa6e17 100644 --- a/src/test/java/vavi/sound/adpcm/oki/OkiInputStreamTest.java +++ b/src/test/java/vavi/sound/adpcm/oki/OkiInputStreamTest.java @@ -49,7 +49,6 @@ public void setup() throws IOException { Debug.println(Level.FINE, "outFile: " + outFile); } - /** */ @Test public void test1() throws Exception { diff --git a/src/test/java/vavi/sound/adpcm/oki/OkiOutputStreamTest.java b/src/test/java/vavi/sound/adpcm/oki/OkiOutputStreamTest.java index b94aad7..ffe9e84 100644 --- a/src/test/java/vavi/sound/adpcm/oki/OkiOutputStreamTest.java +++ b/src/test/java/vavi/sound/adpcm/oki/OkiOutputStreamTest.java @@ -43,7 +43,6 @@ public void setup() throws IOException { Debug.println(Level.FINE, "outFile: " + outFile); } - /** */ @Test public void test1() throws Exception { OutputStream os = Files.newOutputStream(outFile.toPath()); diff --git a/src/test/java/vavi/sound/adpcm/rohm/RohmInputStreamTest.java b/src/test/java/vavi/sound/adpcm/rohm/RohmInputStreamTest.java index 81c0465..0d5862d 100644 --- a/src/test/java/vavi/sound/adpcm/rohm/RohmInputStreamTest.java +++ b/src/test/java/vavi/sound/adpcm/rohm/RohmInputStreamTest.java @@ -51,13 +51,12 @@ public void setup() throws IOException { Debug.println(Level.FINE, "outFile: " + outFile); } - /** */ @Test public void test1() throws Exception { InputStream in = new BufferedInputStream(getClass().getResourceAsStream(inFile)); - //---- + // ---- int sampleRate = 8000; ByteOrder byteOrder = ByteOrder.LITTLE_ENDIAN; diff --git a/src/test/java/vavi/sound/adpcm/rohm/RohmOutputStreamTest.java b/src/test/java/vavi/sound/adpcm/rohm/RohmOutputStreamTest.java index 6ddbe8c..a48a580 100644 --- a/src/test/java/vavi/sound/adpcm/rohm/RohmOutputStreamTest.java +++ b/src/test/java/vavi/sound/adpcm/rohm/RohmOutputStreamTest.java @@ -43,7 +43,6 @@ public void setup() throws IOException { Debug.println(Level.FINE, "outFile: " + outFile); } - /** */ @Test public void test1() throws Exception { OutputStream os = Files.newOutputStream(outFile.toPath()); diff --git a/src/test/java/vavi/sound/adpcm/vox/VoxInputStreamTest.java b/src/test/java/vavi/sound/adpcm/vox/VoxInputStreamTest.java index a36f68e..6e8e135 100644 --- a/src/test/java/vavi/sound/adpcm/vox/VoxInputStreamTest.java +++ b/src/test/java/vavi/sound/adpcm/vox/VoxInputStreamTest.java @@ -51,7 +51,6 @@ public void setup() throws IOException { Debug.println(Level.FINE, "outFile: " + outFile); } - /** */ @Test public void test1() throws Exception { @@ -95,7 +94,7 @@ public void test1() throws Exception { assertEquals(Checksum.getChecksum(getClass().getResourceAsStream(correctFile)), Checksum.getChecksum(outFile)); } - //------------------------------------------------------------------------- + // ---- /** */ public static void main(String[] args) throws Exception { @@ -113,12 +112,10 @@ public static void main(String[] args) throws Exception { byteOrder.equals(ByteOrder.BIG_ENDIAN)); System.err.println(audioFormat); - InputStream is = new VoxInputStream(Files.newInputStream(Paths.get(args[0])), - byteOrder); + InputStream is = new VoxInputStream(Files.newInputStream(Paths.get(args[0])), byteOrder); System.err.println("available: " + is.available()); -// OutputStream os = -// new BufferedOutputStream(new FileOutputStream(args[1])); +//OutputStream os = new BufferedOutputStream(new FileOutputStream(args[1])); DataLine.Info info = new DataLine.Info(SourceDataLine.class, audioFormat); SourceDataLine line = (SourceDataLine) AudioSystem.getLine(info); @@ -136,12 +133,12 @@ public static void main(String[] args) throws Exception { while (is.available() > 0) { l = is.read(buf, 0, 1024); line.write(buf, 0, l); -// os.write(buf, 0, l); +//os.write(buf, 0, l); } line.drain(); line.stop(); line.close(); -// os.close(); +//os.close(); is.close(); } } diff --git a/src/test/java/vavi/sound/adpcm/vox/VoxOutputStreamTest.java b/src/test/java/vavi/sound/adpcm/vox/VoxOutputStreamTest.java index f69fec3..2b16f66 100644 --- a/src/test/java/vavi/sound/adpcm/vox/VoxOutputStreamTest.java +++ b/src/test/java/vavi/sound/adpcm/vox/VoxOutputStreamTest.java @@ -43,7 +43,6 @@ public void setup() throws IOException { Debug.println(Level.FINE, "outFile: " + outFile); } - /** */ @Test public void test1() throws Exception { OutputStream os = Files.newOutputStream(outFile.toPath()); diff --git a/src/test/java/vavi/sound/adpcm/yamaha/YamahaInputStreamTest.java b/src/test/java/vavi/sound/adpcm/yamaha/YamahaInputStreamTest.java index b2520d3..6e61d93 100644 --- a/src/test/java/vavi/sound/adpcm/yamaha/YamahaInputStreamTest.java +++ b/src/test/java/vavi/sound/adpcm/yamaha/YamahaInputStreamTest.java @@ -54,7 +54,6 @@ public void setup() throws IOException { Debug.println(Level.FINE, "outFile: " + outFile); } - /** */ @Test public void test1() throws Exception { @@ -112,7 +111,7 @@ public static void main(String[] args) throws Exception { in = new ByteArrayInputStream(data.getWave()); Debug.println(Level.FINE, "wave: " + in.available()); - //---- + // ---- int sampleRate = format.getSamplingRate(); ByteOrder byteOrder = ByteOrder.LITTLE_ENDIAN; diff --git a/src/test/java/vavi/sound/adpcm/yamaha/YamahaOutputStreamTest.java b/src/test/java/vavi/sound/adpcm/yamaha/YamahaOutputStreamTest.java index 85d06dc..67c5720 100644 --- a/src/test/java/vavi/sound/adpcm/yamaha/YamahaOutputStreamTest.java +++ b/src/test/java/vavi/sound/adpcm/yamaha/YamahaOutputStreamTest.java @@ -49,7 +49,6 @@ public void setup() throws IOException { Debug.println(Level.FINE, "outFile: " + outFile); } - /** */ @Test public void test1() throws Exception { OutputStream os = Files.newOutputStream(outFile.toPath()); @@ -70,7 +69,7 @@ public void test1() throws Exception { assertEquals(Checksum.getChecksum(getClass().getResourceAsStream(correctFile)), Checksum.getChecksum(outFile)); } - // ------------------------------------------------------------------------- + // ---- /** * Input Linear PCM WAV must be 8000Hz, 16bit, mono. diff --git a/src/test/java/vavi/sound/mfi/MfiSystemTest.java b/src/test/java/vavi/sound/mfi/MfiSystemTest.java index 2e7aaab..75dc4f4 100644 --- a/src/test/java/vavi/sound/mfi/MfiSystemTest.java +++ b/src/test/java/vavi/sound/mfi/MfiSystemTest.java @@ -51,7 +51,7 @@ public void test() throws Exception { sequencer.close(); } - //------------------------------------------------------------------------- + // ---- /** * Tests this class. diff --git a/src/test/java/vavi/sound/mfi/vavi/MfiContextTest.java b/src/test/java/vavi/sound/mfi/vavi/MfiContextTest.java index 17a3c18..7b4747c 100644 --- a/src/test/java/vavi/sound/mfi/vavi/MfiContextTest.java +++ b/src/test/java/vavi/sound/mfi/vavi/MfiContextTest.java @@ -54,7 +54,7 @@ public void test() throws Exception { Debug.println(Level.FINE, "write: " + r); } - //------------------------------------------------------------------------- + // ---- /** * Converts the midi file to a mfi file. diff --git a/src/test/java/vavi/sound/mfi/vavi/VaviMfiFileWriterTest.java b/src/test/java/vavi/sound/mfi/vavi/VaviMfiFileWriterTest.java index 1ce6d4e..749e57a 100644 --- a/src/test/java/vavi/sound/mfi/vavi/VaviMfiFileWriterTest.java +++ b/src/test/java/vavi/sound/mfi/vavi/VaviMfiFileWriterTest.java @@ -81,7 +81,7 @@ public void test1() throws Exception { double time = (double) data.getWave().length / bytesPerSecond * 1000; Debug.println(Level.FINE, "time: " + time + " ms"); - //---- + // ---- Sequence sequence = new Sequence(); Track track = sequence.createTrack(); diff --git a/src/test/java/vavi/sound/mfi/vavi/VaviMidiConverterTest.java b/src/test/java/vavi/sound/mfi/vavi/VaviMidiConverterTest.java index 6ed278b..0ef1491 100644 --- a/src/test/java/vavi/sound/mfi/vavi/VaviMidiConverterTest.java +++ b/src/test/java/vavi/sound/mfi/vavi/VaviMidiConverterTest.java @@ -61,7 +61,7 @@ public void test() throws Exception { midiSequencer.close(); } - //------------------------------------------------------------------------- + // ---- /** * Tests this class. diff --git a/src/test/java/vavi/sound/midi/MidiUtilTest.java b/src/test/java/vavi/sound/midi/MidiUtilTest.java index 3cfc7db..629b42b 100644 --- a/src/test/java/vavi/sound/midi/MidiUtilTest.java +++ b/src/test/java/vavi/sound/midi/MidiUtilTest.java @@ -37,32 +37,32 @@ public class MidiUtilTest { * ---------------+---------------------------- * 00000000 | 00 * 00000040 | 40 - * 0000007F | 7F + * 0000007f | 7f * 00000080 | 81 00 - * 00002000 | C0 00 - * 00003FFF | FF 7F + * 00002000 | c0 00 + * 00003fff | ff 7f * 00004000 | 81 80 00 - * 00100000 | C0 80 00 - * 001FFFFF | FF FF 7F + * 00100000 | c0 80 00 + * 001fffff | ff ff 7f * 00200000 | 81 80 80 00 - * 08000000 | C0 80 80 00 - * 0FFFFFFF | FF FF FF 7F + * 08000000 | c0 80 80 00 + * 0fffffff | ff ff ff 7f * */ @Test public void testReadOneToFour() throws Exception { - assertEquals(0x00000000, MidiUtil.readVariableLength(new DataInputStream(new ByteArrayInputStream(new byte[] { 0x00 })))); - assertEquals(0x00000040, MidiUtil.readVariableLength(new DataInputStream(new ByteArrayInputStream(new byte[] { 0x40 })))); - assertEquals(0x0000007F, MidiUtil.readVariableLength(new DataInputStream(new ByteArrayInputStream(new byte[] { 0x7F })))); - assertEquals(0x00000080, MidiUtil.readVariableLength(new DataInputStream(new ByteArrayInputStream(new byte[] { (byte) 0x81, 0x00 })))); - assertEquals(0x00002000, MidiUtil.readVariableLength(new DataInputStream(new ByteArrayInputStream(new byte[] { (byte) 0xC0, 0x00 })))); - assertEquals(0x00003FFF, MidiUtil.readVariableLength(new DataInputStream(new ByteArrayInputStream(new byte[] { (byte) 0xFF, 0x7F })))); - assertEquals(0x00004000, MidiUtil.readVariableLength(new DataInputStream(new ByteArrayInputStream(new byte[] { (byte) 0x81, (byte) 0x80, 0x00 })))); - assertEquals(0x00100000, MidiUtil.readVariableLength(new DataInputStream(new ByteArrayInputStream(new byte[] { (byte) 0xC0, (byte) 0x80, 0x00 })))); - assertEquals(0x001FFFFF, MidiUtil.readVariableLength(new DataInputStream(new ByteArrayInputStream(new byte[] { (byte) 0xFF, (byte) 0xFF, 0x7F })))); - assertEquals(0x00200000, MidiUtil.readVariableLength(new DataInputStream(new ByteArrayInputStream(new byte[] { (byte) 0x81, (byte) 0x80, (byte) 0x80, 0x00 })))); - assertEquals(0x08000000, MidiUtil.readVariableLength(new DataInputStream(new ByteArrayInputStream(new byte[] { (byte) 0xC0, (byte) 0x80, (byte) 0x80, 0x00 })))); - assertEquals(0x0FFFFFFF, MidiUtil.readVariableLength(new DataInputStream(new ByteArrayInputStream(new byte[] { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, 0x7F })))); + assertEquals(0x0000_0000, MidiUtil.readVariableLength(new DataInputStream(new ByteArrayInputStream(new byte[] { 0x00 })))); + assertEquals(0x0000_0040, MidiUtil.readVariableLength(new DataInputStream(new ByteArrayInputStream(new byte[] { 0x40 })))); + assertEquals(0x0000_007f, MidiUtil.readVariableLength(new DataInputStream(new ByteArrayInputStream(new byte[] { 0x7f })))); + assertEquals(0x0000_0080, MidiUtil.readVariableLength(new DataInputStream(new ByteArrayInputStream(new byte[] { (byte) 0x81, 0x00 })))); + assertEquals(0x0000_2000, MidiUtil.readVariableLength(new DataInputStream(new ByteArrayInputStream(new byte[] { (byte) 0xc0, 0x00 })))); + assertEquals(0x0000_3fff, MidiUtil.readVariableLength(new DataInputStream(new ByteArrayInputStream(new byte[] { (byte) 0xff, 0x7f })))); + assertEquals(0x0000_4000, MidiUtil.readVariableLength(new DataInputStream(new ByteArrayInputStream(new byte[] { (byte) 0x81, (byte) 0x80, 0x00 })))); + assertEquals(0x0010_0000, MidiUtil.readVariableLength(new DataInputStream(new ByteArrayInputStream(new byte[] { (byte) 0xc0, (byte) 0x80, 0x00 })))); + assertEquals(0x001f_ffff, MidiUtil.readVariableLength(new DataInputStream(new ByteArrayInputStream(new byte[] { (byte) 0xff, (byte) 0xff, 0x7f })))); + assertEquals(0x0020_0000, MidiUtil.readVariableLength(new DataInputStream(new ByteArrayInputStream(new byte[] { (byte) 0x81, (byte) 0x80, (byte) 0x80, 0x00 })))); + assertEquals(0x0800_0000, MidiUtil.readVariableLength(new DataInputStream(new ByteArrayInputStream(new byte[] { (byte) 0xc0, (byte) 0x80, (byte) 0x80, 0x00 })))); + assertEquals(0x0fff_ffff, MidiUtil.readVariableLength(new DataInputStream(new ByteArrayInputStream(new byte[] { (byte) 0xff, (byte) 0xff, (byte) 0xff, 0x7f })))); } /** diff --git a/src/test/java/vavi/sound/midi/mfi/MfiMidiFileReaderTest.java b/src/test/java/vavi/sound/midi/mfi/MfiMidiFileReaderTest.java index d23bd64..a72bada 100644 --- a/src/test/java/vavi/sound/midi/mfi/MfiMidiFileReaderTest.java +++ b/src/test/java/vavi/sound/midi/mfi/MfiMidiFileReaderTest.java @@ -52,7 +52,7 @@ public void test() throws Exception { sequencer.close(); } - //---- + // ---- /** * Play MFi file. diff --git a/src/test/java/vavi/sound/midi/mfi/MfiVaviSequenceTest.java b/src/test/java/vavi/sound/midi/mfi/MfiVaviSequenceTest.java index 72c7012..f700844 100644 --- a/src/test/java/vavi/sound/midi/mfi/MfiVaviSequenceTest.java +++ b/src/test/java/vavi/sound/midi/mfi/MfiVaviSequenceTest.java @@ -56,7 +56,7 @@ public void test4() throws Exception { assertNotNull(format); } - //---- + // ---- /** load MFi */ public static void main(String[] args) throws Exception { diff --git a/src/test/java/vavi/sound/midi/smaf/SmafVaviSequenceTest.java b/src/test/java/vavi/sound/midi/smaf/SmafVaviSequenceTest.java index 788e698..e1c4fe0 100644 --- a/src/test/java/vavi/sound/midi/smaf/SmafVaviSequenceTest.java +++ b/src/test/java/vavi/sound/midi/smaf/SmafVaviSequenceTest.java @@ -56,7 +56,7 @@ public void test4() throws Exception { assertNotNull(mff); } - //---- + // ---- /** load smaf */ public static void main(String[] args) throws Exception { diff --git a/src/test/java/vavi/sound/mobile/BasicAudioEngineTest.java b/src/test/java/vavi/sound/mobile/BasicAudioEngineTest.java index 8cda5c4..da6b26e 100644 --- a/src/test/java/vavi/sound/mobile/BasicAudioEngineTest.java +++ b/src/test/java/vavi/sound/mobile/BasicAudioEngineTest.java @@ -54,7 +54,7 @@ public void test() throws Exception { sequencer.close(); } - //------------------------------------------------------------------------- + // ---- /** */ private static String fileName; diff --git a/src/test/java/vavi/sound/sampled/mfi/MfiAudioFileWriterTest.java b/src/test/java/vavi/sound/sampled/mfi/MfiAudioFileWriterTest.java index 55fa55b..f1946b8 100644 --- a/src/test/java/vavi/sound/sampled/mfi/MfiAudioFileWriterTest.java +++ b/src/test/java/vavi/sound/sampled/mfi/MfiAudioFileWriterTest.java @@ -60,7 +60,7 @@ public void test() throws Exception { AudioSystem.write(ais, new MFi(properties), new File(nullDevice)); } - //---- + // ---- /** * @param args 0: input PCM, 1: output base dir, 2: length in seconds, 3: base file name, 4: type, 5: null device diff --git a/src/test/java/vavi/sound/sampled/smaf/SmafAudioFileWriterTest.java b/src/test/java/vavi/sound/sampled/smaf/SmafAudioFileWriterTest.java index d5261b6..5233424 100644 --- a/src/test/java/vavi/sound/sampled/smaf/SmafAudioFileWriterTest.java +++ b/src/test/java/vavi/sound/sampled/smaf/SmafAudioFileWriterTest.java @@ -80,7 +80,7 @@ public void test1() throws Exception { ais.close(); } - //---- + // ---- /** * @param args 0: input PCM, 1: output base dir, 2: length in seconds, 3: base file name, 4: type, 5: null device diff --git a/src/test/java/vavi/sound/smaf/SmafFileFormatTest.java b/src/test/java/vavi/sound/smaf/SmafFileFormatTest.java index d03d176..a5fb65b 100644 --- a/src/test/java/vavi/sound/smaf/SmafFileFormatTest.java +++ b/src/test/java/vavi/sound/smaf/SmafFileFormatTest.java @@ -24,12 +24,12 @@ public class SmafFileFormatTest { @Test - public void test() throws Exception, IOException { + public void test() throws Exception { Path path = Paths.get(SmafFileFormatTest.class.getResource("/test.mmf").toURI()); SmafSystem.getSmafFileFormat(new BufferedInputStream(Files.newInputStream(path))); } - //---- + // ---- /** * load only diff --git a/src/test/java/vavi/sound/smaf/SmafSystemTest.java b/src/test/java/vavi/sound/smaf/SmafSystemTest.java index 49acb8e..3f558da 100644 --- a/src/test/java/vavi/sound/smaf/SmafSystemTest.java +++ b/src/test/java/vavi/sound/smaf/SmafSystemTest.java @@ -51,7 +51,7 @@ public void test() throws Exception { sequencer.close(); } - //---- + // ---- /** * Tests this class. diff --git a/src/test/java/vavi/sound/smaf/message/SmafContextTest.java b/src/test/java/vavi/sound/smaf/message/SmafContextTest.java index 0f744b0..187ebb1 100644 --- a/src/test/java/vavi/sound/smaf/message/SmafContextTest.java +++ b/src/test/java/vavi/sound/smaf/message/SmafContextTest.java @@ -55,7 +55,7 @@ public void test() throws Exception { Debug.println(Level.FINE, "write: " + r); } - //------------------------------------------------------------------------- + // ---- /** * Converts the midi file to a smaf file. From 9f8c2e285c21eadfb8a79332e80cc6be80a9c260 Mon Sep 17 00:00:00 2001 From: Naohide Sano Date: Wed, 27 Nov 2024 20:08:53 +0900 Subject: [PATCH 5/8] make tests more effective --- src/test/java/PlayLine.java | 16 ++++++- src/test/java/PlayMFi.java | 13 ++++- src/test/java/PlayPCM.java | 15 +++++- src/test/java/PlayPCM2.java | 15 +++++- src/test/java/PlaySMAF.java | 13 ++++- src/test/java/SoundFontTest.java | 13 ++++- .../adpcm/ccitt/G721InputStreamTest.java | 15 +++++- .../sound/adpcm/dvi/DviInputStreamTest.java | 15 +++++- .../sound/adpcm/ima/ImaInputStreamTest.java | 15 +++++- .../sound/adpcm/ima/ImaOutputStreamTest.java | 14 +++++- .../sound/adpcm/ma/MaInputStreamTest.java | 15 +++++- .../sound/adpcm/ms/MsInputStreamTest.java | 15 +++++- .../sound/adpcm/ms/MsOutputStreamTest.java | 15 +++++- .../sound/adpcm/oki/OkiInputStreamTest.java | 15 +++++- .../sound/adpcm/rohm/RohmInputStreamTest.java | 15 +++++- .../sound/adpcm/vox/VoxInputStreamTest.java | 14 +++++- .../adpcm/yamaha/YamahaInputStreamTest.java | 14 +++++- .../adpcm/ym2608/Ym2608InputStreamTest.java | 15 +++++- .../sound/midi/mfi/MfiMidiFileReaderTest.java | 48 ++++++++++++------- .../sound/pcm/resampling/ssrc/SSRCTest.java | 4 +- .../ccitt/G721RawAudioFileReaderTest.java | 15 +++++- .../adpcm/dvi/DviRawAudioFileReaderTest.java | 15 +++++- .../adpcm/ima/ImaWaveAudioFileReaderTest.java | 15 +++++- .../adpcm/ma/MaRawAudioFileReaderTest.java | 15 +++++- .../adpcm/ms/MsWaveAudioFileReaderTest.java | 14 +++++- .../adpcm/oki/OkiRawAudioFileReaderTest.java | 15 +++++- .../rhom/RohmRawAudioFileReaderTest.java | 15 +++++- .../adpcm/vox/VoxRawAudioFileReaderTest.java | 15 +++++- .../yamaha/YamahaRawAudioFileReaderTest.java | 15 +++++- 29 files changed, 397 insertions(+), 51 deletions(-) diff --git a/src/test/java/PlayLine.java b/src/test/java/PlayLine.java index cdea9df..f13f2dd 100644 --- a/src/test/java/PlayLine.java +++ b/src/test/java/PlayLine.java @@ -5,6 +5,8 @@ */ import java.io.File; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.AudioFileFormat; import javax.sound.sampled.AudioFormat; @@ -15,6 +17,8 @@ import javax.sound.sampled.SourceDataLine; import vavi.util.Debug; +import vavi.util.properties.annotation.Property; +import vavi.util.properties.annotation.PropsEntity; import static vavi.sound.SoundUtil.volume; @@ -25,21 +29,29 @@ * @author Naohide Sano (nsano) * @version 0.00 030711 nsano initial version
*/ +@PropsEntity(url = "file:local.properties") public class PlayLine { - static final double volume = Double.parseDouble(System.getProperty("vavi.test.volume", "0.2")); + static boolean localPropertiesExists() { + return Files.exists(Paths.get("local.properties")); + } + + @Property(name = "vavi.test.volume") + float volume = 0.2f; /** * usage: java PlayLine file ... */ public static void main(String[] args) throws Exception { - for (AudioFileFormat.Type type : AudioSystem.getAudioFileTypes()) { System.err.println(type); } // play PlayLine player = new PlayLine(); + if (localPropertiesExists()) { + PropsEntity.Util.bind(player); + } for (String arg : args) { player.play(arg); } diff --git a/src/test/java/PlayMFi.java b/src/test/java/PlayMFi.java index ba3686e..73307f7 100644 --- a/src/test/java/PlayMFi.java +++ b/src/test/java/PlayMFi.java @@ -5,6 +5,8 @@ */ import java.io.File; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.concurrent.CountDownLatch; import javax.sound.midi.MidiSystem; @@ -29,17 +31,24 @@ @PropsEntity(url = "file:local.properties") public class PlayMFi { + static boolean localPropertiesExists() { + return Files.exists(Paths.get("local.properties")); + } + /** * * @param args mfi files ... */ public static void main(String[] args) throws Exception { PlayMFi app = new PlayMFi(); - PropsEntity.Util.bind(app); + if (localPropertiesExists()) { + PropsEntity.Util.bind(app); + } app.exec(args); } - static final float volume = Float.parseFloat(System.getProperty("vavi.test.volume", "0.2")); + @Property(name = "vavi.test.volume") + float volume = 0.2f; @Property(name = "sf2") String sf2 = System.getProperty("user.home") + "/Library/Audio/Sounds/Banks/Orchestra/default.sf2"; diff --git a/src/test/java/PlayPCM.java b/src/test/java/PlayPCM.java index 4c65bfe..26b4422 100644 --- a/src/test/java/PlayPCM.java +++ b/src/test/java/PlayPCM.java @@ -9,12 +9,16 @@ import java.io.InputStream; import java.nio.ByteOrder; import java.nio.file.Files; +import java.nio.file.Paths; 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 vavi.util.properties.annotation.Property; +import vavi.util.properties.annotation.PropsEntity; + import static vavi.sound.SoundUtil.volume; @@ -24,9 +28,15 @@ * @author Naohide Sano (nsano) * @version 0.00 030714 nsano initial version
*/ +@PropsEntity(url = "file:local.properties") public class PlayPCM { - static final double volume = Double.parseDouble(System.getProperty("vavi.test.volume", "0.2")); + static boolean localPropertiesExists() { + return Files.exists(Paths.get("local.properties")); + } + + @Property(name = "vavi.test.volume") + float volume = 0.2f; /** * usage: java PlayPCM pcm_file [sampleRate] [byteOrder(le,be)] @@ -51,6 +61,9 @@ public static void main(String[] args) throws Exception { } PlayPCM player = new PlayPCM(); + if (localPropertiesExists()) { + PropsEntity.Util.bind(player); + } player.play(file, sampleRate, byteOrder); } diff --git a/src/test/java/PlayPCM2.java b/src/test/java/PlayPCM2.java index 0fabd17..fb65843 100644 --- a/src/test/java/PlayPCM2.java +++ b/src/test/java/PlayPCM2.java @@ -9,6 +9,7 @@ import java.io.InputStream; import java.nio.ByteOrder; import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioSystem; import javax.sound.sampled.DataLine; @@ -16,6 +17,8 @@ import javax.sound.sampled.SourceDataLine; import vavi.util.Debug; +import vavi.util.properties.annotation.Property; +import vavi.util.properties.annotation.PropsEntity; import static vavi.sound.SoundUtil.volume; @@ -30,9 +33,15 @@ * @author Naohide Sano (nsano) * @version 0.00 030714 nsano initial version
*/ +@PropsEntity(url = "file:local.properties") public class PlayPCM2 { - static final double volume = Double.parseDouble(System.getProperty("vavi.test.volume", "0.2")); + static boolean localPropertiesExists() { + return Files.exists(Paths.get("local.properties")); + } + + @Property(name = "vavi.test.volume") + float volume = 0.2f; /** * usage: java PlayPCM2 pcm_file @@ -47,8 +56,10 @@ public static void main(String[] args) throws Exception { ByteOrder byteOrder = ByteOrder.BIG_ENDIAN; // 2 - PlayPCM2 player = new PlayPCM2(); + if (localPropertiesExists()) { + PropsEntity.Util.bind(player); + } player.play(file, sampleRate, byteOrder); } diff --git a/src/test/java/PlaySMAF.java b/src/test/java/PlaySMAF.java index c12a353..47cae0a 100644 --- a/src/test/java/PlaySMAF.java +++ b/src/test/java/PlaySMAF.java @@ -5,6 +5,8 @@ */ import java.io.File; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.concurrent.CountDownLatch; import javax.sound.midi.MidiChannel; import javax.sound.midi.MidiSystem; @@ -30,17 +32,24 @@ @PropsEntity(url = "file:local.properties") public class PlaySMAF { + static boolean localPropertiesExists() { + return Files.exists(Paths.get("local.properties")); + } + /** * * @param args smaf files ... */ public static void main(String[] args) throws Exception { PlaySMAF app = new PlaySMAF(); - PropsEntity.Util.bind(app); + if (localPropertiesExists()) { + PropsEntity.Util.bind(app); + } app.exec(args); } - static final float volume = Float.parseFloat(System.getProperty("vavi.test.volume", "0.2")); + @Property(name = "vavi.test.volume") + float volume = 0.2f; @Property(name = "sf2") String sf2 = System.getProperty("user.home") + "/Library/Audio/Sounds/Banks/Orchestra/default.sf2"; diff --git a/src/test/java/SoundFontTest.java b/src/test/java/SoundFontTest.java index 10e06a0..d159773 100644 --- a/src/test/java/SoundFontTest.java +++ b/src/test/java/SoundFontTest.java @@ -6,6 +6,8 @@ import java.io.File; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.concurrent.CountDownLatch; import java.util.logging.Level; import javax.sound.midi.MetaEventListener; @@ -31,6 +33,10 @@ @PropsEntity(url = "file:local.properties") public class SoundFontTest { + static boolean localPropertiesExists() { + return Files.exists(Paths.get("local.properties")); + } + /** * @param args 0: midi */ @@ -38,11 +44,14 @@ public static void main(String[] args) throws Exception { File file = new File(args[0]); SoundFontTest app = new SoundFontTest(); - PropsEntity.Util.bind(app); + if (localPropertiesExists()) { + PropsEntity.Util.bind(app); + } app.exec(file); } - static final float volume = Float.parseFloat(System.getProperty("vavi.test.volume", "0.2")); + @Property(name = "vavi.test.volume") + float volume = 0.2f; @Property(name = "sf2") String sf2name = System.getProperty("user.home") + "/Library/Audio/Sounds/Banks/Orchestra/default.sf2"; diff --git a/src/test/java/vavi/sound/adpcm/ccitt/G721InputStreamTest.java b/src/test/java/vavi/sound/adpcm/ccitt/G721InputStreamTest.java index 4dc430f..6bfdc24 100644 --- a/src/test/java/vavi/sound/adpcm/ccitt/G721InputStreamTest.java +++ b/src/test/java/vavi/sound/adpcm/ccitt/G721InputStreamTest.java @@ -13,6 +13,7 @@ import java.io.OutputStream; import java.nio.ByteOrder; import java.nio.file.Files; +import java.nio.file.Paths; import java.util.logging.Level; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioSystem; @@ -22,6 +23,8 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import vavi.util.Debug; +import vavi.util.properties.annotation.Property; +import vavi.util.properties.annotation.PropsEntity; import vavix.util.Checksum; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -34,9 +37,15 @@ * @author Naohide Sano (nsano) * @version 0.00 060120 nsano initial version
*/ +@PropsEntity(url = "file:local.properties") public class G721InputStreamTest { - static final double volume = Double.parseDouble(System.getProperty("vavi.test.volume", "0.2")); + static boolean localPropertiesExists() { + return Files.exists(Paths.get("local.properties")); + } + + @Property(name = "vavi.test.volume") + float volume = 0.2f; String inFile = "out.4.adpcm"; String correctFile = "out.4.pcm"; @@ -44,6 +53,10 @@ public class G721InputStreamTest { @BeforeEach public void setup() throws IOException { + if (localPropertiesExists()) { + PropsEntity.Util.bind(this); + } + outFile = File.createTempFile("vavi", ".pcm"); outFile.deleteOnExit(); Debug.println(Level.FINE, "outFile: " + outFile); diff --git a/src/test/java/vavi/sound/adpcm/dvi/DviInputStreamTest.java b/src/test/java/vavi/sound/adpcm/dvi/DviInputStreamTest.java index 3e73338..39320e5 100644 --- a/src/test/java/vavi/sound/adpcm/dvi/DviInputStreamTest.java +++ b/src/test/java/vavi/sound/adpcm/dvi/DviInputStreamTest.java @@ -13,6 +13,7 @@ import java.io.OutputStream; import java.nio.ByteOrder; import java.nio.file.Files; +import java.nio.file.Paths; import java.util.logging.Level; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioSystem; @@ -22,6 +23,8 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import vavi.util.Debug; +import vavi.util.properties.annotation.Property; +import vavi.util.properties.annotation.PropsEntity; import vavix.util.Checksum; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -34,9 +37,15 @@ * @author Naohide Sano (nsano) * @version 0.00 060120 nsano initial version
*/ +@PropsEntity(url = "file:local.properties") public class DviInputStreamTest { - static final double volume = Double.parseDouble(System.getProperty("vavi.test.volume", "0.2")); + static boolean localPropertiesExists() { + return Files.exists(Paths.get("local.properties")); + } + + @Property(name = "vavi.test.volume") + float volume = 0.2f; String inFile = "out.adpcm"; String correctFile = "out.pcm"; @@ -44,6 +53,10 @@ public class DviInputStreamTest { @BeforeEach public void setup() throws IOException { + if (localPropertiesExists()) { + PropsEntity.Util.bind(this); + } + outFile = File.createTempFile("vavi", ".pcm"); outFile.deleteOnExit(); Debug.println(Level.FINE, "outFile: " + outFile); diff --git a/src/test/java/vavi/sound/adpcm/ima/ImaInputStreamTest.java b/src/test/java/vavi/sound/adpcm/ima/ImaInputStreamTest.java index 8291d1d..f33357c 100644 --- a/src/test/java/vavi/sound/adpcm/ima/ImaInputStreamTest.java +++ b/src/test/java/vavi/sound/adpcm/ima/ImaInputStreamTest.java @@ -15,6 +15,7 @@ import java.io.OutputStream; import java.nio.ByteOrder; import java.nio.file.Files; +import java.nio.file.Paths; import java.util.logging.Level; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioSystem; @@ -26,6 +27,8 @@ import org.junit.jupiter.api.Test; import vavi.io.LittleEndianDataInputStream; import vavi.util.Debug; +import vavi.util.properties.annotation.Property; +import vavi.util.properties.annotation.PropsEntity; import vavi.util.win32.WAVE; import vavix.util.Checksum; @@ -39,9 +42,15 @@ * @author Naohide Sano (nsano) * @version 0.00 060120 nsano initial version
*/ +@PropsEntity(url = "file:local.properties") public class ImaInputStreamTest { - static final double volume = Double.parseDouble(System.getProperty("vavi.test.volume", "0.2")); + static boolean localPropertiesExists() { + return Files.exists(Paths.get("local.properties")); + } + + @Property(name = "vavi.test.volume") + float volume = 0.2f; String inFile = "ima_8k_4_mono.wav"; String correctFile = "linear_8k_16_mono.pcm"; @@ -49,6 +58,10 @@ public class ImaInputStreamTest { @BeforeEach public void setup() throws IOException { + if (localPropertiesExists()) { + PropsEntity.Util.bind(this); + } + outFile = File.createTempFile("vavi", ".pcm"); outFile.deleteOnExit(); Debug.println(Level.FINE, "outFile: " + outFile); diff --git a/src/test/java/vavi/sound/adpcm/ima/ImaOutputStreamTest.java b/src/test/java/vavi/sound/adpcm/ima/ImaOutputStreamTest.java index 2b8f0d3..8e3215a 100644 --- a/src/test/java/vavi/sound/adpcm/ima/ImaOutputStreamTest.java +++ b/src/test/java/vavi/sound/adpcm/ima/ImaOutputStreamTest.java @@ -28,6 +28,8 @@ import vavi.io.LittleEndianDataInputStream; import vavi.io.OutputEngineInputStream; import vavi.util.Debug; +import vavi.util.properties.annotation.Property; +import vavi.util.properties.annotation.PropsEntity; import vavix.io.IOStreamInputEngine; import vavix.io.IOStreamOutputEngine; import vavix.util.Checksum; @@ -42,9 +44,15 @@ * @author Naohide Sano (nsano) * @version 0.00 060120 nsano initial version
*/ +@PropsEntity(url = "file:local.properties") public class ImaOutputStreamTest { - static final double volume = Double.parseDouble(System.getProperty("vavi.test.volume", "0.2")); + static boolean localPropertiesExists() { + return Files.exists(Paths.get("local.properties")); + } + + @Property(name = "vavi.test.volume") + float volume = 0.2f; String inFile = "out.pcm"; String correctFile = "out_sox.adpcm"; @@ -52,6 +60,10 @@ public class ImaOutputStreamTest { @BeforeEach public void setup() throws IOException { + if (localPropertiesExists()) { + PropsEntity.Util.bind(this); + } + outFile = File.createTempFile("vavi", ".pcm"); outFile.deleteOnExit(); // outFile = new File("src/test/resources/vavi/sound/adpcm/ima/out_vavi.adpcm"); diff --git a/src/test/java/vavi/sound/adpcm/ma/MaInputStreamTest.java b/src/test/java/vavi/sound/adpcm/ma/MaInputStreamTest.java index cebe48f..18f2bc6 100644 --- a/src/test/java/vavi/sound/adpcm/ma/MaInputStreamTest.java +++ b/src/test/java/vavi/sound/adpcm/ma/MaInputStreamTest.java @@ -14,6 +14,7 @@ import java.io.OutputStream; import java.nio.ByteOrder; import java.nio.file.Files; +import java.nio.file.Paths; import java.util.logging.Level; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioSystem; @@ -24,6 +25,8 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import vavi.util.Debug; +import vavi.util.properties.annotation.Property; +import vavi.util.properties.annotation.PropsEntity; import vavix.util.Checksum; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -36,9 +39,15 @@ * @author Naohide Sano (nsano) * @version 0.00 060130 nsano initial version
*/ +@PropsEntity(url = "file:local.properties") public class MaInputStreamTest { - static final double volume = Double.parseDouble(System.getProperty("vavi.test.volume", "0.2")); + static boolean localPropertiesExists() { + return Files.exists(Paths.get("local.properties")); + } + + @Property(name = "vavi.test.volume") + float volume = 0.2f; String inFile = "out.adpcm"; String correctFile = "out.pcm"; @@ -46,6 +55,10 @@ public class MaInputStreamTest { @BeforeEach public void setup() throws IOException { + if (localPropertiesExists()) { + PropsEntity.Util.bind(this); + } + outFile = File.createTempFile("vavi", ".pcm"); outFile.deleteOnExit(); Debug.println(Level.FINE, "outFile: " + outFile); diff --git a/src/test/java/vavi/sound/adpcm/ms/MsInputStreamTest.java b/src/test/java/vavi/sound/adpcm/ms/MsInputStreamTest.java index 26f0f05..c19c819 100644 --- a/src/test/java/vavi/sound/adpcm/ms/MsInputStreamTest.java +++ b/src/test/java/vavi/sound/adpcm/ms/MsInputStreamTest.java @@ -15,6 +15,7 @@ import java.io.OutputStream; import java.nio.ByteOrder; import java.nio.file.Files; +import java.nio.file.Paths; import java.util.logging.Level; import javax.sound.sampled.AudioFormat; @@ -27,6 +28,8 @@ import vavi.io.LittleEndianDataInputStream; import vavi.util.Debug; +import vavi.util.properties.annotation.Property; +import vavi.util.properties.annotation.PropsEntity; import vavi.util.win32.WAVE; import vavix.util.Checksum; @@ -41,9 +44,15 @@ * @author Naohide Sano (nsano) * @version 0.00 060120 nsano initial version
*/ +@PropsEntity(url = "file:local.properties") public class MsInputStreamTest { - static final double volume = Double.parseDouble(System.getProperty("vavi.test.volume", "0.2")); + static boolean localPropertiesExists() { + return Files.exists(Paths.get("local.properties")); + } + + @Property(name = "vavi.test.volume") + float volume = 0.2f; String inFile = "ms_8k_4_mono.wav"; String correctFile = "out_sox.pcm"; @@ -51,6 +60,10 @@ public class MsInputStreamTest { @BeforeEach public void setup() throws IOException { + if (localPropertiesExists()) { + PropsEntity.Util.bind(this); + } + outFile = File.createTempFile("vavi", ".pcm"); outFile.deleteOnExit(); Debug.println(Level.FINE, "outFile: " + outFile); diff --git a/src/test/java/vavi/sound/adpcm/ms/MsOutputStreamTest.java b/src/test/java/vavi/sound/adpcm/ms/MsOutputStreamTest.java index 95d4f6c..1759671 100644 --- a/src/test/java/vavi/sound/adpcm/ms/MsOutputStreamTest.java +++ b/src/test/java/vavi/sound/adpcm/ms/MsOutputStreamTest.java @@ -14,6 +14,7 @@ import java.io.InputStream; import java.io.OutputStream; import java.nio.file.Files; +import java.nio.file.Paths; import java.util.logging.Level; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioSystem; @@ -25,6 +26,8 @@ import vavi.io.LittleEndianDataInputStream; import vavi.io.OutputEngineInputStream; import vavi.util.Debug; +import vavi.util.properties.annotation.Property; +import vavi.util.properties.annotation.PropsEntity; import vavix.io.IOStreamOutputEngine; import vavix.util.Checksum; @@ -38,9 +41,15 @@ * @author Naohide Sano (nsano) * @version 0.00 060120 nsano initial version
*/ +@PropsEntity(url = "file:local.properties") public class MsOutputStreamTest { - static final double volume = Double.parseDouble(System.getProperty("vavi.test.volume", "0.2")); + static boolean localPropertiesExists() { + return Files.exists(Paths.get("local.properties")); + } + + @Property(name = "vavi.test.volume") + float volume = 0.2f; String inFile = "out.pcm"; String correctFile = "out_sox.adpcm"; @@ -48,6 +57,10 @@ public class MsOutputStreamTest { @BeforeEach public void setup() throws IOException { + if (localPropertiesExists()) { + PropsEntity.Util.bind(this); + } + outFile = File.createTempFile("vavi", ".pcm"); outFile.deleteOnExit(); // outFile = new File("src/test/resources/vavi/sound/adpcm/ms/out_vavi.adpcm"); diff --git a/src/test/java/vavi/sound/adpcm/oki/OkiInputStreamTest.java b/src/test/java/vavi/sound/adpcm/oki/OkiInputStreamTest.java index 9fa6e17..3109a80 100644 --- a/src/test/java/vavi/sound/adpcm/oki/OkiInputStreamTest.java +++ b/src/test/java/vavi/sound/adpcm/oki/OkiInputStreamTest.java @@ -13,6 +13,7 @@ import java.io.OutputStream; import java.nio.ByteOrder; import java.nio.file.Files; +import java.nio.file.Paths; import java.util.logging.Level; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioSystem; @@ -22,6 +23,8 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import vavi.util.Debug; +import vavi.util.properties.annotation.Property; +import vavi.util.properties.annotation.PropsEntity; import vavix.util.Checksum; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -34,9 +37,15 @@ * @author Naohide Sano (nsano) * @version 0.00 060120 nsano initial version
*/ +@PropsEntity(url = "file:local.properties") public class OkiInputStreamTest { - static final double volume = Double.parseDouble(System.getProperty("vavi.test.volume", "0.2")); + static boolean localPropertiesExists() { + return Files.exists(Paths.get("local.properties")); + } + + @Property(name = "vavi.test.volume") + float volume = 0.2f; String inFile = "out.adpcm"; String correctFile = "out.pcm"; @@ -44,6 +53,10 @@ public class OkiInputStreamTest { @BeforeEach public void setup() throws IOException { + if (localPropertiesExists()) { + PropsEntity.Util.bind(this); + } + outFile = File.createTempFile("vavi", ".pcm"); outFile.deleteOnExit(); Debug.println(Level.FINE, "outFile: " + outFile); diff --git a/src/test/java/vavi/sound/adpcm/rohm/RohmInputStreamTest.java b/src/test/java/vavi/sound/adpcm/rohm/RohmInputStreamTest.java index 0d5862d..ad6ffea 100644 --- a/src/test/java/vavi/sound/adpcm/rohm/RohmInputStreamTest.java +++ b/src/test/java/vavi/sound/adpcm/rohm/RohmInputStreamTest.java @@ -14,6 +14,7 @@ import java.io.OutputStream; import java.nio.ByteOrder; import java.nio.file.Files; +import java.nio.file.Paths; import java.util.logging.Level; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioSystem; @@ -24,6 +25,8 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import vavi.util.Debug; +import vavi.util.properties.annotation.Property; +import vavi.util.properties.annotation.PropsEntity; import vavix.util.Checksum; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -36,9 +39,15 @@ * @author Naohide Sano (nsano) * @version 0.00 060130 nsano initial version
*/ +@PropsEntity(url = "file:local.properties") public class RohmInputStreamTest { - static final double volume = Double.parseDouble(System.getProperty("vavi.test.volume", "0.2")); + static boolean localPropertiesExists() { + return Files.exists(Paths.get("local.properties")); + } + + @Property(name = "vavi.test.volume") + float volume = 0.2f; String inFile = "out.adpcm"; String correctFile = "out.pcm"; @@ -46,6 +55,10 @@ public class RohmInputStreamTest { @BeforeEach public void setup() throws IOException { + if (localPropertiesExists()) { + PropsEntity.Util.bind(this); + } + outFile = File.createTempFile("vavi", ".pcm"); outFile.deleteOnExit(); Debug.println(Level.FINE, "outFile: " + outFile); diff --git a/src/test/java/vavi/sound/adpcm/vox/VoxInputStreamTest.java b/src/test/java/vavi/sound/adpcm/vox/VoxInputStreamTest.java index 6e8e135..4ff027b 100644 --- a/src/test/java/vavi/sound/adpcm/vox/VoxInputStreamTest.java +++ b/src/test/java/vavi/sound/adpcm/vox/VoxInputStreamTest.java @@ -24,6 +24,8 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import vavi.util.Debug; +import vavi.util.properties.annotation.Property; +import vavi.util.properties.annotation.PropsEntity; import vavix.util.Checksum; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -36,9 +38,15 @@ * @author Naohide Sano (nsano) * @version 0.00 060120 nsano initial version
*/ +@PropsEntity(url = "file:local.properties") public class VoxInputStreamTest { - static final double volume = Double.parseDouble(System.getProperty("vavi.test.volume", "0.2")); + static boolean localPropertiesExists() { + return Files.exists(Paths.get("local.properties")); + } + + @Property(name = "vavi.test.volume") + float volume = 0.2f; String inFile = "out.adpcm"; String correctFile = "out.pcm"; @@ -46,6 +54,10 @@ public class VoxInputStreamTest { @BeforeEach public void setup() throws IOException { + if (localPropertiesExists()) { + PropsEntity.Util.bind(this); + } + outFile = File.createTempFile("vavi", ".pcm"); outFile.deleteOnExit(); Debug.println(Level.FINE, "outFile: " + outFile); diff --git a/src/test/java/vavi/sound/adpcm/yamaha/YamahaInputStreamTest.java b/src/test/java/vavi/sound/adpcm/yamaha/YamahaInputStreamTest.java index 6e61d93..a2c6b4f 100644 --- a/src/test/java/vavi/sound/adpcm/yamaha/YamahaInputStreamTest.java +++ b/src/test/java/vavi/sound/adpcm/yamaha/YamahaInputStreamTest.java @@ -26,6 +26,8 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import vavi.util.Debug; +import vavi.util.properties.annotation.Property; +import vavi.util.properties.annotation.PropsEntity; import vavi.util.win32.WAVE; import vavix.util.Checksum; @@ -39,9 +41,15 @@ * @author Naohide Sano (nsano) * @version 0.00 060120 nsano initial version
*/ +@PropsEntity(url = "file:local.properties") public class YamahaInputStreamTest { - static final double volume = Double.parseDouble(System.getProperty("vavi.test.volume", "0.2")); + static boolean localPropertiesExists() { + return Files.exists(Paths.get("local.properties")); + } + + @Property(name = "vavi.test.volume") + float volume = 0.2f; String inFile = "out.adpcm"; String correctFile = "out.pcm"; @@ -49,6 +57,10 @@ public class YamahaInputStreamTest { @BeforeEach public void setup() throws IOException { + if (localPropertiesExists()) { + PropsEntity.Util.bind(this); + } + outFile = File.createTempFile("vavi", ".pcm"); outFile.deleteOnExit(); Debug.println(Level.FINE, "outFile: " + outFile); diff --git a/src/test/java/vavi/sound/adpcm/ym2608/Ym2608InputStreamTest.java b/src/test/java/vavi/sound/adpcm/ym2608/Ym2608InputStreamTest.java index fac0777..566cbab 100644 --- a/src/test/java/vavi/sound/adpcm/ym2608/Ym2608InputStreamTest.java +++ b/src/test/java/vavi/sound/adpcm/ym2608/Ym2608InputStreamTest.java @@ -13,6 +13,7 @@ import java.io.OutputStream; import java.nio.ByteOrder; import java.nio.file.Files; +import java.nio.file.Paths; import java.util.logging.Level; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioSystem; @@ -22,6 +23,8 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import vavi.util.Debug; +import vavi.util.properties.annotation.Property; +import vavi.util.properties.annotation.PropsEntity; import vavix.util.Checksum; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -34,9 +37,15 @@ * @author Naohide Sano (nsano) * @version 0.00 060124 nsano initial version
*/ +@PropsEntity(url = "file:local.properties") public class Ym2608InputStreamTest { - static final double volume = Double.parseDouble(System.getProperty("vavi.test.volume", "0.2")); + static boolean localPropertiesExists() { + return Files.exists(Paths.get("local.properties")); + } + + @Property(name = "vavi.test.volume") + float volume = 0.2f; String inFile = "out.adpcm"; String correctFile = "out.pcm"; @@ -44,6 +53,10 @@ public class Ym2608InputStreamTest { @BeforeEach public void setup() throws IOException { + if (localPropertiesExists()) { + PropsEntity.Util.bind(this); + } + outFile = File.createTempFile("vavi", ".pcm"); outFile.deleteOnExit(); // outFile = new File("src/test/resources/vavi/sound/adpcm/ym2608/out_vavi.pcm"); diff --git a/src/test/java/vavi/sound/midi/mfi/MfiMidiFileReaderTest.java b/src/test/java/vavi/sound/midi/mfi/MfiMidiFileReaderTest.java index a72bada..d65b9fe 100644 --- a/src/test/java/vavi/sound/midi/mfi/MfiMidiFileReaderTest.java +++ b/src/test/java/vavi/sound/midi/mfi/MfiMidiFileReaderTest.java @@ -7,14 +7,22 @@ package vavi.sound.midi.mfi; import java.io.File; +import java.io.IOException; import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.concurrent.CountDownLatch; +import java.util.logging.Level; import javax.sound.midi.MidiSystem; import javax.sound.midi.Sequence; import javax.sound.midi.Sequencer; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import vavi.util.Debug; +import vavi.util.properties.annotation.Property; +import vavi.util.properties.annotation.PropsEntity; /** @@ -23,10 +31,23 @@ * @author Naohide Sano (umjammer) * @version 0.00 2012/10/02 umjammer initial version
*/ +@PropsEntity(url = "file:local.properties") public class MfiMidiFileReaderTest { - static { - System.setProperty("vavi.sound.mobile.AudioEngine.volume", System.getProperty("vavi.test.volume", "0.02")); + static boolean localPropertiesExists() { + return Files.exists(Paths.get("local.properties")); + } + + @Property(name = "vavi.test.volume") + float volume = 0.2f; + + @BeforeEach + public void setup() throws IOException { + if (localPropertiesExists()) { + PropsEntity.Util.bind(this); + } + + System.setProperty("vavi.sound.mobile.AudioEngine.volume", String.valueOf(volume)); Debug.println("adpcm volume: " + System.getProperty("vavi.sound.mobile.AudioEngine.volume")); } @@ -34,6 +55,10 @@ public class MfiMidiFileReaderTest { public void test() throws Exception { InputStream is = MfiVaviSequenceTest.class.getResourceAsStream("/test.mld"); + play(is); + } + + void play(InputStream is) throws Exception { CountDownLatch cdl = new CountDownLatch(1); Sequencer sequencer = MidiSystem.getSequencer(); @@ -59,21 +84,8 @@ public void test() throws Exception { * @param args [0] filename */ public static void main(String[] args) throws Exception { - CountDownLatch cdl = new CountDownLatch(1); - - Sequencer sequencer = MidiSystem.getSequencer(); - sequencer.open(); - Sequence sequence = MidiSystem.getSequence(new File(args[0])); -Debug.println(sequence); - sequencer.setSequence(sequence); - sequencer.addMetaEventListener(meta -> { -Debug.println(meta.getType()); - if (meta.getType() == 47) { - cdl.countDown(); - } - }); - sequencer.start(); - cdl.await(); - sequencer.close(); + MfiMidiFileReaderTest app = new MfiMidiFileReaderTest(); + app.setup(); + app.play(Files.newInputStream(Path.of(args[0]))); } } 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 eb691e4..36c1c1c 100644 --- a/src/test/java/vavi/sound/pcm/resampling/ssrc/SSRCTest.java +++ b/src/test/java/vavi/sound/pcm/resampling/ssrc/SSRCTest.java @@ -51,12 +51,14 @@ static boolean localPropertiesExists() { @Property String ssrc = "src/test/resources/vavi/sound/pcm/resampling/ssrc/44100.wav"; + @Property(name = "vavi.test.volume") + float volume = 0.2f; + static final Path outPath = Paths.get("tmp/out.vavi.wav"); static final String inFile = "src/test/resources/vavi/sound/pcm/resampling/ssrc/44100.wav"; static final String correctDownFile = "src/test/resources/vavi/sound/pcm/resampling/ssrc/down.wav"; static final String correctUpFile = "src/test/resources/vavi/sound/pcm/resampling/ssrc/up.wav"; - static double volume = Double.parseDouble(System.getProperty("vavi.test.volume", "0.2")); static boolean onIde = System.getProperty("vavi.test", "").equals("ide"); @BeforeAll diff --git a/src/test/java/vavi/sound/sampled/adpcm/ccitt/G721RawAudioFileReaderTest.java b/src/test/java/vavi/sound/sampled/adpcm/ccitt/G721RawAudioFileReaderTest.java index 03cc942..afac32e 100644 --- a/src/test/java/vavi/sound/sampled/adpcm/ccitt/G721RawAudioFileReaderTest.java +++ b/src/test/java/vavi/sound/sampled/adpcm/ccitt/G721RawAudioFileReaderTest.java @@ -12,6 +12,7 @@ import java.io.OutputStream; import java.nio.ByteOrder; import java.nio.file.Files; +import java.nio.file.Paths; import java.util.logging.Level; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioInputStream; @@ -22,6 +23,8 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import vavi.util.Debug; +import vavi.util.properties.annotation.Property; +import vavi.util.properties.annotation.PropsEntity; import vavix.util.Checksum; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -34,9 +37,15 @@ * @author Naohide Sano (nsano) * @version 0.00 060120 nsano initial version
*/ +@PropsEntity(url = "file:local.properties") public class G721RawAudioFileReaderTest { - static final double volume = Double.parseDouble(System.getProperty("vavi.test.volume", "0.2")); + static boolean localPropertiesExists() { + return Files.exists(Paths.get("local.properties")); + } + + @Property(name = "vavi.test.volume") + float volume = 0.2f; String inFile = "/vavi/sound/adpcm/ccitt/out.4.adpcm"; String correctFile = "/vavi/sound/adpcm/ccitt/out.4.pcm"; @@ -44,6 +53,10 @@ public class G721RawAudioFileReaderTest { @BeforeEach public void setup() throws IOException { + if (localPropertiesExists()) { + PropsEntity.Util.bind(this); + } + outFile = File.createTempFile("vavi", ".pcm"); outFile.deleteOnExit(); Debug.println(Level.FINE, "outFile: " + outFile); diff --git a/src/test/java/vavi/sound/sampled/adpcm/dvi/DviRawAudioFileReaderTest.java b/src/test/java/vavi/sound/sampled/adpcm/dvi/DviRawAudioFileReaderTest.java index a0a6c4d..6ee7dc5 100644 --- a/src/test/java/vavi/sound/sampled/adpcm/dvi/DviRawAudioFileReaderTest.java +++ b/src/test/java/vavi/sound/sampled/adpcm/dvi/DviRawAudioFileReaderTest.java @@ -12,6 +12,7 @@ import java.io.OutputStream; import java.nio.ByteOrder; import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioSystem; @@ -21,6 +22,8 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import vavi.util.Debug; +import vavi.util.properties.annotation.Property; +import vavi.util.properties.annotation.PropsEntity; import vavix.util.Checksum; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -33,9 +36,15 @@ * @author Naohide Sano (nsano) * @version 0.00 201020 nsano initial version
*/ +@PropsEntity(url = "file:local.properties") public class DviRawAudioFileReaderTest { - static final double volume = Double.parseDouble(System.getProperty("vavi.test.volume", "0.2")); + static boolean localPropertiesExists() { + return Files.exists(Paths.get("local.properties")); + } + + @Property(name = "vavi.test.volume") + float volume = 0.2f; String inFile = "/vavi/sound/adpcm/dvi/out.adpcm"; String correctFile = "/vavi/sound/adpcm/dvi/out.pcm"; @@ -43,6 +52,10 @@ public class DviRawAudioFileReaderTest { @BeforeEach public void setup() throws IOException { + if (localPropertiesExists()) { + PropsEntity.Util.bind(this); + } + outFile = File.createTempFile("vavi", ".pcm"); outFile.deleteOnExit(); Debug.println("outFile: " + outFile); 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 0e30f94..502c423 100644 --- a/src/test/java/vavi/sound/sampled/adpcm/ima/ImaWaveAudioFileReaderTest.java +++ b/src/test/java/vavi/sound/sampled/adpcm/ima/ImaWaveAudioFileReaderTest.java @@ -12,6 +12,7 @@ import java.io.OutputStream; import java.nio.ByteOrder; import java.nio.file.Files; +import java.nio.file.Paths; import java.util.Arrays; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioInputStream; @@ -23,6 +24,8 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import vavi.util.Debug; +import vavi.util.properties.annotation.Property; +import vavi.util.properties.annotation.PropsEntity; import vavix.util.Checksum; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -35,9 +38,15 @@ * @author Naohide Sano (nsano) * @version 0.00 201020 nsano initial version
*/ +@PropsEntity(url = "file:local.properties") public class ImaWaveAudioFileReaderTest { - static final double volume = Double.parseDouble(System.getProperty("vavi.test.volume", "0.2")); + static boolean localPropertiesExists() { + return Files.exists(Paths.get("local.properties")); + } + + @Property(name = "vavi.test.volume") + float volume = 0.2f; String inFile = "/vavi/sound/adpcm/ima/ima_8k_4_mono.wav"; String correctFile = "/vavi/sound/adpcm/ima/linear_8k_16_mono.pcm"; @@ -45,6 +54,10 @@ public class ImaWaveAudioFileReaderTest { @BeforeEach public void setup() throws IOException { + if (localPropertiesExists()) { + PropsEntity.Util.bind(this); + } + outFile = File.createTempFile("vavi", ".pcm"); outFile.deleteOnExit(); Debug.println("outFile: " + outFile); diff --git a/src/test/java/vavi/sound/sampled/adpcm/ma/MaRawAudioFileReaderTest.java b/src/test/java/vavi/sound/sampled/adpcm/ma/MaRawAudioFileReaderTest.java index 740820c..a9cfb5e 100644 --- a/src/test/java/vavi/sound/sampled/adpcm/ma/MaRawAudioFileReaderTest.java +++ b/src/test/java/vavi/sound/sampled/adpcm/ma/MaRawAudioFileReaderTest.java @@ -12,6 +12,7 @@ import java.io.OutputStream; import java.nio.ByteOrder; import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioSystem; @@ -21,6 +22,8 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import vavi.util.Debug; +import vavi.util.properties.annotation.Property; +import vavi.util.properties.annotation.PropsEntity; import vavix.util.Checksum; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -33,9 +36,15 @@ * @author Naohide Sano (nsano) * @version 0.00 201020 nsano initial version
*/ +@PropsEntity(url = "file:local.properties") public class MaRawAudioFileReaderTest { - static final double volume = Double.parseDouble(System.getProperty("vavi.test.volume", "0.2")); + static boolean localPropertiesExists() { + return Files.exists(Paths.get("local.properties")); + } + + @Property(name = "vavi.test.volume") + float volume = 0.2f; String inFile = "/vavi/sound/adpcm/ma/out.adpcm"; String correctFile = "/vavi/sound/adpcm/ma/out.pcm"; @@ -43,6 +52,10 @@ public class MaRawAudioFileReaderTest { @BeforeEach public void setup() throws IOException { + if (localPropertiesExists()) { + PropsEntity.Util.bind(this); + } + outFile = File.createTempFile("vavi", ".pcm"); outFile.deleteOnExit(); Debug.println("outFile: " + outFile); diff --git a/src/test/java/vavi/sound/sampled/adpcm/ms/MsWaveAudioFileReaderTest.java b/src/test/java/vavi/sound/sampled/adpcm/ms/MsWaveAudioFileReaderTest.java index ba5b033..56bfcdc 100644 --- a/src/test/java/vavi/sound/sampled/adpcm/ms/MsWaveAudioFileReaderTest.java +++ b/src/test/java/vavi/sound/sampled/adpcm/ms/MsWaveAudioFileReaderTest.java @@ -26,6 +26,8 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import vavi.util.Debug; +import vavi.util.properties.annotation.Property; +import vavi.util.properties.annotation.PropsEntity; import vavix.util.Checksum; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -39,9 +41,15 @@ * @author Naohide Sano (nsano) * @version 0.00 201020 nsano initial version
*/ +@PropsEntity(url = "file:local.properties") public class MsWaveAudioFileReaderTest { - static final double volume = Double.parseDouble(System.getProperty("vavi.test.volume", "0.2")); + static boolean localPropertiesExists() { + return Files.exists(Paths.get("local.properties")); + } + + @Property(name = "vavi.test.volume") + float volume = 0.2f; String inFile = "/vavi/sound/adpcm/ms/ms_8k_4_mono.wav"; String correctFile = "/vavi/sound/adpcm/ms/out_sox.pcm"; @@ -49,6 +57,10 @@ public class MsWaveAudioFileReaderTest { @BeforeEach public void setup() throws IOException { + if (localPropertiesExists()) { + PropsEntity.Util.bind(this); + } + outFile = File.createTempFile("vavi", ".pcm"); outFile.deleteOnExit(); Debug.println("outFile: " + outFile); diff --git a/src/test/java/vavi/sound/sampled/adpcm/oki/OkiRawAudioFileReaderTest.java b/src/test/java/vavi/sound/sampled/adpcm/oki/OkiRawAudioFileReaderTest.java index 8924bf8..66225de 100644 --- a/src/test/java/vavi/sound/sampled/adpcm/oki/OkiRawAudioFileReaderTest.java +++ b/src/test/java/vavi/sound/sampled/adpcm/oki/OkiRawAudioFileReaderTest.java @@ -12,6 +12,7 @@ import java.io.OutputStream; import java.nio.ByteOrder; import java.nio.file.Files; +import java.nio.file.Paths; import java.util.logging.Level; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioInputStream; @@ -22,6 +23,8 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import vavi.util.Debug; +import vavi.util.properties.annotation.Property; +import vavi.util.properties.annotation.PropsEntity; import vavix.util.Checksum; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -34,9 +37,15 @@ * @author Naohide Sano (nsano) * @version 0.00 201020 nsano initial version
*/ +@PropsEntity(url = "file:local.properties") public class OkiRawAudioFileReaderTest { - static final double volume = Double.parseDouble(System.getProperty("vavi.test.volume", "0.2")); + static boolean localPropertiesExists() { + return Files.exists(Paths.get("local.properties")); + } + + @Property(name = "vavi.test.volume") + float volume = 0.2f; String inFile = "/vavi/sound/adpcm/oki/out.adpcm"; String correctFile = "/vavi/sound/adpcm/oki/out.pcm"; @@ -44,6 +53,10 @@ public class OkiRawAudioFileReaderTest { @BeforeEach public void setup() throws IOException { + if (localPropertiesExists()) { + PropsEntity.Util.bind(this); + } + outFile = File.createTempFile("vavi", ".pcm"); outFile.deleteOnExit(); Debug.println(Level.FINE, "outFile: " + outFile); diff --git a/src/test/java/vavi/sound/sampled/adpcm/rhom/RohmRawAudioFileReaderTest.java b/src/test/java/vavi/sound/sampled/adpcm/rhom/RohmRawAudioFileReaderTest.java index 3011868..c64bc67 100644 --- a/src/test/java/vavi/sound/sampled/adpcm/rhom/RohmRawAudioFileReaderTest.java +++ b/src/test/java/vavi/sound/sampled/adpcm/rhom/RohmRawAudioFileReaderTest.java @@ -12,6 +12,7 @@ import java.io.OutputStream; import java.nio.ByteOrder; import java.nio.file.Files; +import java.nio.file.Paths; import java.util.logging.Level; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioInputStream; @@ -23,6 +24,8 @@ import org.junit.jupiter.api.Test; import vavi.sound.sampled.adpcm.rohm.RohmEncoding; import vavi.util.Debug; +import vavi.util.properties.annotation.Property; +import vavi.util.properties.annotation.PropsEntity; import vavix.util.Checksum; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -35,9 +38,15 @@ * @author Naohide Sano (nsano) * @version 0.00 201020 nsano initial version
*/ +@PropsEntity(url = "file:local.properties") public class RohmRawAudioFileReaderTest { - static final double volume = Double.parseDouble(System.getProperty("vavi.test.volume", "0.2")); + static boolean localPropertiesExists() { + return Files.exists(Paths.get("local.properties")); + } + + @Property(name = "vavi.test.volume") + float volume = 0.2f; String inFile = "/vavi/sound/adpcm/rohm/out.adpcm"; String correctFile = "/vavi/sound/adpcm/rohm/out.pcm"; @@ -45,6 +54,10 @@ public class RohmRawAudioFileReaderTest { @BeforeEach public void setup() throws IOException { + if (localPropertiesExists()) { + PropsEntity.Util.bind(this); + } + outFile = File.createTempFile("vavi", ".pcm"); outFile.deleteOnExit(); Debug.println(Level.FINE, "outFile: " + outFile); diff --git a/src/test/java/vavi/sound/sampled/adpcm/vox/VoxRawAudioFileReaderTest.java b/src/test/java/vavi/sound/sampled/adpcm/vox/VoxRawAudioFileReaderTest.java index 4e547e3..75e74c9 100644 --- a/src/test/java/vavi/sound/sampled/adpcm/vox/VoxRawAudioFileReaderTest.java +++ b/src/test/java/vavi/sound/sampled/adpcm/vox/VoxRawAudioFileReaderTest.java @@ -12,6 +12,7 @@ import java.io.OutputStream; import java.nio.ByteOrder; import java.nio.file.Files; +import java.nio.file.Paths; import java.util.logging.Level; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioInputStream; @@ -22,6 +23,8 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import vavi.util.Debug; +import vavi.util.properties.annotation.Property; +import vavi.util.properties.annotation.PropsEntity; import vavix.util.Checksum; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -34,9 +37,15 @@ * @author Naohide Sano (nsano) * @version 0.00 201020 nsano initial version
*/ +@PropsEntity(url = "file:local.properties") public class VoxRawAudioFileReaderTest { - static final double volume = Double.parseDouble(System.getProperty("vavi.test.volume", "0.2")); + static boolean localPropertiesExists() { + return Files.exists(Paths.get("local.properties")); + } + + @Property(name = "vavi.test.volume") + float volume = 0.2f; String inFile = "/vavi/sound/adpcm/vox/out.adpcm"; String correctFile = "/vavi/sound/adpcm/vox/out.pcm"; @@ -44,6 +53,10 @@ public class VoxRawAudioFileReaderTest { @BeforeEach public void setup() throws IOException { + if (localPropertiesExists()) { + PropsEntity.Util.bind(this); + } + outFile = File.createTempFile("vavi", ".pcm"); outFile.deleteOnExit(); Debug.println(Level.FINE, "outFile: " + outFile); diff --git a/src/test/java/vavi/sound/sampled/adpcm/yamaha/YamahaRawAudioFileReaderTest.java b/src/test/java/vavi/sound/sampled/adpcm/yamaha/YamahaRawAudioFileReaderTest.java index 306bec1..37f9a15 100644 --- a/src/test/java/vavi/sound/sampled/adpcm/yamaha/YamahaRawAudioFileReaderTest.java +++ b/src/test/java/vavi/sound/sampled/adpcm/yamaha/YamahaRawAudioFileReaderTest.java @@ -12,6 +12,7 @@ import java.io.OutputStream; import java.nio.ByteOrder; import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioSystem; @@ -21,6 +22,8 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import vavi.util.Debug; +import vavi.util.properties.annotation.Property; +import vavi.util.properties.annotation.PropsEntity; import vavix.util.Checksum; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -33,9 +36,15 @@ * @author Naohide Sano (nsano) * @version 0.00 201020 nsano initial version
*/ +@PropsEntity(url = "file:local.properties") public class YamahaRawAudioFileReaderTest { - static final double volume = Double.parseDouble(System.getProperty("vavi.test.volume", "0.2")); + static boolean localPropertiesExists() { + return Files.exists(Paths.get("local.properties")); + } + + @Property(name = "vavi.test.volume") + float volume = 0.2f; String inFile = "/vavi/sound/adpcm/ym2608/out.adpcm"; String correctFile = "/vavi/sound/adpcm/ym2608/out.pcm"; @@ -43,6 +52,10 @@ public class YamahaRawAudioFileReaderTest { @BeforeEach public void setup() throws IOException { + if (localPropertiesExists()) { + PropsEntity.Util.bind(this); + } + outFile = File.createTempFile("vavi", ".pcm"); outFile.deleteOnExit(); Debug.println("outFile: " + outFile); From 18bbffaf8db9f4e6d84d54a4ef474feae49e9cd2 Mon Sep 17 00:00:00 2001 From: Naohide Sano Date: Sat, 30 Nov 2024 12:10:39 +0900 Subject: [PATCH 6/8] [util] add util for input stream --- src/main/java/vavi/sound/SoundUtil.java | 61 +++++++++++++++++++++ src/test/java/vavi/sound/SoundUtilTest.java | 57 +++++++++++++++++++ 2 files changed, 118 insertions(+) create mode 100644 src/test/java/vavi/sound/SoundUtilTest.java diff --git a/src/main/java/vavi/sound/SoundUtil.java b/src/main/java/vavi/sound/SoundUtil.java index 895aa8f..af9024c 100644 --- a/src/main/java/vavi/sound/SoundUtil.java +++ b/src/main/java/vavi/sound/SoundUtil.java @@ -6,9 +6,18 @@ package vavi.sound; +import java.io.BufferedInputStream; +import java.io.FilterInputStream; +import java.lang.System.Logger; +import java.lang.System.Logger.Level; +import java.lang.reflect.Field; +import java.net.URI; import javax.sound.sampled.DataLine; import javax.sound.sampled.FloatControl; +import static java.lang.System.Logger.Level.DEBUG; +import static java.lang.System.getLogger; + /** * SoundUtil. @@ -18,6 +27,8 @@ */ public final class SoundUtil { + private static final Logger logger = getLogger(SoundUtil.class.getName()); + private SoundUtil() {} /** @@ -29,4 +40,54 @@ public static void volume(DataLine line, double gain) { float dB = (float) (Math.log10(gain) * 20.0); gainControl.setValue(dB); } + + /** + * Gets a source path from an input stream. + *

+ * java runtime option + *

    + *
      {@code --add-opens=java.base/java.io=ALL-UNNAMED}
    + *
      {@code --add-opens=java.base/sun.nio.ch=ALL-UNNAMED}
    + *
+ * + * @param object input stream + * @return source object as URI, nullable + */ + public static URI getSource(Object object) { + Class c = object.getClass(); + try { + do { +logger.log(DEBUG, "object1: " + c.getName()); + if (object instanceof BufferedInputStream) { + Field pathField = FilterInputStream.class.getDeclaredField("in"); + pathField.setAccessible(true); + object = pathField.get(object); + } + if (object instanceof java.io.FileInputStream) { + Field pathField = object.getClass().getDeclaredField("path"); + pathField.setAccessible(true); + String path = (String) pathField.get(object); +logger.log(DEBUG, "source: java.io.FileInputStream: path : " + path); + return path != null ? URI.create(path) : null; + } + if (object.getClass().getName().equals("sun.nio.ch.ChannelInputStream")) { // because it's package private + Field pathField = object.getClass().getDeclaredField("ch"); + pathField.setAccessible(true); + object = pathField.get(object); + } + if (object.getClass().getName().equals("sun.nio.ch.FileChannelImpl")) { // because it's package private + Field pathField = object.getClass().getDeclaredField("path"); + pathField.setAccessible(true); + String path = (String) pathField.get(object); +logger.log(DEBUG, "source: sun.nio.ch.FileChannelImpl: path : " + path); + return path != null ? URI.create(path) : null; + } +logger.log(DEBUG, "object2: " + object.getClass().getName()); + c = c.getSuperclass(); + } while (c.getSuperclass() != null); + } catch (Exception e) { +logger.log(Level.WARNING, e.getMessage(), e); + } + return null; + } } diff --git a/src/test/java/vavi/sound/SoundUtilTest.java b/src/test/java/vavi/sound/SoundUtilTest.java new file mode 100644 index 0000000..d221292 --- /dev/null +++ b/src/test/java/vavi/sound/SoundUtilTest.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2024 by Naohide Sano, All rights reserved. + * + * Programmed by Naohide Sano + */ + +package vavi.sound; + +import java.io.BufferedInputStream; +import java.io.FileInputStream; +import java.io.InputStream; +import java.net.URI; +import java.nio.file.Files; +import java.nio.file.Path; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + + +/** + * SoundUtilTest. + *

+ * java runtime option + *

    + *
      {@code --add-opens=java.base/java.io=ALL-UNNAMED}
    + *
      {@code --add-opens=java.base/sun.nio.ch=ALL-UNNAMED}
    + *
+ * + * @author Naohide Sano (nsano) + * @version 0.00 241129 nsano initial version
+ */ +class SoundUtilTest { + + @Test + void test1() throws Exception { + InputStream is = SoundUtil.class.getResourceAsStream("/test.mid"); + URI uri = SoundUtil.getSource(is); + assertNotNull(uri); + assertTrue(uri.toString().endsWith("target/test-classes/test.mid")); + + is = new BufferedInputStream(Files.newInputStream(Path.of("src/test/resources/test.mid"))); + uri = SoundUtil.getSource(is); + assertNotNull(uri); + assertTrue(uri.toString().endsWith("src/test/resources/test.mid")); + + is = new BufferedInputStream(new FileInputStream("src/test/resources/test.mid")); + uri = SoundUtil.getSource(is); + assertNotNull(uri); + assertTrue(uri.toString().endsWith("src/test/resources/test.mid")); + + is = new BufferedInputStream(Files.newInputStream(Path.of(SoundUtil.class.getResource("/test.mid").toURI()))); + uri = SoundUtil.getSource(is); + assertNotNull(uri); + assertTrue(uri.toString().endsWith("target/test-classes/test.mid")); + } +} From d294b2bd9234559c27175b59d86ed7a80f5518b9 Mon Sep 17 00:00:00 2001 From: Naohide Sano Date: Sat, 30 Nov 2024 12:11:05 +0900 Subject: [PATCH 7/8] update settings --- README.md | 2 ++ pom.xml | 10 ++++++---- src/main/java/vavi/sound/adpcm/ccitt/readme.md | 3 +++ src/main/java/vavi/sound/adpcm/vox/readme.md | 2 +- .../javax.sound.sampled.spi.FormatConversionProvider | 1 + 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 7116030..39a8c25 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,8 @@ A. yes you can, follow those steps * ~~`tritonus:tritonus-remaining:org.tritonus.sampled.file.WaveAudioFileReader`~~ * use service provider for mfi, smaf sequencer * service loader instead of vavi.properties + * [RTTTL (Ringing Tones text transfer language)](https://web.archive.org/web/20070704033948/http://www.convertyourtone.com/rtttl.html) + * https://github.com/SatyrDiamond/adpcm --- images by melody, cellphone diff --git a/pom.xml b/pom.xml index a0b41ff..6be4260 100644 --- a/pom.xml +++ b/pom.xml @@ -135,7 +135,7 @@ TODO org.apache.maven.plugins maven-compiler-plugin - 3.11.0 + 3.12.1 17 @@ -160,9 +160,11 @@ TODO org.apache.maven.plugins maven-surefire-plugin - 3.2.2 + 3.2.5 + --add-opens=java.base/java.io=ALL-UNNAMED + --add-opens=java.base/sun.nio.ch=ALL-UNNAMED -Djava.util.logging.config.file=${project.build.testOutputDirectory}/logging.properties -Dvavi.test.dev.null=@{dev.null} -Dvavi.test.volume=@{vavi.test.volume} @@ -191,7 +193,7 @@ TODO org.junit junit-bom - 5.10.2 + 5.10.3 pom import @@ -202,7 +204,7 @@ TODO com.github.umjammer vavi-commons - 1.1.13 + 1.1.14 com.github.umjammer diff --git a/src/main/java/vavi/sound/adpcm/ccitt/readme.md b/src/main/java/vavi/sound/adpcm/ccitt/readme.md index 9a02864..7620713 100644 --- a/src/main/java/vavi/sound/adpcm/ccitt/readme.md +++ b/src/main/java/vavi/sound/adpcm/ccitt/readme.md @@ -7,6 +7,9 @@ Provides CCITT recommendation audio compression related classes. * encoder.exe is little endian * it's necessary to provide '16Bit Signed' value when `PCM_SIGNED` + + * G.711 ... VoIP + ## TODO * 3, 5bit diff --git a/src/main/java/vavi/sound/adpcm/vox/readme.md b/src/main/java/vavi/sound/adpcm/vox/readme.md index f15ad6b..3e54be1 100644 --- a/src/main/java/vavi/sound/adpcm/vox/readme.md +++ b/src/main/java/vavi/sound/adpcm/vox/readme.md @@ -2,7 +2,7 @@ Provides VOX ADPCM codec related classes. -# Status +## Status completed diff --git a/src/main/resources/META-INF/services/javax.sound.sampled.spi.FormatConversionProvider b/src/main/resources/META-INF/services/javax.sound.sampled.spi.FormatConversionProvider index 3817ef1..44c0813 100644 --- a/src/main/resources/META-INF/services/javax.sound.sampled.spi.FormatConversionProvider +++ b/src/main/resources/META-INF/services/javax.sound.sampled.spi.FormatConversionProvider @@ -15,3 +15,4 @@ vavi.sound.sampled.adpcm.oki.OkiFormatConversionProvider vavi.sound.sampled.adpcm.rohm.RohmFormatConversionProvider vavi.sound.sampled.adpcm.vox.VoxFormatConversionProvider vavi.sound.sampled.adpcm.yamaha.YamahaFormatConversionProvider +#vavi.sound.pcm.resampling.ssrc.SSRCSampleRateConversionProvider From 94fec78b31b46537fa48d0ee62f8e61aa8760bf8 Mon Sep 17 00:00:00 2001 From: Naohide Sano Date: Sat, 30 Nov 2024 12:12:12 +0900 Subject: [PATCH 8/8] bump version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6be4260..87b9326 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ vavi vavi-sound - 1.0.19 + 1.0.20 Vavi Sound API https://github.com/umjammer/vavi-sound