From 9987e78487dff496652166c5394038c80cdc37ce Mon Sep 17 00:00:00 2001 From: Naohide Sano Date: Tue, 15 Nov 2022 15:08:59 +0900 Subject: [PATCH 1/7] update github ci settings --- .github/workflows/maven.yml | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index aa9c942..eb50c00 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -15,12 +15,19 @@ jobs: runs-on: macos-latest steps: - - uses: actions/checkout@v3 - - name: Set up JDK 1.8 - uses: actions/setup-java@v3 - with: - java-version: '8' - distribution: 'temurin' - cache: maven - - name: Build with Maven - run: mvn -B package --file pom.xml + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Check w/o SNAPSHOT when "bump version" + if: ${{ contains(github.event.head_commit.message, 'bump version') }} + run: grep "" pom.xml | head -1 | grep -v SNAPSHOT + + - name: Set up JDK 8 + uses: actions/setup-java@v3 + with: + java-version: '8' + distribution: 'temurin' + cache: maven + + - name: Build with Maven + run: mvn -B package --file pom.xml From 0dd677162c5579a727554b59e79bde0c0f407125 Mon Sep 17 00:00:00 2001 From: Naohide Sano Date: Tue, 15 Nov 2022 15:09:09 +0900 Subject: [PATCH 2/7] update dependencies --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 384003b..153ce11 100644 --- a/pom.xml +++ b/pom.xml @@ -119,7 +119,7 @@ TODO org.junit junit-bom - 5.9.0 + 5.9.1 pom import @@ -130,7 +130,7 @@ TODO com.github.umjammer vavi-commons - 1.1.7 + 1.1.8 com.github.umjammer From 96fa93e0b857885d95c92e43487283f87c2f8729 Mon Sep 17 00:00:00 2001 From: Naohide Sano Date: Tue, 13 Dec 2022 17:58:45 +0900 Subject: [PATCH 3/7] fix logging level --- src/main/java/vavi/sound/mfi/MfiSystem.java | 4 +- .../vavi/sound/mfi/vavi/AudioDataMessage.java | 19 +++--- .../vavi/sound/mfi/vavi/MetaEventAdapter.java | 4 +- .../java/vavi/sound/mfi/vavi/MfiContext.java | 46 +++++++------- .../java/vavi/sound/mfi/vavi/MidiContext.java | 16 ++--- .../sound/mfi/vavi/VaviMfiFileFormat.java | 15 ++--- .../sound/mfi/vavi/VaviMidiConverter.java | 14 ++--- .../vavi/sound/mfi/vavi/VaviNoteMessage.java | 2 +- .../vavi/sound/mfi/vavi/VaviSequencer.java | 7 ++- .../sound/mfi/vavi/mitsubishi/Function1.java | 4 +- .../mfi/vavi/mitsubishi/Function129.java | 4 +- .../mfi/vavi/mitsubishi/Function130.java | 4 +- .../mfi/vavi/mitsubishi/Function131.java | 7 ++- .../mfi/vavi/mitsubishi/Function132.java | 9 ++- .../mfi/vavi/mitsubishi/Function143.java | 7 ++- .../sound/mfi/vavi/mitsubishi/Function16.java | 4 +- .../sound/mfi/vavi/mitsubishi/Function17.java | 4 +- .../sound/mfi/vavi/mitsubishi/Function2.java | 4 +- .../sound/mfi/vavi/mitsubishi/Function3.java | 4 +- .../vavi/mitsubishi/MitsubishiMessage.java | 25 ++++---- .../vavi/mitsubishi/MitsubishiSequencer.java | 7 ++- .../sound/mfi/vavi/nec/Function1_240_7.java | 7 ++- .../sound/mfi/vavi/nec/Function1_241_3.java | 4 +- .../sound/mfi/vavi/nec/Function1_241_4.java | 4 +- .../sound/mfi/vavi/nec/Function1_241_5.java | 4 +- .../sound/mfi/vavi/nec/Function1_241_6.java | 4 +- .../sound/mfi/vavi/nec/Function1_243_3.java | 4 +- .../sound/mfi/vavi/nec/Function1_243_4.java | 4 +- .../sound/mfi/vavi/nec/Function240_1.java | 6 +- .../sound/mfi/vavi/nec/Function240_2.java | 9 ++- .../sound/mfi/vavi/nec/Function241_0.java | 6 +- .../sound/mfi/vavi/nec/Function241_1.java | 6 +- .../sound/mfi/vavi/nec/Function241_2.java | 6 +- .../sound/mfi/vavi/nec/Function242_1.java | 4 +- .../sound/mfi/vavi/nec/Function242_4.java | 6 +- .../sound/mfi/vavi/nec/Function242_5.java | 6 +- .../vavi/sound/mfi/vavi/nec/NecMessage.java | 61 ++++++++++--------- .../vavi/sound/mfi/vavi/nec/NecSequencer.java | 8 ++- .../sequencer/MachineDependentFunction.java | 6 +- .../mfi/vavi/sequencer/UndefinedFunction.java | 10 +-- .../sound/mfi/vavi/sharp/Function129.java | 4 +- .../sound/mfi/vavi/sharp/Function130.java | 4 +- .../sound/mfi/vavi/sharp/Function131.java | 7 ++- .../sound/mfi/vavi/sharp/Function132.java | 9 ++- .../sound/mfi/vavi/sharp/Function143.java | 4 +- .../sound/mfi/vavi/sharp/SharpMessage.java | 17 +++--- .../sound/mfi/vavi/sharp/SharpSequencer.java | 7 ++- .../vavi/sound/mobile/BasicAudioEngine.java | 26 ++++---- .../vavi/sound/mobile/FuetrekAudioEngine.java | 3 +- .../smaf/message/yamaha/YamahaMessage.java | 3 +- .../adpcm/oki/OkiAudioFileReaderTest.java | 3 +- 51 files changed, 274 insertions(+), 188 deletions(-) diff --git a/src/main/java/vavi/sound/mfi/MfiSystem.java b/src/main/java/vavi/sound/mfi/MfiSystem.java index 2aad22e..d9e6e14 100644 --- a/src/main/java/vavi/sound/mfi/MfiSystem.java +++ b/src/main/java/vavi/sound/mfi/MfiSystem.java @@ -156,7 +156,7 @@ public static MfiFileFormat getMfiFileFormat(InputStream stream) //Debug.println(StringUtil.paramString(mff)); return mff; } catch (Exception e) { -Debug.println(e); +Debug.println(Level.WARNING, e); } } @@ -309,7 +309,7 @@ public static int write(Sequence in, int fileType, File out) providers = ServiceLoader.load(vavi.sound.mfi.spi.MfiDeviceProvider.class); providers.forEach(System.err::println); provider = StreamSupport.stream(providers.spliterator(), false).filter(p -> p.getClass().getName().equals(defaultProvider)).findFirst().get(); -Debug.println("default provider: " + provider.getClass().getName()); +Debug.println(Level.FINE, "default provider: " + provider.getClass().getName()); readers = ServiceLoader.load(vavi.sound.mfi.spi.MfiFileReader.class); providers.forEach(System.err::println); diff --git a/src/main/java/vavi/sound/mfi/vavi/AudioDataMessage.java b/src/main/java/vavi/sound/mfi/vavi/AudioDataMessage.java index 6c805e9..7bbb620 100644 --- a/src/main/java/vavi/sound/mfi/vavi/AudioDataMessage.java +++ b/src/main/java/vavi/sound/mfi/vavi/AudioDataMessage.java @@ -13,6 +13,7 @@ import java.io.OutputStream; import java.util.LinkedHashMap; import java.util.Map; +import java.util.logging.Level; import javax.sound.midi.InvalidMidiDataException; import javax.sound.midi.MetaMessage; @@ -131,15 +132,15 @@ public void writeTo(OutputStream os) // 1. recalc int dataLength = data.length; -Debug.println("dataLength: " + dataLength); +Debug.println(Level.FINE, "dataLength: " + dataLength); int subChunksLength = 0; for (SubMessage subChunk : subChunks.values()) { subChunksLength += 4 + 2 + subChunk.getDataLength(); // type + length + ... } -Debug.println("subChunksLength: " + subChunksLength); +Debug.println(Level.FINE, "subChunksLength: " + subChunksLength); int headerLength = 1 + 1 + subChunksLength; // format + attribute + ... int audioDataLength = 2 + headerLength + dataLength; // headerLength + ... -Debug.println("audioDataLength: " + audioDataLength); +Debug.println(Level.FINE, "audioDataLength: " + audioDataLength); // 2. write DataOutputStream dos = new DataOutputStream(os); @@ -183,7 +184,7 @@ public void readFrom(InputStream is) int headerLength = dis.readUnsignedShort(); this.format = dis.readUnsignedByte(); this.attribute = dis.readUnsignedByte(); -Debug.printf("adat header: %d: f: %02x, a: %02x", headerLength, format, attribute); +Debug.printf(Level.FINE, "adat header: %d: f: %02x, a: %02x", headerLength, format, attribute); // sub chunks int l = 0; @@ -191,14 +192,14 @@ public void readFrom(InputStream is) SubMessage subChunk = SubMessage.readFrom(is); subChunks.put(subChunk.getSubType(), subChunk); l += subChunk.getDataLength() + 4 + 2; // + type + length -Debug.println("audio subchunk length sum: " + l + " / " + (headerLength - 2)); +Debug.println(Level.FINE, "audio subchunk length sum: " + l + " / " + (headerLength - 2)); } // data int dataLength = audioDataLength - (headerLength + 1 + 1); // + format + attribute data = new byte[dataLength]; // TODO 全部のデータ含めるべき dis.readFully(data, 0, dataLength); -Debug.println("adat length[" + audioDataNumber + "]: " + dataLength + " bytes\n" + StringUtil.getDump(data, 16)); +Debug.println(Level.FINE, "adat length[" + audioDataNumber + "]: " + dataLength + " bytes\n" + StringUtil.getDump(data, 16)); // this.length = audioDataLength + 4 + 4; // + type + length @@ -214,15 +215,15 @@ public void setData(byte[] data) { // calc int dataLength = data.length; -Debug.println("dataLength: " + dataLength); +Debug.println(Level.FINE, "dataLength: " + dataLength); int subChunksLength = 0; for (SubMessage subChunk : subChunks.values()) { subChunksLength += 4 + 2 + subChunk.getDataLength(); // type + length + ... } -Debug.println("subChunksLength: " + subChunksLength); +Debug.println(Level.FINE, "subChunksLength: " + subChunksLength); int headerLength = 1 + 1 + subChunksLength; // format + attribute + ... int audioDataLength = 2 + headerLength + dataLength; // headerLength + ... -Debug.println("audioDataLength: " + audioDataLength); +Debug.println(Level.FINE, "audioDataLength: " + audioDataLength); this.length = audioDataLength + 4 + 4; // + type + length } diff --git a/src/main/java/vavi/sound/mfi/vavi/MetaEventAdapter.java b/src/main/java/vavi/sound/mfi/vavi/MetaEventAdapter.java index 6d4272d..c402729 100644 --- a/src/main/java/vavi/sound/mfi/vavi/MetaEventAdapter.java +++ b/src/main/java/vavi/sound/mfi/vavi/MetaEventAdapter.java @@ -83,14 +83,14 @@ public void meta(javax.sound.midi.MetaMessage message) { case META_TEXT_EVENT: // テキスト・イベント case META_COPYRIGHT: // 著作権表示 case META_NAME: // シーケンス名またはトラック名 -Debug.println("meta " + message.getType() + ": " + MidiUtil.getDecodedMessage(message.getData())); +Debug.println(Level.FINE, "meta " + message.getType() + ": " + MidiUtil.getDecodedMessage(message.getData())); break; case META_END_OF_TRACK: // トラックの終わり case META_TEMPO: // テンポ設定 Debug.println(Level.FINE, "this handler ignore meta: " + message.getType()); break; default: -Debug.println("no meta sub handler: " + message.getType()); +Debug.println(Level.FINE, "no meta sub handler: " + message.getType()); break; } } diff --git a/src/main/java/vavi/sound/mfi/vavi/MfiContext.java b/src/main/java/vavi/sound/mfi/vavi/MfiContext.java index 1cd70c1..1924e9f 100644 --- a/src/main/java/vavi/sound/mfi/vavi/MfiContext.java +++ b/src/main/java/vavi/sound/mfi/vavi/MfiContext.java @@ -57,7 +57,7 @@ public int getType() { /** MIDI format type */ public void setType(int type) { -Debug.println("type: " + type); +Debug.println(Level.FINE, "type: " + type); this.type = type; } @@ -225,7 +225,7 @@ public MfiEvent[] getIntervalMfiEvents(int mfiTrackNumber) { } else if (midiMessage instanceof MetaMessage && ((MetaMessage) midiMessage).getType() == 81) { // tempo interval = retrieveAdjustedDelta(mfiTrackNumber, midiEvent.getTick()); -Debug.println("interval for tempo[" + mfiTrackNumber + "]: " + interval); +Debug.println(Level.FINE, "interval for tempo[" + mfiTrackNumber + "]: " + interval); } else if (midiMessage instanceof MetaMessage && ((MetaMessage) midiMessage).getType() == 47) { // eot interval = retrieveAdjustedDelta(mfiTrackNumber, midiEvent.getTick()); @@ -353,7 +353,7 @@ public void setMidiSequence(Sequence midiSequence) { } } this.scale = Math.ceil(this.scale); -Debug.println("(SCALE) final scale: " + scale + ", " + scaleChanged); +Debug.println(Level.FINE, "(SCALE) final scale: " + scale + ", " + scaleChanged); for (int t = 0; t < midiTracks.length; t++) { for (int i = 0; i < midiTracks[t].size(); i++) { @@ -362,28 +362,28 @@ public void setMidiSequence(Sequence midiSequence) { } Collections.sort(midiEvents, new Comparator() { - /** */ - public int compare(MidiEvent e1, MidiEvent e2) { - long t1 = e1.getTick(); - long t2 = e2.getTick(); - if (t1 - t2 != 0) { - return (int) (t1 - t2); - } else { - int c1 = getChannel(e1); - int c2 = getChannel(e2); - return c1 - c2; - } + /** */ + public int compare(MidiEvent e1, MidiEvent e2) { + long t1 = e1.getTick(); + long t2 = e2.getTick(); + if (t1 - t2 != 0) { + return (int) (t1 - t2); + } else { + int c1 = getChannel(e1); + int c2 = getChannel(e2); + return c1 - c2; } - /** */ - int getChannel(MidiEvent e) { - MidiMessage m = e.getMessage(); - if (m instanceof ShortMessage) { - return ((ShortMessage) m).getChannel(); - } else { - return -1; - } + } + /** */ + int getChannel(MidiEvent e) { + MidiMessage m = e.getMessage(); + if (m instanceof ShortMessage) { + return ((ShortMessage) m).getChannel(); + } else { + return -1; } - }); + } + }); this.noteOffEventUsed = new BitSet(midiEvents.size()); } diff --git a/src/main/java/vavi/sound/mfi/vavi/MidiContext.java b/src/main/java/vavi/sound/mfi/vavi/MidiContext.java index 975cd4a..d523542 100644 --- a/src/main/java/vavi/sound/mfi/vavi/MidiContext.java +++ b/src/main/java/vavi/sound/mfi/vavi/MidiContext.java @@ -6,6 +6,8 @@ package vavi.sound.mfi.vavi; +import java.util.logging.Level; + import vavi.sound.mfi.InvalidMfiDataException; import vavi.sound.mfi.MfiEvent; import vavi.sound.mfi.MfiMessage; @@ -100,7 +102,7 @@ public void addCurrent(long value) { */ public void setDrum(int channel, ChannelConfiguration value) { if (drumSwapChannel != CHANNEL_UNUSED && channel == drumSwapChannel) { -Debug.println("already swapped: " + channel + ", " + value); +Debug.println(Level.FINE, "already swapped: " + channel + ", " + value); } else { drums[channel] = value; } @@ -110,12 +112,12 @@ public void setDrum(int channel, ChannelConfiguration value) { for (int k = MAX_MIDI_CHANNELS - 1; k >= 0; k--) { if (k != CHANNEL_DRUM && drums[k] == ChannelConfiguration.UNUSED) { drumSwapChannel = k; // TODO 複数対応? -Debug.println("channel 9 -> " + k); +Debug.println(Level.FINE, "channel 9 -> " + k); break; } } if (drumSwapChannel == CHANNEL_UNUSED) { -Debug.println("cannot swap: " + channel + ", " + value); +Debug.println(Level.FINE, "cannot swap: " + channel + ", " + value); } } } @@ -153,7 +155,7 @@ public int getVolume(int channel) { */ public int setProgram(int channel, int program) { if (channel != drumSwapChannel && drums[channel] == ChannelConfiguration.PERCUSSION) { -Debug.println("drum always zero:[" + channel + "]: " + program); +Debug.println(Level.FINE, "drum always zero:[" + channel + "]: " + program); program = 0; } @@ -170,7 +172,7 @@ public int setProgram(int channel, int program) { */ public int setBank(int channel, int bank) { if (channel != drumSwapChannel && drums[channel] == ChannelConfiguration.PERCUSSION) { -Debug.println("drum always zero:[" + channel + "]: " + bank); +Debug.println(Level.FINE, "drum always zero:[" + channel + "]: " + bank); bank = 0; } @@ -265,7 +267,7 @@ public int retrieveRealPitch(int channel) { int pitch = // (int) ((pb * rgb * 100f / 32f) + ((fpb * rgb * 100f) / (32f * 32f))); (pb * rg * 100 / 32) + ((fpb * rg * 100) / (32 * 32)) / 20; -Debug.println("pitch[" + channel + "]: " + pitch); +Debug.println(Level.FINE, "pitch[" + channel + "]: " + pitch); return pitch; } @@ -293,7 +295,7 @@ public int getResolution(Track[] mfiTracks) } } -Debug.println("no tempo message in track 0"); +Debug.println(Level.INFO, "no tempo message in track 0"); return 48; // MFi default time base } } diff --git a/src/main/java/vavi/sound/mfi/vavi/VaviMfiFileFormat.java b/src/main/java/vavi/sound/mfi/vavi/VaviMfiFileFormat.java index 8595227..b3470f6 100644 --- a/src/main/java/vavi/sound/mfi/vavi/VaviMfiFileFormat.java +++ b/src/main/java/vavi/sound/mfi/vavi/VaviMfiFileFormat.java @@ -13,6 +13,7 @@ import java.util.List; import java.util.Map; import java.util.NoSuchElementException; +import java.util.logging.Level; import vavi.sound.mfi.InvalidMfiDataException; import vavi.sound.mfi.MfiEvent; @@ -174,7 +175,7 @@ private int getAudioDataLength() { audioDataLength += message.getLength(); } } -Debug.println("audioDataLength: " + audioDataLength); +Debug.println(Level.FINE, "audioDataLength: " + audioDataLength); return audioDataLength; } @@ -266,7 +267,7 @@ public static VaviMfiFileFormat readFrom(InputStream is) // 2. audio data for (int audioDataNumber = 0; audioDataNumber < audioDataCount; audioDataNumber++) { -Debug.println("audio data number: " + audioDataNumber); +Debug.println(Level.FINE, "audio data number: " + audioDataNumber); AudioDataMessage audioDataChunk = new AudioDataMessage(audioDataNumber); audioDataChunk.readFrom(is); @@ -274,12 +275,12 @@ public static VaviMfiFileFormat readFrom(InputStream is) audioDataChunks.add(audioDataChunk); l += audioDataChunk.getLength(); -Debug.println("adat length sum: " + l + " / " + dataLength); +Debug.println(Level.FINE, "adat length sum: " + l + " / " + dataLength); } // 3. track for (int trackNumber = 0; trackNumber < tracksCount; trackNumber++) { -Debug.println("track number: " + trackNumber); +Debug.println(Level.FINE, "track number: " + trackNumber); Track track = mff.sequence.createTrack(); @@ -294,10 +295,10 @@ public static VaviMfiFileFormat readFrom(InputStream is) trackChunk.readFrom(is); l += trackChunk.getLength(); -Debug.println("trac length sum: " + l + " / " + dataLength); +Debug.println(Level.FINE, "trac length sum: " + l + " / " + dataLength); } -Debug.println("is rest: " + is.available()); +Debug.println(Level.FINE, "is rest: " + is.available()); return mff; } @@ -361,7 +362,7 @@ public int getNoteLength() { if (subChunk != null) { return subChunk.getNoteLength(); } else { -Debug.println("no note info, use 0"); +Debug.println(Level.INFO, "no note info, use 0"); return 0; } } diff --git a/src/main/java/vavi/sound/mfi/vavi/VaviMidiConverter.java b/src/main/java/vavi/sound/mfi/vavi/VaviMidiConverter.java index 44117ca..927fbbc 100644 --- a/src/main/java/vavi/sound/mfi/vavi/VaviMidiConverter.java +++ b/src/main/java/vavi/sound/mfi/vavi/VaviMidiConverter.java @@ -103,10 +103,10 @@ public vavi.sound.mfi.Sequence toMfiSequence(Sequence midiSequence, int fileType protected vavi.sound.mfi.Sequence convert(Sequence midiSequence, int fileType) throws InvalidMfiDataException, IOException { -Debug.println("divisionType: " + midiSequence.getDivisionType()); -Debug.println("microsecondLength: " + midiSequence.getMicrosecondLength()); -Debug.println("resolution: " + midiSequence.getResolution()); -Debug.println("tickLength: " + midiSequence.getTickLength()); +Debug.println(Level.FINE, "divisionType: " + midiSequence.getDivisionType()); +Debug.println(Level.FINE, "microsecondLength: " + midiSequence.getMicrosecondLength()); +Debug.println(Level.FINE, "resolution: " + midiSequence.getResolution()); +Debug.println(Level.FINE, "tickLength: " + midiSequence.getTickLength()); // vavi.sound.mfi.Sequence mfiSequence = new vavi.sound.mfi.Sequence(); @@ -169,7 +169,7 @@ protected vavi.sound.mfi.Sequence convert(Sequence midiSequence, int fileType) // master volume if (maxTracks == 0) { mfiSequence.createTrack(); -Debug.println("create MFi track: 0"); +Debug.println(Level.FINE, "create MFi track: 0"); mfiTracks = mfiSequence.getTracks(); maxTracks = mfiTracks.length; } @@ -189,7 +189,7 @@ protected vavi.sound.mfi.Sequence convert(Sequence midiSequence, int fileType) if (maxTracks == 0) { mfiSequence.createTrack(); -Debug.println("create MFi track: 0"); +Debug.println(Level.FINE, "create MFi track: 0"); mfiTracks = mfiSequence.getTracks(); maxTracks = mfiTracks.length; } @@ -227,7 +227,7 @@ protected vavi.sound.mfi.Sequence convert(Sequence midiSequence, int fileType) //Debug.println("EOF already set[" + t + "]"); } } else { -Debug.println("message is null[" + mfiTracks[t].size() + "]: " + midiMessage); +Debug.println(Level.FINE, "message is null[" + mfiTracks[t].size() + "]: " + midiMessage); } } } else { diff --git a/src/main/java/vavi/sound/mfi/vavi/VaviNoteMessage.java b/src/main/java/vavi/sound/mfi/vavi/VaviNoteMessage.java index a683c0a..f3ef266 100644 --- a/src/main/java/vavi/sound/mfi/vavi/VaviNoteMessage.java +++ b/src/main/java/vavi/sound/mfi/vavi/VaviNoteMessage.java @@ -97,7 +97,7 @@ public MfiEvent[] getMfiEvents(MidiEvent midiEvent, MfiContext context) (command == ShortMessage.NOTE_ON && data2 == 0)) { if (!context.isNoteOffEventUsed()) { -Debug.println("[" + context.getMidiEventIndex() + "] no pair of ON for: " + channel + "ch, " + data1); +Debug.println(Level.INFO, "[" + context.getMidiEventIndex() + "] no pair of ON for: " + channel + "ch, " + data1); } return null; diff --git a/src/main/java/vavi/sound/mfi/vavi/VaviSequencer.java b/src/main/java/vavi/sound/mfi/vavi/VaviSequencer.java index 2af7f34..262233a 100644 --- a/src/main/java/vavi/sound/mfi/vavi/VaviSequencer.java +++ b/src/main/java/vavi/sound/mfi/vavi/VaviSequencer.java @@ -8,6 +8,7 @@ import java.io.IOException; import java.io.InputStream; +import java.util.logging.Level; import javax.sound.midi.Instrument; import javax.sound.midi.InvalidMidiDataException; @@ -114,10 +115,10 @@ public void setSequence(Sequence sequence) try { midiSequencer.setSequence(MfiSystem.toMidiSequence(sequence)); } catch (InvalidMidiDataException e) { -Debug.println(e); +Debug.println(Level.SEVERE, e); throw new InvalidMfiDataException(e); } catch (MfiUnavailableException e) { -Debug.println(e); +Debug.println(Level.SEVERE, e); throw new IllegalStateException(e); } } @@ -208,7 +209,7 @@ public void meta(javax.sound.midi.MetaMessage message) { fireMeta(metaMessage); off(); } catch (InvalidMfiDataException e) { -Debug.println(e); +Debug.println(Level.SEVERE, e); } catch (RuntimeException e) { Debug.printStackTrace(e); diff --git a/src/main/java/vavi/sound/mfi/vavi/mitsubishi/Function1.java b/src/main/java/vavi/sound/mfi/vavi/mitsubishi/Function1.java index 54c4b4d..e5732f4 100644 --- a/src/main/java/vavi/sound/mfi/vavi/mitsubishi/Function1.java +++ b/src/main/java/vavi/sound/mfi/vavi/mitsubishi/Function1.java @@ -6,6 +6,8 @@ package vavi.sound.mfi.vavi.mitsubishi; +import java.util.logging.Level; + import vavi.sound.mfi.InvalidMfiDataException; import vavi.sound.mfi.vavi.sequencer.MachineDependentFunction; import vavi.sound.mfi.vavi.track.MachineDependentMessage; @@ -42,7 +44,7 @@ public void process(MachineDependentMessage message) int pitchBend = data[7] & 0x3f; // -32 ~ 31 pitchBend *= (data[7] & 0x20) != 0 ? -1 : 0; // pitchBend * Pitch Bend Range * 100 / 32 [セント] -Debug.printf("Pitch Bend: %02x %d\n", voice, pitchBend); +Debug.printf(Level.FINE, "Pitch Bend: %02x %d\n", voice, pitchBend); } } diff --git a/src/main/java/vavi/sound/mfi/vavi/mitsubishi/Function129.java b/src/main/java/vavi/sound/mfi/vavi/mitsubishi/Function129.java index cb4e7be..d5ce1ce 100644 --- a/src/main/java/vavi/sound/mfi/vavi/mitsubishi/Function129.java +++ b/src/main/java/vavi/sound/mfi/vavi/mitsubishi/Function129.java @@ -6,6 +6,8 @@ package vavi.sound.mfi.vavi.mitsubishi; +import java.util.logging.Level; + import vavi.sound.mfi.InvalidMfiDataException; import vavi.sound.mfi.vavi.sequencer.MachineDependentFunction; import vavi.sound.mfi.vavi.track.MachineDependentMessage; @@ -40,7 +42,7 @@ public void process(MachineDependentMessage message) this.channel = (data[7] & 0xc0) >> 6; // 0 ~ 3 this.volume = data[7] & 0x3f; // -Debug.printf("ADPCM volume: %dch %02x\n", channel, volume); +Debug.printf(Level.FINE, "ADPCM volume: %dch %02x\n", channel, volume); } /** */ diff --git a/src/main/java/vavi/sound/mfi/vavi/mitsubishi/Function130.java b/src/main/java/vavi/sound/mfi/vavi/mitsubishi/Function130.java index 61eab2c..0d1f2bb 100644 --- a/src/main/java/vavi/sound/mfi/vavi/mitsubishi/Function130.java +++ b/src/main/java/vavi/sound/mfi/vavi/mitsubishi/Function130.java @@ -6,6 +6,8 @@ package vavi.sound.mfi.vavi.mitsubishi; +import java.util.logging.Level; + import vavi.sound.mfi.InvalidMfiDataException; import vavi.sound.mfi.vavi.sequencer.MachineDependentFunction; import vavi.sound.mfi.vavi.track.MachineDependentMessage; @@ -40,7 +42,7 @@ public void process(MachineDependentMessage message) this.channel = (data[7] & 0xc0) >> 6; // 0 ~ 3 this.panpot = data[7] & 0x3f; // 0x20 center -Debug.printf("ADPCM pan: %dch %02x\n", channel, panpot); +Debug.printf(Level.FINE, "ADPCM pan: %dch %02x\n", channel, panpot); } /** */ 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 20ff775..a911826 100644 --- a/src/main/java/vavi/sound/mfi/vavi/mitsubishi/Function131.java +++ b/src/main/java/vavi/sound/mfi/vavi/mitsubishi/Function131.java @@ -13,6 +13,7 @@ import vavi.sound.mfi.vavi.track.MachineDependentMessage; import vavi.sound.mobile.AudioEngine; import vavi.util.Debug; +import vavi.util.StringUtil; /** @@ -75,12 +76,12 @@ public void process(MachineDependentMessage message) this.continued = (data[9] & 0x01) == 1; // int adpcmLength = data.length - HEADER_LENGTH; -Debug.printf("ADPCM voice: %dch, No.%d, mode=%d, continued=%d, %d\n", channel, packetId, mode, continued, adpcmLength); -//Debug.dump(data); +Debug.printf(Level.FINE, "ADPCM voice: %dch, No.%d, mode=%d, continued=%d, %d\n", channel, packetId, mode, continued, adpcmLength); +Debug.println(Level.FINEST, "data:\n" + StringUtil.getDump(data, 32)); this.sampleRate = getSamplingRateInternal(format1); this.bits = getSamplingBitsInternal(format2); -Debug.printf("sampling: %02x: rate=%d, bits=%d\n", data[8] & 0x3f, sampleRate, bits); +Debug.printf(Level.FINE, "sampling: %02x: rate=%d, bits=%d\n", data[8] & 0x3f, sampleRate, bits); this.adpcm = new byte[adpcmLength]; System.arraycopy(data, HEADER_LENGTH, adpcm, 0, adpcmLength); diff --git a/src/main/java/vavi/sound/mfi/vavi/mitsubishi/Function132.java b/src/main/java/vavi/sound/mfi/vavi/mitsubishi/Function132.java index 63d1f2d..32d0d22 100644 --- a/src/main/java/vavi/sound/mfi/vavi/mitsubishi/Function132.java +++ b/src/main/java/vavi/sound/mfi/vavi/mitsubishi/Function132.java @@ -6,9 +6,12 @@ package vavi.sound.mfi.vavi.mitsubishi; +import java.util.logging.Level; + import vavi.sound.mfi.InvalidMfiDataException; import vavi.sound.mfi.vavi.track.MachineDependentMessage; import vavi.util.Debug; +import vavi.util.StringUtil; /** @@ -59,12 +62,12 @@ public void process(MachineDependentMessage message) data[13]; int adpcmLength = data.length - HEADER_LENGTH; -Debug.printf("ADPCM voice: " + channel + "ch, No.%d, mode=%d, continued=%d, playSize=%d, %d\n", packetId, mode, continued, length, adpcmLength); -//Debug.dump(data); +Debug.printf(Level.FINE, "ADPCM voice: " + channel + "ch, No.%d, mode=%d, continued=%d, playSize=%d, %d\n", packetId, mode, continued, length, adpcmLength); +Debug.println(Level.FINEST, "data:\n" + StringUtil.getDump(data, 32)); this.sampleRate = getSamplingRateInternal(format1); this.bits = getSamplingBitsInternal(format2); -Debug.printf("sampling: %02x: rate=%d, bits=%d\n", data[8] & 0x3f, sampleRate, bits); +Debug.printf(Level.FINE, "sampling: %02x: rate=%d, bits=%d\n", data[8] & 0x3f, sampleRate, bits); this.adpcm = new byte[adpcmLength]; System.arraycopy(data, HEADER_LENGTH, adpcm, 0, adpcmLength); diff --git a/src/main/java/vavi/sound/mfi/vavi/mitsubishi/Function143.java b/src/main/java/vavi/sound/mfi/vavi/mitsubishi/Function143.java index f1428aa..97a1040 100644 --- a/src/main/java/vavi/sound/mfi/vavi/mitsubishi/Function143.java +++ b/src/main/java/vavi/sound/mfi/vavi/mitsubishi/Function143.java @@ -8,6 +8,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.logging.Level; import vavi.sound.mfi.InvalidMfiDataException; import vavi.sound.mfi.vavi.sequencer.MachineDependentFunction; @@ -52,7 +53,7 @@ public void process(MachineDependentMessage message) byte[] subIdData = new byte[subIdLength]; System.arraycopy(data, index, subIdData, 0, subIdLength); index += subIdLength; -Debug.printf("ADPCM subId: %02x\n%s\n", subId, StringUtil.getDump(subIdData)); +Debug.printf(Level.FINE, "ADPCM subId: %02x\n%s\n", subId, StringUtil.getDump(subIdData)); subIds.add(new SubIdChunk(subId, subIdData)); } } @@ -147,12 +148,12 @@ private class SubIdChunk { /** */ private int getSubIdsLength() { -Debug.println("subIds: " + subIds.size()); +Debug.println(Level.FINE, "subIds: " + subIds.size()); int length = 0; for (SubIdChunk subId : subIds) { length += (1 + 1 + subId.data.length); } -Debug.println("subIds length: " + length); +Debug.println(Level.FINE, "subIds length: " + length); return length; } diff --git a/src/main/java/vavi/sound/mfi/vavi/mitsubishi/Function16.java b/src/main/java/vavi/sound/mfi/vavi/mitsubishi/Function16.java index 5280e42..798d837 100644 --- a/src/main/java/vavi/sound/mfi/vavi/mitsubishi/Function16.java +++ b/src/main/java/vavi/sound/mfi/vavi/mitsubishi/Function16.java @@ -6,6 +6,8 @@ package vavi.sound.mfi.vavi.mitsubishi; +import java.util.logging.Level; + import vavi.sound.mfi.InvalidMfiDataException; import vavi.sound.mfi.vavi.sequencer.MachineDependentFunction; import vavi.sound.mfi.vavi.track.MachineDependentMessage; @@ -40,7 +42,7 @@ public void process(MachineDependentMessage message) int channel = (data[7] & 0xc0) >> 6; // 0 ~ 3 int f2 = data[7] & 0x3f; // 0 ~ 31 -Debug.printf("0x10: %02x %02x\n", channel, f2); +Debug.printf(Level.FINE, "0x10: %02x %02x\n", channel, f2); } } diff --git a/src/main/java/vavi/sound/mfi/vavi/mitsubishi/Function17.java b/src/main/java/vavi/sound/mfi/vavi/mitsubishi/Function17.java index 1bc9abb..7dc30b4 100644 --- a/src/main/java/vavi/sound/mfi/vavi/mitsubishi/Function17.java +++ b/src/main/java/vavi/sound/mfi/vavi/mitsubishi/Function17.java @@ -6,6 +6,8 @@ package vavi.sound.mfi.vavi.mitsubishi; +import java.util.logging.Level; + import vavi.sound.mfi.InvalidMfiDataException; import vavi.sound.mfi.vavi.sequencer.MachineDependentFunction; import vavi.sound.mfi.vavi.track.MachineDependentMessage; @@ -40,7 +42,7 @@ public void process(MachineDependentMessage message) int channel = (data[7] & 0xc0) >> 6; // 0 ~ 3 int f2 = data[7] & 0x3f; // 0 ~ 31 -Debug.printf("0x11: %02x %02x\n", channel, f2); +Debug.printf(Level.FINE, "0x11: %02x %02x\n", channel, f2); } } diff --git a/src/main/java/vavi/sound/mfi/vavi/mitsubishi/Function2.java b/src/main/java/vavi/sound/mfi/vavi/mitsubishi/Function2.java index 9e983a9..9c87cd4 100644 --- a/src/main/java/vavi/sound/mfi/vavi/mitsubishi/Function2.java +++ b/src/main/java/vavi/sound/mfi/vavi/mitsubishi/Function2.java @@ -6,6 +6,8 @@ package vavi.sound.mfi.vavi.mitsubishi; +import java.util.logging.Level; + import vavi.sound.mfi.InvalidMfiDataException; import vavi.sound.mfi.vavi.sequencer.MachineDependentFunction; import vavi.sound.mfi.vavi.track.MachineDependentMessage; @@ -40,7 +42,7 @@ public void process(MachineDependentMessage message) int voice = (data[7] & 0xc0) >> 6; // 0 ~ 3 int pitchBendRange = data[7] & 0x3f; // 0 ~ 16 -Debug.printf("Pitch Bend Range: %02x %02x\n", voice, pitchBendRange); +Debug.printf(Level.FINE, "Pitch Bend Range: %02x %02x\n", voice, pitchBendRange); } } diff --git a/src/main/java/vavi/sound/mfi/vavi/mitsubishi/Function3.java b/src/main/java/vavi/sound/mfi/vavi/mitsubishi/Function3.java index ecf44ad..8997114 100755 --- a/src/main/java/vavi/sound/mfi/vavi/mitsubishi/Function3.java +++ b/src/main/java/vavi/sound/mfi/vavi/mitsubishi/Function3.java @@ -6,6 +6,8 @@ package vavi.sound.mfi.vavi.mitsubishi; +import java.util.logging.Level; + import vavi.sound.mfi.InvalidMfiDataException; import vavi.sound.mfi.vavi.sequencer.MachineDependentFunction; import vavi.sound.mfi.vavi.track.MachineDependentMessage; @@ -40,7 +42,7 @@ public void process(MachineDependentMessage message) int voice = (data[7] & 0xc0) >> 6; // 0 ~ 3 int modulation = data[7] & 0x3f; // 0 ~ 63 -Debug.printf("Vibrato: %d %02x\n", voice, modulation); +Debug.printf(Level.FINE, "Vibrato: %d %02x\n", voice, modulation); } } diff --git a/src/main/java/vavi/sound/mfi/vavi/mitsubishi/MitsubishiMessage.java b/src/main/java/vavi/sound/mfi/vavi/mitsubishi/MitsubishiMessage.java index 5af5df8..e5ac4a1 100644 --- a/src/main/java/vavi/sound/mfi/vavi/mitsubishi/MitsubishiMessage.java +++ b/src/main/java/vavi/sound/mfi/vavi/mitsubishi/MitsubishiMessage.java @@ -8,6 +8,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.logging.Level; import vavi.sound.mfi.InvalidMfiDataException; import vavi.sound.mfi.MfiEvent; @@ -50,19 +51,19 @@ public final class MitsubishiMessage extends FuetrekAudioMessage { */ public static List getAdpcmEvents(byte[] pcm, float time, int sampleRate, int bits, int channels) throws InvalidMfiDataException { int delta = getDelta(time); -Debug.println("delta: " + delta); +Debug.println(Level.FINE, "delta: " + delta); AudioEngine audioEngine = MitsubishiSequencer.getAudioEngine(); byte[] adpcm = audioEngine.encode(bits, channels, pcm); -Debug.println("adpcm mono length: " + adpcm.length); +Debug.println(Level.FINE, "adpcm mono length: " + adpcm.length); List events = new ArrayList<>(); if (channels == 1) { -Debug.println("adpcm length: " + adpcm.length); +Debug.println(Level.FINE, "adpcm length: " + adpcm.length); events.addAll(getAdpcmEventsSub(L, 0, sampleRate, bits, adpcm)); // 0x83 adpcm recycle events.add(getWaveEvent(L, 0, sampleRate, bits)); } else { byte[] temp = new byte[adpcm.length / 2]; -Debug.println("adpcm L, R length: " + temp.length); +Debug.println(Level.FINE, "adpcm L, R length: " + temp.length); System.arraycopy(adpcm, 0, temp, 0, adpcm.length / 2); events.addAll(getAdpcmEventsSub(L, 0, sampleRate, bits, temp)); System.arraycopy(adpcm, adpcm.length / 2, temp, 0, adpcm.length / 2); @@ -97,7 +98,7 @@ private static List getAdpcmEventsSub(int channel, int packetId, int s for (int i = 0; i < numberOfChunks; i++) { byte[] chunk = new byte[MAX_BLOCK]; System.arraycopy(adpcm, MAX_BLOCK * i, chunk, 0, MAX_BLOCK); -Debug.println("wave chunk(" + i + "): " + chunk.length); +Debug.println(Level.FINE, "wave chunk(" + i + "): " + chunk.length); // 0x83 adpcm data events.add(getWaveEvent(channel, packetId, sampleRate, bits, !(i == (numberOfChunks - 1) && moduloOfChunks == 0), chunk)); @@ -105,7 +106,7 @@ private static List getAdpcmEventsSub(int channel, int packetId, int s if (moduloOfChunks != 0) { byte[] chunk = new byte[moduloOfChunks]; System.arraycopy(adpcm, MAX_BLOCK * numberOfChunks, chunk, 0, moduloOfChunks); -Debug.println("wave chunk(" + numberOfChunks + "): " + chunk.length); +Debug.println(Level.FINE, "wave chunk(" + numberOfChunks + "): " + chunk.length); // 0x83 adpcm data events.add(getWaveEvent(channel, packetId, sampleRate, bits, false, chunk)); @@ -126,7 +127,7 @@ private static MfiEvent getWaveEvent(int channel, int packetId, int sampleRate, function.setContinued(continued); function.setAdpcm(adpcm); message.setMessage(0x00, function.getMessage()); - return new MfiEvent(message, 0l); + return new MfiEvent(message, 0L); } /** @@ -145,7 +146,7 @@ private static MfiEvent getWaveEvent(int channel, int packetId, int sampleRate, function.setContinued(false); function.setAdpcm(new byte[0]); message.setMessage(0x00, function.getMessage()); - return new MfiEvent(message, 0l); + return new MfiEvent(message, 0L); } /** 0x84 store (unused) */ @@ -161,7 +162,7 @@ public static MfiEvent getWaveEvent(int channel, int packetId, int sampleRate, i function.setLength(length); function.setAdpcm(adpcm); message.setMessage(0x00, function.getMessage()); - return new MfiEvent(message, 0l); + return new MfiEvent(message, 0L); } /** @@ -187,7 +188,7 @@ private static MfiEvent getVolumeEvent(int channel, int realAdpcmVolume) throws function.setChannel(channel); function.setVolume(realAdpcmVolume); message.setMessage(0x00, function.getMessage()); - return new MfiEvent(message, 0l); + return new MfiEvent(message, 0L); } /** 0x82 */ @@ -209,7 +210,7 @@ private static MfiEvent getPanpotEvent(int channel, int pan) throws InvalidMfiDa function.setChannel(channel); function.setPanpot(pan); message.setMessage(0x00, function.getMessage()); - return new MfiEvent(message, 0l); + return new MfiEvent(message, 0L); } /** 0x8f */ @@ -225,7 +226,7 @@ public static MfiEvent getSettingEvent(int sampleRate, int bits, int channels) t // 0x8B 要は 16kHz, 4bit mono の時 = 4, 8kHz, 4bit mono の時に 2 function.setMaxParallelCue(sampleRate * (bits / 2) * channels); // TODO bit 適当 message.setMessage(0x00, function.getMessage()); - return new MfiEvent(message, 0l); + return new MfiEvent(message, 0L); } } 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 aaedcc2..54f6a2c 100644 --- a/src/main/java/vavi/sound/mfi/vavi/mitsubishi/MitsubishiSequencer.java +++ b/src/main/java/vavi/sound/mfi/vavi/mitsubishi/MitsubishiSequencer.java @@ -6,12 +6,15 @@ package vavi.sound.mfi.vavi.mitsubishi; +import java.util.logging.Level; + import vavi.sound.mfi.InvalidMfiDataException; import vavi.sound.mfi.vavi.sequencer.MachineDependentFunction; import vavi.sound.mfi.vavi.sequencer.MachineDependentSequencer; import vavi.sound.mfi.vavi.track.MachineDependentMessage; import vavi.sound.mobile.AudioEngine; import vavi.sound.mobile.FuetrekAudioEngine; +import vavi.util.Debug; /** @@ -37,10 +40,10 @@ public void sequence(MachineDependentMessage message) byte[] data = message.getMessage(); int function = data[6] & 0xff; -//Debug.println("function: 0x" + StringUtil.toHex2(function)); +Debug.printf(Level.FINER, "function: 0x%02x", function); MachineDependentFunction mdf = factory.getFunction(String.valueOf(function)); - mdf.process(message); + mdf.process(message); } //------------------------------------------------------------------------- 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 b729ae4..2d66d4a 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 @@ -6,10 +6,13 @@ package vavi.sound.mfi.vavi.nec; +import java.util.logging.Level; + import vavi.sound.mfi.InvalidMfiDataException; import vavi.sound.mfi.vavi.sequencer.MachineDependentFunction; import vavi.sound.mfi.vavi.track.MachineDependentMessage; import vavi.util.Debug; +import vavi.util.StringUtil; /** @@ -61,8 +64,8 @@ public void process(MachineDependentMessage message) this.sampleRate = ((data[11] & 0xff) << 8) + (data[12] & 0xff); // 4000 ~ 16000 (stereo 時は半分) int adpcmLength = data.length - HEADER_LENGTH; -Debug.println("ADPCM: No." + streamNumber + ", " + sampleRate + "Hz, " + adpcmLength + " bytes, " + (mono ? "mono" : "stereo") + ", " + format); -//Debug.dump(data, 64); +Debug.println(Level.FINE, "ADPCM: No." + streamNumber + ", " + sampleRate + "Hz, " + adpcmLength + " bytes, " + (mono ? "mono" : "stereo") + ", " + format); +Debug.println(Level.FINEST, "data:\n" + StringUtil.getDump(data, 32)); this.adpcm = new byte[adpcmLength]; System.arraycopy(data, HEADER_LENGTH, adpcm, 0, adpcmLength); diff --git a/src/main/java/vavi/sound/mfi/vavi/nec/Function1_241_3.java b/src/main/java/vavi/sound/mfi/vavi/nec/Function1_241_3.java index 373c018..50bda54 100755 --- a/src/main/java/vavi/sound/mfi/vavi/nec/Function1_241_3.java +++ b/src/main/java/vavi/sound/mfi/vavi/nec/Function1_241_3.java @@ -6,6 +6,8 @@ package vavi.sound.mfi.vavi.nec; +import java.util.logging.Level; + import vavi.sound.mfi.InvalidMfiDataException; import vavi.sound.mfi.vavi.sequencer.MachineDependentFunction; import vavi.sound.mfi.vavi.track.MachineDependentMessage; @@ -52,7 +54,7 @@ public void process(MachineDependentMessage message) this.streamNumber = data[ 9] & 0x1f; // stream number 0 ~ 31 this.velocity = data[10] & 0x7f; // 0 ~ 127 -Debug.println("StreamOn: " + channel + "ch, No." + streamNumber + ", velocity=" + velocity); +Debug.println(Level.FINE, "StreamOn: " + channel + "ch, No." + streamNumber + ", velocity=" + velocity); NecSequencer.getAudioEngine().start(streamNumber); } diff --git a/src/main/java/vavi/sound/mfi/vavi/nec/Function1_241_4.java b/src/main/java/vavi/sound/mfi/vavi/nec/Function1_241_4.java index de98094..8f2aeea 100644 --- a/src/main/java/vavi/sound/mfi/vavi/nec/Function1_241_4.java +++ b/src/main/java/vavi/sound/mfi/vavi/nec/Function1_241_4.java @@ -6,6 +6,8 @@ package vavi.sound.mfi.vavi.nec; +import java.util.logging.Level; + import vavi.sound.mfi.InvalidMfiDataException; import vavi.sound.mfi.vavi.sequencer.MachineDependentFunction; import vavi.sound.mfi.vavi.track.MachineDependentMessage; @@ -52,7 +54,7 @@ public void process(MachineDependentMessage message) this.streamNumber = data[ 9] & 0x1f; // stream number 0 ~ 31 this.velocity = data[10] & 0x7f; // 0 ~ 127 -Debug.println("StreamSlaveOn: " + channel + "ch, No." + streamNumber + ", velocity=" + velocity); +Debug.println(Level.FINE, "StreamSlaveOn: " + channel + "ch, No." + streamNumber + ", velocity=" + velocity); NecSequencer.getAudioEngine().start(streamNumber); } diff --git a/src/main/java/vavi/sound/mfi/vavi/nec/Function1_241_5.java b/src/main/java/vavi/sound/mfi/vavi/nec/Function1_241_5.java index 887cf3d..fe933ec 100644 --- a/src/main/java/vavi/sound/mfi/vavi/nec/Function1_241_5.java +++ b/src/main/java/vavi/sound/mfi/vavi/nec/Function1_241_5.java @@ -6,6 +6,8 @@ package vavi.sound.mfi.vavi.nec; +import java.util.logging.Level; + import vavi.sound.mfi.InvalidMfiDataException; import vavi.sound.mfi.vavi.sequencer.MachineDependentFunction; import vavi.sound.mfi.vavi.track.MachineDependentMessage; @@ -48,7 +50,7 @@ public void process(MachineDependentMessage message) this.channel = (data[8] & 0xc0) >> 6; // this.streamNumber = data[9] & 0x1f; // stream number 0 ~ 31 -Debug.println("StreamOff: " + channel + "ch, No." + streamNumber); +Debug.println(Level.FINE, "StreamOff: " + channel + "ch, No." + streamNumber); NecSequencer.getAudioEngine().stop(streamNumber); // TODO channel ??? } diff --git a/src/main/java/vavi/sound/mfi/vavi/nec/Function1_241_6.java b/src/main/java/vavi/sound/mfi/vavi/nec/Function1_241_6.java index 8f427a6..cb4d50d 100644 --- a/src/main/java/vavi/sound/mfi/vavi/nec/Function1_241_6.java +++ b/src/main/java/vavi/sound/mfi/vavi/nec/Function1_241_6.java @@ -6,6 +6,8 @@ package vavi.sound.mfi.vavi.nec; +import java.util.logging.Level; + import vavi.sound.mfi.InvalidMfiDataException; import vavi.sound.mfi.vavi.sequencer.MachineDependentFunction; import vavi.sound.mfi.vavi.track.MachineDependentMessage; @@ -50,7 +52,7 @@ public void process(MachineDependentMessage message) this.streamNumber = data[ 9] & 0x1f; // stream number 0 ~ 31 this.pan = data[10]; // pan -Debug.println("StreamPan: " + channel + "ch, No." + streamNumber + ", pan: " + pan); +Debug.println(Level.FINE, "StreamPan: " + channel + "ch, No." + streamNumber + ", pan: " + pan); } /** channel 0 ~ 3 */ diff --git a/src/main/java/vavi/sound/mfi/vavi/nec/Function1_243_3.java b/src/main/java/vavi/sound/mfi/vavi/nec/Function1_243_3.java index 0225670..7636b60 100644 --- a/src/main/java/vavi/sound/mfi/vavi/nec/Function1_243_3.java +++ b/src/main/java/vavi/sound/mfi/vavi/nec/Function1_243_3.java @@ -6,6 +6,8 @@ package vavi.sound.mfi.vavi.nec; +import java.util.logging.Level; + import vavi.sound.mfi.InvalidMfiDataException; import vavi.sound.mfi.vavi.sequencer.MachineDependentFunction; import vavi.sound.mfi.vavi.track.MachineDependentMessage; @@ -48,7 +50,7 @@ public void process(MachineDependentMessage message) this.maxGain = data[9]; -Debug.println("MaxGain: " + maxGain); +Debug.println(Level.FINE, "MaxGain: " + maxGain); } /** 0 ~ 96 (-96db) */ diff --git a/src/main/java/vavi/sound/mfi/vavi/nec/Function1_243_4.java b/src/main/java/vavi/sound/mfi/vavi/nec/Function1_243_4.java index df5063d..58e0ef9 100644 --- a/src/main/java/vavi/sound/mfi/vavi/nec/Function1_243_4.java +++ b/src/main/java/vavi/sound/mfi/vavi/nec/Function1_243_4.java @@ -6,6 +6,8 @@ package vavi.sound.mfi.vavi.nec; +import java.util.logging.Level; + import vavi.sound.mfi.InvalidMfiDataException; import vavi.sound.mfi.vavi.sequencer.MachineDependentFunction; import vavi.sound.mfi.vavi.track.MachineDependentMessage; @@ -49,7 +51,7 @@ public void process(MachineDependentMessage message) this.maxStreamNumber = data[9] & 0x03; -Debug.println("maxStreamNumber: " + maxStreamNumber); +Debug.println(Level.FINE, "maxStreamNumber: " + maxStreamNumber); } /** 0 ~ 2, default 0 */ diff --git a/src/main/java/vavi/sound/mfi/vavi/nec/Function240_1.java b/src/main/java/vavi/sound/mfi/vavi/nec/Function240_1.java index 1abed7d..fc3662b 100755 --- a/src/main/java/vavi/sound/mfi/vavi/nec/Function240_1.java +++ b/src/main/java/vavi/sound/mfi/vavi/nec/Function240_1.java @@ -6,6 +6,8 @@ package vavi.sound.mfi.vavi.nec; +import java.util.logging.Level; + import vavi.sound.mfi.InvalidMfiDataException; import vavi.sound.mfi.vavi.sequencer.MachineDependentFunction; import vavi.sound.mfi.vavi.track.MachineDependentMessage; @@ -42,8 +44,8 @@ public void process(MachineDependentMessage message) byte[] data = message.getMessage(); int channel = (data[7] & 0xc0) >> 6; // 0 ~ 3 -Debug.println("FM voice change: " + channel); -Debug.println(StringUtil.getDump(data)); +Debug.println(Level.FINE, "FM voice change: " + channel); +Debug.println(Level.FINEST, "data:\n" + StringUtil.getDump(data, 32)); } } diff --git a/src/main/java/vavi/sound/mfi/vavi/nec/Function240_2.java b/src/main/java/vavi/sound/mfi/vavi/nec/Function240_2.java index f89d039..f3ce2ee 100644 --- a/src/main/java/vavi/sound/mfi/vavi/nec/Function240_2.java +++ b/src/main/java/vavi/sound/mfi/vavi/nec/Function240_2.java @@ -6,11 +6,14 @@ package vavi.sound.mfi.vavi.nec; +import java.util.logging.Level; + import vavi.sound.mfi.InvalidMfiDataException; import vavi.sound.mfi.vavi.sequencer.MachineDependentFunction; import vavi.sound.mfi.vavi.track.MachineDependentMessage; import vavi.sound.mobile.AudioEngine; import vavi.util.Debug; +import vavi.util.StringUtil; /** @@ -62,8 +65,8 @@ public void process(MachineDependentMessage message) } int adpcmLength = data.length - HEADER_LENGTH; -Debug.println("ADPCM data: No." + streamNumber + ", " + sampleRate + "Hz, " + adpcmLength); -//Debug.dump(data, 64); +Debug.println(Level.FINE, "ADPCM data: No." + streamNumber + ", " + sampleRate + "Hz, " + adpcmLength); +Debug.println(Level.FINEST, "data:\n" + StringUtil.getDump(data, 64)); this.adpcm = new byte[adpcmLength]; System.arraycopy(data, HEADER_LENGTH, adpcm, 0, adpcmLength); @@ -101,7 +104,7 @@ public byte[] getMessage() throws InvalidMfiDataException { AudioEngine audioEngine = NecSequencer.getAudioEngine(); adpcm = audioEngine.encode(4, 1, pcm); // TODO bits, channel -Debug.println("adpcm length: " + adpcm.length); +Debug.println(Level.FINE, "adpcm length: " + adpcm.length); // [10~] byte[] tmp = new byte[adpcm.length + 5]; diff --git a/src/main/java/vavi/sound/mfi/vavi/nec/Function241_0.java b/src/main/java/vavi/sound/mfi/vavi/nec/Function241_0.java index d7cd838..095607f 100644 --- a/src/main/java/vavi/sound/mfi/vavi/nec/Function241_0.java +++ b/src/main/java/vavi/sound/mfi/vavi/nec/Function241_0.java @@ -6,9 +6,13 @@ package vavi.sound.mfi.vavi.nec; +import java.util.logging.Level; + import vavi.sound.mfi.InvalidMfiDataException; import vavi.sound.mfi.vavi.sequencer.MachineDependentFunction; import vavi.sound.mfi.vavi.track.MachineDependentMessage; +import vavi.util.Debug; +import vavi.util.StringUtil; /** @@ -39,7 +43,7 @@ public void process(MachineDependentMessage message) throws InvalidMfiDataException { byte[] data = message.getMessage(); -//Debug.dump(data, 64); +Debug.println(Level.FINEST, "data:\n" + StringUtil.getDump(data, 64)); this.channel = (data[7] & 0xc0) >> 6; // 0 ~ 3 this.streamNumber = data[8] & 0xff; // stream number 0 ~ 31 diff --git a/src/main/java/vavi/sound/mfi/vavi/nec/Function241_1.java b/src/main/java/vavi/sound/mfi/vavi/nec/Function241_1.java index 62f6132..6d688e3 100644 --- a/src/main/java/vavi/sound/mfi/vavi/nec/Function241_1.java +++ b/src/main/java/vavi/sound/mfi/vavi/nec/Function241_1.java @@ -6,6 +6,8 @@ package vavi.sound.mfi.vavi.nec; +import java.util.logging.Level; + import vavi.sound.mfi.InvalidMfiDataException; import vavi.sound.mfi.vavi.sequencer.MachineDependentFunction; import vavi.sound.mfi.vavi.track.MachineDependentMessage; @@ -43,8 +45,8 @@ public void process(MachineDependentMessage message) int channel = (data[7] & 0xc0) >> 6; // 0 ~ 3 // 8 vibrato -Debug.println("Vibrato: " + channel + ", " + data[8]); -Debug.println(StringUtil.getDump(data)); +Debug.println(Level.FINE, "Vibrato: " + channel + ", " + data[8]); +Debug.println(Level.FINEST, "\n" + StringUtil.getDump(data, 32)); } } diff --git a/src/main/java/vavi/sound/mfi/vavi/nec/Function241_2.java b/src/main/java/vavi/sound/mfi/vavi/nec/Function241_2.java index 4753998..7421818 100644 --- a/src/main/java/vavi/sound/mfi/vavi/nec/Function241_2.java +++ b/src/main/java/vavi/sound/mfi/vavi/nec/Function241_2.java @@ -6,6 +6,8 @@ package vavi.sound.mfi.vavi.nec; +import java.util.logging.Level; + import vavi.sound.mfi.InvalidMfiDataException; import vavi.sound.mfi.vavi.sequencer.MachineDependentFunction; import vavi.sound.mfi.vavi.track.MachineDependentMessage; @@ -43,8 +45,8 @@ public void process(MachineDependentMessage message) int channel = (data[7] & 0xc0) >> 6; // 0 ~ 3 // 8 pitch bend -Debug.println("Pitch Bend: " + channel + ", " + data[8]); -Debug.println(StringUtil.getDump(data)); +Debug.println(Level.FINE, "Pitch Bend: " + channel + ", " + data[8]); +Debug.println(Level.FINEST, StringUtil.getDump(data)); } } diff --git a/src/main/java/vavi/sound/mfi/vavi/nec/Function242_1.java b/src/main/java/vavi/sound/mfi/vavi/nec/Function242_1.java index 8b7a007..ee18342 100644 --- a/src/main/java/vavi/sound/mfi/vavi/nec/Function242_1.java +++ b/src/main/java/vavi/sound/mfi/vavi/nec/Function242_1.java @@ -6,6 +6,8 @@ package vavi.sound.mfi.vavi.nec; +import java.util.logging.Level; + import vavi.sound.mfi.InvalidMfiDataException; import vavi.sound.mfi.vavi.sequencer.MachineDependentFunction; import vavi.sound.mfi.vavi.track.MachineDependentMessage; @@ -45,7 +47,7 @@ public void process(MachineDependentMessage message) this.volume = data[8] & 0x3f; // // 8 volume -Debug.println("ADPCM volume: " + volume); +Debug.println(Level.FINE, "ADPCM volume: " + volume); } /** */ diff --git a/src/main/java/vavi/sound/mfi/vavi/nec/Function242_4.java b/src/main/java/vavi/sound/mfi/vavi/nec/Function242_4.java index fd006f6..0e62962 100644 --- a/src/main/java/vavi/sound/mfi/vavi/nec/Function242_4.java +++ b/src/main/java/vavi/sound/mfi/vavi/nec/Function242_4.java @@ -6,6 +6,8 @@ package vavi.sound.mfi.vavi.nec; +import java.util.logging.Level; + import vavi.sound.mfi.InvalidMfiDataException; import vavi.sound.mfi.vavi.sequencer.MachineDependentFunction; import vavi.sound.mfi.vavi.track.MachineDependentMessage; @@ -44,8 +46,8 @@ public void process(MachineDependentMessage message) // 8 ? // 9 ? 00 -Debug.println("Vibrator: " + channel); -Debug.println(StringUtil.getDump(data)); +Debug.println(Level.FINE, "Vibrator: " + channel); +Debug.println(Level.FINEST, StringUtil.getDump(data)); } } diff --git a/src/main/java/vavi/sound/mfi/vavi/nec/Function242_5.java b/src/main/java/vavi/sound/mfi/vavi/nec/Function242_5.java index 2765187..f93eab8 100755 --- a/src/main/java/vavi/sound/mfi/vavi/nec/Function242_5.java +++ b/src/main/java/vavi/sound/mfi/vavi/nec/Function242_5.java @@ -6,6 +6,8 @@ package vavi.sound.mfi.vavi.nec; +import java.util.logging.Level; + import vavi.sound.mfi.InvalidMfiDataException; import vavi.sound.mfi.vavi.sequencer.MachineDependentFunction; import vavi.sound.mfi.vavi.track.MachineDependentMessage; @@ -44,8 +46,8 @@ public void process(MachineDependentMessage message) // 8 ? // 9 ? 00 -Debug.println("LED: " + channel); -Debug.println(StringUtil.getDump(data)); +Debug.println(Level.FINE, "LED: " + channel); +Debug.println(Level.FINE, StringUtil.getDump(data)); } } 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 e33098e..4bb690f 100644 --- a/src/main/java/vavi/sound/mfi/vavi/nec/NecMessage.java +++ b/src/main/java/vavi/sound/mfi/vavi/nec/NecMessage.java @@ -8,6 +8,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.logging.Level; import vavi.sound.mfi.InvalidMfiDataException; import vavi.sound.mfi.MfiEvent; @@ -37,7 +38,7 @@ public class NecMessage extends YamahaAudioMessage { private static void initSequence() { if (sequence.get() == null) { sequence.set(0); -//System.err.println("thread local sequence: init"); +Debug.println(Level.FINER, "thread local sequence: init"); } } @@ -70,7 +71,7 @@ private static MfiEvent getStreamOn(int streamNumber, int velocity) throws Inval */ public static List getAdpcmEvents(byte[] pcm, float time, int sampleRate, int bits, int channels, int adpcmVolume) throws InvalidMfiDataException { int delta = getDelta(time); -Debug.println("delta: " + delta + ", time: " + time); +Debug.println(Level.FINE, "delta: " + delta + ", time: " + time); int velocity = (int) (adpcmVolume * maxVelocity / 100f); AudioEngine audioEngine = NecSequencer.getAudioEngine(); @@ -87,7 +88,7 @@ public static List getAdpcmEvents(byte[] pcm, float time, int sampleRa System.arraycopy(pcm, (PCM_MAX_BLOCK * channels) * i, temp, 0, PCM_MAX_BLOCK * channels); byte[] chunk = audioEngine.encode(4, channels, temp); if (channels == 1) { -Debug.println("wave chunk(" + i + "): " + chunk.length); +Debug.println(Level.FINE, "wave chunk(" + i + "): " + chunk.length); // adpcm data events.add(getVoiceEvent(streamNumber++, channels, sampleRate, chunk)); @@ -96,13 +97,13 @@ public static List getAdpcmEvents(byte[] pcm, float time, int sampleRa byte[] chunkM = new byte[chunk.length / 2]; System.arraycopy(chunk, 0, chunkM, 0, chunkM.length); -Debug.println("wave l chunk(" + i + "): " + chunkM.length); +Debug.println(Level.FINE, "wave l chunk(" + i + "): " + chunkM.length); // adpcm data L events.add(getVoiceEvent(streamNumber++, 1, sampleRate, chunkM)); // TODO channel is 1 System.arraycopy(chunk, chunkM.length, chunkM, 0, chunkM.length); -Debug.println("wave r chunk(" + i + "): " + chunkM.length); +Debug.println(Level.FINE, "wave r chunk(" + i + "): " + chunkM.length); // adpcm data R events.add(getVoiceEvent(streamNumber++, 1, sampleRate, chunkM)); // TODO channel is 1 @@ -113,7 +114,7 @@ public static List getAdpcmEvents(byte[] pcm, float time, int sampleRa System.arraycopy(pcm, (PCM_MAX_BLOCK * channels) * numberOfChunks, temp, 0, moduloOfChunks); byte[] chunk = audioEngine.encode(4, channels, temp); if (channels == 1) { -Debug.println("wave chunk(" + numberOfChunks + "): " + chunk.length); +Debug.println(Level.FINE, "wave chunk(" + numberOfChunks + "): " + chunk.length); // adpcm data events.add(getVoiceEvent(streamNumber++, channels, sampleRate, chunk)); @@ -122,13 +123,13 @@ public static List getAdpcmEvents(byte[] pcm, float time, int sampleRa byte[] chunkM = new byte[chunk.length / 2]; System.arraycopy(chunk, 0, chunkM, 0, chunkM.length); -Debug.println("wave l chunk(" + numberOfChunks + "): " + chunkM.length); +Debug.println(Level.FINE, "wave l chunk(" + numberOfChunks + "): " + chunkM.length); // adpcm data L events.add(getVoiceEvent(streamNumber++, 1, sampleRate, chunkM)); // TODO channel is 1 System.arraycopy(chunk, chunkM.length, chunkM, 0, chunkM.length); -Debug.println("wave r chunk(" + numberOfChunks + "): " + chunkM.length); +Debug.println(Level.FINE, "wave r chunk(" + numberOfChunks + "): " + chunkM.length); // adpcm data R events.add(getVoiceEvent(streamNumber++, 1, sampleRate, chunkM)); // TODO channel is 1 @@ -169,11 +170,11 @@ public static List getAdpcmEvents(byte[] pcm, float time, int sampleRa // nop2 for (int j = 0; j < blockDelta / Nop2Message.maxDelta; j++) { Nop2Message nop2 = new Nop2Message(0xff, 0xff); - events.add(new MfiEvent(nop2, 0l)); + events.add(new MfiEvent(nop2, 0L)); } int moduloOfBlockDelta = blockDelta % Nop2Message.maxDelta; Nop2Message nop2 = new Nop2Message(moduloOfBlockDelta % 0x100, moduloOfBlockDelta / 0x100); - events.add(new MfiEvent(nop2, 0l)); + events.add(new MfiEvent(nop2, 0L)); } if (moduloOfChunks != 0) { if (channels == 1) { @@ -189,11 +190,11 @@ public static List getAdpcmEvents(byte[] pcm, float time, int sampleRa int moduloOfDelta = delta % blockDelta; for (int j = 0; j < moduloOfDelta / Nop2Message.maxDelta; j++) { Nop2Message nop2 = new Nop2Message(0xff, 0xff); - events.add(new MfiEvent(nop2, 0l)); + events.add(new MfiEvent(nop2, 0L)); } int moduloOfBlockDelta = moduloOfDelta % Nop2Message.maxDelta; Nop2Message nop2 = new Nop2Message(moduloOfBlockDelta % 0x100, moduloOfBlockDelta / 0x100); - events.add(new MfiEvent(nop2, 0l)); + events.add(new MfiEvent(nop2, 0L)); } return events; @@ -204,12 +205,12 @@ private static MfiEvent getVoiceEvent(int streamNumber, int channels, int sample MachineDependentMessage message = new NecMessage(); Function1_240_7 function = new Function1_240_7(); function.setStreamNumber(streamNumber); - function.setMono(channels == 1 ? true : false); + function.setMono(channels == 1); function.setFormat(1); function.setSamplingRate(sampleRate); function.setAdpcm(adpcm); message.setMessage(0x00, function.getMessage()); - return new MfiEvent(message, 0l); + return new MfiEvent(message, 0L); } /** @@ -224,7 +225,7 @@ public static MfiEvent getMaxGainEvent(int maxGain) throws InvalidMfiDataExcepti Function1_243_3 function = new Function1_243_3(); function.setMaxGain(maxGain); message.setMessage(0x00, function.getMessage()); - return new MfiEvent(message, 0l); + return new MfiEvent(message, 0L); } /** @@ -239,7 +240,7 @@ public static MfiEvent getSettingEvent(int maxStreamNumber) throws InvalidMfiDat Function1_243_4 function = new Function1_243_4(); function.setMaxStreamNumber(maxStreamNumber); message.setMessage(0x00, function.getMessage()); - return new MfiEvent(message, 0l); + return new MfiEvent(message, 0L); } /** @@ -255,7 +256,7 @@ public static MfiEvent getStreamOnEvent(int channel, int streamNumber, int veloc function.setStreamNumber(streamNumber); function.setVelocity(velocity); message.setMessage(0x00, function.getMessage()); - return new MfiEvent(message, 0l); + return new MfiEvent(message, 0L); } /** @@ -271,7 +272,7 @@ public static MfiEvent getStreamSlaveOnEvent(int channel, int streamNumber, int function.setStreamNumber(streamNumber); function.setVelocity(velocity); message.setMessage(0x00, function.getMessage()); - return new MfiEvent(message, 0l); + return new MfiEvent(message, 0L); } /** @@ -286,7 +287,7 @@ public static MfiEvent getVolumeEvent(int volume) throws InvalidMfiDataException Function242_1 function = new Function242_1(); function.setVolume(volume); message.setMessage(0x00, function.getMessage()); - return new MfiEvent(message, 0l); + return new MfiEvent(message, 0L); } /** @@ -302,7 +303,7 @@ public static MfiEvent getPanEvent(int channel, int streamNumber, int pan) throw function.setStreamNumber(streamNumber); function.setPan(pan); message.setMessage(0x00, function.getMessage()); - return new MfiEvent(message, 0l); + return new MfiEvent(message, 0L); } //---- @@ -318,13 +319,13 @@ public static MfiEvent getPanEvent(int channel, int streamNumber, int pan) throw */ public static List getAdpcmEventsEx(byte[] pcm, float time, int sampleRate, int bits, int channels, int adpcmVolume) throws InvalidMfiDataException { int delta = getDelta(time); -Debug.println("delta: " + delta + ", time: " + time); +Debug.println(Level.FINE, "delta: " + delta + ", time: " + time); int velocity = (int) (adpcmVolume * maxVelocity / 100f); AudioEngine audioEngine = NecSequencer.getAudioEngine(); byte[] adpcm = audioEngine.encode(4, channels, pcm); -Debug.println("adpcm length: " + adpcm.length); +Debug.println(Level.FINE, "adpcm length: " + adpcm.length); //System.err.println("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; @@ -342,7 +343,7 @@ public static List getAdpcmEventsEx(byte[] pcm, float time, int sample System.arraycopy(adpcm, (MAX_BLOCK / 2) * i, chunk, 0, MAX_BLOCK / 2); System.arraycopy(adpcm, (adpcm.length / 2) + (MAX_BLOCK / 2) * i, chunk, MAX_BLOCK / 2, MAX_BLOCK / 2); } -Debug.println("wave chunk(" + i + "): " + chunk.length); +Debug.println(Level.FINE, "wave chunk(" + i + "): " + chunk.length); // adpcm data events.add(getVoiceEvent(streamNumber++, channels, sampleRate, chunk)); @@ -355,7 +356,7 @@ public static List getAdpcmEventsEx(byte[] pcm, float time, int sample System.arraycopy(adpcm, (MAX_BLOCK / 2) * numberOfChunks, chunk, 0, moduloOfChunks / 2); System.arraycopy(adpcm, (adpcm.length / 2) + (MAX_BLOCK / 2) * numberOfChunks, chunk, moduloOfChunks / 2, moduloOfChunks / 2); } -Debug.println("wave chunk(" + numberOfChunks + "): " + chunk.length); +Debug.println(Level.FINE, "wave chunk(" + numberOfChunks + "): " + chunk.length); // adpcm data events.add(getVoiceEvent(streamNumber++, channels, sampleRate, chunk)); @@ -367,30 +368,30 @@ public static List getAdpcmEventsEx(byte[] pcm, float time, int sample streamNumber = 0; for (int i = 0; i < numberOfChunks; i++) { // adpcm on -//System.err.println("thread local sequence: " + sequence.get()); +Debug.println(Level.FINER, "thread local sequence: " + sequence.get()); events.add(getStreamOn(streamNumber++, velocity)); // nop2 for (int j = 0; j < blockDelta / Nop2Message.maxDelta; j++) { Nop2Message nop2 = new Nop2Message(0xff, 0xff); - events.add(new MfiEvent(nop2, 0l)); + events.add(new MfiEvent(nop2, 0L)); } int moduloOfDelta = blockDelta % Nop2Message.maxDelta; Nop2Message nop2 = new Nop2Message(moduloOfDelta % 0x100, moduloOfDelta / 0x100); - events.add(new MfiEvent(nop2, 0l)); + events.add(new MfiEvent(nop2, 0L)); } if (moduloOfChunks != 0) { // adpcm on -//System.err.println("thread local sequence: " + sequence.get()); +Debug.println(Level.FINER, "thread local sequence: " + sequence.get()); events.add(getStreamOn(streamNumber++, velocity)); // nop2 int moduloOfBlockDelta = delta % blockDelta; for (int j = 0; j < moduloOfBlockDelta / Nop2Message.maxDelta; j++) { Nop2Message nop2 = new Nop2Message(0xff, 0xff); - events.add(new MfiEvent(nop2, 0l)); + events.add(new MfiEvent(nop2, 0L)); } int moduloOfDelta = moduloOfBlockDelta % Nop2Message.maxDelta; Nop2Message nop2 = new Nop2Message(moduloOfDelta % 0x100, moduloOfDelta / 0x100); - events.add(new MfiEvent(nop2, 0l)); + events.add(new MfiEvent(nop2, 0L)); } return events; 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 f49219a..b6da81c 100644 --- a/src/main/java/vavi/sound/mfi/vavi/nec/NecSequencer.java +++ b/src/main/java/vavi/sound/mfi/vavi/nec/NecSequencer.java @@ -6,6 +6,8 @@ package vavi.sound.mfi.vavi.nec; +import java.util.logging.Level; + import vavi.sound.mfi.InvalidMfiDataException; import vavi.sound.mfi.vavi.sequencer.MachineDependentFunction; import vavi.sound.mfi.vavi.sequencer.MachineDependentSequencer; @@ -57,16 +59,16 @@ public void sequence(MachineDependentMessage message) if (f1 == 0x01) { f2 = data[7] & 0xff; // 0 ~ 32 int f3 = data[8] & 0x0f; // 0 ~ 16 -Debug.printf("%02x %02x %02x\n", f1, f2, f3); +Debug.printf(Level.FINE, "%02x %02x %02x\n", f1, f2, f3); key = f1 + "." + f2 + "." + f3; } else { f2 = data[7] & 0x0f; // 0 ~ 16 -Debug.printf("%02x %02x\n", f1, f2); +Debug.printf(Level.FINE, "%02x %02x\n", f1, f2); key = f1 + "." + f2; } MachineDependentFunction mdf = factory.getFunction(key); - mdf.process(message); + mdf.process(message); } //------------------------------------------------------------------------- diff --git a/src/main/java/vavi/sound/mfi/vavi/sequencer/MachineDependentFunction.java b/src/main/java/vavi/sound/mfi/vavi/sequencer/MachineDependentFunction.java index b99693e..0f78869 100644 --- a/src/main/java/vavi/sound/mfi/vavi/sequencer/MachineDependentFunction.java +++ b/src/main/java/vavi/sound/mfi/vavi/sequencer/MachineDependentFunction.java @@ -6,6 +6,8 @@ package vavi.sound.mfi.vavi.sequencer; +import java.util.logging.Level; + import vavi.sound.mfi.InvalidMfiDataException; import vavi.sound.mfi.vavi.track.MachineDependentMessage; import vavi.util.Debug; @@ -58,8 +60,8 @@ public MachineDependentFunction getFunction(String key) { try { return get(key); } catch (IllegalArgumentException e) { -Debug.println(key); -Debug.printStackTrace(e); +Debug.println(Level.WARNING, key); +Debug.printStackTrace(Level.WARNING, e); return new UndefinedFunction(); // TODO should throw exception or not? } } diff --git a/src/main/java/vavi/sound/mfi/vavi/sequencer/UndefinedFunction.java b/src/main/java/vavi/sound/mfi/vavi/sequencer/UndefinedFunction.java index 36e3c42..82a1a09 100644 --- a/src/main/java/vavi/sound/mfi/vavi/sequencer/UndefinedFunction.java +++ b/src/main/java/vavi/sound/mfi/vavi/sequencer/UndefinedFunction.java @@ -6,6 +6,8 @@ package vavi.sound.mfi.vavi.sequencer; +import java.util.logging.Level; + import vavi.sound.mfi.InvalidMfiDataException; import vavi.sound.mfi.vavi.track.MachineDependentMessage; import vavi.util.Debug; @@ -42,14 +44,14 @@ public void process(MachineDependentMessage message) int f3 = -1; if (data.length > 8) { f3 = data[8] & 0xff; -Debug.printf("undefined function: %02x %02x %02x\n", f1, f2, f3); +Debug.printf(Level.INFO, "undefined function: %02x %02x %02x\n", f1, f2, f3); } else if (data.length > 7) { f2 = data[7] & 0xff; -Debug.printf("undefined function: %02x %02x\n", f1, f2); +Debug.printf(Level.INFO, "undefined function: %02x %02x\n", f1, f2); } else { -Debug.printf("undefined function: %02x \n", f1); +Debug.printf(Level.INFO, "undefined function: %02x \n", f1); } -Debug.println(StringUtil.getDump(message.getMessage(), 128)); +Debug.println(Level.INFO, StringUtil.getDump(message.getMessage(), 128)); } } diff --git a/src/main/java/vavi/sound/mfi/vavi/sharp/Function129.java b/src/main/java/vavi/sound/mfi/vavi/sharp/Function129.java index 1a6b40a..0c7c348 100644 --- a/src/main/java/vavi/sound/mfi/vavi/sharp/Function129.java +++ b/src/main/java/vavi/sound/mfi/vavi/sharp/Function129.java @@ -6,6 +6,8 @@ package vavi.sound.mfi.vavi.sharp; +import java.util.logging.Level; + import vavi.sound.mfi.InvalidMfiDataException; import vavi.sound.mfi.vavi.sequencer.MachineDependentFunction; import vavi.sound.mfi.vavi.track.MachineDependentMessage; @@ -45,7 +47,7 @@ public void process(MachineDependentMessage message) this.channel = (data[7] & 0xc0) >> 6; // 0 ~ 3 this.volume = data[7] & 0x3f; // -Debug.printf("ADPCM volume: %dch %02x\n", channel, volume); +Debug.printf(Level.FINE, "ADPCM volume: %dch %02x\n", channel, volume); } /** */ diff --git a/src/main/java/vavi/sound/mfi/vavi/sharp/Function130.java b/src/main/java/vavi/sound/mfi/vavi/sharp/Function130.java index 70cfd68..efd5143 100644 --- a/src/main/java/vavi/sound/mfi/vavi/sharp/Function130.java +++ b/src/main/java/vavi/sound/mfi/vavi/sharp/Function130.java @@ -6,6 +6,8 @@ package vavi.sound.mfi.vavi.sharp; +import java.util.logging.Level; + import vavi.sound.mfi.InvalidMfiDataException; import vavi.sound.mfi.vavi.sequencer.MachineDependentFunction; import vavi.sound.mfi.vavi.track.MachineDependentMessage; @@ -45,7 +47,7 @@ public void process(MachineDependentMessage message) this.channel = (data[7] & 0xc0) >> 6; // 0 ~ 3 this.panpot = data[7] & 0x3f; // 0x20 center -Debug.printf("ADPCM pan: %dch %02x\n", channel, panpot); +Debug.printf(Level.FINE, "ADPCM pan: %dch %02x\n", channel, panpot); } /** */ 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 ef5c189..0595c0e 100644 --- a/src/main/java/vavi/sound/mfi/vavi/sharp/Function131.java +++ b/src/main/java/vavi/sound/mfi/vavi/sharp/Function131.java @@ -13,6 +13,7 @@ import vavi.sound.mfi.vavi.track.MachineDependentMessage; import vavi.sound.mobile.AudioEngine; import vavi.util.Debug; +import vavi.util.StringUtil; /** @@ -75,12 +76,12 @@ public void process(MachineDependentMessage message) this.continued = (data[9] & 0x01) == 1; // int adpcmLength = data.length - HEADER_LENGTH; -Debug.printf("ADPCM voice: %dch, No.%d, mode=%d, continued=%d, %d\n", channel, packetId, mode, continued, adpcmLength); -//Debug.dump(data); +Debug.printf(Level.FINE, "ADPCM voice: %dch, No.%d, mode=%d, continued=%d, %d\n", channel, packetId, mode, continued, adpcmLength); +Debug.println(Level.FINER, "data:\n" + StringUtil.getDump(data)); this.sampleRate = getSamplingRateInternal(format1); this.bits = getSamplingBitsInternal(format2); -Debug.printf("sampling: %02x: rate=%d, bits=%d\n", data[8] & 0x3f, sampleRate, bits); +Debug.printf(Level.FINE, "sampling: %02x: rate=%d, bits=%d\n", data[8] & 0x3f, sampleRate, bits); this.adpcm = new byte[adpcmLength]; System.arraycopy(data, HEADER_LENGTH, adpcm, 0, adpcmLength); diff --git a/src/main/java/vavi/sound/mfi/vavi/sharp/Function132.java b/src/main/java/vavi/sound/mfi/vavi/sharp/Function132.java index 7ac47be..e4499f2 100644 --- a/src/main/java/vavi/sound/mfi/vavi/sharp/Function132.java +++ b/src/main/java/vavi/sound/mfi/vavi/sharp/Function132.java @@ -6,9 +6,12 @@ package vavi.sound.mfi.vavi.sharp; +import java.util.logging.Level; + import vavi.sound.mfi.InvalidMfiDataException; import vavi.sound.mfi.vavi.track.MachineDependentMessage; import vavi.util.Debug; +import vavi.util.StringUtil; /** @@ -68,12 +71,12 @@ public void process(MachineDependentMessage message) data[13]; int adpcmLength = data.length - HEADER_LENGTH; -Debug.printf("ADPCM voice: %dch, No.%d, mode=%d, continued=%d, %d\n", channel, packetId, mode, continued, adpcmLength); -//Debug.dump(data); +Debug.printf(Level.FINE, "ADPCM voice: %dch, No.%d, mode=%d, continued=%s, %d\n", channel, packetId, mode, continued, adpcmLength); +Debug.println(Level.FINER, "data:\n" + StringUtil.getDump(data, 32)); this.sampleRate = getSamplingRateInternal(format1); this.bits = getSamplingBitsInternal(format2); -Debug.printf("sampling: %02x: rate=%d, bits=%d\n", data[8] & 0x3f, sampleRate, bits); +Debug.printf(Level.FINE, "sampling: %02x: rate=%d, bits=%d\n", data[8] & 0x3f, sampleRate, bits); this.adpcm = new byte[adpcmLength]; System.arraycopy(data, HEADER_LENGTH, adpcm, 0, adpcmLength); diff --git a/src/main/java/vavi/sound/mfi/vavi/sharp/Function143.java b/src/main/java/vavi/sound/mfi/vavi/sharp/Function143.java index fddd85b..183b294 100644 --- a/src/main/java/vavi/sound/mfi/vavi/sharp/Function143.java +++ b/src/main/java/vavi/sound/mfi/vavi/sharp/Function143.java @@ -8,11 +8,13 @@ import java.util.ArrayList; import java.util.List; +import java.util.logging.Level; import vavi.sound.mfi.InvalidMfiDataException; import vavi.sound.mfi.vavi.sequencer.MachineDependentFunction; import vavi.sound.mfi.vavi.track.MachineDependentMessage; import vavi.util.Debug; +import vavi.util.StringUtil; /** @@ -52,7 +54,7 @@ public void process(MachineDependentMessage message) byte[] subIdData = new byte[subIdLength]; System.arraycopy(data, index, subIdData, 0, subIdLength); index += subIdLength; -Debug.printf("ADPCM subId: %d\n%s\n", subId, subIdData); +Debug.printf(Level.FINER, "ADPCM subId: %d\n%s", subId, StringUtil.getDump(subIdData)); subIds.add(new SubIdChunk(subId, subIdData)); } } diff --git a/src/main/java/vavi/sound/mfi/vavi/sharp/SharpMessage.java b/src/main/java/vavi/sound/mfi/vavi/sharp/SharpMessage.java index e10673f..47416c7 100644 --- a/src/main/java/vavi/sound/mfi/vavi/sharp/SharpMessage.java +++ b/src/main/java/vavi/sound/mfi/vavi/sharp/SharpMessage.java @@ -8,6 +8,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.logging.Level; import vavi.sound.mfi.InvalidMfiDataException; import vavi.sound.mfi.MfiEvent; @@ -44,18 +45,18 @@ public class SharpMessage extends FuetrekAudioMessage { */ public static List getAdpcmEvents(byte[] pcm, float time, int sampleRate, int bits, int channels, boolean fillNop) throws InvalidMfiDataException { int delta = getDelta(time, sampleRate); -Debug.println("delta: " + delta); +Debug.println(Level.FINE, "delta: " + delta); AudioEngine audioEngine = SharpSequencer.getAudioEngine(); byte[] adpcm = audioEngine.encode(bits, channels, pcm); List events = new ArrayList<>(); if (channels == 1) { -Debug.println("adpcm mono length: " + adpcm.length); +Debug.println(Level.FINE, "adpcm mono length: " + adpcm.length); events.addAll(getAdpcmEventsSub(L, 0, sampleRate, bits, adpcm)); // 0x84 adpcm recycle events.add(getWaveEvent(L, 0, sampleRate, bits, adpcm.length)); } else { byte[] temp = new byte[adpcm.length / 2]; -Debug.println("adpcm L, R length: " + temp.length); +Debug.println(Level.FINE, "adpcm L, R length: " + temp.length); System.arraycopy(adpcm, 0, temp, 0, adpcm.length / 2); events.addAll(getAdpcmEventsSub(L, 0, sampleRate, bits, temp)); System.arraycopy(adpcm, adpcm.length / 2, temp, 0, adpcm.length / 2); @@ -88,7 +89,7 @@ private static List getAdpcmEventsSub(int channel, int packetId, int s for (int i = 0; i < numberOfChunks; i++) { byte[] chunk = new byte[MAX_BLOCK]; System.arraycopy(adpcm, MAX_BLOCK * i, chunk, 0, MAX_BLOCK); -Debug.println("wave chunk(" + i + "): " + chunk.length); +Debug.println(Level.FINE, "wave chunk(" + i + "): " + chunk.length); // 0x84 adpcm data events.add(getWaveEvent(channel, packetId, sampleRate, bits, !(i == (numberOfChunks - 1) && moduloOfChunks == 0), i == 0 ? adpcm.length : 0, chunk)); @@ -96,7 +97,7 @@ private static List getAdpcmEventsSub(int channel, int packetId, int s if (moduloOfChunks != 0) { byte[] chunk = new byte[moduloOfChunks]; System.arraycopy(adpcm, MAX_BLOCK * numberOfChunks, chunk, 0, moduloOfChunks); -Debug.println("wave chunk(" + numberOfChunks + "): " + chunk.length); +Debug.println(Level.FINE, "wave chunk(" + numberOfChunks + "): " + chunk.length); // 0x84 adpcm data events.add(getWaveEvent(channel, packetId, sampleRate, bits, false, numberOfChunks == 0 ? adpcm.length : 0, chunk)); @@ -172,7 +173,7 @@ private static MfiEvent getVolumeEvent(int channel, int realAdpcmVolume) throws function.setChannel(channel); function.setVolume(realAdpcmVolume); message.setMessage(0x00, function.getMessage()); - return new MfiEvent(message, 0l); + return new MfiEvent(message, 0L); } /** 0x82 */ @@ -194,7 +195,7 @@ private static MfiEvent getPanEvent(int channel, int pan) throws InvalidMfiDataE function.setChannel(channel); function.setPanpot(pan); message.setMessage(0x00, function.getMessage()); - return new MfiEvent(message, 0l); + return new MfiEvent(message, 0L); } /** 0x8f setting */ @@ -210,7 +211,7 @@ public static MfiEvent getSettingEvent(int sampleRate, int bits, int channels) t // 0x8B 要は 16kHz, 4bit mono の時 = 4, 8kHz, 4bit mono の時に 2 function.setMaxParallelCue(sampleRate * (sampleRate / 8000) * channels); // TODO 適当 message.setMessage(0x00, function.getMessage()); - return new MfiEvent(message, 0l); + return new MfiEvent(message, 0L); } } 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 78a2b1d..e6c071d 100644 --- a/src/main/java/vavi/sound/mfi/vavi/sharp/SharpSequencer.java +++ b/src/main/java/vavi/sound/mfi/vavi/sharp/SharpSequencer.java @@ -6,12 +6,15 @@ package vavi.sound.mfi.vavi.sharp; +import java.util.logging.Level; + import vavi.sound.mfi.InvalidMfiDataException; import vavi.sound.mfi.vavi.sequencer.MachineDependentFunction; import vavi.sound.mfi.vavi.sequencer.MachineDependentSequencer; import vavi.sound.mfi.vavi.track.MachineDependentMessage; import vavi.sound.mobile.AudioEngine; import vavi.sound.mobile.FuetrekAudioEngine; +import vavi.util.Debug; /** @@ -35,10 +38,10 @@ public void sequence(MachineDependentMessage message) byte[] data = message.getMessage(); int function = data[6] & 0xff; -//Debug.println("function: 0x" + StringUtil.toHex2(function)); +Debug.printf(Level.FINER, "function: 0x%02x", function); MachineDependentFunction mdf = factory.getFunction(String.valueOf(function)); - mdf.process(message); + mdf.process(message); } //------------------------------------------------------------------------- diff --git a/src/main/java/vavi/sound/mobile/BasicAudioEngine.java b/src/main/java/vavi/sound/mobile/BasicAudioEngine.java index bfddc6b..b95b5bd 100644 --- a/src/main/java/vavi/sound/mobile/BasicAudioEngine.java +++ b/src/main/java/vavi/sound/mobile/BasicAudioEngine.java @@ -12,6 +12,7 @@ import java.io.InputStream; import java.io.OutputStream; import java.nio.ByteOrder; +import java.util.logging.Level; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioSystem; @@ -20,6 +21,7 @@ import javax.sound.sampled.SourceDataLine; import vavi.util.Debug; +import vavi.util.StringUtil; import static vavi.sound.SoundUtil.volume; @@ -80,7 +82,7 @@ public void start(int streamNumber) { int channels = getChannels(streamNumber); if (channels == -1) { -Debug.println("always used: no: " + streamNumber + ", ch: " + this.data[streamNumber].channel); +Debug.println(Level.INFO, "always used: no: " + streamNumber + ", ch: " + this.data[streamNumber].channel); return; } @@ -92,7 +94,7 @@ public void start(int streamNumber) { 2 * channels, this.data[streamNumber].sampleRate, false); -Debug.println(audioFormat); +Debug.println(Level.FINE, audioFormat); try { @@ -111,12 +113,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); +Debug.println(Level.FINEST, "data:\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); + int lR = iss[1].read(buf, 512, 512); //System.err.println("l : " + lL + ", r: " + lR); for (int i = 0; i < lL / 2; i++) { byte[] temp = new byte[4]; @@ -132,9 +134,7 @@ public void start(int streamNumber) { line.stop(); line.close(); // debug4(os); - } catch (IOException e) { - throw new IllegalStateException(e); - } catch (LineUnavailableException e) { + } catch (IOException | LineUnavailableException e) { throw new IllegalStateException(e); } } @@ -152,11 +152,11 @@ public byte[] encode(int bits, int channels, byte[] pcm) { InputStream is = new ByteArrayInputStream(pcm); ByteArrayOutputStream baos = new ByteArrayOutputStream(); OutputStream os = getOutputStream(baos); -Debug.println("pcm length: " + is.available()); +Debug.println(Level.FINE, "pcm length: " + is.available()); while (is.available() > 0) { int c = is.read(); if (c == -1) { -Debug.println("read returns -1"); +Debug.println(Level.FINE, "read returns -1"); break; } os.write(c); @@ -170,11 +170,11 @@ public byte[] encode(int bits, int channels, byte[] pcm) { InputStream is = new ByteArrayInputStream(monos[0]); ByteArrayOutputStream baos = new ByteArrayOutputStream(); OutputStream os = getOutputStream(baos); -Debug.println("pcm L length: " + is.available()); +Debug.println(Level.FINE, "pcm L length: " + is.available()); while (is.available() > 0) { int c = is.read(); if (c == -1) { -Debug.println("Illegal EOF L: " + is.available()); +Debug.println(Level.FINE, "Illegal EOF L: " + is.available()); break; } os.write(c); @@ -184,11 +184,11 @@ public byte[] encode(int bits, int channels, byte[] pcm) { is = new ByteArrayInputStream(monos[1]); baos = new ByteArrayOutputStream(); os = getOutputStream(baos); -Debug.println("pcm R length: " + is.available()); +Debug.println(Level.FINE, "pcm R length: " + is.available()); while (is.available() > 0) { int c = is.read(); if (c == -1) { -Debug.println("Illegal EOF R: " + is.available()); +Debug.println(Level.FINE, "Illegal EOF R: " + is.available()); break; } os.write(c); diff --git a/src/main/java/vavi/sound/mobile/FuetrekAudioEngine.java b/src/main/java/vavi/sound/mobile/FuetrekAudioEngine.java index cae3c17..9d26520 100644 --- a/src/main/java/vavi/sound/mobile/FuetrekAudioEngine.java +++ b/src/main/java/vavi/sound/mobile/FuetrekAudioEngine.java @@ -10,6 +10,7 @@ import java.io.InputStream; import java.io.OutputStream; import java.nio.ByteOrder; +import java.util.logging.Level; import vavi.sound.adpcm.ccitt.G721InputStream; import vavi.sound.adpcm.ccitt.G721OutputStream; @@ -48,7 +49,7 @@ protected int getChannels(int streamNumber) { if (data[streamNumber].channel != -1) { // from MachineDependent if (streamNumber % 2 == 1 && data[streamNumber].channel % 2 == 1 && (data[streamNumber - 1] != null && data[streamNumber - 1].channel % 2 == 0)) { -Debug.println("always used: no: " + streamNumber + ", ch: " + data[streamNumber].channel); +Debug.println(Level.FINE, "always used: no: " + streamNumber + ", ch: " + data[streamNumber].channel); return -1; } 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 da53fa1..7fb8976 100644 --- a/src/main/java/vavi/sound/smaf/message/yamaha/YamahaMessage.java +++ b/src/main/java/vavi/sound/smaf/message/yamaha/YamahaMessage.java @@ -6,6 +6,7 @@ package vavi.sound.smaf.message.yamaha; +import java.util.logging.Level; import javax.sound.midi.InvalidMidiDataException; import javax.sound.midi.MetaMessage; import javax.sound.midi.MidiEvent; @@ -159,7 +160,7 @@ public MidiEvent[] getMidiEvents(MidiContext context) throws InvalidMidiDataExce /* TODO 今、超適当 */ public void sequence() throws InvalidSmafDataException { -Debug.println("yamaha: " + data.length + "\n" + StringUtil.getDump(data, 64)); +Debug.println(Level.INFO, "yamaha: " + data.length + "\n" + StringUtil.getDump(data, 64)); switch (data[1]) { case 0x79: switch (data[3]) { diff --git a/src/test/java/vavi/sound/sampled/adpcm/oki/OkiAudioFileReaderTest.java b/src/test/java/vavi/sound/sampled/adpcm/oki/OkiAudioFileReaderTest.java index c559e42..9cf896a 100644 --- a/src/test/java/vavi/sound/sampled/adpcm/oki/OkiAudioFileReaderTest.java +++ b/src/test/java/vavi/sound/sampled/adpcm/oki/OkiAudioFileReaderTest.java @@ -12,6 +12,7 @@ import java.io.OutputStream; import java.nio.ByteOrder; import java.nio.file.Files; +import java.util.logging.Level; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioSystem; @@ -43,7 +44,7 @@ public class OkiAudioFileReaderTest { public void setup() throws IOException { outFile = File.createTempFile("vavi", ".pcm"); outFile.deleteOnExit(); -Debug.println("outFile: " + outFile); +Debug.println(Level.FINE, "outFile: " + outFile); } @Test From 7499f3e6078aabcf390b4be62f61f9772b945514 Mon Sep 17 00:00:00 2001 From: Naohide Sano Date: Tue, 13 Dec 2022 17:58:56 +0900 Subject: [PATCH 4/7] avoid npe --- .../vavi/sound/mfi/vavi/mitsubishi/MitsubishiSequencer.java | 4 ++++ src/main/java/vavi/sound/mfi/vavi/nec/NecSequencer.java | 4 ++++ src/main/java/vavi/sound/mfi/vavi/sharp/SharpSequencer.java | 4 ++++ 3 files changed, 12 insertions(+) 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 54f6a2c..7f432b1 100644 --- a/src/main/java/vavi/sound/mfi/vavi/mitsubishi/MitsubishiSequencer.java +++ b/src/main/java/vavi/sound/mfi/vavi/mitsubishi/MitsubishiSequencer.java @@ -43,7 +43,11 @@ public void sequence(MachineDependentMessage message) Debug.printf(Level.FINER, "function: 0x%02x", function); MachineDependentFunction mdf = factory.getFunction(String.valueOf(function)); + if (mdf != null) { mdf.process(message); + } else { +Debug.printf(Level.WARNING, "unsupported function: 0x%02x", function); + } } //------------------------------------------------------------------------- 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 b6da81c..b497f8d 100644 --- a/src/main/java/vavi/sound/mfi/vavi/nec/NecSequencer.java +++ b/src/main/java/vavi/sound/mfi/vavi/nec/NecSequencer.java @@ -68,7 +68,11 @@ public void sequence(MachineDependentMessage message) } MachineDependentFunction mdf = factory.getFunction(key); + if (mdf != null) { mdf.process(message); + } else { +Debug.printf(Level.WARNING, "unsupported function: %s", key); + } } //------------------------------------------------------------------------- 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 e6c071d..d904ee8 100644 --- a/src/main/java/vavi/sound/mfi/vavi/sharp/SharpSequencer.java +++ b/src/main/java/vavi/sound/mfi/vavi/sharp/SharpSequencer.java @@ -41,7 +41,11 @@ public void sequence(MachineDependentMessage message) Debug.printf(Level.FINER, "function: 0x%02x", function); MachineDependentFunction mdf = factory.getFunction(String.valueOf(function)); + if (mdf != null) { mdf.process(message); + } else { +Debug.printf(Level.WARNING, "unsupported function: 0x%02x", function); + } } //------------------------------------------------------------------------- From 56acfc29e4031914a3baaa9c22514b83bd9653a7 Mon Sep 17 00:00:00 2001 From: Naohide Sano Date: Tue, 13 Dec 2022 17:59:09 +0900 Subject: [PATCH 5/7] follow ide advices --- .../vavi/sound/adpcm/AdpcmInputStream.java | 2 +- src/main/java/vavi/sound/adpcm/dvi/Dvi.java | 2 +- src/main/java/vavi/sound/adpcm/ima/Ima.java | 2 +- .../vavi/sound/adpcm/ima/ImaInputEngine.java | 2 +- src/main/java/vavi/sound/adpcm/ms/Ms.java | 2 +- .../vavi/sound/adpcm/ms/MsInputEngine.java | 2 +- .../vavi/sound/adpcm/ms/MsOutputEngine.java | 10 +++--- src/main/java/vavi/sound/adpcm/vox/Vox.java | 2 +- .../java/vavi/sound/adpcm/yamaha/Yamaha.java | 2 +- src/main/java/vavi/sound/mfi/MfiDevice.java | 2 +- src/main/java/vavi/sound/mfi/MfiSystem.java | 31 ++++++++-------- .../java/vavi/sound/mfi/vavi/HeaderChunk.java | 2 +- .../java/vavi/sound/mfi/vavi/MfiContext.java | 31 ++++++++-------- .../vavi/sound/mfi/vavi/MfiConvertible.java | 2 +- .../java/vavi/sound/mfi/vavi/MidiContext.java | 2 +- .../java/vavi/sound/mfi/vavi/SubMessage.java | 15 ++++---- .../vavi/sound/mfi/vavi/TrackMessage.java | 23 ++++++------ .../sound/mfi/vavi/VaviMfiDeviceProvider.java | 13 +++---- .../sound/mfi/vavi/VaviMfiFileFormat.java | 4 +-- .../sound/mfi/vavi/VaviMfiFileReader.java | 6 ++-- .../sound/mfi/vavi/VaviMfiFileWriter.java | 8 ++--- .../sound/mfi/vavi/VaviMidiConverter.java | 35 +++++++++---------- .../vavi/sound/mfi/vavi/VaviNoteMessage.java | 4 +-- .../vavi/sound/mfi/vavi/VaviSequencer.java | 5 +-- .../mfi/vavi/audio/CommonAudioMessage.java | 30 ++++++++-------- .../mfi/vavi/audio/FuetrekAudioMessage.java | 8 ++--- .../mfi/vavi/audio/RohmAudioMessage.java | 4 +-- .../mfi/vavi/audio/YamahaAudioMessage.java | 4 +-- .../sound/mfi/vavi/header/AinfMessage.java | 11 +++--- .../sound/mfi/vavi/header/CopyMessage.java | 2 +- .../sound/mfi/vavi/header/ProtMessage.java | 2 +- .../sound/mfi/vavi/header/TitlMessage.java | 2 +- .../mfi/vavi/mitsubishi/Function143.java | 4 +-- .../vavi/mitsubishi/MitsubishiMessage.java | 4 +-- .../vavi/sound/mfi/vavi/nec/NecSequencer.java | 2 +- .../vavi/sequencer/AudioDataSequencer.java | 2 +- .../sequencer/MachineDependentFunction.java | 22 ++++++------ .../sequencer/MachineDependentSequencer.java | 4 +-- .../mfi/vavi/sequencer/UndefinedFunction.java | 2 +- .../sound/mfi/vavi/sharp/Function143.java | 4 +-- .../sound/mfi/vavi/sharp/SharpMessage.java | 8 ++--- .../sound/mfi/vavi/track/TempoMessage.java | 13 +++---- .../vavi/sound/midi/BasicMidiFileReader.java | 6 ++-- .../vavi/sound/midi/BasicMidiFileWriter.java | 4 +-- .../java/vavi/sound/midi/MidiConstants.java | 2 +- src/main/java/vavi/sound/midi/MidiUtil.java | 2 +- .../vavi/sound/pcm/resampling/ssrc/SSRC.java | 22 ++++++------ .../SSRCSampleRateConversionProvider.java | 4 +-- .../ccitt/G721FormatConversionProvider.java | 8 ++--- .../dvi/DviFormatConversionProvider.java | 8 ++--- .../ima/ImaFormatConversionProvider.java | 8 ++--- .../adpcm/ma/MaFormatConversionProvider.java | 8 ++--- .../adpcm/ms/MsFormatConversionProvider.java | 8 ++--- .../oki/OkiFormatConversionProvider.java | 8 ++--- .../rohm/RohmFormatConversionProvider.java | 8 ++--- .../vox/VoxFormatConversionProvider.java | 8 ++--- .../YamahaFormatConversionProvider.java | 8 ++--- .../MachineDependentMfiWithVoiceMaker.java | 2 +- .../sound/sampled/mfi/MfiAudioFileWriter.java | 8 ++--- .../sound/sampled/mfi/MfiWithVoiceMaker.java | 12 +++---- .../sampled/smaf/SmafAudioFileWriter.java | 4 +-- .../sampled/smaf/SmafWithVoiceMaker.java | 6 ++-- .../vavi/sound/smaf/MetaEventAdapter.java | 2 +- src/main/java/vavi/sound/smaf/Sequence.java | 2 +- src/main/java/vavi/sound/smaf/SmafDevice.java | 2 +- .../vavi/sound/smaf/SmafDeviceProvider.java | 13 +++---- .../java/vavi/sound/smaf/SmafFileFormat.java | 4 +-- .../java/vavi/sound/smaf/SmafFileReader.java | 6 ++-- .../java/vavi/sound/smaf/SmafFileWriter.java | 8 ++--- .../vavi/sound/smaf/SmafMidiConverter.java | 6 ++-- .../java/vavi/sound/smaf/SmafSequencer.java | 5 +-- src/main/java/vavi/sound/smaf/SmafSystem.java | 11 +++--- .../vavi/sound/smaf/chunk/ChannelStatus.java | 4 +-- .../java/vavi/sound/smaf/chunk/DataChunk.java | 4 +-- .../DisplayParameterDefinitionChunk.java | 2 +- .../java/vavi/sound/smaf/chunk/FileChunk.java | 2 +- .../sound/smaf/chunk/GraphicsTrackChunk.java | 2 +- .../chunk/GraphicsTrackSequenceDataChunk.java | 2 +- .../sound/smaf/chunk/PcmAudioTrackChunk.java | 6 ++-- .../sound/smaf/chunk/ScoreTrackChunk.java | 8 ++--- .../sound/smaf/chunk/SequenceDataChunk.java | 2 +- .../vavi/sound/smaf/chunk/SetupDataChunk.java | 4 +-- .../java/vavi/sound/smaf/chunk/SubData.java | 4 +-- .../vavi/sound/smaf/chunk/TrackChunk.java | 6 ++-- .../sound/smaf/message/BankSelectMessage.java | 2 +- .../vavi/sound/smaf/message/MidiContext.java | 4 +-- .../vavi/sound/smaf/message/NoteMessage.java | 6 ++-- .../vavi/sound/smaf/message/STMessage.java | 2 +- .../vavi/sound/smaf/message/SmafContext.java | 10 +++--- .../vavi/sound/smaf/message/VNMessage.java | 2 +- .../GeneralPurposeDisplayMessage.java | 2 +- .../sequencer/MachineDependentSequencer.java | 2 +- .../sound/smaf/sequencer/WaveSequencer.java | 2 +- src/main/java/vavi/util/SplitRadixFft.java | 6 ++-- src/test/java/PlayMFi.java | 2 +- src/test/java/PlayPCM.java | 2 +- src/test/java/PlayPCM2.java | 2 +- src/test/java/PlaySMAF.java | 2 +- .../vavi/io/InputEngineOutputStreamTest.java | 18 +++------- .../java/vavi/sound/adpcm/ccitt/Encoder.java | 2 +- .../sound/mfi/vavi/VaviMfiFileWriterTest.java | 6 ++-- .../sound/mfi/vavi/VaviMidiConverterTest.java | 6 ++-- .../MachineDependentSequencerTest.java | 12 +++---- .../sound/midi/mfi/MfiMidiFileReaderTest.java | 8 ++--- .../sound/mobile/BasicAudioEngineTest.java | 2 +- .../adpcm/ccitt/G721AudioFileReaderTest.java | 2 +- 106 files changed, 322 insertions(+), 366 deletions(-) diff --git a/src/main/java/vavi/sound/adpcm/AdpcmInputStream.java b/src/main/java/vavi/sound/adpcm/AdpcmInputStream.java index 029f4d4..da0c36f 100644 --- a/src/main/java/vavi/sound/adpcm/AdpcmInputStream.java +++ b/src/main/java/vavi/sound/adpcm/AdpcmInputStream.java @@ -99,7 +99,7 @@ public int read() throws IOException { } /* */ - public int read(byte b[], int off, int len) throws IOException { + public int read(byte[] b, int off, int len) throws IOException { if (b == null) { throw new NullPointerException(); } else if ((off < 0) || (off > b.length) || (len < 0) || diff --git a/src/main/java/vavi/sound/adpcm/dvi/Dvi.java b/src/main/java/vavi/sound/adpcm/dvi/Dvi.java index a8a3e55..c5ef325 100644 --- a/src/main/java/vavi/sound/adpcm/dvi/Dvi.java +++ b/src/main/java/vavi/sound/adpcm/dvi/Dvi.java @@ -73,7 +73,7 @@ class Dvi implements Codec { }; /** */ - private class State { + private static class State { /** */ int valPrev; /** */ diff --git a/src/main/java/vavi/sound/adpcm/ima/Ima.java b/src/main/java/vavi/sound/adpcm/ima/Ima.java index 9378ec9..c0c0c21 100644 --- a/src/main/java/vavi/sound/adpcm/ima/Ima.java +++ b/src/main/java/vavi/sound/adpcm/ima/Ima.java @@ -60,7 +60,7 @@ private static int adjustState(int c) { /** */ private static int[][] stateAdjustTable = new int[ISSTMAX + 1][8]; - /** */ + /* */ static { for (int i = 0; i <= ISSTMAX; i++) { for (int j = 0; j < 8; j++) { diff --git a/src/main/java/vavi/sound/adpcm/ima/ImaInputEngine.java b/src/main/java/vavi/sound/adpcm/ima/ImaInputEngine.java index 8359036..6c7d6d1 100644 --- a/src/main/java/vavi/sound/adpcm/ima/ImaInputEngine.java +++ b/src/main/java/vavi/sound/adpcm/ima/ImaInputEngine.java @@ -41,7 +41,7 @@ class ImaInputEngine implements InputEngine { public ImaInputEngine(OutputStream out, int samplesPerBlock, int channels, - final ByteOrder byteOrder) { + ByteOrder byteOrder) { this.out = out; this.samplesPerBlock = samplesPerBlock; this.channels = channels; diff --git a/src/main/java/vavi/sound/adpcm/ms/Ms.java b/src/main/java/vavi/sound/adpcm/ms/Ms.java index 55d8dbf..4c3e386 100644 --- a/src/main/java/vavi/sound/adpcm/ms/Ms.java +++ b/src/main/java/vavi/sound/adpcm/ms/Ms.java @@ -44,7 +44,7 @@ class Ms { /** */ - private class State { + private static class State { /** step size */ int step; int[] iCoef = new int[2]; diff --git a/src/main/java/vavi/sound/adpcm/ms/MsInputEngine.java b/src/main/java/vavi/sound/adpcm/ms/MsInputEngine.java index 91f4217..b44c06c 100644 --- a/src/main/java/vavi/sound/adpcm/ms/MsInputEngine.java +++ b/src/main/java/vavi/sound/adpcm/ms/MsInputEngine.java @@ -41,7 +41,7 @@ class MsInputEngine implements InputEngine { public MsInputEngine(OutputStream out, int samplesPerBlock, int channels, - final ByteOrder byteOrder) { + ByteOrder byteOrder) { this.out = out; this.samplesPerBlock = samplesPerBlock; this.channels = channels; diff --git a/src/main/java/vavi/sound/adpcm/ms/MsOutputEngine.java b/src/main/java/vavi/sound/adpcm/ms/MsOutputEngine.java index 9091966..c91cd00 100644 --- a/src/main/java/vavi/sound/adpcm/ms/MsOutputEngine.java +++ b/src/main/java/vavi/sound/adpcm/ms/MsOutputEngine.java @@ -44,12 +44,12 @@ class MsOutputEngine implements OutputEngine { /** */ public MsOutputEngine(InputStream in, - final int samplesPerBlock, - final int nCoefs, - final int[][] iCoefs, - final int channels, + int samplesPerBlock, + int nCoefs, + int[][] iCoefs, + int channels, int blockSize, - final ByteOrder byteOrder) { + ByteOrder byteOrder) { this.in = in; this.samplesPerBlock = samplesPerBlock; if (nCoefs < 7 || nCoefs > 0x100) { diff --git a/src/main/java/vavi/sound/adpcm/vox/Vox.java b/src/main/java/vavi/sound/adpcm/vox/Vox.java index 2787ee2..7b7c046 100644 --- a/src/main/java/vavi/sound/adpcm/vox/Vox.java +++ b/src/main/java/vavi/sound/adpcm/vox/Vox.java @@ -18,7 +18,7 @@ class Vox implements Codec { /** */ - private class State { + private static class State { int index; int last; } diff --git a/src/main/java/vavi/sound/adpcm/yamaha/Yamaha.java b/src/main/java/vavi/sound/adpcm/yamaha/Yamaha.java index d7b5413..fe99063 100644 --- a/src/main/java/vavi/sound/adpcm/yamaha/Yamaha.java +++ b/src/main/java/vavi/sound/adpcm/yamaha/Yamaha.java @@ -18,7 +18,7 @@ class Yamaha implements Codec { /** */ - private class Status { + private static class Status { int index = 127; int last = 0; } diff --git a/src/main/java/vavi/sound/mfi/MfiDevice.java b/src/main/java/vavi/sound/mfi/MfiDevice.java index 172e49e..f25bb36 100644 --- a/src/main/java/vavi/sound/mfi/MfiDevice.java +++ b/src/main/java/vavi/sound/mfi/MfiDevice.java @@ -17,7 +17,7 @@ public interface MfiDevice { /** */ - static class Info { + class Info { /** */ String name; diff --git a/src/main/java/vavi/sound/mfi/MfiSystem.java b/src/main/java/vavi/sound/mfi/MfiSystem.java index d9e6e14..31f0917 100644 --- a/src/main/java/vavi/sound/mfi/MfiSystem.java +++ b/src/main/java/vavi/sound/mfi/MfiSystem.java @@ -9,12 +9,11 @@ import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.URL; +import java.nio.file.Files; import java.util.ArrayList; import java.util.List; import java.util.Properties; @@ -72,8 +71,8 @@ public static Sequencer getSequencer() throws MfiUnavailableException { MfiDevice.Info[] infos = provider.getDeviceInfo(); - for (int i = 0; i < infos.length; i++) { - MfiDevice device = provider.getDevice(infos[i]); + for (MfiDevice.Info info : infos) { + MfiDevice device = provider.getDevice(info); if (device instanceof Sequencer) { return (Sequencer) device; } @@ -87,8 +86,8 @@ public static javax.sound.midi.MetaEventListener getMetaEventListener() throws MfiUnavailableException { MfiDevice.Info[] infos = provider.getDeviceInfo(); - for (int i = 0; i < infos.length; i++) { - MfiDevice device = provider.getDevice(infos[i]); + for (MfiDevice.Info info : infos) { + MfiDevice device = provider.getDevice(info); if (device instanceof javax.sound.midi.MetaEventListener) { return (javax.sound.midi.MetaEventListener) device; } @@ -103,8 +102,8 @@ public static MidiConverter getMidiConverter() throws MfiUnavailableException { MfiDevice.Info[] infos = provider.getDeviceInfo(); - for (int i = 0; i < infos.length; i++) { - MfiDevice device = provider.getDevice(infos[i]); + for (MfiDevice.Info info : infos) { + MfiDevice device = provider.getDevice(info); if (device instanceof MidiConverter) { return (MidiConverter) device; } @@ -168,7 +167,7 @@ public static MfiFileFormat getMfiFileFormat(File file) throws InvalidMfiDataException, IOException { - return getMfiFileFormat(new BufferedInputStream(new FileInputStream(file))); + return getMfiFileFormat(new BufferedInputStream(Files.newInputStream(file.toPath()))); } /** MFi ファイルフォーマットを取得します。 */ @@ -204,7 +203,7 @@ public static Sequence getSequence(File file) throws InvalidMfiDataException, IOException { - return getSequence(new BufferedInputStream(new FileInputStream(file))); + return getSequence(new BufferedInputStream(Files.newInputStream(file.toPath()))); } /** MFi シーケンスを取得します。 */ @@ -220,8 +219,8 @@ public static int[] getMfiFileTypes() { List types = new ArrayList<>(); for (MfiFileWriter writer : writers) { int[] ts = writer.getMfiFileTypes(); - for (int j = 0; j < ts.length; j++) { - types.add(ts[j]); + for (int t : ts) { + types.add(t); } } @@ -238,8 +237,8 @@ public static int[] getMfiFileTypes(Sequence sequence) { List types = new ArrayList<>(); for (MfiFileWriter writer : writers) { int[] ts = writer.getMfiFileTypes(sequence); - for (int j = 0; j < ts.length; j++) { - types.add(ts[j]); + for (int t : ts) { + types.add(t); } } @@ -278,7 +277,7 @@ public static int write(Sequence in, int fileType, OutputStream out) public static int write(Sequence in, int fileType, File out) throws IOException { - return write(in, fileType, new BufferedOutputStream(new FileOutputStream(out))); + return write(in, fileType, new BufferedOutputStream(Files.newOutputStream(out.toPath()))); } //------------------------------------------------------------------------- @@ -293,7 +292,7 @@ public static int write(Sequence in, int fileType, File out) /** default プロバイダ */ private static MfiDeviceProvider provider; - /** + /* * default は MfiSystem.properties で指定します。 *
  • vavi.sound.mfi.spi.MfiDeviceProvider */ diff --git a/src/main/java/vavi/sound/mfi/vavi/HeaderChunk.java b/src/main/java/vavi/sound/mfi/vavi/HeaderChunk.java index 8e7f79b..d230811 100644 --- a/src/main/java/vavi/sound/mfi/vavi/HeaderChunk.java +++ b/src/main/java/vavi/sound/mfi/vavi/HeaderChunk.java @@ -68,7 +68,7 @@ class HeaderChunk { private Support support; /** */ - public static interface Support { + public interface Support { /** * {@link #support} から {@link SubMessage} を取り出します。 * {@link SubMessage} は {@link Sequence#getTracks()}[0] の先頭にあるのが仕様 diff --git a/src/main/java/vavi/sound/mfi/vavi/MfiContext.java b/src/main/java/vavi/sound/mfi/vavi/MfiContext.java index 1924e9f..303e9f2 100644 --- a/src/main/java/vavi/sound/mfi/vavi/MfiContext.java +++ b/src/main/java/vavi/sound/mfi/vavi/MfiContext.java @@ -8,7 +8,6 @@ import java.util.ArrayList; import java.util.BitSet; -import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.NoSuchElementException; @@ -215,7 +214,7 @@ private int getAdjustedDelta(int mfiTrackNumber, double doubleDelta) { */ public MfiEvent[] getIntervalMfiEvents(int mfiTrackNumber) { - int interval = 0; + int interval; MidiEvent midiEvent = midiEvents.get(midiEventIndex); MidiMessage midiMessage = midiEvent.getMessage(); @@ -250,10 +249,10 @@ public MfiEvent[] getIntervalMfiEvents(int mfiTrackNumber) { MfiEvent[] mfiEvents = new MfiEvent[nopLength]; for (int i = 0; i < nopLength; i++) { NopMessage mfiMessage = new NopMessage(255, 0); - mfiEvents[i] = new MfiEvent(mfiMessage, 0l); // TODO 0l + mfiEvents[i] = new MfiEvent(mfiMessage, 0L); // TODO 0l // 255 Δ 分後ろにずらしていく incrementPreviousTick(mfiTrackNumber, Math.round(255 * scale)); - }; + } //Debug.println(nopLength + " nops inserted"); return mfiEvents; @@ -326,15 +325,15 @@ public void setMidiSequence(Sequence midiSequence) { this.timeBase = midiSequence.getResolution(); - Track midiTracks[] = midiSequence.getTracks(); - for (int t = 0; t < midiTracks.length; t++) { - for (int i = 0; i < midiTracks[t].size(); i++) { - javax.sound.midi.MidiMessage midiMessage = midiTracks[t].get(i).getMessage(); + Track[] midiTracks = midiSequence.getTracks(); + for (Track track : midiTracks) { + for (int i = 0; i < track.size(); i++) { + MidiMessage midiMessage = track.get(i).getMessage(); if (midiMessage instanceof MetaMessage && - ((MetaMessage) midiMessage).getType() == MetaEvent.META_TEMPO.number()) { + ((MetaMessage) midiMessage).getType() == MetaEvent.META_TEMPO.number()) { MetaMessage metaMessage = (MetaMessage) midiMessage; - byte data[] = metaMessage.getData(); + byte[] data = metaMessage.getData(); int timeBase = TempoMessage.getNearestTimeBase(this.timeBase); int l = (data[0] & 0xff) << 16 | (data[1] & 0xff) << 8 | data[2] & 0xff; @@ -355,13 +354,12 @@ public void setMidiSequence(Sequence midiSequence) { this.scale = Math.ceil(this.scale); Debug.println(Level.FINE, "(SCALE) final scale: " + scale + ", " + scaleChanged); - for (int t = 0; t < midiTracks.length; t++) { - for (int i = 0; i < midiTracks[t].size(); i++) { - this.midiEvents.add(midiTracks[t].get(i)); + for (Track midiTrack : midiTracks) { + for (int i = 0; i < midiTrack.size(); i++) { + this.midiEvents.add(midiTrack.get(i)); } } - Collections.sort(midiEvents, - new Comparator() { + midiEvents.sort(new Comparator() { /** */ public int compare(MidiEvent e1, MidiEvent e2) { long t1 = e1.getTick(); @@ -374,6 +372,7 @@ public int compare(MidiEvent e1, MidiEvent e2) { return c1 - c2; } } + /** */ int getChannel(MidiEvent e) { MidiMessage m = e.getMessage(); @@ -420,7 +419,7 @@ int getMidiEventIndex() { */ public MidiEvent getNoteOffMidiEvent() throws NoSuchElementException { - ShortMessage shortMessage = null; + ShortMessage shortMessage; MidiEvent midiEvent = midiEvents.get(midiEventIndex); MidiMessage midiMessage = midiEvent.getMessage(); diff --git a/src/main/java/vavi/sound/mfi/vavi/MfiConvertible.java b/src/main/java/vavi/sound/mfi/vavi/MfiConvertible.java index 15cec59..f21c081 100644 --- a/src/main/java/vavi/sound/mfi/vavi/MfiConvertible.java +++ b/src/main/java/vavi/sound/mfi/vavi/MfiConvertible.java @@ -35,7 +35,7 @@ MfiEvent[] getMfiEvents(MidiEvent midiEvent, MfiContext context) throws InvalidMfiDataException; /** factory */ - static final PrefixedPropertiesFactory factory = + PrefixedPropertiesFactory factory = new PrefixedClassPropertiesFactory<>("/vavi/sound/mfi/vavi/vavi.properties", "midi."); } diff --git a/src/main/java/vavi/sound/mfi/vavi/MidiContext.java b/src/main/java/vavi/sound/mfi/vavi/MidiContext.java index d523542..37ef2c4 100644 --- a/src/main/java/vavi/sound/mfi/vavi/MidiContext.java +++ b/src/main/java/vavi/sound/mfi/vavi/MidiContext.java @@ -38,7 +38,7 @@ public enum ChannelConfiguration { SOUND_SET, /** 未使用 */ UNUSED - }; + } /** channel 9 はデフォルトでリズム */ public static final int CHANNEL_DRUM = 9; diff --git a/src/main/java/vavi/sound/mfi/vavi/SubMessage.java b/src/main/java/vavi/sound/mfi/vavi/SubMessage.java index 64a096b..bcec9a2 100644 --- a/src/main/java/vavi/sound/mfi/vavi/SubMessage.java +++ b/src/main/java/vavi/sound/mfi/vavi/SubMessage.java @@ -85,9 +85,7 @@ protected SubMessage(String subType, String data) { byte[] tmp = data.getBytes(writingEncoding); byte[] message = getSubMessage(subType, tmp, tmp.length); setMessage(META_TYPE, message, message.length); - } catch (UnsupportedEncodingException e) { - throw new IllegalStateException(e); - } catch (InvalidMfiDataException e) { + } catch (UnsupportedEncodingException | InvalidMfiDataException e) { throw new IllegalStateException(e); } } @@ -191,7 +189,7 @@ public static SubMessage readFrom(InputStream is) byte[] cs = new byte[SUB_TYPE_LENGTH]; dis.read(cs, 0, SUB_TYPE_LENGTH); // type - final String subType = new String(cs); + String subType = new String(cs); String key = null; String headerKey = "mfi.header." + subType; @@ -203,10 +201,10 @@ public static SubMessage readFrom(InputStream is) key = audioKey; } - SubMessage subChunk = null; + SubMessage subChunk; int length = dis.readShort(); - final byte[] subData = new byte[length]; + byte[] subData = new byte[length]; dis.readFully(subData, 0, length); if (key != null) { @@ -248,9 +246,8 @@ public static SubMessage readFrom(InputStream is) props.load(SubMessage.class.getResourceAsStream(path)); // header/audio sub chunks - Iterator i = props.keySet().iterator(); - while (i.hasNext()) { - String key = (String) i.next(); + for (Object o : props.keySet()) { + String key = (String) o; if (key.matches("mfi\\.(header|audio)\\.\\w+")) { @SuppressWarnings("unchecked") Class clazz = (Class) Class.forName(props.getProperty(key)); diff --git a/src/main/java/vavi/sound/mfi/vavi/TrackMessage.java b/src/main/java/vavi/sound/mfi/vavi/TrackMessage.java index 8a4446c..c267c55 100644 --- a/src/main/java/vavi/sound/mfi/vavi/TrackMessage.java +++ b/src/main/java/vavi/sound/mfi/vavi/TrackMessage.java @@ -158,7 +158,7 @@ public void readFrom(InputStream is) int l = 0; while (l < trackLength) { MfiMessage message = getMessage(dis); - track.add(new MfiEvent(message, 0l)); + track.add(new MfiEvent(message, 0L)); l += message.getLength(); //Debug.println("track[" + trackNumber + "] event length sum: " + l + " / " + trackLlength); @@ -203,7 +203,7 @@ private MfiMessage getClassOrNormalMessage(int delta, int data1 = dis.readUnsignedByte(); // 拡張ステータス - MfiMessage message = null; + MfiMessage message; if (data1 >= 0x00 && data1 <= 0x7f) { // 拡張ステータス A ... LongMessage message = LongMessageFactory.getMessage(delta, status, data1, dis, exst); @@ -349,9 +349,8 @@ public static MfiMessage getMessage(int delta, props.load(TrackMessage.class.getResourceAsStream(path)); // - Iterator i = props.keySet().iterator(); - while (i.hasNext()) { - String key = (String) i.next(); + for (Object o : props.keySet()) { + String key = (String) o; if (key.matches("mfi\\.track\\.\\d+\\.e\\.\\d+")) { Class clazz = Class.forName(props.getProperty(key)); //Debug.println("sysex class: " + StringUtil.getClassName(clazz)); @@ -389,7 +388,7 @@ public static MfiMessage getMessage(int delta, // String key = String.format("mfi.track.%d.%c.%d", status, 'b', data1); - Constructor constructor = null; + Constructor constructor; if (shortMessageConstructors.containsKey(key)) { constructor = shortMessageConstructors.get(key); } else { @@ -416,9 +415,8 @@ public static MfiMessage getMessage(int delta, props.load(TrackMessage.class.getResourceAsStream(path)); // - Iterator i = props.keySet().iterator(); - while (i.hasNext()) { - String key = (String) i.next(); + for (Object o : props.keySet()) { + String key = (String) o; if (key.matches("mfi\\.track\\.\\d+\\.b\\.\\d+")) { @SuppressWarnings("unchecked") Class shortMessageClass = (Class) Class.forName(props.getProperty(key)); @@ -461,7 +459,7 @@ public static MfiMessage getMessage(int delta, // String key = String.format("mfi.track.%d.%c.%d", status, 'a', data1); - Constructor constructor = null; + Constructor constructor; if (longMessageConstructors.containsKey(key)) { constructor = longMessageConstructors.get(key); } else { @@ -488,9 +486,8 @@ public static MfiMessage getMessage(int delta, props.load(TrackMessage.class.getResourceAsStream(path)); // - Iterator i = props.keySet().iterator(); - while (i.hasNext()) { - String key = (String) i.next(); + for (Object o : props.keySet()) { + String key = (String) o; if (key.matches("mfi\\.track\\.\\d+\\.a\\.\\d+")) { @SuppressWarnings("unchecked") Class longMessageClass = (Class) Class.forName(props.getProperty(key)); diff --git a/src/main/java/vavi/sound/mfi/vavi/VaviMfiDeviceProvider.java b/src/main/java/vavi/sound/mfi/vavi/VaviMfiDeviceProvider.java index ab5923f..13408fa 100644 --- a/src/main/java/vavi/sound/mfi/vavi/VaviMfiDeviceProvider.java +++ b/src/main/java/vavi/sound/mfi/vavi/VaviMfiDeviceProvider.java @@ -32,7 +32,7 @@ public class VaviMfiDeviceProvider extends MfiDeviceProvider { public static final String version = "1.0.10"; /** */ - private MfiDevice.Info mfiDeviceInfos[]; + private MfiDevice.Info[] mfiDeviceInfos; /** */ public VaviMfiDeviceProvider() { @@ -68,11 +68,9 @@ private static class Factory { public static MfiDevice.Info[] getMfiDeviceInfos() { List tmp = new ArrayList<>(); - for (MfiDevice.Info mfiDeviceInfo : deviceMap.keySet()) { - tmp.add(mfiDeviceInfo); - } + tmp.addAll(deviceMap.keySet()); - return tmp.toArray(new MfiDevice.Info[tmp.size()]); + return tmp.toArray(new MfiDevice.Info[0]); } /** */ @@ -100,9 +98,8 @@ public static MfiDevice getMfiDevice(MfiDevice.Info mfiDeviceInfo) { props.load(Factory.class.getResourceAsStream(path)); // midi - Iterator i = props.keySet().iterator(); - while (i.hasNext()) { - String key = (String) i.next(); + for (Object o : props.keySet()) { + String key = (String) o; if (key.startsWith("mfi.device.")) { @SuppressWarnings("unchecked") Class deviceClass = (Class) Class.forName(props.getProperty(key)); diff --git a/src/main/java/vavi/sound/mfi/vavi/VaviMfiFileFormat.java b/src/main/java/vavi/sound/mfi/vavi/VaviMfiFileFormat.java index b3470f6..59b7981 100644 --- a/src/main/java/vavi/sound/mfi/vavi/VaviMfiFileFormat.java +++ b/src/main/java/vavi/sound/mfi/vavi/VaviMfiFileFormat.java @@ -315,13 +315,13 @@ private static void doSpecial(Map headerSubChunks, // Track 0 の先頭に SubMessage を押し込む // TODO HeaderChunk ですべき予感??? for (SubMessage headerSubChunk : headerSubChunks.values()) { - track.add(new MfiEvent(headerSubChunk, 0l)); + track.add(new MfiEvent(headerSubChunk, 0L)); } // Track 0 の header sub chunks の次に AudioDataMessage を押し込む for (AudioDataMessage audioDataChunk : audioDataChunks) { // TODO {@link MetaMessage} に変換??? - track.add(new MfiEvent(audioDataChunk, 0l)); + track.add(new MfiEvent(audioDataChunk, 0L)); } } diff --git a/src/main/java/vavi/sound/mfi/vavi/VaviMfiFileReader.java b/src/main/java/vavi/sound/mfi/vavi/VaviMfiFileReader.java index c570e1c..23aff3a 100644 --- a/src/main/java/vavi/sound/mfi/vavi/VaviMfiFileReader.java +++ b/src/main/java/vavi/sound/mfi/vavi/VaviMfiFileReader.java @@ -8,10 +8,10 @@ import java.io.BufferedInputStream; import java.io.File; -import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.net.URL; +import java.nio.file.Files; import vavi.sound.mfi.InvalidMfiDataException; import vavi.sound.mfi.MfiFileFormat; @@ -45,7 +45,7 @@ public MfiFileFormat getMfiFileFormat(File file) throws InvalidMfiDataException, IOException { - InputStream is = new BufferedInputStream(new FileInputStream(file)); + InputStream is = new BufferedInputStream(Files.newInputStream(file.toPath())); return VaviMfiFileFormat.readFrom(is); } @@ -73,7 +73,7 @@ public Sequence getSequence(File file) throws InvalidMfiDataException, IOException { - InputStream is = new BufferedInputStream(new FileInputStream(file)); + InputStream is = new BufferedInputStream(Files.newInputStream(file.toPath())); return getSequence(is); } diff --git a/src/main/java/vavi/sound/mfi/vavi/VaviMfiFileWriter.java b/src/main/java/vavi/sound/mfi/vavi/VaviMfiFileWriter.java index 3c05138..4cbff22 100644 --- a/src/main/java/vavi/sound/mfi/vavi/VaviMfiFileWriter.java +++ b/src/main/java/vavi/sound/mfi/vavi/VaviMfiFileWriter.java @@ -8,9 +8,9 @@ import java.io.BufferedOutputStream; import java.io.File; -import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; +import java.nio.file.Files; import java.util.NoSuchElementException; import java.util.Properties; import java.util.logging.Level; @@ -62,8 +62,8 @@ public int[] getMfiFileTypes(Sequence sequence) { /** */ public boolean isFileTypeSupported(int fileType) { - for (int i = 0; i < types.length; i++) { - if (types[i] == fileType) { + for (int type : types) { + if (type == fileType) { return true; } } @@ -138,7 +138,7 @@ public int write(Sequence in, int fileType, OutputStream out) public int write(Sequence in, int fileType, File out) throws IOException { - OutputStream os = new BufferedOutputStream(new FileOutputStream(out)); + OutputStream os = new BufferedOutputStream(Files.newOutputStream(out.toPath())); return write(in, fileType, os); } diff --git a/src/main/java/vavi/sound/mfi/vavi/VaviMidiConverter.java b/src/main/java/vavi/sound/mfi/vavi/VaviMidiConverter.java index 927fbbc..6d95cee 100644 --- a/src/main/java/vavi/sound/mfi/vavi/VaviMidiConverter.java +++ b/src/main/java/vavi/sound/mfi/vavi/VaviMidiConverter.java @@ -87,10 +87,7 @@ public vavi.sound.mfi.Sequence toMfiSequence(Sequence midiSequence, int fileType try { return convert(midiSequence, fileType); - } catch (IOException e) { -Debug.printStackTrace(e); - throw (InvalidMidiDataException) new InvalidMidiDataException().initCause(e); - } catch (InvalidMfiDataException e) { + } catch (IOException | InvalidMfiDataException e) { Debug.printStackTrace(e); throw (InvalidMidiDataException) new InvalidMidiDataException().initCause(e); } @@ -216,8 +213,8 @@ protected vavi.sound.mfi.Sequence convert(Sequence midiSequence, int fileType) MfiEvent[] nops = mfiContext.getIntervalMfiEvents(t); if (nops != null) { - for (int j = 0; j < nops.length; j++) { - mfiTracks[t].add(nops[j]); + for (MfiEvent nop : nops) { + mfiTracks[t].add(nop); } } @@ -234,22 +231,22 @@ protected vavi.sound.mfi.Sequence convert(Sequence midiSequence, int fileType) // interval MfiEvent[] mfiEvents = mfiContext.getIntervalMfiEvents(mfiTrackNumber); if (mfiEvents != null) { - for (int j = 0; j < mfiEvents.length; j++) { -if (mfiEvents[j] == null) { - Debug.println(Level.WARNING, "NOP is null[" + mfiTracks[mfiTrackNumber].size() + "]: " + MidiUtil.paramString(midiMessage)); -} - addEventToTrack(mfiContext, midiEvent.getTick(), mfiTracks[mfiTrackNumber], mfiTrackNumber, mfiEvents[j]); + for (MfiEvent mfiEvent : mfiEvents) { + if (mfiEvent == null) { + Debug.println(Level.WARNING, "NOP is null[" + mfiTracks[mfiTrackNumber].size() + "]: " + MidiUtil.paramString(midiMessage)); + } + addEventToTrack(mfiContext, midiEvent.getTick(), mfiTracks[mfiTrackNumber], mfiTrackNumber, mfiEvent); } } // converted mfiEvents = converter.getMfiEvents(midiEvent, mfiContext); if (mfiEvents != null) { - for (int j = 0; j < mfiEvents.length; j++) { -if (mfiEvents[j] == null) { - Debug.println(Level.WARNING, "event is null[" + mfiTracks[mfiTrackNumber].size() + ", " + mfiEvents.length + "]: " + converter.getClass() + ", " + MidiUtil.paramString(midiMessage)); -} - addEventToTrack(mfiContext, midiEvent.getTick(), mfiTracks[mfiTrackNumber], mfiTrackNumber, mfiEvents[j]); + for (MfiEvent mfiEvent : mfiEvents) { + if (mfiEvent == null) { + Debug.println(Level.WARNING, "event is null[" + mfiTracks[mfiTrackNumber].size() + ", " + mfiEvents.length + "]: " + converter.getClass() + ", " + MidiUtil.paramString(midiMessage)); + } + addEventToTrack(mfiContext, midiEvent.getTick(), mfiTracks[mfiTrackNumber], mfiTrackNumber, mfiEvent); } } } @@ -261,7 +258,7 @@ protected vavi.sound.mfi.Sequence convert(Sequence midiSequence, int fileType) return mfiSequence; } -private int deltas[] = new int[4]; +private int[] deltas = new int[4]; private void addEventToTrack(MfiContext mfiContext, long tick, Track mfiTrack, int mfiTrackNumber, MfiEvent mfiEvent) { MfiMessage mfiMessage = mfiEvent.getMessage(); @@ -324,8 +321,8 @@ protected Sequence convert(vavi.sound.mfi.Sequence mfiSequence) //Debug.println("midi convertible: " + message); MidiEvent[] midiEvents = ((MidiConvertible) mfiMessage).getMidiEvents(midiContext); if (midiEvents != null) { - for (int k = 0; k < midiEvents.length; k++) { - midiTrack.add(midiEvents[k]); + for (MidiEvent midiEvent : midiEvents) { + midiTrack.add(midiEvent); } } } else if (mfiMessage instanceof SubMessage) { diff --git a/src/main/java/vavi/sound/mfi/vavi/VaviNoteMessage.java b/src/main/java/vavi/sound/mfi/vavi/VaviNoteMessage.java index f3ef266..bcb9035 100644 --- a/src/main/java/vavi/sound/mfi/vavi/VaviNoteMessage.java +++ b/src/main/java/vavi/sound/mfi/vavi/VaviNoteMessage.java @@ -103,7 +103,7 @@ public MfiEvent[] getMfiEvents(MidiEvent midiEvent, MfiContext context) return null; } else /* if (command == ShortMessage.NOTE_ON) */ { - MidiEvent noteOffEvent = null; + MidiEvent noteOffEvent; try { noteOffEvent = context.getNoteOffMidiEvent(); @@ -161,7 +161,7 @@ public MfiEvent[] getMfiEvents(MidiEvent midiEvent, MfiContext context) Debug.println(channel + "ch, " + mfiMessage.getNote() + ", " + mfiMessage.getDelta() + ":[" + i + "]:" + (i == onLength - 1 ? length % 255 : 255) + "/" + length); } //Debug.println(channel + ", " + mfiMessage.getVoice() + ", " + ((mfiMessage.getMessage()[1] & 0xc0) >> 6)); - mfiEvents[i] = new MfiEvent(mfiMessage, 0l); // TODO 0l + mfiEvents[i] = new MfiEvent(mfiMessage, 0L); // TODO 0l //if (mfiEvents[i] == null) { // Debug.println("[" + 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 262233a..2206a14 100644 --- a/src/main/java/vavi/sound/mfi/vavi/VaviSequencer.java +++ b/src/main/java/vavi/sound/mfi/vavi/VaviSequencer.java @@ -211,10 +211,7 @@ public void meta(javax.sound.midi.MetaMessage message) { } catch (InvalidMfiDataException e) { Debug.println(Level.SEVERE, e); } -catch (RuntimeException e) { -Debug.printStackTrace(e); - throw e; -} catch (Error e) { +catch (RuntimeException | Error e) { Debug.printStackTrace(e); throw e; } diff --git a/src/main/java/vavi/sound/mfi/vavi/audio/CommonAudioMessage.java b/src/main/java/vavi/sound/mfi/vavi/audio/CommonAudioMessage.java index cd8a77d..e0f498a 100644 --- a/src/main/java/vavi/sound/mfi/vavi/audio/CommonAudioMessage.java +++ b/src/main/java/vavi/sound/mfi/vavi/audio/CommonAudioMessage.java @@ -47,7 +47,7 @@ public class CommonAudioMessage { public static MfiEvent getMasterVolumeEvent(int masterVolume) { int realMasterVolume = (int) (masterVolume * maxMasterVolume / 100f); MfiMessage message = new MasterVolumeMessage(0x00, 0xff, 0xb0, realMasterVolume); - return new MfiEvent(message, 0l); + return new MfiEvent(message, 0L); } /** @@ -57,7 +57,7 @@ public static MfiEvent getMasterVolumeEvent(int masterVolume) { public static MfiEvent getVolumeEvent(int adpcmVolume) { int realAdpcmVolume = (int) (adpcmVolume * maxAdpcmVolume / 100f); MfiMessage message = new AudioChannelVolumeMessage(0x00, 0x7f, 0x80, realAdpcmVolume); - return new MfiEvent(message, 0l); + return new MfiEvent(message, 0L); } /** @@ -66,13 +66,13 @@ public static MfiEvent getVolumeEvent(int adpcmVolume) { */ public static MfiEvent getPanEvent(int pan) { MfiMessage message = new AudioChannelPanpotMessage(0x00, 0x7f, 0x81, pan); - return new MfiEvent(message, 0l); + return new MfiEvent(message, 0L); } /** */ public static MfiEvent getPlayEvent() { MfiMessage message = new AudioPlayMessage(0x00, 0x7f, 0x00, new byte[] { 0, 63 }); - return new MfiEvent(message, 0l); + return new MfiEvent(message, 0L); } /** @@ -81,7 +81,7 @@ public static MfiEvent getPlayEvent() { */ public static MfiEvent getCuePointEvent(boolean start) { MfiMessage message = new CuePointMessage(0x00, start ? 0x00 : 0x01); - return new MfiEvent(message, 0l); + return new MfiEvent(message, 0L); } /** */ @@ -89,7 +89,7 @@ public static MfiEvent getCuePointEvent(boolean start) { /** @return TempoMessage is always the same instance */ public static MfiEvent getTempoEvent() { - return new MfiEvent(tempoMessage, 0l); + return new MfiEvent(tempoMessage, 0L); } /** */ @@ -106,17 +106,17 @@ public static List getNop2Events(float time) { int delta = getDelta(time); Debug.println("delta: " + delta); for (int i = 0; i < delta / Nop2Message.maxDelta; i++) { - events.add(new MfiEvent(new Nop2Message(0xff, 0xff), 0l)); + events.add(new MfiEvent(new Nop2Message(0xff, 0xff), 0L)); } int moduloOfDelta = delta % Nop2Message.maxDelta; - events.add(new MfiEvent(new Nop2Message(moduloOfDelta % 0x100, moduloOfDelta / 0x100), 0l)); + events.add(new MfiEvent(new Nop2Message(moduloOfDelta % 0x100, moduloOfDelta / 0x100), 0L)); return events; } /** */ public static List getAudioEvents(int format, byte[] data, int sampleRate, int bits, int channels) { - List events = null; + List events; switch (format) { case 0x80: events = getAudioEventsType1(data, sampleRate, bits, channels); @@ -134,10 +134,10 @@ public static List getAudioEvents(int format, byte[] data, int sampleR private static List getAudioEventsType1(byte[] data, int sampleRate, int bits, int channels) { List events = new ArrayList<>(); // exst - events.add(new MfiEvent(new ExstMessage(1), 0l)); + events.add(new MfiEvent(new ExstMessage(1), 0L)); // ainf - events.add(new MfiEvent(new AinfMessage(false, 1), 0l)); + events.add(new MfiEvent(new AinfMessage(false, 1), 0L)); // audio data AudioEngine audioEngine = Factory.getAudioEngine(0x80); // TODO 0x80 is not defined in spec @@ -145,7 +145,7 @@ private static List getAudioEventsType1(byte[] data, int sampleRate, i AdpmMessage adpmMessage = new AdpmMessage(sampleRate / 1000, bits, false, channels); AudioDataMessage audioData = new AudioDataMessage(0x80, 0x00, adpmMessage); // TODO 0x80 is not defined in spec audioData.setData(adpcm); - events.add(new MfiEvent(audioData, 0l)); + events.add(new MfiEvent(audioData, 0L)); return events; } @@ -155,10 +155,10 @@ private static List getAudioEventsType2(byte[] data, int sampleRate, i List events = new ArrayList<>(); // exst - events.add(new MfiEvent(new ExstMessage(1), 0l)); + events.add(new MfiEvent(new ExstMessage(1), 0L)); // ainf - events.add(new MfiEvent(new AinfMessage(false, 1, new AinfMessage.AudioInfo(0x81, new byte[] { 0x10, 0x08, 0x10, 0x10, 0x08, 0x10 })), 0l)); + events.add(new MfiEvent(new AinfMessage(false, 1, new AinfMessage.AudioInfo(0x81, new byte[] { 0x10, 0x08, 0x10, 0x10, 0x08, 0x10 })), 0L)); // audio data AudioEngine audioEngine = Factory.getAudioEngine(0x81); @@ -166,7 +166,7 @@ private static List getAudioEventsType2(byte[] data, int sampleRate, i AdpmMessage adpmMessage = new AdpmMessage(sampleRate / 1000, bits, false, channels); AudioDataMessage audioData = new AudioDataMessage(AudioDataMessage.FORMAT_ADPCM_TYPE2, 0x00, adpmMessage); audioData.setData(adpcm); - events.add(new MfiEvent(audioData, 0l)); + events.add(new MfiEvent(audioData, 0L)); return events; } diff --git a/src/main/java/vavi/sound/mfi/vavi/audio/FuetrekAudioMessage.java b/src/main/java/vavi/sound/mfi/vavi/audio/FuetrekAudioMessage.java index 809b95a..880297b 100644 --- a/src/main/java/vavi/sound/mfi/vavi/audio/FuetrekAudioMessage.java +++ b/src/main/java/vavi/sound/mfi/vavi/audio/FuetrekAudioMessage.java @@ -36,7 +36,7 @@ public class FuetrekAudioMessage extends MachineDependentMessage { public static MfiEvent getMasterVolumeEvent(int masterVolume) { int realMasterVolume = (int) (masterVolume * maxMasterVolume / 100f); MfiMessage message = new MasterVolumeMessage(0x00, 0xff, 0xb0, realMasterVolume); - return new MfiEvent(message, 0l); + return new MfiEvent(message, 0L); } /** @@ -45,13 +45,13 @@ public static MfiEvent getMasterVolumeEvent(int masterVolume) { */ public static MfiEvent getCuePointEvent(boolean start) { MfiMessage message = new CuePointMessage(0x00, start ? 0x00 : 0x01); - return new MfiEvent(message, 0l); + return new MfiEvent(message, 0L); } /** */ public static MfiEvent getTempoEvent(float time, int sampleRate) { TempoMessage message = getTempoMessage(time, sampleRate); - return new MfiEvent(message, 0l); + return new MfiEvent(message, 0L); } /** */ @@ -101,7 +101,7 @@ public static int getDelta(float time, int sampleRate) { * @return TempoMessage is always the same instance */ public static MfiEvent getTempoEvent() { - return new MfiEvent(tempoMessageOld, 0l); + return new MfiEvent(tempoMessageOld, 0L); } /** older version */ diff --git a/src/main/java/vavi/sound/mfi/vavi/audio/RohmAudioMessage.java b/src/main/java/vavi/sound/mfi/vavi/audio/RohmAudioMessage.java index e458e6d..97df9eb 100644 --- a/src/main/java/vavi/sound/mfi/vavi/audio/RohmAudioMessage.java +++ b/src/main/java/vavi/sound/mfi/vavi/audio/RohmAudioMessage.java @@ -35,7 +35,7 @@ public class RohmAudioMessage extends MachineDependentMessage { public static MfiEvent getMasterVolumeEvent(int masterVolume) { int realMasterVolume = (int) (masterVolume * maxMasterVolume / 100f); MfiMessage message = new MasterVolumeMessage(0x00, 0xff, 0xb0, realMasterVolume); - return new MfiEvent(message, 0l); + return new MfiEvent(message, 0L); } /** */ @@ -43,7 +43,7 @@ public static MfiEvent getMasterVolumeEvent(int masterVolume) { /** @return TempoMessage is always the same instance */ public static MfiEvent getTempoEvent() { - return new MfiEvent(tempoMessage, 0l); + return new MfiEvent(tempoMessage, 0L); } /** */ diff --git a/src/main/java/vavi/sound/mfi/vavi/audio/YamahaAudioMessage.java b/src/main/java/vavi/sound/mfi/vavi/audio/YamahaAudioMessage.java index 0dca790..958b245 100644 --- a/src/main/java/vavi/sound/mfi/vavi/audio/YamahaAudioMessage.java +++ b/src/main/java/vavi/sound/mfi/vavi/audio/YamahaAudioMessage.java @@ -35,7 +35,7 @@ public class YamahaAudioMessage extends MachineDependentMessage { public static MfiEvent getMasterVolumeEvent(int masterVolume) { int realMasterVolume = (int) (masterVolume * maxMasterVolume / 100f); MfiMessage message = new MasterVolumeMessage(0x00, 0xff, 0xb0, realMasterVolume); - return new MfiEvent(message, 0l); + return new MfiEvent(message, 0L); } /** */ @@ -43,7 +43,7 @@ public static MfiEvent getMasterVolumeEvent(int masterVolume) { /** @return TempoMessage is always the same instance */ public static MfiEvent getTempoEvent() { - return new MfiEvent(tempoMessage, 0l); + return new MfiEvent(tempoMessage, 0L); } /** */ diff --git a/src/main/java/vavi/sound/mfi/vavi/header/AinfMessage.java b/src/main/java/vavi/sound/mfi/vavi/header/AinfMessage.java index 3f4b6e6..9523e3f 100644 --- a/src/main/java/vavi/sound/mfi/vavi/header/AinfMessage.java +++ b/src/main/java/vavi/sound/mfi/vavi/header/AinfMessage.java @@ -133,12 +133,11 @@ private AudioInfo(int index, byte[] in, int offset) { } /** */ public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("ainf inf[" + index + "]: "); - sb.append(String.format("%02x, %d", format, length)); - sb.append('\n'); - sb.append(StringUtil.getDump(data)); - return sb.toString(); + String sb = "ainf inf[" + index + "]: " + + String.format("%02x, %d", format, length) + + '\n' + + StringUtil.getDump(data); + return sb; } } diff --git a/src/main/java/vavi/sound/mfi/vavi/header/CopyMessage.java b/src/main/java/vavi/sound/mfi/vavi/header/CopyMessage.java index 8eb479e..5512256 100644 --- a/src/main/java/vavi/sound/mfi/vavi/header/CopyMessage.java +++ b/src/main/java/vavi/sound/mfi/vavi/header/CopyMessage.java @@ -28,7 +28,7 @@ * Copyright 情報 MFi Header Sub Chunk. *
      *  "copy" n bytes: copyright
    - *  MIDI {@link MidiConstants#META_COPYRIGHT META_COPYRIGHT (0x02)}
    + *  MIDI {@link MidiConstants.MetaEvent#META_COPYRIGHT META_COPYRIGHT (0x02)}
      * 
    *
  • TODO use {@link CodeMessage} * @author Naohide Sano (nsano) diff --git a/src/main/java/vavi/sound/mfi/vavi/header/ProtMessage.java b/src/main/java/vavi/sound/mfi/vavi/header/ProtMessage.java index 531d398..fd47c58 100644 --- a/src/main/java/vavi/sound/mfi/vavi/header/ProtMessage.java +++ b/src/main/java/vavi/sound/mfi/vavi/header/ProtMessage.java @@ -26,7 +26,7 @@ * データ管理及び保護情報 MFi Header Sub Chunk. *
      *  "prot" n bytes: data managing
    - *  MIDI {@link MidiConstants#META_TEXT_EVENT META_TEXT_EVENT (0x01)}
    + *  MIDI {@link MidiConstants.MetaEvent#META_TEXT_EVENT META_TEXT_EVENT (0x01)}
      * 
    *
  • TODO use {@link CodeMessage} * @author Naohide Sano (nsano) 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 af9d129..9edd532 100644 --- a/src/main/java/vavi/sound/mfi/vavi/header/TitlMessage.java +++ b/src/main/java/vavi/sound/mfi/vavi/header/TitlMessage.java @@ -28,7 +28,7 @@ * タイトル情報 MFi Header Sub Chunk. *
      *  "titl" n byte: mld title, < 16 bytes expected, SJIS encoded
    - *  MIDI {@link MidiConstants#META_NAME META_NAME (0x03)}
    + *  MIDI {@link MidiConstants.MetaEvent#META_NAME META_NAME (0x03)}
      * 
    *
  • TODO use {@link CodeMessage} * @author Naohide Sano (nsano) diff --git a/src/main/java/vavi/sound/mfi/vavi/mitsubishi/Function143.java b/src/main/java/vavi/sound/mfi/vavi/mitsubishi/Function143.java index 97a1040..cb6758c 100644 --- a/src/main/java/vavi/sound/mfi/vavi/mitsubishi/Function143.java +++ b/src/main/java/vavi/sound/mfi/vavi/mitsubishi/Function143.java @@ -73,7 +73,7 @@ private enum SubId { MAX_PARALLEL(0x83), /** max kHz / 8 kHz */ MAX_PARALLEL_CUE(0x8b); - int value; + final int value; SubId(int value) { this.value = value; } @@ -131,7 +131,7 @@ public void setMaxParallelCue(int sample) { private List subIds = new ArrayList<>(); /** */ - private class SubIdChunk { + private static class SubIdChunk { SubIdChunk(SubId id, int value) { this.id = id.value; this.data = new byte[] { (byte) value }; diff --git a/src/main/java/vavi/sound/mfi/vavi/mitsubishi/MitsubishiMessage.java b/src/main/java/vavi/sound/mfi/vavi/mitsubishi/MitsubishiMessage.java index e5ac4a1..998ce9b 100644 --- a/src/main/java/vavi/sound/mfi/vavi/mitsubishi/MitsubishiMessage.java +++ b/src/main/java/vavi/sound/mfi/vavi/mitsubishi/MitsubishiMessage.java @@ -76,11 +76,11 @@ public static List getAdpcmEvents(byte[] pcm, float time, int sampleRa // fill nop for (int i = 0; i < delta / Nop2Message.maxDelta; i++) { Nop2Message nop2 = new Nop2Message(0xff, 0xff); - events.add(new MfiEvent(nop2, 0l)); + events.add(new MfiEvent(nop2, 0L)); } int moduloOfDelta = delta % Nop2Message.maxDelta; Nop2Message nop2 = new Nop2Message(moduloOfDelta % 0x100, moduloOfDelta / 0x100); - events.add(new MfiEvent(nop2, 0l)); + events.add(new MfiEvent(nop2, 0L)); return events; } 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 b497f8d..501a8c3 100644 --- a/src/main/java/vavi/sound/mfi/vavi/nec/NecSequencer.java +++ b/src/main/java/vavi/sound/mfi/vavi/nec/NecSequencer.java @@ -52,7 +52,7 @@ public void sequence(MachineDependentMessage message) byte[] data = message.getMessage(); int f1 = data[6] & 0xff; - int f2 = 0; + int f2; String key; diff --git a/src/main/java/vavi/sound/mfi/vavi/sequencer/AudioDataSequencer.java b/src/main/java/vavi/sound/mfi/vavi/sequencer/AudioDataSequencer.java index d010fb8..810a18b 100644 --- a/src/main/java/vavi/sound/mfi/vavi/sequencer/AudioDataSequencer.java +++ b/src/main/java/vavi/sound/mfi/vavi/sequencer/AudioDataSequencer.java @@ -25,7 +25,7 @@ public interface AudioDataSequencer { /** for {@link AudioDataSequencer} */ - final int META_FUNCTION_ID_MFi4 = 0x02; + int META_FUNCTION_ID_MFi4 = 0x02; /** */ void sequence() throws InvalidMfiDataException; diff --git a/src/main/java/vavi/sound/mfi/vavi/sequencer/MachineDependentFunction.java b/src/main/java/vavi/sound/mfi/vavi/sequencer/MachineDependentFunction.java index 0f78869..c1188cb 100644 --- a/src/main/java/vavi/sound/mfi/vavi/sequencer/MachineDependentFunction.java +++ b/src/main/java/vavi/sound/mfi/vavi/sequencer/MachineDependentFunction.java @@ -30,18 +30,18 @@ */ public interface MachineDependentFunction { - final int VENDOR_NEC = 0x10; // N - final int VENDOR_FUJITSU = 0x20; // F - final int VENDOR_SONY = 0x30; // SO - final int VENDOR_PANASONIC = 0x40; // P - final int VENDOR_NIHONMUSEN = 0x50; // R - final int VENDOR_MITSUBISHI = 0x60; // D - final int VENDOR_SHARP = 0x70; // SH - final int VENDOR_SANYO = 0x80; // SA - final int VENDOR_MOTOROLA = 0x90; // M + int VENDOR_NEC = 0x10; // N + int VENDOR_FUJITSU = 0x20; // F + int VENDOR_SONY = 0x30; // SO + int VENDOR_PANASONIC = 0x40; // P + int VENDOR_NIHONMUSEN = 0x50; // R + int VENDOR_MITSUBISHI = 0x60; // D + int VENDOR_SHARP = 0x70; // SH + int VENDOR_SANYO = 0x80; // SA + int VENDOR_MOTOROLA = 0x90; // M - final int CARRIER_AU = 0x00; // au - final int CARRIER_DOCOMO = 0x01; // DoCoMo + int CARRIER_AU = 0x00; // au + int CARRIER_DOCOMO = 0x01; // DoCoMo /** */ void process(MachineDependentMessage message) diff --git a/src/main/java/vavi/sound/mfi/vavi/sequencer/MachineDependentSequencer.java b/src/main/java/vavi/sound/mfi/vavi/sequencer/MachineDependentSequencer.java index e78df4c..8ca75ee 100644 --- a/src/main/java/vavi/sound/mfi/vavi/sequencer/MachineDependentSequencer.java +++ b/src/main/java/vavi/sound/mfi/vavi/sequencer/MachineDependentSequencer.java @@ -25,14 +25,14 @@ public interface MachineDependentSequencer { /** for {@link MachineDependentSequencer} */ - static final int META_FUNCTION_ID_MACHINE_DEPEND = 0x01; + int META_FUNCTION_ID_MACHINE_DEPEND = 0x01; /** processes a message */ void sequence(MachineDependentMessage message) throws InvalidMfiDataException; /** factory */ - static final PrefixedPropertiesFactory factory = + PrefixedPropertiesFactory factory = new PrefixedClassPropertiesFactory<>("/vavi/sound/mfi/vavi/vavi.properties", "sequencer.vendor."); } diff --git a/src/main/java/vavi/sound/mfi/vavi/sequencer/UndefinedFunction.java b/src/main/java/vavi/sound/mfi/vavi/sequencer/UndefinedFunction.java index 82a1a09..1fccd18 100644 --- a/src/main/java/vavi/sound/mfi/vavi/sequencer/UndefinedFunction.java +++ b/src/main/java/vavi/sound/mfi/vavi/sequencer/UndefinedFunction.java @@ -41,7 +41,7 @@ public void process(MachineDependentMessage message) int f1 = data[6] & 0xff; int f2 = -1; - int f3 = -1; + int f3; if (data.length > 8) { f3 = data[8] & 0xff; Debug.printf(Level.INFO, "undefined function: %02x %02x %02x\n", f1, f2, f3); diff --git a/src/main/java/vavi/sound/mfi/vavi/sharp/Function143.java b/src/main/java/vavi/sound/mfi/vavi/sharp/Function143.java index 183b294..519ad7a 100644 --- a/src/main/java/vavi/sound/mfi/vavi/sharp/Function143.java +++ b/src/main/java/vavi/sound/mfi/vavi/sharp/Function143.java @@ -73,7 +73,7 @@ private enum SubId { MAX_PARALLEL(0x83), /** max kHz / 8 kHz */ MAX_PARALLEL_CUE(0x8b); - int value; + final int value; SubId(int value) { this.value = value; } @@ -125,7 +125,7 @@ public void setMaxParallelCue(int sample) { private List subIds = new ArrayList<>(); /** */ - private class SubIdChunk { + private static class SubIdChunk { SubIdChunk(SubId id, int value) { this.id = id.value; this.data = new byte[] { (byte) value }; diff --git a/src/main/java/vavi/sound/mfi/vavi/sharp/SharpMessage.java b/src/main/java/vavi/sound/mfi/vavi/sharp/SharpMessage.java index 47416c7..0b0c8a3 100644 --- a/src/main/java/vavi/sound/mfi/vavi/sharp/SharpMessage.java +++ b/src/main/java/vavi/sound/mfi/vavi/sharp/SharpMessage.java @@ -70,11 +70,11 @@ public static List getAdpcmEvents(byte[] pcm, float time, int sampleRa if (fillNop) { for (int i = 0; i < delta / Nop2Message.maxDelta; i++) { Nop2Message nop2 = new Nop2Message(0xff, 0xff); - events.add(new MfiEvent(nop2, 0l)); + events.add(new MfiEvent(nop2, 0L)); } int moduloOfDelta = delta % Nop2Message.maxDelta; Nop2Message nop2 = new Nop2Message(moduloOfDelta % 0x100, moduloOfDelta / 0x100); - events.add(new MfiEvent(nop2, 0l)); + events.add(new MfiEvent(nop2, 0L)); } return events; } @@ -126,7 +126,7 @@ private static MfiEvent getWaveEvent(int channel, int packetId, int sampleRate, function.setLength(length); function.setAdpcm(adpcm); message.setMessage(0x00, function.getMessage()); - return new MfiEvent(message, 0l); + return new MfiEvent(message, 0L); } /** @@ -147,7 +147,7 @@ private static MfiEvent getWaveEvent(int channel, int packetId, int sampleRate, function.setLength(length); function.setAdpcm(new byte[0]); message.setMessage(0x00, function.getMessage()); - return new MfiEvent(message, 0l); + return new MfiEvent(message, 0L); } /** 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 a417898..be9b313 100644 --- a/src/main/java/vavi/sound/mfi/vavi/track/TempoMessage.java +++ b/src/main/java/vavi/sound/mfi/vavi/track/TempoMessage.java @@ -200,14 +200,11 @@ public static int getNearestTimeBase(int timeBase) { } } - Collections.sort(table, - new Comparator() { - public int compare(Pair p1, Pair p2) { - int v1 = p1.value; - int v2 = p2.value; - return v1 - v2; - } - }); + table.sort((p1, p2) -> { + int v1 = p1.value; + int v2 = p2.value; + return v1 - v2; + }); //for (int i = 0; i < table.size(); i++) { // Debug.println("(" + i + ") timeBaseTable[" + table.get(i).index + "], " + table.get(i).value); //} diff --git a/src/main/java/vavi/sound/midi/BasicMidiFileReader.java b/src/main/java/vavi/sound/midi/BasicMidiFileReader.java index 661aeb4..7238db6 100644 --- a/src/main/java/vavi/sound/midi/BasicMidiFileReader.java +++ b/src/main/java/vavi/sound/midi/BasicMidiFileReader.java @@ -10,10 +10,10 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; -import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.net.URL; +import java.nio.file.Files; import java.util.logging.Level; import javax.sound.midi.InvalidMidiDataException; @@ -59,7 +59,7 @@ public MidiFileFormat getMidiFileFormat(File file) IOException { Debug.println(Level.FINE, "file: " + file); - InputStream is = new BufferedInputStream(new FileInputStream(file)); + InputStream is = new BufferedInputStream(Files.newInputStream(file.toPath())); return getMidiFileFormat(is); } @@ -77,7 +77,7 @@ public Sequence getSequence(File file) throws InvalidMidiDataException, IOException { - InputStream is = new BufferedInputStream(new FileInputStream(file)); + InputStream is = new BufferedInputStream(Files.newInputStream(file.toPath())); return getSequence(is); } diff --git a/src/main/java/vavi/sound/midi/BasicMidiFileWriter.java b/src/main/java/vavi/sound/midi/BasicMidiFileWriter.java index 1f71bc4..eda9c1d 100644 --- a/src/main/java/vavi/sound/midi/BasicMidiFileWriter.java +++ b/src/main/java/vavi/sound/midi/BasicMidiFileWriter.java @@ -7,8 +7,8 @@ package vavi.sound.midi; import java.io.File; -import java.io.FileOutputStream; import java.io.IOException; +import java.nio.file.Files; import javax.sound.midi.Sequence; import javax.sound.midi.spi.MidiFileWriter; @@ -28,7 +28,7 @@ public abstract class BasicMidiFileWriter extends MidiFileWriter { public final int write(Sequence in, int fileType, File out) throws IOException { - return write(in, fileType, new FileOutputStream(out)); + return write(in, fileType, Files.newOutputStream(out.toPath())); } } diff --git a/src/main/java/vavi/sound/midi/MidiConstants.java b/src/main/java/vavi/sound/midi/MidiConstants.java index 9daba0c..4114bdf 100644 --- a/src/main/java/vavi/sound/midi/MidiConstants.java +++ b/src/main/java/vavi/sound/midi/MidiConstants.java @@ -323,7 +323,7 @@ public String toString() { //------------------------------------------------------------------------- - /** */ + /* */ static { try { final Class clazz = MidiConstants.class; diff --git a/src/main/java/vavi/sound/midi/MidiUtil.java b/src/main/java/vavi/sound/midi/MidiUtil.java index bb030fb..afa8345 100644 --- a/src/main/java/vavi/sound/midi/MidiUtil.java +++ b/src/main/java/vavi/sound/midi/MidiUtil.java @@ -201,7 +201,7 @@ public static byte[] getEncodedMessage(String text) { /** */ public static byte[] getEncodedMessage(String text, String encoding) { - byte[] textData = null; + byte[] textData; try { textData = text.getBytes(encoding); } catch (UnsupportedEncodingException e) { 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 84b4b32..9881fab 100644 --- a/src/main/java/vavi/sound/pcm/resampling/ssrc/SSRC.java +++ b/src/main/java/vavi/sound/pcm/resampling/ssrc/SSRC.java @@ -482,14 +482,14 @@ class Upsampler extends Resampler { /* */ int resample(ReadableByteChannel fpi, WritableByteChannel fpo) throws IOException { - int frqgcd, osf = 0, fs1, fs2; + int frqgcd, osf, fs1, fs2; double[][] stage1; double[] stage2; int n1, n1x, n1y, n2, n2b; int filter2len; int[] f1order, f1inc; - int[] fft_ip = null; - double[] fft_w = null; + int[] fft_ip; + double[] fft_w; ByteBuffer rawinbuf, rawoutbuf; double[] inbuf, outbuf; double[][] buf1, buf2; @@ -648,7 +648,7 @@ int resample(ReadableByteChannel fpi, WritableByteChannel fpo) throws IOExceptio int s1p_backup, osc_backup; int ch, p; int inbuflen; - int delay = 0; + int delay; buf1 = new double[nch][n2b2 / osf + 1]; @@ -1054,7 +1054,7 @@ class Downsampler extends Resampler { /* */ int resample(ReadableByteChannel fpi, WritableByteChannel fpo) throws IOException { - int frqgcd, osf = 0, fs1, fs2; + int frqgcd, osf, fs1, fs2; double[] stage1; double[][] stage2; int n2, n2x, n2y, n1, n1b; @@ -1242,7 +1242,7 @@ int resample(ReadableByteChannel fpi, WritableByteChannel fpo) throws IOExceptio int k, ch, p; int inbuflen = 0; int sumread, sumwrite; - int delay = 0; + int delay; int op; // |....B....|....C....| buf1 n1b2+n1b2 @@ -1688,7 +1688,7 @@ int resample(ReadableByteChannel fpi, WritableByteChannel fpo) throws IOExceptio s = buf.order(byteOrder).asIntBuffer().get(0); f = (1 / (double) 0x7fffffff) * s; break; - }; + } if (r <= 0) { break; @@ -2017,10 +2017,10 @@ public void exec(String[] argv) throws IOException { } if (!quiet) { - final String[] dtype = { + String[] dtype = { "none", "no noise shaping", "triangular spectral shape", "ATH based noise shaping", "ATH based noise shaping(less amplitude)" }; - final String[] ptype = { + String[] ptype = { "rectangular", "triangular", "gaussian" }; System.err.printf("frequency : %d -> %d\n", sfrq, dfrq); @@ -2370,10 +2370,10 @@ void io(ReadableByteChannel fpi, WritableByteChannel fpo, int length, int nch, i } if (!quiet) { - final String[] dtype = { + String[] dtype = { "none", "no noise shaping", "triangular spectral shape", "ATH based noise shaping", "ATH based noise shaping(less amplitude)" }; - final String[] ptype = { + String[] ptype = { "rectangular", "triangular", "gaussian" }; System.err.printf("frequency : %d -> %d\n", sfrq, dfrq); 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 5783699..002869f 100755 --- a/src/main/java/vavi/sound/pcm/resampling/ssrc/SSRCSampleRateConversionProvider.java +++ b/src/main/java/vavi/sound/pcm/resampling/ssrc/SSRCSampleRateConversionProvider.java @@ -46,7 +46,7 @@ public AudioFormat.Encoding[] getTargetEncodings() { public AudioFormat.Encoding[] getTargetEncodings(AudioFormat sourceFormat) { if (sourceFormat.getEncoding().equals(AudioFormat.Encoding.PCM_SIGNED)) { - AudioFormat.Encoding encs[] = new AudioFormat.Encoding[1]; + AudioFormat.Encoding[] encs = new AudioFormat.Encoding[1]; encs[0] = AudioFormat.Encoding.PCM_SIGNED; return encs; } else { @@ -93,7 +93,7 @@ public AudioInputStream getAudioInputStream(AudioFormat targetFormat, AudioInput return new AudioInputStream(resampler, outputFormat, AudioSystem.NOT_SPECIFIED); } else { throw new IllegalArgumentException("Unsupported conversion: " + sourceStream.getFormat().toString() + " to " - + targetFormat.toString()); + + targetFormat); } } catch (IOException e) { throw new IllegalStateException(e); diff --git a/src/main/java/vavi/sound/sampled/adpcm/ccitt/G721FormatConversionProvider.java b/src/main/java/vavi/sound/sampled/adpcm/ccitt/G721FormatConversionProvider.java index dd5daf5..e7b5356 100644 --- a/src/main/java/vavi/sound/sampled/adpcm/ccitt/G721FormatConversionProvider.java +++ b/src/main/java/vavi/sound/sampled/adpcm/ccitt/G721FormatConversionProvider.java @@ -85,9 +85,9 @@ public AudioInputStream getAudioInputStream(AudioFormat.Encoding targetEncoding, } else if (sourceFormat.getEncoding() instanceof CcittEncoding && targetFormat.getEncoding().equals(AudioFormat.Encoding.PCM_SIGNED)) { return new G721ToPcmAudioInputStream(sourceStream, targetFormat, AudioSystem.NOT_SPECIFIED); } else if (sourceFormat.getEncoding().equals(AudioFormat.Encoding.PCM_SIGNED) && targetFormat.getEncoding() instanceof CcittEncoding) { - throw new IllegalArgumentException("unable to convert " + sourceFormat.toString() + " to " + targetFormat.toString()); + throw new IllegalArgumentException("unable to convert " + sourceFormat + " to " + targetFormat); } else { - throw new IllegalArgumentException("unable to convert " + sourceFormat.toString() + " to " + targetFormat.toString()); + throw new IllegalArgumentException("unable to convert " + sourceFormat + " to " + targetFormat.toString()); } } else { throw new IllegalArgumentException("target format not found"); @@ -109,9 +109,9 @@ public AudioInputStream getAudioInputStream(AudioFormat targetFormat, AudioInput targetFormat.getEncoding().equals(AudioFormat.Encoding.PCM_SIGNED)) { return new G721ToPcmAudioInputStream(sourceStream, targetFormat, AudioSystem.NOT_SPECIFIED); } else if (sourceFormat.getEncoding().equals(AudioFormat.Encoding.PCM_SIGNED) && targetFormat.getEncoding() instanceof CcittEncoding) { - throw new IllegalArgumentException("unable to convert " + sourceFormat.toString() + " to " + targetFormat.toString()); + throw new IllegalArgumentException("unable to convert " + sourceFormat + " to " + targetFormat); } else { - throw new IllegalArgumentException("unable to convert " + sourceFormat.toString() + " to " + targetFormat.toString()); + throw new IllegalArgumentException("unable to convert " + sourceFormat + " to " + targetFormat); } } else { throw new IllegalArgumentException("target format not found"); diff --git a/src/main/java/vavi/sound/sampled/adpcm/dvi/DviFormatConversionProvider.java b/src/main/java/vavi/sound/sampled/adpcm/dvi/DviFormatConversionProvider.java index 0704533..43a6ed9 100644 --- a/src/main/java/vavi/sound/sampled/adpcm/dvi/DviFormatConversionProvider.java +++ b/src/main/java/vavi/sound/sampled/adpcm/dvi/DviFormatConversionProvider.java @@ -85,9 +85,9 @@ public AudioInputStream getAudioInputStream(AudioFormat.Encoding targetEncoding, } else if (sourceFormat.getEncoding() instanceof DviEncoding && targetFormat.getEncoding().equals(AudioFormat.Encoding.PCM_SIGNED)) { return new Dvi2PcmAudioInputStream(sourceStream, targetFormat, AudioSystem.NOT_SPECIFIED); } else if (sourceFormat.getEncoding().equals(AudioFormat.Encoding.PCM_SIGNED) && targetFormat.getEncoding() instanceof DviEncoding) { - throw new IllegalArgumentException("unable to convert " + sourceFormat.toString() + " to " + targetFormat.toString()); + throw new IllegalArgumentException("unable to convert " + sourceFormat + " to " + targetFormat); } else { - throw new IllegalArgumentException("unable to convert " + sourceFormat.toString() + " to " + targetFormat.toString()); + throw new IllegalArgumentException("unable to convert " + sourceFormat + " to " + targetFormat.toString()); } } else { throw new IllegalArgumentException("target format not found"); @@ -109,9 +109,9 @@ public AudioInputStream getAudioInputStream(AudioFormat targetFormat, AudioInput targetFormat.getEncoding().equals(AudioFormat.Encoding.PCM_SIGNED)) { return new Dvi2PcmAudioInputStream(sourceStream, targetFormat, AudioSystem.NOT_SPECIFIED); } else if (sourceFormat.getEncoding().equals(AudioFormat.Encoding.PCM_SIGNED) && targetFormat.getEncoding() instanceof DviEncoding) { - throw new IllegalArgumentException("unable to convert " + sourceFormat.toString() + " to " + targetFormat.toString()); + throw new IllegalArgumentException("unable to convert " + sourceFormat + " to " + targetFormat); } else { - throw new IllegalArgumentException("unable to convert " + sourceFormat.toString() + " to " + targetFormat.toString()); + throw new IllegalArgumentException("unable to convert " + sourceFormat + " to " + targetFormat); } } else { throw new IllegalArgumentException("target format not found"); diff --git a/src/main/java/vavi/sound/sampled/adpcm/ima/ImaFormatConversionProvider.java b/src/main/java/vavi/sound/sampled/adpcm/ima/ImaFormatConversionProvider.java index 8fe3201..234df76 100644 --- a/src/main/java/vavi/sound/sampled/adpcm/ima/ImaFormatConversionProvider.java +++ b/src/main/java/vavi/sound/sampled/adpcm/ima/ImaFormatConversionProvider.java @@ -96,9 +96,9 @@ public AudioInputStream getAudioInputStream(AudioFormat.Encoding targetEncoding, throw new UncheckedIOException(e); } } else if (sourceFormat.getEncoding().equals(AudioFormat.Encoding.PCM_SIGNED) && targetFormat.getEncoding() instanceof ImaEncoding) { - throw new IllegalArgumentException("unable to convert " + sourceFormat.toString() + " to " + targetFormat.toString()); + throw new IllegalArgumentException("unable to convert " + sourceFormat + " to " + targetFormat); } else { - throw new IllegalArgumentException("unable to convert " + sourceFormat.toString() + " to " + targetFormat.toString()); + throw new IllegalArgumentException("unable to convert " + sourceFormat + " to " + targetFormat.toString()); } } else { throw new IllegalArgumentException("target format not found"); @@ -126,9 +126,9 @@ public AudioInputStream getAudioInputStream(AudioFormat targetFormat, AudioInput throw new UncheckedIOException(e); } } else if (sourceFormat.getEncoding().equals(AudioFormat.Encoding.PCM_SIGNED) && targetFormat.getEncoding() instanceof ImaEncoding) { - throw new IllegalArgumentException("unable to convert " + sourceFormat.toString() + " to " + targetFormat.toString()); + throw new IllegalArgumentException("unable to convert " + sourceFormat + " to " + targetFormat); } else { - throw new IllegalArgumentException("unable to convert " + sourceFormat.toString() + " to " + targetFormat.toString()); + throw new IllegalArgumentException("unable to convert " + sourceFormat + " to " + targetFormat); } } else { throw new IllegalArgumentException("target format not found"); diff --git a/src/main/java/vavi/sound/sampled/adpcm/ma/MaFormatConversionProvider.java b/src/main/java/vavi/sound/sampled/adpcm/ma/MaFormatConversionProvider.java index 6ff4e33..d993b23 100644 --- a/src/main/java/vavi/sound/sampled/adpcm/ma/MaFormatConversionProvider.java +++ b/src/main/java/vavi/sound/sampled/adpcm/ma/MaFormatConversionProvider.java @@ -85,9 +85,9 @@ public AudioInputStream getAudioInputStream(AudioFormat.Encoding targetEncoding, } else if (sourceFormat.getEncoding() instanceof MaEncoding && targetFormat.getEncoding().equals(AudioFormat.Encoding.PCM_SIGNED)) { return new Ma2PcmAudioInputStream(sourceStream, targetFormat, AudioSystem.NOT_SPECIFIED); } else if (sourceFormat.getEncoding().equals(AudioFormat.Encoding.PCM_SIGNED) && targetFormat.getEncoding() instanceof MaEncoding) { - throw new IllegalArgumentException("unable to convert " + sourceFormat.toString() + " to " + targetFormat.toString()); + throw new IllegalArgumentException("unable to convert " + sourceFormat + " to " + targetFormat); } else { - throw new IllegalArgumentException("unable to convert " + sourceFormat.toString() + " to " + targetFormat.toString()); + throw new IllegalArgumentException("unable to convert " + sourceFormat + " to " + targetFormat.toString()); } } else { throw new IllegalArgumentException("target format not found"); @@ -109,9 +109,9 @@ public AudioInputStream getAudioInputStream(AudioFormat targetFormat, AudioInput targetFormat.getEncoding().equals(AudioFormat.Encoding.PCM_SIGNED)) { return new Ma2PcmAudioInputStream(sourceStream, targetFormat, AudioSystem.NOT_SPECIFIED); } else if (sourceFormat.getEncoding().equals(AudioFormat.Encoding.PCM_SIGNED) && targetFormat.getEncoding() instanceof MaEncoding) { - throw new IllegalArgumentException("unable to convert " + sourceFormat.toString() + " to " + targetFormat.toString()); + throw new IllegalArgumentException("unable to convert " + sourceFormat + " to " + targetFormat); } else { - throw new IllegalArgumentException("unable to convert " + sourceFormat.toString() + " to " + targetFormat.toString()); + throw new IllegalArgumentException("unable to convert " + sourceFormat + " to " + targetFormat); } } else { throw new IllegalArgumentException("target format not found"); diff --git a/src/main/java/vavi/sound/sampled/adpcm/ms/MsFormatConversionProvider.java b/src/main/java/vavi/sound/sampled/adpcm/ms/MsFormatConversionProvider.java index dfb1f03..309b7ea 100644 --- a/src/main/java/vavi/sound/sampled/adpcm/ms/MsFormatConversionProvider.java +++ b/src/main/java/vavi/sound/sampled/adpcm/ms/MsFormatConversionProvider.java @@ -98,9 +98,9 @@ public AudioInputStream getAudioInputStream(AudioFormat.Encoding targetEncoding, throw new UncheckedIOException(e); } } else if (sourceFormat.getEncoding().equals(AudioFormat.Encoding.PCM_SIGNED) && targetFormat.getEncoding() instanceof MsEncoding) { - throw new IllegalArgumentException("unable to convert " + sourceFormat.toString() + " to " + targetFormat.toString()); + throw new IllegalArgumentException("unable to convert " + sourceFormat + " to " + targetFormat); } else { - throw new IllegalArgumentException("unable to convert " + sourceFormat.toString() + " to " + targetFormat.toString()); + throw new IllegalArgumentException("unable to convert " + sourceFormat + " to " + targetFormat.toString()); } } else { throw new IllegalArgumentException("target format not found"); @@ -130,9 +130,9 @@ public AudioInputStream getAudioInputStream(AudioFormat targetFormat, AudioInput throw new UncheckedIOException(e); } } else if (sourceFormat.getEncoding().equals(AudioFormat.Encoding.PCM_SIGNED) && targetFormat.getEncoding() instanceof MsEncoding) { - throw new IllegalArgumentException("unable to convert " + sourceFormat.toString() + " to " + targetFormat.toString()); + throw new IllegalArgumentException("unable to convert " + sourceFormat + " to " + targetFormat); } else { - throw new IllegalArgumentException("unable to convert " + sourceFormat.toString() + " to " + targetFormat.toString()); + throw new IllegalArgumentException("unable to convert " + sourceFormat + " to " + targetFormat); } } else { throw new IllegalArgumentException("target format not found"); diff --git a/src/main/java/vavi/sound/sampled/adpcm/oki/OkiFormatConversionProvider.java b/src/main/java/vavi/sound/sampled/adpcm/oki/OkiFormatConversionProvider.java index 8bb4903..4bd0c4b 100644 --- a/src/main/java/vavi/sound/sampled/adpcm/oki/OkiFormatConversionProvider.java +++ b/src/main/java/vavi/sound/sampled/adpcm/oki/OkiFormatConversionProvider.java @@ -85,9 +85,9 @@ public AudioInputStream getAudioInputStream(AudioFormat.Encoding targetEncoding, } else if (sourceFormat.getEncoding() instanceof OkiEncoding && targetFormat.getEncoding().equals(AudioFormat.Encoding.PCM_SIGNED)) { return new Oki2PcmAudioInputStream(sourceStream, targetFormat, AudioSystem.NOT_SPECIFIED); } else if (sourceFormat.getEncoding().equals(AudioFormat.Encoding.PCM_SIGNED) && targetFormat.getEncoding() instanceof OkiEncoding) { - throw new IllegalArgumentException("unable to convert " + sourceFormat.toString() + " to " + targetFormat.toString()); + throw new IllegalArgumentException("unable to convert " + sourceFormat + " to " + targetFormat); } else { - throw new IllegalArgumentException("unable to convert " + sourceFormat.toString() + " to " + targetFormat.toString()); + throw new IllegalArgumentException("unable to convert " + sourceFormat + " to " + targetFormat.toString()); } } else { throw new IllegalArgumentException("target format not found"); @@ -109,9 +109,9 @@ public AudioInputStream getAudioInputStream(AudioFormat targetFormat, AudioInput targetFormat.getEncoding().equals(AudioFormat.Encoding.PCM_SIGNED)) { return new Oki2PcmAudioInputStream(sourceStream, targetFormat, AudioSystem.NOT_SPECIFIED); } else if (sourceFormat.getEncoding().equals(AudioFormat.Encoding.PCM_SIGNED) && targetFormat.getEncoding() instanceof OkiEncoding) { - throw new IllegalArgumentException("unable to convert " + sourceFormat.toString() + " to " + targetFormat.toString()); + throw new IllegalArgumentException("unable to convert " + sourceFormat + " to " + targetFormat); } else { - throw new IllegalArgumentException("unable to convert " + sourceFormat.toString() + " to " + targetFormat.toString()); + throw new IllegalArgumentException("unable to convert " + sourceFormat + " to " + targetFormat); } } else { throw new IllegalArgumentException("target format not found"); diff --git a/src/main/java/vavi/sound/sampled/adpcm/rohm/RohmFormatConversionProvider.java b/src/main/java/vavi/sound/sampled/adpcm/rohm/RohmFormatConversionProvider.java index 72439fc..1d7b19f 100644 --- a/src/main/java/vavi/sound/sampled/adpcm/rohm/RohmFormatConversionProvider.java +++ b/src/main/java/vavi/sound/sampled/adpcm/rohm/RohmFormatConversionProvider.java @@ -85,9 +85,9 @@ public AudioInputStream getAudioInputStream(AudioFormat.Encoding targetEncoding, } else if (sourceFormat.getEncoding() instanceof RohmEncoding && targetFormat.getEncoding().equals(AudioFormat.Encoding.PCM_SIGNED)) { return new Rohm2PcmAudioInputStream(sourceStream, targetFormat, AudioSystem.NOT_SPECIFIED); } else if (sourceFormat.getEncoding().equals(AudioFormat.Encoding.PCM_SIGNED) && targetFormat.getEncoding() instanceof RohmEncoding) { - throw new IllegalArgumentException("unable to convert " + sourceFormat.toString() + " to " + targetFormat.toString()); + throw new IllegalArgumentException("unable to convert " + sourceFormat + " to " + targetFormat); } else { - throw new IllegalArgumentException("unable to convert " + sourceFormat.toString() + " to " + targetFormat.toString()); + throw new IllegalArgumentException("unable to convert " + sourceFormat + " to " + targetFormat.toString()); } } else { throw new IllegalArgumentException("target format not found"); @@ -109,9 +109,9 @@ public AudioInputStream getAudioInputStream(AudioFormat targetFormat, AudioInput targetFormat.getEncoding().equals(AudioFormat.Encoding.PCM_SIGNED)) { return new Rohm2PcmAudioInputStream(sourceStream, targetFormat, AudioSystem.NOT_SPECIFIED); } else if (sourceFormat.getEncoding().equals(AudioFormat.Encoding.PCM_SIGNED) && targetFormat.getEncoding() instanceof RohmEncoding) { - throw new IllegalArgumentException("unable to convert " + sourceFormat.toString() + " to " + targetFormat.toString()); + throw new IllegalArgumentException("unable to convert " + sourceFormat + " to " + targetFormat); } else { - throw new IllegalArgumentException("unable to convert " + sourceFormat.toString() + " to " + targetFormat.toString()); + throw new IllegalArgumentException("unable to convert " + sourceFormat + " to " + targetFormat); } } else { throw new IllegalArgumentException("target format not found"); diff --git a/src/main/java/vavi/sound/sampled/adpcm/vox/VoxFormatConversionProvider.java b/src/main/java/vavi/sound/sampled/adpcm/vox/VoxFormatConversionProvider.java index f3f82cb..81be93a 100644 --- a/src/main/java/vavi/sound/sampled/adpcm/vox/VoxFormatConversionProvider.java +++ b/src/main/java/vavi/sound/sampled/adpcm/vox/VoxFormatConversionProvider.java @@ -85,9 +85,9 @@ public AudioInputStream getAudioInputStream(AudioFormat.Encoding targetEncoding, } else if (sourceFormat.getEncoding() instanceof VoxEncoding && targetFormat.getEncoding().equals(AudioFormat.Encoding.PCM_SIGNED)) { return new Vox2PcmAudioInputStream(sourceStream, targetFormat, AudioSystem.NOT_SPECIFIED); } else if (sourceFormat.getEncoding().equals(AudioFormat.Encoding.PCM_SIGNED) && targetFormat.getEncoding() instanceof VoxEncoding) { - throw new IllegalArgumentException("unable to convert " + sourceFormat.toString() + " to " + targetFormat.toString()); + throw new IllegalArgumentException("unable to convert " + sourceFormat + " to " + targetFormat); } else { - throw new IllegalArgumentException("unable to convert " + sourceFormat.toString() + " to " + targetFormat.toString()); + throw new IllegalArgumentException("unable to convert " + sourceFormat + " to " + targetFormat.toString()); } } else { throw new IllegalArgumentException("target format not found"); @@ -109,9 +109,9 @@ public AudioInputStream getAudioInputStream(AudioFormat targetFormat, AudioInput targetFormat.getEncoding().equals(AudioFormat.Encoding.PCM_SIGNED)) { return new Vox2PcmAudioInputStream(sourceStream, targetFormat, AudioSystem.NOT_SPECIFIED); } else if (sourceFormat.getEncoding().equals(AudioFormat.Encoding.PCM_SIGNED) && targetFormat.getEncoding() instanceof VoxEncoding) { - throw new IllegalArgumentException("unable to convert " + sourceFormat.toString() + " to " + targetFormat.toString()); + throw new IllegalArgumentException("unable to convert " + sourceFormat + " to " + targetFormat); } else { - throw new IllegalArgumentException("unable to convert " + sourceFormat.toString() + " to " + targetFormat.toString()); + throw new IllegalArgumentException("unable to convert " + sourceFormat + " to " + targetFormat); } } else { throw new IllegalArgumentException("target format not found"); diff --git a/src/main/java/vavi/sound/sampled/adpcm/yamaha/YamahaFormatConversionProvider.java b/src/main/java/vavi/sound/sampled/adpcm/yamaha/YamahaFormatConversionProvider.java index 79e6505..4406a33 100644 --- a/src/main/java/vavi/sound/sampled/adpcm/yamaha/YamahaFormatConversionProvider.java +++ b/src/main/java/vavi/sound/sampled/adpcm/yamaha/YamahaFormatConversionProvider.java @@ -85,9 +85,9 @@ public AudioInputStream getAudioInputStream(AudioFormat.Encoding targetEncoding, } else if (sourceFormat.getEncoding() instanceof YamahaEncoding && targetFormat.getEncoding().equals(AudioFormat.Encoding.PCM_SIGNED)) { return new Yamaha2PcmAudioInputStream(sourceStream, targetFormat, AudioSystem.NOT_SPECIFIED); } else if (sourceFormat.getEncoding().equals(AudioFormat.Encoding.PCM_SIGNED) && targetFormat.getEncoding() instanceof YamahaEncoding) { - throw new IllegalArgumentException("unable to convert " + sourceFormat.toString() + " to " + targetFormat.toString()); + throw new IllegalArgumentException("unable to convert " + sourceFormat + " to " + targetFormat); } else { - throw new IllegalArgumentException("unable to convert " + sourceFormat.toString() + " to " + targetFormat.toString()); + throw new IllegalArgumentException("unable to convert " + sourceFormat + " to " + targetFormat.toString()); } } else { throw new IllegalArgumentException("target format not found"); @@ -109,9 +109,9 @@ public AudioInputStream getAudioInputStream(AudioFormat targetFormat, AudioInput targetFormat.getEncoding().equals(AudioFormat.Encoding.PCM_SIGNED)) { return new Yamaha2PcmAudioInputStream(sourceStream, targetFormat, AudioSystem.NOT_SPECIFIED); } else if (sourceFormat.getEncoding().equals(AudioFormat.Encoding.PCM_SIGNED) && targetFormat.getEncoding() instanceof YamahaEncoding) { - throw new IllegalArgumentException("unable to convert " + sourceFormat.toString() + " to " + targetFormat.toString()); + throw new IllegalArgumentException("unable to convert " + sourceFormat + " to " + targetFormat); } else { - throw new IllegalArgumentException("unable to convert " + sourceFormat.toString() + " to " + targetFormat.toString()); + throw new IllegalArgumentException("unable to convert " + sourceFormat + " to " + targetFormat); } } else { throw new IllegalArgumentException("target format not found"); diff --git a/src/main/java/vavi/sound/sampled/mfi/MachineDependentMfiWithVoiceMaker.java b/src/main/java/vavi/sound/sampled/mfi/MachineDependentMfiWithVoiceMaker.java index 337f805..b67ae08 100644 --- a/src/main/java/vavi/sound/sampled/mfi/MachineDependentMfiWithVoiceMaker.java +++ b/src/main/java/vavi/sound/sampled/mfi/MachineDependentMfiWithVoiceMaker.java @@ -38,7 +38,7 @@ List getEvents(byte[] data, float time, int sampleRate, int bits, int throws InvalidMfiDataException, IOException; /** factory */ - static final PrefixedPropertiesFactory factory = + PrefixedPropertiesFactory factory = new PrefixedClassPropertiesFactory("/vavi/sound/sampled/mfi/MfiWithVoiceMaker.properties", "class.") { @Override diff --git a/src/main/java/vavi/sound/sampled/mfi/MfiAudioFileWriter.java b/src/main/java/vavi/sound/sampled/mfi/MfiAudioFileWriter.java index 2ba4e3f..3c00bfe 100644 --- a/src/main/java/vavi/sound/sampled/mfi/MfiAudioFileWriter.java +++ b/src/main/java/vavi/sound/sampled/mfi/MfiAudioFileWriter.java @@ -7,9 +7,9 @@ package vavi.sound.sampled.mfi; import java.io.File; -import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; +import java.nio.file.Files; import javax.sound.sampled.AudioFileFormat.Type; import javax.sound.sampled.AudioInputStream; @@ -87,9 +87,7 @@ public int write(AudioInputStream stream, Type fileType, OutputStream out) throw int r = mwvm.create(); return r; } - } catch (UnsupportedAudioFileException e) { - throw (IOException) new IOException().initCause(e); - } catch (InvalidMfiDataException e) { + } catch (UnsupportedAudioFileException | InvalidMfiDataException e) { throw (IOException) new IOException().initCause(e); } catch (IllegalArgumentException e) { Debug.printStackTrace(e); @@ -103,7 +101,7 @@ public int write(AudioInputStream stream, Type fileType, OutputStream out) throw * @param out null 出力を指定してください。 win32: "nul", *nix: "/dev/null" */ public int write(AudioInputStream stream, Type fileType, File out) throws IOException { - return write(stream, fileType, new FileOutputStream(out)); + return write(stream, fileType, Files.newOutputStream(out.toPath())); } } diff --git a/src/main/java/vavi/sound/sampled/mfi/MfiWithVoiceMaker.java b/src/main/java/vavi/sound/sampled/mfi/MfiWithVoiceMaker.java index 5ae72b3..7b1122a 100644 --- a/src/main/java/vavi/sound/sampled/mfi/MfiWithVoiceMaker.java +++ b/src/main/java/vavi/sound/sampled/mfi/MfiWithVoiceMaker.java @@ -143,21 +143,21 @@ protected int createMFi(byte[] data, File file) throws InvalidMfiDataException, // copyright message = new SorcMessage(sorc); - track.add(new MfiEvent(message, 0l)); + track.add(new MfiEvent(message, 0L)); // title String title = file.getName(); title = title.substring(0, title.lastIndexOf('.')); message = new TitlMessage(title); - track.add(new MfiEvent(message, 0l)); + track.add(new MfiEvent(message, 0L)); // version message = new VersMessage(vers); - track.add(new MfiEvent(message, 0l)); + track.add(new MfiEvent(message, 0L)); // maker message = new ProtMessage(prot); - track.add(new MfiEvent(message, 0l)); + track.add(new MfiEvent(message, 0L)); // machine depend, do every thing! for (MfiEvent event: mdvm.getEvents(data, time, samplingRate, bits, channels, masterVolume, adpcmVolume)) { @@ -166,7 +166,7 @@ protected int createMFi(byte[] data, File file) throws InvalidMfiDataException, // eot message = new EndOfTrackMessage(0, 0); - track.add(new MfiEvent(message, 0l)); + track.add(new MfiEvent(message, 0L)); if (!file.getParentFile().exists()) { file.getParentFile().mkdirs(); @@ -189,7 +189,7 @@ protected int createMFi(byte[] data, File file) throws InvalidMfiDataException, /** */ protected static String defaultModel; - /** */ + /* */ static { try { Properties props = new Properties(); diff --git a/src/main/java/vavi/sound/sampled/smaf/SmafAudioFileWriter.java b/src/main/java/vavi/sound/sampled/smaf/SmafAudioFileWriter.java index 314d87b..a0a013d 100644 --- a/src/main/java/vavi/sound/sampled/smaf/SmafAudioFileWriter.java +++ b/src/main/java/vavi/sound/sampled/smaf/SmafAudioFileWriter.java @@ -7,9 +7,9 @@ package vavi.sound.sampled.smaf; import java.io.File; -import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; +import java.nio.file.Files; import javax.sound.sampled.AudioFileFormat.Type; import javax.sound.sampled.AudioInputStream; @@ -95,7 +95,7 @@ public int write(AudioInputStream stream, Type fileType, OutputStream out) throw * @param out null 出力を指定してください。 win32: "nul", *nix: "/dev/null" */ public int write(AudioInputStream stream, Type fileType, File out) throws IOException { - return write(stream, fileType, new FileOutputStream(out)); + return write(stream, fileType, Files.newOutputStream(out.toPath())); } } diff --git a/src/main/java/vavi/sound/sampled/smaf/SmafWithVoiceMaker.java b/src/main/java/vavi/sound/sampled/smaf/SmafWithVoiceMaker.java index 8c285ff..6225239 100644 --- a/src/main/java/vavi/sound/sampled/smaf/SmafWithVoiceMaker.java +++ b/src/main/java/vavi/sound/sampled/smaf/SmafWithVoiceMaker.java @@ -7,8 +7,8 @@ package vavi.sound.sampled.smaf; import java.io.File; -import java.io.FileOutputStream; import java.io.IOException; +import java.nio.file.Files; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Properties; @@ -243,7 +243,7 @@ protected int createSMAF(byte[] data, File file) throws InvalidSmafDataException if (!file.getParentFile().exists()) { file.getParentFile().mkdirs(); } - fileChunk.writeTo(new FileOutputStream(file)); + fileChunk.writeTo(Files.newOutputStream(file.toPath())); int r = fileChunk.getSize(); Debug.println("write: " + r); return r; @@ -258,7 +258,7 @@ protected int createSMAF(byte[] data, File file) throws InvalidSmafDataException /** */ protected static String defaultModel; - /** */ + /* */ static { try { Properties props = new Properties(); diff --git a/src/main/java/vavi/sound/smaf/MetaEventAdapter.java b/src/main/java/vavi/sound/smaf/MetaEventAdapter.java index eadee39..fc11d87 100644 --- a/src/main/java/vavi/sound/smaf/MetaEventAdapter.java +++ b/src/main/java/vavi/sound/smaf/MetaEventAdapter.java @@ -148,7 +148,7 @@ private void processSpecial_Vavi_MachineDependent(javax.sound.midi.MetaMessage m byte[] data = message.getData(); int id = (data[2] & 0xff) * 0xff + (data[3] & 0xff); //Debug.println("message id: " + id); - MachineDependentSequencer sequencer = MachineDependentSequencer.class.cast(SmafMessageStore.get(id)); + MachineDependentSequencer sequencer = (MachineDependentSequencer) SmafMessageStore.get(id); sequencer.sequence(); } diff --git a/src/main/java/vavi/sound/smaf/Sequence.java b/src/main/java/vavi/sound/smaf/Sequence.java index 94448ec..c063e67 100644 --- a/src/main/java/vavi/sound/smaf/Sequence.java +++ b/src/main/java/vavi/sound/smaf/Sequence.java @@ -48,7 +48,7 @@ public boolean deleteTrack(Track track) { /** */ public Track[] getTracks() { - return tracks.toArray(new Track[tracks.size()]); + return tracks.toArray(new Track[0]); } } diff --git a/src/main/java/vavi/sound/smaf/SmafDevice.java b/src/main/java/vavi/sound/smaf/SmafDevice.java index 0f93b6b..05e0344 100644 --- a/src/main/java/vavi/sound/smaf/SmafDevice.java +++ b/src/main/java/vavi/sound/smaf/SmafDevice.java @@ -16,7 +16,7 @@ public interface SmafDevice { /** */ - static class Info { + class Info { /** */ String name; diff --git a/src/main/java/vavi/sound/smaf/SmafDeviceProvider.java b/src/main/java/vavi/sound/smaf/SmafDeviceProvider.java index a5fbbe7..85090e3 100644 --- a/src/main/java/vavi/sound/smaf/SmafDeviceProvider.java +++ b/src/main/java/vavi/sound/smaf/SmafDeviceProvider.java @@ -28,7 +28,7 @@ public class SmafDeviceProvider { public static final String version = "1.0.10"; /** */ - private SmafDevice.Info smafDeviceInfos[]; + private SmafDevice.Info[] smafDeviceInfos; /** */ public SmafDeviceProvider() { @@ -64,11 +64,9 @@ private static class Factory { public static SmafDevice.Info[] getSmafDeviceInfos() { List tmp = new ArrayList<>(); - for (SmafDevice.Info smafDeviceInfo : deviceMap.keySet()) { - tmp.add(smafDeviceInfo); - } + tmp.addAll(deviceMap.keySet()); - return tmp.toArray(new SmafDevice.Info[tmp.size()]); + return tmp.toArray(new SmafDevice.Info[0]); } /** */ @@ -96,9 +94,8 @@ public static SmafDevice getSmafDevice(SmafDevice.Info smafDeviceInfo) { props.load(Factory.class.getResourceAsStream(path)); // midi - Iterator i = props.keySet().iterator(); - while (i.hasNext()) { - String key = (String) i.next(); + for (Object o : props.keySet()) { + String key = (String) o; if (key.startsWith("smaf.device.")) { @SuppressWarnings("unchecked") Class deviceClass = (Class) Class.forName(props.getProperty(key)); diff --git a/src/main/java/vavi/sound/smaf/SmafFileFormat.java b/src/main/java/vavi/sound/smaf/SmafFileFormat.java index 30878a9..1eefbc6 100644 --- a/src/main/java/vavi/sound/smaf/SmafFileFormat.java +++ b/src/main/java/vavi/sound/smaf/SmafFileFormat.java @@ -72,8 +72,8 @@ Sequence getSequence() { static SmafFileFormat readFrom(InputStream is) throws InvalidSmafDataException, IOException { try { Chunk chunk = Chunk.readFrom(is, null); - if (FileChunk.class.isInstance(chunk)) { - FileChunk fileChunk = FileChunk.class.cast(chunk); + if (chunk instanceof FileChunk) { + FileChunk fileChunk = (FileChunk) chunk; SmafFileFormat sff = new SmafFileFormat(fileChunk.getSize()); sff.sequence = new SmafSequence(fileChunk); return sff; diff --git a/src/main/java/vavi/sound/smaf/SmafFileReader.java b/src/main/java/vavi/sound/smaf/SmafFileReader.java index 6ece4e6..ca8db41 100644 --- a/src/main/java/vavi/sound/smaf/SmafFileReader.java +++ b/src/main/java/vavi/sound/smaf/SmafFileReader.java @@ -8,10 +8,10 @@ import java.io.BufferedInputStream; import java.io.File; -import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.net.URL; +import java.nio.file.Files; /** @@ -35,7 +35,7 @@ public SmafFileFormat getSmafFileFormat(File file) throws InvalidSmafDataException, IOException { - InputStream is = new BufferedInputStream(new FileInputStream(file)); + InputStream is = new BufferedInputStream(Files.newInputStream(file.toPath())); return SmafFileFormat.readFrom(is); } @@ -63,7 +63,7 @@ public Sequence getSequence(File file) throws InvalidSmafDataException, IOException { - InputStream is = new BufferedInputStream(new FileInputStream(file)); + InputStream is = new BufferedInputStream(Files.newInputStream(file.toPath())); return getSequence(is); } diff --git a/src/main/java/vavi/sound/smaf/SmafFileWriter.java b/src/main/java/vavi/sound/smaf/SmafFileWriter.java index 741b848..1d3be8b 100644 --- a/src/main/java/vavi/sound/smaf/SmafFileWriter.java +++ b/src/main/java/vavi/sound/smaf/SmafFileWriter.java @@ -8,9 +8,9 @@ import java.io.BufferedOutputStream; import java.io.File; -import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; +import java.nio.file.Files; import java.util.logging.Level; import vavi.util.Debug; @@ -40,8 +40,8 @@ public int[] getSmafFileTypes(Sequence sequence) { /** */ public boolean isFileTypeSupported(int fileType) { - for (int i = 0; i < types.length; i++) { - if (types[i] == fileType) { + for (int type : types) { + if (type == fileType) { return true; } } @@ -93,7 +93,7 @@ public int write(Sequence in, int fileType, OutputStream out) public int write(Sequence in, int fileType, File out) throws IOException { - OutputStream os = new BufferedOutputStream(new FileOutputStream(out)); + OutputStream os = new BufferedOutputStream(Files.newOutputStream(out.toPath())); return write(in, fileType, os); } } diff --git a/src/main/java/vavi/sound/smaf/SmafMidiConverter.java b/src/main/java/vavi/sound/smaf/SmafMidiConverter.java index b8df790..2b3dafa 100644 --- a/src/main/java/vavi/sound/smaf/SmafMidiConverter.java +++ b/src/main/java/vavi/sound/smaf/SmafMidiConverter.java @@ -110,15 +110,15 @@ Sequence convert(vavi.sound.smaf.Sequence smafSequence) //} MidiEvent[] midiEvents = ((MidiConvertible) smafMessage).getMidiEvents(midiContext); if (midiEvents != null) { - for (int k = 0; k < midiEvents.length; k++) { - midiTrack.add(midiEvents[k]); + for (MidiEvent midiEvent : midiEvents) { + midiTrack.add(midiEvent); // addSmafMessage(midiTrack, midiEvents[k]); } } } else if (smafMessage instanceof MetaMessage) { Debug.println("meta: " + MetaMessage.class.cast(smafMessage).getType()); - for (Map.Entry entry : MetaMessage.class.cast(smafMessage).data.entrySet()) { Debug.println(entry.getKey() + "=" + entry.getValue()); + for (Map.Entry entry : ((MetaMessage) smafMessage).data.entrySet()) { } } else { if (!uc.contains(smafMessage.getClass())) { diff --git a/src/main/java/vavi/sound/smaf/SmafSequencer.java b/src/main/java/vavi/sound/smaf/SmafSequencer.java index bbd5143..b4ac153 100644 --- a/src/main/java/vavi/sound/smaf/SmafSequencer.java +++ b/src/main/java/vavi/sound/smaf/SmafSequencer.java @@ -190,10 +190,7 @@ public void meta(javax.sound.midi.MetaMessage message) { } catch (InvalidSmafDataException e) { Debug.println(e); } -catch (RuntimeException e) { -Debug.printStackTrace(e); - throw e; -} catch (Error e) { +catch (RuntimeException | Error e) { Debug.printStackTrace(e); throw e; } diff --git a/src/main/java/vavi/sound/smaf/SmafSystem.java b/src/main/java/vavi/sound/smaf/SmafSystem.java index 7d0878d..a345ec2 100644 --- a/src/main/java/vavi/sound/smaf/SmafSystem.java +++ b/src/main/java/vavi/sound/smaf/SmafSystem.java @@ -8,10 +8,10 @@ import java.io.BufferedInputStream; import java.io.File; -import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.nio.file.Files; import javax.sound.midi.InvalidMidiDataException; import javax.sound.midi.MetaEventListener; @@ -39,7 +39,7 @@ public final class SmafSystem { /** */ private static SmafFileWriter writer; - /** */ + /* */ static { // TODO SmafDeviceProvider sequencer = new SmafSequencer(); @@ -94,7 +94,7 @@ public static vavi.sound.smaf.Sequence getSequence(InputStream is) public static vavi.sound.smaf.Sequence getSequence(File file) throws InvalidSmafDataException, IOException { - return getSequence(new BufferedInputStream(new FileInputStream(file))); + return getSequence(new BufferedInputStream(Files.newInputStream(file.toPath()))); } /** @@ -122,10 +122,7 @@ public static vavi.sound.smaf.Sequence toSmafSequence(Sequence in, int fileType) try { return converter.convert(in, fileType); - } catch (IOException e) { -Debug.printStackTrace(e); - throw (InvalidMidiDataException) new InvalidMidiDataException().initCause(e); - } catch (InvalidSmafDataException e) { + } catch (IOException | InvalidSmafDataException e) { Debug.printStackTrace(e); throw (InvalidMidiDataException) new InvalidMidiDataException().initCause(e); } diff --git a/src/main/java/vavi/sound/smaf/chunk/ChannelStatus.java b/src/main/java/vavi/sound/smaf/chunk/ChannelStatus.java index e25d4f5..c55de7d 100644 --- a/src/main/java/vavi/sound/smaf/chunk/ChannelStatus.java +++ b/src/main/java/vavi/sound/smaf/chunk/ChannelStatus.java @@ -17,7 +17,7 @@ public class ChannelStatus { private enum Status { OFF, ON - }; + } /** */ public enum Type { @@ -25,7 +25,7 @@ public enum Type { Melody, NoMelody, Rhythm - }; + } /** smaf channel */ private int channel; diff --git a/src/main/java/vavi/sound/smaf/chunk/DataChunk.java b/src/main/java/vavi/sound/smaf/chunk/DataChunk.java index fac4588..6382eb2 100644 --- a/src/main/java/vavi/sound/smaf/chunk/DataChunk.java +++ b/src/main/java/vavi/sound/smaf/chunk/DataChunk.java @@ -180,9 +180,9 @@ public String toString() { } //System.err.println(); if (printable) { - return "SubData(" + new String(tag) + ", lang: " + getLanguageCode() + ", size: " + data.length + "): " + string; + return "SubData(" + tag + ", lang: " + getLanguageCode() + ", size: " + data.length + "): " + string; } else { - return "SubData(" + new String(tag) + ", lang: " + getLanguageCode() + ", size: " + data.length + ")\n" + StringUtil.getDump(data, 128); + return "SubData(" + tag + ", lang: " + getLanguageCode() + ", size: " + data.length + ")\n" + StringUtil.getDump(data, 128); } } catch (UnsupportedEncodingException e) { assert false; diff --git a/src/main/java/vavi/sound/smaf/chunk/DisplayParameterDefinitionChunk.java b/src/main/java/vavi/sound/smaf/chunk/DisplayParameterDefinitionChunk.java index fd7d2d6..e9258d5 100644 --- a/src/main/java/vavi/sound/smaf/chunk/DisplayParameterDefinitionChunk.java +++ b/src/main/java/vavi/sound/smaf/chunk/DisplayParameterDefinitionChunk.java @@ -132,7 +132,7 @@ enum ParameterID { /** 透明処理の有効フラグ */ TransparentEnable(0x32); /** */ - int value; + final int value; /** */ ParameterID(int value) { this.value = value; diff --git a/src/main/java/vavi/sound/smaf/chunk/FileChunk.java b/src/main/java/vavi/sound/smaf/chunk/FileChunk.java index a73da17..7050e58 100644 --- a/src/main/java/vavi/sound/smaf/chunk/FileChunk.java +++ b/src/main/java/vavi/sound/smaf/chunk/FileChunk.java @@ -116,7 +116,7 @@ public void write(int b) throws IOException { } /** */ public int getCrc() { - return (int) crc16.getValue(); + return crc16.getValue(); } } diff --git a/src/main/java/vavi/sound/smaf/chunk/GraphicsTrackChunk.java b/src/main/java/vavi/sound/smaf/chunk/GraphicsTrackChunk.java index d1256f3..5b6f11e 100644 --- a/src/main/java/vavi/sound/smaf/chunk/GraphicsTrackChunk.java +++ b/src/main/java/vavi/sound/smaf/chunk/GraphicsTrackChunk.java @@ -161,7 +161,7 @@ public List getSmafEvents() throws InvalidSmafDataException { MetaMessage metaMessage = new MetaMessage(); metaMessage.setMessage(MetaEvent.META_MACHINE_DEPEND.number(), props); - events.add(new SmafEvent(metaMessage, 0l)); + events.add(new SmafEvent(metaMessage, 0L)); return null; // TODO } diff --git a/src/main/java/vavi/sound/smaf/chunk/GraphicsTrackSequenceDataChunk.java b/src/main/java/vavi/sound/smaf/chunk/GraphicsTrackSequenceDataChunk.java index e9ca304..9357518 100644 --- a/src/main/java/vavi/sound/smaf/chunk/GraphicsTrackSequenceDataChunk.java +++ b/src/main/java/vavi/sound/smaf/chunk/GraphicsTrackSequenceDataChunk.java @@ -69,7 +69,7 @@ protected void init(MyDataInputStream dis, Chunk parent) protected void readHandyPhoneStandard(DataInputStream dis) throws InvalidSmafDataException, IOException { - SmafMessage smafMessage = null; + SmafMessage smafMessage; while (dis.available() > 0) { // -------- duration -------- diff --git a/src/main/java/vavi/sound/smaf/chunk/PcmAudioTrackChunk.java b/src/main/java/vavi/sound/smaf/chunk/PcmAudioTrackChunk.java index dfb64b1..ff3301c 100644 --- a/src/main/java/vavi/sound/smaf/chunk/PcmAudioTrackChunk.java +++ b/src/main/java/vavi/sound/smaf/chunk/PcmAudioTrackChunk.java @@ -164,18 +164,18 @@ public List getSmafEvents() throws InvalidSmafDataException { MetaMessage metaMessage = new MetaMessage(); metaMessage.setMessage(MetaEvent.META_MACHINE_DEPEND.number(), props); - events.add(new SmafEvent(metaMessage, 0l)); + events.add(new SmafEvent(metaMessage, 0L)); // for (Chunk waveDataChunk : waveDataChunks) { SmafMessage smafMessage = ((WaveDataChunk) waveDataChunk).toSmafMessage(waveType); - events.add(new SmafEvent(smafMessage, 0l)); + events.add(new SmafEvent(smafMessage, 0L)); } // List messages = ((SequenceDataChunk) sequenceDataChunk).getSmafMessages(); for (SmafMessage message : messages) { - events.add(new SmafEvent(message, 0l)); + events.add(new SmafEvent(message, 0L)); } return events; diff --git a/src/main/java/vavi/sound/smaf/chunk/ScoreTrackChunk.java b/src/main/java/vavi/sound/smaf/chunk/ScoreTrackChunk.java index fb4f216..29a25f9 100644 --- a/src/main/java/vavi/sound/smaf/chunk/ScoreTrackChunk.java +++ b/src/main/java/vavi/sound/smaf/chunk/ScoreTrackChunk.java @@ -195,13 +195,13 @@ public List getSmafEvents() throws InvalidSmafDataException { MetaMessage metaMessage = new MetaMessage(); metaMessage.setMessage(MetaEvent.META_MACHINE_DEPEND.number(), props); - events.add(new SmafEvent(metaMessage, 0l)); + events.add(new SmafEvent(metaMessage, 0L)); // if (setupDataChunk != null) { List messages = ((SetupDataChunk) setupDataChunk).getSmafMessages(); for (SmafMessage message : messages) { - events.add(new SmafEvent(message, 0l)); + events.add(new SmafEvent(message, 0L)); //Debug.println("SetupDataChunk: " + message); } } @@ -210,7 +210,7 @@ public List getSmafEvents() throws InvalidSmafDataException { if (streamPcmDataChunk != null) { List messages = ((StreamPcmDataChunk) streamPcmDataChunk).getSmafMessages(); for (SmafMessage message : messages) { - events.add(new SmafEvent(message, 0l)); // TODO 0l + events.add(new SmafEvent(message, 0L)); // TODO 0l //Debug.println("StreamPcmDataChunk: " + message); } } @@ -218,7 +218,7 @@ public List getSmafEvents() throws InvalidSmafDataException { // List messages = ((SequenceDataChunk) sequenceDataChunk).getSmafMessages(); for (SmafMessage message : messages) { - events.add(new SmafEvent(message, 0l)); // TODO 0l + events.add(new SmafEvent(message, 0L)); // TODO 0l //Debug.println("SequenceDataChunk: " + message); } diff --git a/src/main/java/vavi/sound/smaf/chunk/SequenceDataChunk.java b/src/main/java/vavi/sound/smaf/chunk/SequenceDataChunk.java index 541cc82..7c02cac 100644 --- a/src/main/java/vavi/sound/smaf/chunk/SequenceDataChunk.java +++ b/src/main/java/vavi/sound/smaf/chunk/SequenceDataChunk.java @@ -227,7 +227,7 @@ protected void readHandyPhoneStandard(MyDataInputStream dis) private void readMobileStandard(MyDataInputStream dis) throws InvalidSmafDataException, IOException { - SmafMessage smafMessage = null; + SmafMessage smafMessage; while (dis.available() > 0) { // duration diff --git a/src/main/java/vavi/sound/smaf/chunk/SetupDataChunk.java b/src/main/java/vavi/sound/smaf/chunk/SetupDataChunk.java index 5660f82..2c4add1 100644 --- a/src/main/java/vavi/sound/smaf/chunk/SetupDataChunk.java +++ b/src/main/java/vavi/sound/smaf/chunk/SetupDataChunk.java @@ -75,7 +75,7 @@ protected void init(MyDataInputStream dis, Chunk parent) throws InvalidSmafDataE */ private void readHandyPhoneStandard(MyDataInputStream dis) throws InvalidSmafDataException, IOException { - SmafMessage smafMessage = null; + SmafMessage smafMessage; while (dis.available() > 0) { // -------- event -------- @@ -111,7 +111,7 @@ private void readHandyPhoneStandard(MyDataInputStream dis) throws InvalidSmafDat /** formatType 1, 2 */ private void readMobileStandard(MyDataInputStream dis) throws InvalidSmafDataException, IOException { - SmafMessage smafMessage = null; + SmafMessage smafMessage; while (dis.available() > 0) { // event diff --git a/src/main/java/vavi/sound/smaf/chunk/SubData.java b/src/main/java/vavi/sound/smaf/chunk/SubData.java index 2f32c74..6a6f5f0 100644 --- a/src/main/java/vavi/sound/smaf/chunk/SubData.java +++ b/src/main/java/vavi/sound/smaf/chunk/SubData.java @@ -107,10 +107,10 @@ public byte[] getData() { /** */ public String toString() { try { - return new String(tag) + "(" + data.length + "): lang: " + contentsCodeType + ": " + new String(data, "Windows-31J") + return tag + "(" + data.length + "): lang: " + contentsCodeType + ": " + new String(data, "Windows-31J") /* + "\n" + StringUtil.getDump(data) */; } catch (UnsupportedEncodingException e) { - return new String(tag) + "(" + data.length + "): lang: " + contentsCodeType + ":\n" + StringUtil.getDump(data); + return tag + "(" + data.length + "): lang: " + contentsCodeType + ":\n" + StringUtil.getDump(data); } } } diff --git a/src/main/java/vavi/sound/smaf/chunk/TrackChunk.java b/src/main/java/vavi/sound/smaf/chunk/TrackChunk.java index 41dfe83..a0ca77b 100644 --- a/src/main/java/vavi/sound/smaf/chunk/TrackChunk.java +++ b/src/main/java/vavi/sound/smaf/chunk/TrackChunk.java @@ -64,9 +64,9 @@ public enum FormatType { /** TODO what? */ Unknown3(32, false); /** */ - boolean compressed; + final boolean compressed; /** size in file */ - int size; + final int size; /** */ FormatType(int size, boolean compressed) { this.size = size; @@ -104,7 +104,7 @@ public enum SequenceType { * Sequence Data は複数のフレーズデータを連続で表記したものである。Phrase List は外部から個 * 別フレーズを認識する為に用いる。 */ - SubSequence; + SubSequence } /** */ diff --git a/src/main/java/vavi/sound/smaf/message/BankSelectMessage.java b/src/main/java/vavi/sound/smaf/message/BankSelectMessage.java index 465f4b4..db3f3cd 100644 --- a/src/main/java/vavi/sound/smaf/message/BankSelectMessage.java +++ b/src/main/java/vavi/sound/smaf/message/BankSelectMessage.java @@ -39,7 +39,7 @@ public class BankSelectMessage extends vavi.sound.smaf.ShortMessage public enum Significant { Least(0x20), Most(0x00); - int data1; + final int data1; Significant(int data1) { this.data1 = data1; } diff --git a/src/main/java/vavi/sound/smaf/message/MidiContext.java b/src/main/java/vavi/sound/smaf/message/MidiContext.java index db8d547..2623896 100644 --- a/src/main/java/vavi/sound/smaf/message/MidiContext.java +++ b/src/main/java/vavi/sound/smaf/message/MidiContext.java @@ -40,7 +40,7 @@ public enum ChannelConfiguration { SOUND_SET, /** 未使用 */ UNUSED - }; + } /** channel 9 はデフォルトでリズム */ public static final int CHANNEL_DRUM = 9; @@ -480,7 +480,7 @@ public int getVelocity(int smafChannel) { -1, -1, -1, -1, -1, -1, -1, -1 }; - /** */ + /* */ static { Debug.println("tempoTable: " + tempoTable.length); } diff --git a/src/main/java/vavi/sound/smaf/message/NoteMessage.java b/src/main/java/vavi/sound/smaf/message/NoteMessage.java index 48cd407..e83f798 100644 --- a/src/main/java/vavi/sound/smaf/message/NoteMessage.java +++ b/src/main/java/vavi/sound/smaf/message/NoteMessage.java @@ -272,7 +272,7 @@ public SmafEvent[] getSmafEvents(MidiEvent midiEvent, SmafContext context) return null; } else /* if (command == ShortMessage.NOTE_ON) */ { - MidiEvent noteOffEvent = null; + MidiEvent noteOffEvent; try { noteOffEvent = context.getNoteOffMidiEvent(); @@ -305,7 +305,7 @@ public SmafEvent[] getSmafEvents(MidiEvent midiEvent, SmafContext context) Debug.println(channel + "ch, " + smafMessage.getNote() + ", " + smafMessage.getDuration() + ":[" + i + "]:" + (i == onLength - 1 ? length % 255 : 255) + "/" + length); } //Debug.println(channel + ", " + smafMessage.getVoice() + ", " + ((smafMessage.getMessage()[1] & 0xc0) >> 6)); - smafEvents[i] = new SmafEvent(smafMessage, 0l); // TODO 0l + smafEvents[i] = new SmafEvent(smafMessage, 0L); // TODO 0l if (smafEvents[i] == null) { Debug.println("[" + i + "]: " + smafEvents[i]); } @@ -316,7 +316,7 @@ public SmafEvent[] getSmafEvents(MidiEvent midiEvent, SmafContext context) } else { // context.incrementBeforeTick(track, i == onLength - 1 ? length % 255 : 255); } - }; + } return smafEvents; } diff --git a/src/main/java/vavi/sound/smaf/message/STMessage.java b/src/main/java/vavi/sound/smaf/message/STMessage.java index ce3b67f..38abd57 100644 --- a/src/main/java/vavi/sound/smaf/message/STMessage.java +++ b/src/main/java/vavi/sound/smaf/message/STMessage.java @@ -72,7 +72,7 @@ public int getLength() { * @throws InvalidMidiDataException */ public MidiEvent[] getMidiEvents(MidiContext context) throws InvalidMidiDataException { - byte[] data = null; + byte[] data; try { data = songTitle.getBytes("Windows-31J"); } catch (UnsupportedEncodingException e) { diff --git a/src/main/java/vavi/sound/smaf/message/SmafContext.java b/src/main/java/vavi/sound/smaf/message/SmafContext.java index 085ae70..43bd2af 100644 --- a/src/main/java/vavi/sound/smaf/message/SmafContext.java +++ b/src/main/java/vavi/sound/smaf/message/SmafContext.java @@ -191,8 +191,8 @@ private int getAdjustedDelta(int smafTrackNumber, double floatDelta) { */ public SmafEvent[] getIntervalSmafEvents() { - int interval = 0; - int track = 0; + int interval; + int track; MidiEvent midiEvent = midiTrack.get(midiEventIndex); MidiMessage midiMessage = midiEvent.getMessage(); @@ -234,7 +234,7 @@ public SmafEvent[] getIntervalSmafEvents() { SmafEvent[] smafEvents = new SmafEvent[nopLength]; for (int i = 0; i < nopLength; i++) { NopMessage smafMessage = new NopMessage(255); - smafEvents[i] = new SmafEvent(smafMessage, 0l); // TODO 0l + smafEvents[i] = new SmafEvent(smafMessage, 0L); // TODO 0l // 255 Δ 分後ろにずらしていく incrementBeforeTick(track, 255); } @@ -351,7 +351,7 @@ int getMidiEventIndex() { */ public MidiEvent getNextMidiEvent() throws NoSuchElementException { - ShortMessage shortMessage = null; + ShortMessage shortMessage; MidiEvent midiEvent = midiTrack.get(midiEventIndex); MidiMessage midiMessage = midiEvent.getMessage(); @@ -391,7 +391,7 @@ public MidiEvent getNextMidiEvent() throws NoSuchElementException { */ public MidiEvent getNoteOffMidiEvent() throws NoSuchElementException { - ShortMessage shortMessage = null; + ShortMessage shortMessage; MidiEvent midiEvent = midiTrack.get(midiEventIndex); MidiMessage midiMessage = midiEvent.getMessage(); diff --git a/src/main/java/vavi/sound/smaf/message/VNMessage.java b/src/main/java/vavi/sound/smaf/message/VNMessage.java index e0c4216..fd6a4bd 100644 --- a/src/main/java/vavi/sound/smaf/message/VNMessage.java +++ b/src/main/java/vavi/sound/smaf/message/VNMessage.java @@ -72,7 +72,7 @@ public int getLength() { * @throws InvalidMidiDataException */ public MidiEvent[] getMidiEvents(MidiContext context) throws InvalidMidiDataException { - byte[] data = null; + byte[] data; try { data = venderName.getBytes("Windows-31J"); } catch (UnsupportedEncodingException e) { 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 3281c10..bd29b33 100644 --- a/src/main/java/vavi/sound/smaf/message/graphics/GeneralPurposeDisplayMessage.java +++ b/src/main/java/vavi/sound/smaf/message/graphics/GeneralPurposeDisplayMessage.java @@ -61,7 +61,7 @@ enum SubBlockType { Rectangle, TextBlock, ImageTile, - BitmapTile; + BitmapTile } //---- diff --git a/src/main/java/vavi/sound/smaf/sequencer/MachineDependentSequencer.java b/src/main/java/vavi/sound/smaf/sequencer/MachineDependentSequencer.java index 9eb36a7..e8223e0 100644 --- a/src/main/java/vavi/sound/smaf/sequencer/MachineDependentSequencer.java +++ b/src/main/java/vavi/sound/smaf/sequencer/MachineDependentSequencer.java @@ -18,7 +18,7 @@ public interface MachineDependentSequencer { /** for {@link MachineDependentSequencer} */ - static final int META_FUNCTION_ID_MACHINE_DEPEND = 0x01; + int META_FUNCTION_ID_MACHINE_DEPEND = 0x01; /** */ void sequence() diff --git a/src/main/java/vavi/sound/smaf/sequencer/WaveSequencer.java b/src/main/java/vavi/sound/smaf/sequencer/WaveSequencer.java index ebbe910..08b57c2 100644 --- a/src/main/java/vavi/sound/smaf/sequencer/WaveSequencer.java +++ b/src/main/java/vavi/sound/smaf/sequencer/WaveSequencer.java @@ -24,7 +24,7 @@ public interface WaveSequencer { /** for {@link WaveSequencer} */ - final int META_FUNCTION_ID_SMAF = 0x03; + int META_FUNCTION_ID_SMAF = 0x03; /** */ void sequence() throws InvalidSmafDataException; diff --git a/src/main/java/vavi/util/SplitRadixFft.java b/src/main/java/vavi/util/SplitRadixFft.java index 871cb2e..da0ad96 100644 --- a/src/main/java/vavi/util/SplitRadixFft.java +++ b/src/main/java/vavi/util/SplitRadixFft.java @@ -689,7 +689,7 @@ public static void makect(int nc, int[] ip, double[] c, int cP) { /** * 2nd */ - private static final void bitrv2(int n, int[] ip, int ipP, double[] a) { + private static void bitrv2(int n, int[] ip, int ipP, double[] a) { int j, j1, k, k1, l, m, m2; double xr, xi, yr, yi; @@ -790,7 +790,7 @@ private static final void bitrv2(int n, int[] ip, int ipP, double[] a) { /** * 2nd */ - private static final void bitrv2conj(int n, int[] ip, int ipP, double[] a) { + private static void bitrv2conj(int n, int[] ip, int ipP, double[] a) { int j, j1, k, k1, l, m, m2; double xr, xi, yr, yi; @@ -1117,7 +1117,7 @@ private static void cft1st(int n, double[] a, double[] w) { } /** */ - private static final void cftmdl(int n, int l, double[] a, double[] w) { + private static void cftmdl(int n, int l, double[] a, double[] w) { int j, j1, j2, j3, k, k1, k2, m, m2; double wk1r, wk1i, wk2r, wk2i, wk3r, wk3i; double x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i; diff --git a/src/test/java/PlayMFi.java b/src/test/java/PlayMFi.java index 0854ec7..4a2618e 100644 --- a/src/test/java/PlayMFi.java +++ b/src/test/java/PlayMFi.java @@ -30,7 +30,7 @@ public class PlayMFi { * @param args mfi files ... */ public static void main(String[] args) throws Exception { - final Sequencer sequencer = MfiSystem.getSequencer(); + Sequencer sequencer = MfiSystem.getSequencer(); sequencer.open(); Synthesizer synthesizer = (Synthesizer) sequencer; // sf diff --git a/src/test/java/PlayPCM.java b/src/test/java/PlayPCM.java index 991e46b..29a3ea1 100644 --- a/src/test/java/PlayPCM.java +++ b/src/test/java/PlayPCM.java @@ -79,7 +79,7 @@ void play(File file, int sampleRate, ByteOrder byteOrder) throws Exception { volume(line, .2d); line.start(); byte[] buf = new byte[line.getBufferSize()]; - int l = 0; + int l; while (is.available() > 0) { l = is.read(buf, 0, buf.length); line.write(buf, 0, l); diff --git a/src/test/java/PlayPCM2.java b/src/test/java/PlayPCM2.java index fd8d406..434e6f8 100644 --- a/src/test/java/PlayPCM2.java +++ b/src/test/java/PlayPCM2.java @@ -75,7 +75,7 @@ void play(File file, int sampleRate, ByteOrder byteOrder) throws Exception { volume(line, .2d); line.start(); byte[] buf = new byte[line.getBufferSize()]; - int l = 0; + int l; while (is.available() > 0) { l = is.read(buf, 0, buf.length); line.write(buf, 0, l); diff --git a/src/test/java/PlaySMAF.java b/src/test/java/PlaySMAF.java index 5c6e122..1470edf 100644 --- a/src/test/java/PlaySMAF.java +++ b/src/test/java/PlaySMAF.java @@ -30,7 +30,7 @@ public class PlaySMAF { * @param args smaf files ... */ public static void main(String[] args) throws Exception { - final Sequencer sequencer = SmafSystem.getSequencer(); + Sequencer sequencer = SmafSystem.getSequencer(); sequencer.open(); Synthesizer synthesizer = (Synthesizer) sequencer; diff --git a/src/test/java/vavi/io/InputEngineOutputStreamTest.java b/src/test/java/vavi/io/InputEngineOutputStreamTest.java index afe9701..617fb91 100644 --- a/src/test/java/vavi/io/InputEngineOutputStreamTest.java +++ b/src/test/java/vavi/io/InputEngineOutputStreamTest.java @@ -7,8 +7,6 @@ package vavi.io; import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -46,12 +44,8 @@ static void setup() throws IOException { @Test public void test1() throws Exception { // - InputStream is = new OutputEngineInputStream(new IOStreamOutputEngine(getClass().getResourceAsStream(inFile), new IOStreamOutputEngine.OutputStreamFactory() { - public OutputStream getOutputStream(OutputStream out) throws IOException { - return new Rot13.OutputStream(out); - } - })); - OutputStream os = new FileOutputStream(out1File); + InputStream is = new OutputEngineInputStream(new IOStreamOutputEngine(getClass().getResourceAsStream(inFile), out -> new Rot13.OutputStream(out))); + OutputStream os = Files.newOutputStream(Paths.get(out1File)); byte[] buffer = new byte[8192]; while (true) { int amount = is.read(buffer); @@ -65,12 +59,8 @@ public OutputStream getOutputStream(OutputStream out) throws IOException { os.close(); // - is = new FileInputStream(out1File); - os = new InputEngineOutputStream(new IOStreamInputEngine(new FileOutputStream(out2File), new IOStreamInputEngine.InputStreamFactory() { - public InputStream getInputStream(InputStream in) throws IOException { - return new Rot13.InputStream(in); - } - })); + is = Files.newInputStream(Paths.get(out1File)); + os = new InputEngineOutputStream(new IOStreamInputEngine(Files.newOutputStream(Paths.get(out2File)), in -> new Rot13.InputStream(in))); buffer = new byte[8192]; while (true) { int amount = is.read(buffer); diff --git a/src/test/java/vavi/sound/adpcm/ccitt/Encoder.java b/src/test/java/vavi/sound/adpcm/ccitt/Encoder.java index 24cf1ff..a193360 100644 --- a/src/test/java/vavi/sound/adpcm/ccitt/Encoder.java +++ b/src/test/java/vavi/sound/adpcm/ccitt/Encoder.java @@ -109,7 +109,7 @@ public static void main(String[] args) throws Exception { while (is.available() > 0) { int pcm1 = is.read(); int pcm2 = is.read(); - int pcm = 0; + int pcm; if (ByteOrder.BIG_ENDIAN.equals(byteOrder)) { pcm = (pcm1 << 8) | pcm2; } else { diff --git a/src/test/java/vavi/sound/mfi/vavi/VaviMfiFileWriterTest.java b/src/test/java/vavi/sound/mfi/vavi/VaviMfiFileWriterTest.java index e3e42df..4f67517 100644 --- a/src/test/java/vavi/sound/mfi/vavi/VaviMfiFileWriterTest.java +++ b/src/test/java/vavi/sound/mfi/vavi/VaviMfiFileWriterTest.java @@ -86,19 +86,19 @@ public void test1() throws Exception { MfiMessage message; message = new CuePointMessage(0x00, 0x00); - track.add(new MfiEvent(message, 0l)); + track.add(new MfiEvent(message, 0L)); double aDelta = (60d / 120d) / 120d * 1000; int delta = (int) Math.round(time / aDelta); Debug.println("delta: " + delta); message = new TempoMessage(0x00, 0xff, 0xcb, 0x78); - track.add(new MfiEvent(message, 0l)); + track.add(new MfiEvent(message, 0L)); d505i(track, data.getWave(), samplingRate, delta); message = new EndOfTrackMessage(0, 0); - track.add(new MfiEvent(message, 0l)); + track.add(new MfiEvent(message, 0L)); int r = MfiSystem.write(sequence, VaviMfiFileFormat.FILE_TYPE, diff --git a/src/test/java/vavi/sound/mfi/vavi/VaviMidiConverterTest.java b/src/test/java/vavi/sound/mfi/vavi/VaviMidiConverterTest.java index 77ce447..25ce599 100644 --- a/src/test/java/vavi/sound/mfi/vavi/VaviMidiConverterTest.java +++ b/src/test/java/vavi/sound/mfi/vavi/VaviMidiConverterTest.java @@ -93,7 +93,7 @@ public static void main(String[] args) throws Exception { if (play) { midiSequencer.start(); while (midiSequencer.isRunning()) { - try { Thread.sleep(100); } catch (Exception e) {} + try { Thread.sleep(100); } catch (Exception ignored) {} } midiSequencer.stop(); } @@ -101,13 +101,13 @@ public static void main(String[] args) throws Exception { midiSequencer.close(); if (convert) { - int ts[] = MidiSystem.getMidiFileTypes(midiSequence); Debug.println("types: " + ts.length); + int[] ts = MidiSystem.getMidiFileTypes(midiSequence); if (ts.length == 0) { throw new IllegalArgumentException("no support type"); } - for (int i = 0; i < ts.length; i++) { Debug.printf("type: 0x%02x\n", ts[i]); + for (int t : ts) { } file = new File(args[2]); diff --git a/src/test/java/vavi/sound/mfi/vavi/sequencer/MachineDependentSequencerTest.java b/src/test/java/vavi/sound/mfi/vavi/sequencer/MachineDependentSequencerTest.java index 2ca400b..1f18ce7 100644 --- a/src/test/java/vavi/sound/mfi/vavi/sequencer/MachineDependentSequencerTest.java +++ b/src/test/java/vavi/sound/mfi/vavi/sequencer/MachineDependentSequencerTest.java @@ -30,22 +30,22 @@ public void test() { MachineDependentSequencer mds = machineDependentSequencerFactory.get(97); Debug.println(mds); - assertTrue(vavi.sound.mfi.vavi.mitsubishi.MitsubishiSequencer.class.isInstance(mds)); + assertTrue(mds instanceof vavi.sound.mfi.vavi.mitsubishi.MitsubishiSequencer); mds = machineDependentSequencerFactory.get(17); - assertTrue(vavi.sound.mfi.vavi.nec.NecSequencer.class.isInstance(mds)); + assertTrue(mds instanceof vavi.sound.mfi.vavi.nec.NecSequencer); mds = machineDependentSequencerFactory.get(33); - assertTrue(vavi.sound.mfi.vavi.fujitsu.FujitsuSequencer.class.isInstance(mds)); + assertTrue(mds instanceof vavi.sound.mfi.vavi.fujitsu.FujitsuSequencer); mds = machineDependentSequencerFactory.get(49); - assertTrue(vavi.sound.mfi.vavi.sony.SonySequencer.class.isInstance(mds)); + assertTrue(mds instanceof vavi.sound.mfi.vavi.sony.SonySequencer); mds = machineDependentSequencerFactory.get(65); - assertTrue(vavi.sound.mfi.vavi.panasonic.PanasonicSequencer.class.isInstance(mds)); + assertTrue(mds instanceof vavi.sound.mfi.vavi.panasonic.PanasonicSequencer); mds = machineDependentSequencerFactory.get(113); - assertTrue(vavi.sound.mfi.vavi.sharp.SharpSequencer.class.isInstance(mds)); + assertTrue(mds instanceof vavi.sound.mfi.vavi.sharp.SharpSequencer); } } diff --git a/src/test/java/vavi/sound/midi/mfi/MfiMidiFileReaderTest.java b/src/test/java/vavi/sound/midi/mfi/MfiMidiFileReaderTest.java index 27ae848..830008f 100644 --- a/src/test/java/vavi/sound/midi/mfi/MfiMidiFileReaderTest.java +++ b/src/test/java/vavi/sound/midi/mfi/MfiMidiFileReaderTest.java @@ -38,12 +38,10 @@ public void test() throws Exception { Sequence sequence = MidiSystem.getSequence(is); Debug.println(sequence); sequencer.setSequence(sequence); - sequencer.addMetaEventListener(new MetaEventListener() { - public void meta(MetaMessage meta) { + sequencer.addMetaEventListener(meta -> { Debug.println(meta.getType()); - if (meta.getType() == 47) { - cdl.countDown(); - } + if (meta.getType() == 47) { + cdl.countDown(); } }); sequencer.start(); diff --git a/src/test/java/vavi/sound/mobile/BasicAudioEngineTest.java b/src/test/java/vavi/sound/mobile/BasicAudioEngineTest.java index c758bec..c41e5ab 100644 --- a/src/test/java/vavi/sound/mobile/BasicAudioEngineTest.java +++ b/src/test/java/vavi/sound/mobile/BasicAudioEngineTest.java @@ -97,7 +97,7 @@ public void close() throws IOException { /** */ void debug1(byte[] adpcm) { try { - OutputStream os = null; + OutputStream os; if (fileName != null) { Debug.println("★★★★★★★★ adpcm out to file: " + fileName); os = new BufferedOutputStream(new FileOutputStream(fileName, true)); diff --git a/src/test/java/vavi/sound/sampled/adpcm/ccitt/G721AudioFileReaderTest.java b/src/test/java/vavi/sound/sampled/adpcm/ccitt/G721AudioFileReaderTest.java index 60c3326..d7c57a1 100644 --- a/src/test/java/vavi/sound/sampled/adpcm/ccitt/G721AudioFileReaderTest.java +++ b/src/test/java/vavi/sound/sampled/adpcm/ccitt/G721AudioFileReaderTest.java @@ -84,7 +84,7 @@ public void test1() throws Exception { line.open(outFormat); line.start(); byte[] buf = new byte[1024]; - int l = 0; + int l; volume(line, .2d); while (oais.available() > 0) { From 4b019b25fcde249f9178b7560b5316263b581981 Mon Sep 17 00:00:00 2001 From: Naohide Sano Date: Tue, 13 Dec 2022 19:01:01 +0900 Subject: [PATCH 6/7] fix logging level --- src/main/java/vavi/sound/adpcm/ima/Ima.java | 4 ++- .../vavi/sound/adpcm/ima/ImaInputEngine.java | 3 ++- src/main/java/vavi/sound/adpcm/ms/Ms.java | 4 ++- .../vavi/sound/adpcm/ms/MsInputEngine.java | 3 ++- .../vavi/sound/adpcm/ms/MsInputStream.java | 5 ++-- .../vavi/sound/adpcm/oki/OkiInputStream.java | 3 ++- .../sound/mfi/vavi/VaviMidiConverter.java | 4 +-- .../vavi/sound/mfi/vavi/VaviNoteMessage.java | 2 +- .../mfi/vavi/audio/CommonAudioMessage.java | 5 ++-- .../mfi/vavi/audio/FuetrekAudioMessage.java | 10 +++++--- .../mfi/vavi/audio/RohmAudioMessage.java | 4 ++- .../mfi/vavi/audio/YamahaAudioMessage.java | 4 ++- .../mfi/vavi/track/ChannelChangeMessage.java | 3 ++- .../track/ChannelConfigurationMessage.java | 3 ++- .../mfi/vavi/track/ExtendedEditMessage.java | 4 ++- .../mfi/vavi/track/LoopPointMessage.java | 3 ++- .../sound/mfi/vavi/track/Nop2Message.java | 5 ++-- src/main/java/vavi/sound/midi/MidiUtil.java | 2 +- .../sound/midi/mfi/MfiMidiFileWriter.java | 15 +++++------ .../sound/midi/smaf/SmafMidiFileWriter.java | 6 ++--- .../sound/sampled/MonauralInputFilter.java | 5 ++-- .../sampled/Pcm16BitMonauralWaveDivider.java | 21 ++++++++-------- .../sampled/SimpleResamplingInputFilter.java | 7 +++--- .../sampled/TemporaryFiledInputFilter.java | 3 ++- .../java/vavi/sound/sampled/WaveDivider.java | 3 ++- .../sampled/mfi/DividedMfiWithVoiceMaker.java | 5 ++-- .../sound/sampled/mfi/MfiWithVoiceMaker.java | 3 ++- .../smaf/DividedSmafWithVoiceMaker.java | 4 +-- .../sampled/smaf/SmafWithVoiceMaker.java | 19 +++++++------- .../vavi/sound/smaf/MetaEventAdapter.java | 4 +-- .../vavi/sound/smaf/SmafMidiConverter.java | 10 ++++---- .../java/vavi/sound/smaf/SmafSequence.java | 3 ++- .../smaf/chunk/AudioSequenceDataChunk.java | 5 ++-- .../vavi/sound/smaf/chunk/BitmapChunk.java | 3 ++- .../DisplayParameterDefinitionChunk.java | 5 ++-- .../java/vavi/sound/smaf/chunk/FileChunk.java | 6 ++--- .../smaf/chunk/GraphicsSetupDataChunk.java | 2 +- .../sound/smaf/chunk/GraphicsTrackChunk.java | 2 +- .../chunk/GraphicsTrackSequenceDataChunk.java | 9 ++++--- .../chunk/HuffmanDecodingInputStream.java | 11 ++++---- .../vavi/sound/smaf/chunk/ImageChunk.java | 5 ++-- .../vavi/sound/smaf/chunk/ImageDataChunk.java | 4 +-- .../java/vavi/sound/smaf/chunk/LinkChunk.java | 3 ++- .../sound/smaf/chunk/MasterTrackChunk.java | 4 +-- .../chunk/MasterTrackSequenceDataChunk.java | 3 ++- .../sound/smaf/chunk/OptionalDataChunk.java | 3 ++- .../sound/smaf/chunk/PcmAudioTrackChunk.java | 12 ++++----- .../sound/smaf/chunk/ScoreTrackChunk.java | 10 ++++---- .../smaf/chunk/SeekAndPhraseInfoChunk.java | 5 ++-- .../sound/smaf/chunk/SequenceDataChunk.java | 6 ++--- .../vavi/sound/smaf/chunk/SetupDataChunk.java | 4 +-- .../sound/smaf/chunk/StreamPcmDataChunk.java | 2 +- .../sound/smaf/chunk/StreamWaveDataChunk.java | 3 ++- .../vavi/sound/smaf/chunk/WaveDataChunk.java | 3 ++- .../java/vavi/sound/smaf/chunk/WaveType.java | 7 +++--- .../sound/smaf/message/BankSelectMessage.java | 5 ++-- .../smaf/message/EndOfSequenceMessage.java | 3 ++- .../vavi/sound/smaf/message/MidiContext.java | 25 ++++++++++--------- .../vavi/sound/smaf/message/NoteMessage.java | 6 ++--- .../vavi/sound/smaf/message/SmafContext.java | 16 ++++++------ .../vavi/sound/smaf/message/TrackMessage.java | 3 ++- .../sound/smaf/message/VolumeMessage.java | 5 ++-- .../sound/smaf/message/WaveDataMessage.java | 3 ++- .../vavi/sound/smaf/message/WaveMessage.java | 3 ++- .../smaf/message/yamaha/YamahaMessage.java | 4 +-- src/test/java/SoundFontTest.java | 7 +++--- .../adpcm/ccitt/G721InputStreamTest.java | 3 ++- .../adpcm/ccitt/G721OutputStreamTest.java | 3 ++- .../sound/adpcm/dvi/DviInputStreamTest.java | 3 ++- .../sound/adpcm/dvi/DviOutputStreamTest.java | 4 +-- .../sound/adpcm/ima/ImaInputStreamTest.java | 9 ++++--- .../sound/adpcm/ima/ImaOutputStreamTest.java | 11 ++++---- .../sound/adpcm/ma/MaInputStreamTest.java | 7 +++--- .../sound/adpcm/ma/MaOutputStreamTest.java | 3 ++- .../sound/adpcm/ms/MsInputStreamTest.java | 15 ++++++----- .../sound/adpcm/ms/MsOutputStreamTest.java | 13 +++++----- .../sound/adpcm/oki/OkiInputStreamTest.java | 3 ++- .../sound/adpcm/oki/OkiOutputStreamTest.java | 3 ++- .../sound/adpcm/rohm/RohmInputStreamTest.java | 3 ++- .../adpcm/rohm/RohmOutputStreamTest.java | 3 ++- .../sound/adpcm/vox/VoxInputStreamTest.java | 3 ++- .../sound/adpcm/vox/VoxOutputStreamTest.java | 3 ++- .../adpcm/yamaha/YamahaInputStreamTest.java | 7 +++--- .../adpcm/yamaha/YamahaOutputStreamTest.java | 3 ++- .../adpcm/ym2608/Ym2608InputStreamTest.java | 3 ++- .../adpcm/ym2608/Ym2608OutputStreamTest.java | 3 ++- .../java/vavi/sound/mfi/MfiSystemTest.java | 9 ++++--- .../vavi/sound/mfi/vavi/MfiContextTest.java | 13 +++++----- .../sound/mfi/vavi/VaviMfiFileWriterTest.java | 13 +++++----- .../sound/mfi/vavi/VaviMidiConverterTest.java | 19 +++++++------- .../java/vavi/sound/midi/MidiUtilTest.java | 5 ++-- .../adpcm/ccitt/G721AudioFileReaderTest.java | 3 ++- .../adpcm/rhom/RohmAudioFileReaderTest.java | 3 ++- .../adpcm/vox/VoxAudioFileReaderTest.java | 3 ++- .../sound/smaf/message/SmafContextTest.java | 5 ++-- src/test/resources/logging.properties | 14 +++-------- 96 files changed, 318 insertions(+), 250 deletions(-) diff --git a/src/main/java/vavi/sound/adpcm/ima/Ima.java b/src/main/java/vavi/sound/adpcm/ima/Ima.java index c0c0c21..9281c73 100644 --- a/src/main/java/vavi/sound/adpcm/ima/Ima.java +++ b/src/main/java/vavi/sound/adpcm/ima/Ima.java @@ -18,6 +18,8 @@ package vavi.sound.adpcm.ima; +import java.util.logging.Level; + import vavi.util.Debug; @@ -104,7 +106,7 @@ private void decode(int channel, } int state = inBuffer[ip + 2] & 0xff; if (state > ISSTMAX) { -Debug.println("IMA_ADPCM block ch" + channel + " initial-state (" + state + ") out of range"); +Debug.println(Level.FINE, "IMA_ADPCM block ch" + channel + " initial-state (" + state + ") out of range"); state = 0; } // specs say to ignore ip[3] , but write it as 0 diff --git a/src/main/java/vavi/sound/adpcm/ima/ImaInputEngine.java b/src/main/java/vavi/sound/adpcm/ima/ImaInputEngine.java index 6c7d6d1..3d67527 100644 --- a/src/main/java/vavi/sound/adpcm/ima/ImaInputEngine.java +++ b/src/main/java/vavi/sound/adpcm/ima/ImaInputEngine.java @@ -11,6 +11,7 @@ import java.io.InputStream; import java.io.OutputStream; import java.nio.ByteOrder; +import java.util.logging.Level; import vavi.io.InputEngine; import vavi.io.LittleEndianDataInputStream; @@ -46,7 +47,7 @@ public ImaInputEngine(OutputStream out, this.samplesPerBlock = samplesPerBlock; this.channels = channels; this.byteOrder = byteOrder; -Debug.println("byteOrder: " + this.byteOrder); +Debug.println(Level.FINE, "byteOrder: " + this.byteOrder); } /* */ diff --git a/src/main/java/vavi/sound/adpcm/ms/Ms.java b/src/main/java/vavi/sound/adpcm/ms/Ms.java index 4c3e386..2f3a623 100644 --- a/src/main/java/vavi/sound/adpcm/ms/Ms.java +++ b/src/main/java/vavi/sound/adpcm/ms/Ms.java @@ -18,6 +18,8 @@ package vavi.sound.adpcm.ms; +import java.util.logging.Level; + import vavi.util.Debug; @@ -133,7 +135,7 @@ public void decodeBlock(int channels, for (int channel = 0; channel < channels; channel++) { int bpred = inBuffer[ip++] & 0xff; if (bpred >= nCoef) { -Debug.println("MSADPCM bpred >= nCoef, arbitrarily using 0"); +Debug.println(Level.FINE, "MSADPCM bpred >= nCoef, arbitrarily using 0"); bpred = 0; } state[channel] = new State(); diff --git a/src/main/java/vavi/sound/adpcm/ms/MsInputEngine.java b/src/main/java/vavi/sound/adpcm/ms/MsInputEngine.java index b44c06c..9cc2b26 100644 --- a/src/main/java/vavi/sound/adpcm/ms/MsInputEngine.java +++ b/src/main/java/vavi/sound/adpcm/ms/MsInputEngine.java @@ -11,6 +11,7 @@ import java.io.InputStream; import java.io.OutputStream; import java.nio.ByteOrder; +import java.util.logging.Level; import vavi.io.InputEngine; import vavi.io.LittleEndianDataInputStream; @@ -46,7 +47,7 @@ public MsInputEngine(OutputStream out, this.samplesPerBlock = samplesPerBlock; this.channels = channels; this.byteOrder = byteOrder; -Debug.println("byteOrder: " + this.byteOrder); +Debug.println(Level.FINE, "byteOrder: " + this.byteOrder); } /* */ diff --git a/src/main/java/vavi/sound/adpcm/ms/MsInputStream.java b/src/main/java/vavi/sound/adpcm/ms/MsInputStream.java index 54ea3da..f8ed36b 100644 --- a/src/main/java/vavi/sound/adpcm/ms/MsInputStream.java +++ b/src/main/java/vavi/sound/adpcm/ms/MsInputStream.java @@ -10,6 +10,7 @@ import java.io.IOException; import java.io.InputStream; import java.nio.ByteOrder; +import java.util.logging.Level; import vavi.io.OutputEngineInputStream; import vavi.util.Debug; @@ -60,9 +61,9 @@ public MsInputStream(InputStream in, channels, blockSize, samplesPerBlock); -Debug.println("numSamples: " + numSamples); +Debug.println(Level.FINE, "numSamples: " + numSamples); this.available = numSamples * channels * bytesPerSample; -Debug.println("available: " + available); +Debug.println(Level.FINE, "available: " + available); } /** */ diff --git a/src/main/java/vavi/sound/adpcm/oki/OkiInputStream.java b/src/main/java/vavi/sound/adpcm/oki/OkiInputStream.java index e03ef92..c9bdf0f 100644 --- a/src/main/java/vavi/sound/adpcm/oki/OkiInputStream.java +++ b/src/main/java/vavi/sound/adpcm/oki/OkiInputStream.java @@ -8,6 +8,7 @@ import java.io.InputStream; import java.nio.ByteOrder; +import java.util.logging.Level; import vavi.sound.adpcm.AdpcmInputStream; import vavi.sound.adpcm.Codec; @@ -33,7 +34,7 @@ protected Codec getCodec() { */ public OkiInputStream(InputStream in, ByteOrder byteOrder) { super(in, byteOrder, 4, ByteOrder.LITTLE_ENDIAN); // oki adpcm は little endian 固定 -Debug.println(this.in); +Debug.println(Level.FINE, this.in); } } diff --git a/src/main/java/vavi/sound/mfi/vavi/VaviMidiConverter.java b/src/main/java/vavi/sound/mfi/vavi/VaviMidiConverter.java index 6d95cee..63c81ae 100644 --- a/src/main/java/vavi/sound/mfi/vavi/VaviMidiConverter.java +++ b/src/main/java/vavi/sound/mfi/vavi/VaviMidiConverter.java @@ -139,7 +139,7 @@ protected vavi.sound.mfi.Sequence convert(Sequence midiSequence, int fileType) for (int j = maxTracks; j <= mfiTrackNumber; j++) { mfiSequence.createTrack(); -Debug.println(">>>> create MFi track: " + j); +Debug.println(Level.FINE, ">>>> create MFi track: " + j); mfiTracks = mfiSequence.getTracks(); maxTracks = mfiTracks.length; } @@ -300,7 +300,7 @@ protected Sequence convert(vavi.sound.mfi.Sequence mfiSequence) MidiContext midiContext = new MidiContext(); int resolution = midiContext.getResolution(mfiTracks); -Debug.println("resolution: " + resolution); +Debug.println(Level.FINE, "resolution: " + resolution); Sequence midiSequence = new MfiVaviSequence(Sequence.PPQ, resolution, 1); javax.sound.midi.Track midiTrack = midiSequence.getTracks()[0]; diff --git a/src/main/java/vavi/sound/mfi/vavi/VaviNoteMessage.java b/src/main/java/vavi/sound/mfi/vavi/VaviNoteMessage.java index bcb9035..3bb6303 100644 --- a/src/main/java/vavi/sound/mfi/vavi/VaviNoteMessage.java +++ b/src/main/java/vavi/sound/mfi/vavi/VaviNoteMessage.java @@ -158,7 +158,7 @@ public MfiEvent[] getMfiEvents(MidiEvent midiEvent, MfiContext context) mfiMessage.setGateTime(i == onLength - 1 ? length % 255 : 255); mfiMessage.setVelocity(data2 / 2); if (length >= 255) { - Debug.println(channel + "ch, " + mfiMessage.getNote() + ", " + mfiMessage.getDelta() + ":[" + i + "]:" + (i == onLength - 1 ? length % 255 : 255) + "/" + length); + Debug.println(Level.INFO, channel + "ch, " + mfiMessage.getNote() + ", " + mfiMessage.getDelta() + ":[" + i + "]:" + (i == onLength - 1 ? length % 255 : 255) + "/" + length); } //Debug.println(channel + ", " + mfiMessage.getVoice() + ", " + ((mfiMessage.getMessage()[1] & 0xc0) >> 6)); mfiEvents[i] = new MfiEvent(mfiMessage, 0L); // TODO 0l diff --git a/src/main/java/vavi/sound/mfi/vavi/audio/CommonAudioMessage.java b/src/main/java/vavi/sound/mfi/vavi/audio/CommonAudioMessage.java index e0f498a..b97227e 100644 --- a/src/main/java/vavi/sound/mfi/vavi/audio/CommonAudioMessage.java +++ b/src/main/java/vavi/sound/mfi/vavi/audio/CommonAudioMessage.java @@ -8,6 +8,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.logging.Level; import vavi.sound.mfi.MfiEvent; import vavi.sound.mfi.MfiMessage; @@ -95,7 +96,7 @@ public static MfiEvent getTempoEvent() { /** */ private static int getDelta(float time) { float aDelta = (60f / tempoMessage.getTempo()) / tempoMessage.getTimeBase(); -Debug.println("a delta: " + aDelta + ", tempo: " + tempoMessage.getTempo() + ", " + tempoMessage.getTimeBase()); +Debug.println(Level.FINE, "a delta: " + aDelta + ", tempo: " + tempoMessage.getTempo() + ", " + tempoMessage.getTimeBase()); return Math.round(time / aDelta); } @@ -104,7 +105,7 @@ public static List getNop2Events(float time) { List events = new ArrayList<>(); int delta = getDelta(time); -Debug.println("delta: " + delta); +Debug.println(Level.FINE, "delta: " + delta); for (int i = 0; i < delta / Nop2Message.maxDelta; i++) { events.add(new MfiEvent(new Nop2Message(0xff, 0xff), 0L)); } diff --git a/src/main/java/vavi/sound/mfi/vavi/audio/FuetrekAudioMessage.java b/src/main/java/vavi/sound/mfi/vavi/audio/FuetrekAudioMessage.java index 880297b..ed8e115 100644 --- a/src/main/java/vavi/sound/mfi/vavi/audio/FuetrekAudioMessage.java +++ b/src/main/java/vavi/sound/mfi/vavi/audio/FuetrekAudioMessage.java @@ -6,6 +6,8 @@ package vavi.sound.mfi.vavi.audio; +import java.util.logging.Level; + import vavi.sound.mfi.MfiEvent; import vavi.sound.mfi.MfiMessage; import vavi.sound.mfi.vavi.track.CuePointMessage; @@ -61,7 +63,7 @@ private static TempoMessage getTempoMessage(float time, int sampleRate) { float aDelta; TempoMessage message; while (true) { -Debug.printf("tempo: %d, timeBase: 0x02x\n", baseTempo, baseTimeBase); +Debug.printf(Level.FINE, "tempo: %d, timeBase: 0x02x\n", baseTempo, baseTimeBase); message = new TempoMessage(0x00, 0xff, baseTimeBase, baseTempo); aDelta = (60f / message.getTempo()) / message.getTimeBase(); if (Math.round(time / aDelta) > 255) { @@ -74,7 +76,7 @@ private static TempoMessage getTempoMessage(float time, int sampleRate) { if ((baseTempo / 2) > 0) { baseTempo /= 2; } else { -Debug.println("over limit"); +Debug.println(Level.INFO, "over limit"); break; } } @@ -90,7 +92,7 @@ private static TempoMessage getTempoMessage(float time, int sampleRate) { public static int getDelta(float time, int sampleRate) { TempoMessage message = getTempoMessage(time, sampleRate); float aDelta = (60f / message.getTempo()) / message.getTimeBase(); -Debug.println("a delta: " + aDelta + ", tempo: " + message.getTempo() + ", " + message.getTimeBase()); +Debug.println(Level.FINE, "a delta: " + aDelta + ", tempo: " + message.getTempo() + ", " + message.getTimeBase()); return Math.round(time / aDelta); } @@ -107,7 +109,7 @@ public static MfiEvent getTempoEvent() { /** older version */ public static int getDelta(float time) { float aDelta = (60f / tempoMessageOld.getTempo()) / tempoMessageOld.getTimeBase(); -Debug.println("a delta: " + aDelta + ", tempo: " + tempoMessageOld.getTempo() + ", " + tempoMessageOld.getTimeBase()); +Debug.println(Level.FINE, "a delta: " + aDelta + ", tempo: " + tempoMessageOld.getTempo() + ", " + tempoMessageOld.getTimeBase()); return Math.round(time / aDelta); } } diff --git a/src/main/java/vavi/sound/mfi/vavi/audio/RohmAudioMessage.java b/src/main/java/vavi/sound/mfi/vavi/audio/RohmAudioMessage.java index 97df9eb..b9fa86f 100644 --- a/src/main/java/vavi/sound/mfi/vavi/audio/RohmAudioMessage.java +++ b/src/main/java/vavi/sound/mfi/vavi/audio/RohmAudioMessage.java @@ -6,6 +6,8 @@ package vavi.sound.mfi.vavi.audio; +import java.util.logging.Level; + import vavi.sound.mfi.MfiEvent; import vavi.sound.mfi.MfiMessage; import vavi.sound.mfi.vavi.track.MachineDependentMessage; @@ -49,7 +51,7 @@ public static MfiEvent getTempoEvent() { /** */ public static int getDelta(float time) { float aDelta = (60f / tempoMessage.getTempo()) / tempoMessage.getTimeBase(); -Debug.println("a delta: " + aDelta + ", tempo: " + tempoMessage.getTempo() + ", " + tempoMessage.getTimeBase()); +Debug.println(Level.FINE, "a delta: " + aDelta + ", tempo: " + tempoMessage.getTempo() + ", " + tempoMessage.getTimeBase()); return Math.round(time / aDelta); } } diff --git a/src/main/java/vavi/sound/mfi/vavi/audio/YamahaAudioMessage.java b/src/main/java/vavi/sound/mfi/vavi/audio/YamahaAudioMessage.java index 958b245..2e101ff 100644 --- a/src/main/java/vavi/sound/mfi/vavi/audio/YamahaAudioMessage.java +++ b/src/main/java/vavi/sound/mfi/vavi/audio/YamahaAudioMessage.java @@ -6,6 +6,8 @@ package vavi.sound.mfi.vavi.audio; +import java.util.logging.Level; + import vavi.sound.mfi.MfiEvent; import vavi.sound.mfi.MfiMessage; import vavi.sound.mfi.vavi.track.MachineDependentMessage; @@ -49,7 +51,7 @@ public static MfiEvent getTempoEvent() { /** */ public static int getDelta(float time) { float aDelta = (60f / tempoMessage.getTempo()) / tempoMessage.getTimeBase(); -Debug.println("a delta: " + aDelta + ", tempo: " + tempoMessage.getTempo() + ", " + tempoMessage.getTimeBase()); +Debug.println(Level.FINE, "a delta: " + aDelta + ", tempo: " + tempoMessage.getTempo() + ", " + tempoMessage.getTimeBase()); return Math.round(time / aDelta); } } 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 3123dc8..93a9c98 100644 --- a/src/main/java/vavi/sound/mfi/vavi/track/ChannelChangeMessage.java +++ b/src/main/java/vavi/sound/mfi/vavi/track/ChannelChangeMessage.java @@ -6,6 +6,7 @@ package vavi.sound.mfi.vavi.track; +import java.util.logging.Level; import javax.sound.midi.MidiEvent; import vavi.sound.mfi.ChannelMessage; import vavi.sound.mfi.ShortMessage; @@ -83,7 +84,7 @@ public String toString() { /** */ public MidiEvent[] getMidiEvents(MidiContext context) { -Debug.println("ignore: " + this); +Debug.println(Level.INFO, "ignore: " + this); return null; } } diff --git a/src/main/java/vavi/sound/mfi/vavi/track/ChannelConfigurationMessage.java b/src/main/java/vavi/sound/mfi/vavi/track/ChannelConfigurationMessage.java index 2d1c816..085423f 100644 --- a/src/main/java/vavi/sound/mfi/vavi/track/ChannelConfigurationMessage.java +++ b/src/main/java/vavi/sound/mfi/vavi/track/ChannelConfigurationMessage.java @@ -6,6 +6,7 @@ package vavi.sound.mfi.vavi.track; +import java.util.logging.Level; import javax.sound.midi.MidiEvent; import vavi.sound.mfi.ShortMessage; import vavi.sound.mfi.vavi.MidiContext; @@ -74,7 +75,7 @@ public String toString() { * @return 何も返しません */ public MidiEvent[] getMidiEvents(MidiContext context) { -Debug.println(this); +Debug.println(Level.FINE, this); context.setDrum(getChannel(), isDrum() ? MidiContext.ChannelConfiguration.PERCUSSION : MidiContext.ChannelConfiguration.SOUND_SET); diff --git a/src/main/java/vavi/sound/mfi/vavi/track/ExtendedEditMessage.java b/src/main/java/vavi/sound/mfi/vavi/track/ExtendedEditMessage.java index ced1357..16700a1 100644 --- a/src/main/java/vavi/sound/mfi/vavi/track/ExtendedEditMessage.java +++ b/src/main/java/vavi/sound/mfi/vavi/track/ExtendedEditMessage.java @@ -9,6 +9,8 @@ import java.io.DataInputStream; import java.io.InputStream; import java.io.IOException; +import java.util.logging.Level; + import vavi.sound.mfi.InvalidMfiDataException; import vavi.sound.mfi.SysexMessage; import vavi.util.Debug; @@ -47,7 +49,7 @@ public static ExtendedEditMessage readFrom(int delta, int status, int data1, Inp dummy = dis.read(); // 0x01 int part = dis.read(); int zwitch = dis.read(); -Debug.println("dummy " + dummy + ", part " + part + ", switch " + zwitch); +Debug.println(Level.FINE, "dummy " + dummy + ", part " + part + ", switch " + zwitch); throw new InvalidMfiDataException("unsupported: " + 0xf2); } diff --git a/src/main/java/vavi/sound/mfi/vavi/track/LoopPointMessage.java b/src/main/java/vavi/sound/mfi/vavi/track/LoopPointMessage.java index 660d2c5..73c99f5 100644 --- a/src/main/java/vavi/sound/mfi/vavi/track/LoopPointMessage.java +++ b/src/main/java/vavi/sound/mfi/vavi/track/LoopPointMessage.java @@ -6,6 +6,7 @@ package vavi.sound.mfi.vavi.track; +import java.util.logging.Level; import javax.sound.midi.MidiEvent; import vavi.sound.mfi.ShortMessage; import vavi.sound.mfi.vavi.MidiContext; @@ -87,7 +88,7 @@ public String toString() { /** */ public MidiEvent[] getMidiEvents(MidiContext context) { -Debug.println("ignore: " + this); +Debug.println(Level.INFO, "ignore: " + this); return null; } } 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 44a892d..24ae2a1 100644 --- a/src/main/java/vavi/sound/mfi/vavi/track/Nop2Message.java +++ b/src/main/java/vavi/sound/mfi/vavi/track/Nop2Message.java @@ -6,6 +6,7 @@ package vavi.sound.mfi.vavi.track; +import java.util.logging.Level; import javax.sound.midi.MidiEvent; import vavi.sound.mfi.ShortMessage; @@ -42,7 +43,7 @@ public class Nop2Message extends ShortMessage */ public Nop2Message(int delta, int data2) { super(delta, 0xff, 0xdc, data2); -Debug.println("NOP2: delta: " + delta); +Debug.println(Level.FINE, "NOP2: delta: " + delta); } /** @@ -54,7 +55,7 @@ public Nop2Message(int delta, int data2) { */ public Nop2Message(int delta, int status, int data1, int data2) { super(delta, 0xff, 0xdc, data2); -Debug.println("NOP2: delta: " + delta); +Debug.println(Level.FINE, "NOP2: delta: " + delta); } /** */ diff --git a/src/main/java/vavi/sound/midi/MidiUtil.java b/src/main/java/vavi/sound/midi/MidiUtil.java index afa8345..fc85772 100644 --- a/src/main/java/vavi/sound/midi/MidiUtil.java +++ b/src/main/java/vavi/sound/midi/MidiUtil.java @@ -269,7 +269,7 @@ public static byte[] getEncodedMessage(String text, String encoding) { value = props.getProperty("defaultSynthesizer"); if (value != null) { String defaultSynthesizer = value; -Debug.println("defaultSynthesizer: " + defaultSynthesizer); +Debug.println(Level.FINE, "defaultSynthesizer: " + defaultSynthesizer); if (defaultSynthesizer.contains("#")) { String[] pair = defaultSynthesizer.split("#"); synthesizerClassName = pair[0]; diff --git a/src/main/java/vavi/sound/midi/mfi/MfiMidiFileWriter.java b/src/main/java/vavi/sound/midi/mfi/MfiMidiFileWriter.java index aab8e5b..0e19fa8 100644 --- a/src/main/java/vavi/sound/midi/mfi/MfiMidiFileWriter.java +++ b/src/main/java/vavi/sound/midi/mfi/MfiMidiFileWriter.java @@ -8,6 +8,7 @@ import java.io.IOException; import java.io.OutputStream; +import java.util.Arrays; import java.util.logging.Level; import javax.sound.midi.InvalidMidiDataException; @@ -32,21 +33,21 @@ public class MfiMidiFileWriter extends BasicMidiFileWriter { @Override public int[] getMidiFileTypes() { -Debug.println("(1): " + StringUtil.expand(MfiSystem.getMfiFileTypes())); +Debug.println(Level.FINE, "(1): " + Arrays.toString(MfiSystem.getMfiFileTypes())); return MfiSystem.getMfiFileTypes(); } /** @param sequence MIDI sequence */ @Override public int[] getMidiFileTypes(Sequence sequence) { -Debug.println("(2): " + StringUtil.expand(MfiSystem.getMfiFileTypes())); +Debug.println(Level.FINE, "(2): " + Arrays.toString(MfiSystem.getMfiFileTypes())); return MfiSystem.getMfiFileTypes(); } /** @param fileType 0x88:MFi (vavi) をサポートします */ @Override public boolean isFileTypeSupported(int fileType) { -Debug.println("(1): fileType: " + fileType); +Debug.println(Level.FINE, "(1): fileType: " + fileType); return MfiSystem.isFileTypeSupported(fileType); } @@ -56,7 +57,7 @@ public boolean isFileTypeSupported(int fileType) { */ @Override public boolean isFileTypeSupported(int fileType, Sequence sequence) { -Debug.println("(2): fileType: " + fileType); +Debug.println(Level.FINE, "(2): fileType: " + fileType); //Debug.println(sequence); return MfiSystem.isFileTypeSupported(fileType); } @@ -69,9 +70,9 @@ public boolean isFileTypeSupported(int fileType, Sequence sequence) { @Override public int write(Sequence in, int fileType, OutputStream out) throws IOException { -Debug.println("in: " + in); -Debug.println("fileType: " + fileType); -Debug.println("out: " + out); +Debug.println(Level.FINE, "in: " + in); +Debug.println(Level.FINE, "fileType: " + fileType); +Debug.println(Level.FINE, "out: " + out); try { if (isFileTypeSupported(fileType)) { vavi.sound.mfi.Sequence mfiSequence = MfiSystem.toMfiSequence(in, fileType); diff --git a/src/main/java/vavi/sound/midi/smaf/SmafMidiFileWriter.java b/src/main/java/vavi/sound/midi/smaf/SmafMidiFileWriter.java index 4662998..8beddf0 100644 --- a/src/main/java/vavi/sound/midi/smaf/SmafMidiFileWriter.java +++ b/src/main/java/vavi/sound/midi/smaf/SmafMidiFileWriter.java @@ -63,9 +63,9 @@ public boolean isFileTypeSupported(int fileType, Sequence sequence) { @Override public int write(Sequence in, int fileType, OutputStream out) throws IOException { -Debug.println("in: " + in); -Debug.println("fileType: " + fileType); -Debug.println("out: " + out); +Debug.println(Level.FINE, "in: " + in); +Debug.println(Level.FINE, "fileType: " + fileType); +Debug.println(Level.FINE, "out: " + out); try { if (isFileTypeSupported(fileType)) { vavi.sound.smaf.Sequence smafSequence = SmafSystem.toSmafSequence(in, fileType); diff --git a/src/main/java/vavi/sound/sampled/MonauralInputFilter.java b/src/main/java/vavi/sound/sampled/MonauralInputFilter.java index 525e410..5d35a98 100644 --- a/src/main/java/vavi/sound/sampled/MonauralInputFilter.java +++ b/src/main/java/vavi/sound/sampled/MonauralInputFilter.java @@ -7,6 +7,7 @@ package vavi.sound.sampled; import java.io.IOException; +import java.util.logging.Level; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioInputStream; @@ -41,8 +42,8 @@ public AudioInputStream doFilter(AudioInputStream sourceAis) throws IOException, inAudioFormat.getFrameSize(), inAudioFormat.getFrameRate(), inAudioFormat.isBigEndian()); -Debug.println("OUT: " + outAudioFormat); -Debug.println("OK: " + AudioSystem.isConversionSupported(outAudioFormat, inAudioFormat)); +Debug.println(Level.FINE, "OUT: " + outAudioFormat); +Debug.println(Level.FINE, "OK: " + AudioSystem.isConversionSupported(outAudioFormat, inAudioFormat)); return AudioSystem.getAudioInputStream(outAudioFormat, sourceAis); } diff --git a/src/main/java/vavi/sound/sampled/Pcm16BitMonauralWaveDivider.java b/src/main/java/vavi/sound/sampled/Pcm16BitMonauralWaveDivider.java index d3f4fa3..f827c90 100644 --- a/src/main/java/vavi/sound/sampled/Pcm16BitMonauralWaveDivider.java +++ b/src/main/java/vavi/sound/sampled/Pcm16BitMonauralWaveDivider.java @@ -8,6 +8,7 @@ import java.io.EOFException; import java.io.IOException; +import java.util.logging.Level; import javax.sound.sampled.AudioInputStream; @@ -46,25 +47,25 @@ class Pcm16BitMonauralWaveDivider implements WaveDivider { public void divide(float seconds, Event event) throws IOException { int numberChannels = targetAis.getFormat().getChannels(); -Debug.println("numberChannels: " + numberChannels); +Debug.println(Level.FINE, "numberChannels: " + numberChannels); int samplingRate = (int) targetAis.getFormat().getSampleRate(); -Debug.println("samplingRate: " + samplingRate); +Debug.println(Level.FINE, "samplingRate: " + samplingRate); int samplingBytes = targetAis.getFormat().getSampleSizeInBits() / 8; -Debug.println("samplingBytes: " + samplingBytes); +Debug.println(Level.FINE, "samplingBytes: " + samplingBytes); int bytesPerSecond = samplingRate * samplingBytes; -Debug.println("bytesPerSecond: " + bytesPerSecond); -Debug.println("header.bytesPerSecond: " + targetAis.getFormat().getFrameSize() * targetAis.getFormat().getFrameRate()); +Debug.println(Level.FINE, "bytesPerSecond: " + bytesPerSecond); +Debug.println(Level.FINE, "header.bytesPerSecond: " + targetAis.getFormat().getFrameSize() * targetAis.getFormat().getFrameRate()); long totalTime = (long) (targetAis.available() / (targetAis.getFormat().getFrameSize() * targetAis.getFormat().getFrameRate()) * 1000); -Debug.println("totalTime= " + (totalTime / (60 * 1000)) + ":" + ((totalTime % (60 * 1000)) / 1000) + "." + ((totalTime % (60 * 1000)) % 1000)); +Debug.println(Level.FINE, "totalTime= " + (totalTime / (60 * 1000)) + ":" + ((totalTime % (60 * 1000)) / 1000) + "." + ((totalTime % (60 * 1000)) % 1000)); // all channel, per second int blockSize = samplingRate * numberChannels * samplingBytes; -Debug.println("blockSize: " + blockSize); +Debug.println(Level.FINE, "blockSize: " + blockSize); int numberOfChunks = targetAis.available() / (int) (blockSize * seconds); int moduloOfChunks = targetAis.available() % (int) (blockSize * seconds); -Debug.println("numberOfChunks: " + numberOfChunks + ", moduloOfChunks: " + moduloOfChunks); +Debug.println(Level.FINE, "numberOfChunks: " + numberOfChunks + ", moduloOfChunks: " + moduloOfChunks); for (int i = 0; i < numberOfChunks; i++) { byte[] buffer = new byte[(int) (blockSize * seconds)]; @@ -76,7 +77,7 @@ public void divide(float seconds, Event event) throws IOException { } l += r; } -Debug.println("CHUNK[" + i + "] " + buffer.length + " bytes"); +Debug.println(Level.FINE, "CHUNK[" + i + "] " + buffer.length + " bytes"); event.exec(new Chunk(i, buffer, samplingRate, samplingBytes * 8, numberChannels)); } if (moduloOfChunks >= 0) { @@ -90,7 +91,7 @@ public void divide(float seconds, Event event) throws IOException { l += r; } event.exec(new Chunk(numberOfChunks, buffer, samplingRate, samplingBytes * 8, numberChannels)); -Debug.println("modulo bytes: " + buffer.length + ", " + (((totalTime / 1000) % seconds) + 1) + " [s]"); +Debug.println(Level.FINE, "modulo bytes: " + buffer.length + ", " + (((totalTime / 1000) % seconds) + 1) + " [s]"); } } } diff --git a/src/main/java/vavi/sound/sampled/SimpleResamplingInputFilter.java b/src/main/java/vavi/sound/sampled/SimpleResamplingInputFilter.java index c7b18e3..1913af9 100644 --- a/src/main/java/vavi/sound/sampled/SimpleResamplingInputFilter.java +++ b/src/main/java/vavi/sound/sampled/SimpleResamplingInputFilter.java @@ -7,6 +7,7 @@ package vavi.sound.sampled; import java.io.IOException; +import java.util.logging.Level; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioInputStream; @@ -36,7 +37,7 @@ public SimpleResamplingInputFilter(int outSamplingRate) { /** */ public AudioInputStream doFilter(AudioInputStream sourceAis) throws IOException, UnsupportedAudioFileException { AudioFormat inAudioFormat = sourceAis.getFormat(); -Debug.println("IN: " + inAudioFormat); +Debug.println(Level.FINE, "IN: " + inAudioFormat); // 1: PCM_SIGNED ? Hz, 16 bit, stereo, 2 bytes/frame, little-endian AudioFormat outAudioFormat = new AudioFormat( inAudioFormat.getEncoding(), @@ -46,8 +47,8 @@ public AudioInputStream doFilter(AudioInputStream sourceAis) throws IOException, inAudioFormat.getFrameSize(), inAudioFormat.getFrameRate(), inAudioFormat.isBigEndian()); -Debug.println("OUT: " + outAudioFormat); -Debug.println("OK: " + AudioSystem.isConversionSupported(outAudioFormat, inAudioFormat)); +Debug.println(Level.FINE, "OUT: " + outAudioFormat); +Debug.println(Level.FINE, "OK: " + AudioSystem.isConversionSupported(outAudioFormat, inAudioFormat)); return AudioSystem.getAudioInputStream(outAudioFormat, sourceAis); } diff --git a/src/main/java/vavi/sound/sampled/TemporaryFiledInputFilter.java b/src/main/java/vavi/sound/sampled/TemporaryFiledInputFilter.java index 778af76..35a0395 100644 --- a/src/main/java/vavi/sound/sampled/TemporaryFiledInputFilter.java +++ b/src/main/java/vavi/sound/sampled/TemporaryFiledInputFilter.java @@ -8,6 +8,7 @@ import java.io.File; import java.io.IOException; +import java.util.logging.Level; import javax.sound.sampled.AudioFileFormat; import javax.sound.sampled.AudioInputStream; @@ -30,7 +31,7 @@ public AudioInputStream doFilter(AudioInputStream sourceAis) throws IOException, // 一回 temp ファイルに落とす File tmpFile = File.createTempFile("temp", ".wav"); int r = AudioSystem.write(sourceAis, AudioFileFormat.Type.WAVE, tmpFile); -Debug.println("RESULT: " + r); +Debug.println(Level.FINE, "RESULT: " + r); return AudioSystem.getAudioInputStream(tmpFile); } diff --git a/src/main/java/vavi/sound/sampled/WaveDivider.java b/src/main/java/vavi/sound/sampled/WaveDivider.java index 4913818..fed0bed 100644 --- a/src/main/java/vavi/sound/sampled/WaveDivider.java +++ b/src/main/java/vavi/sound/sampled/WaveDivider.java @@ -7,6 +7,7 @@ package vavi.sound.sampled; import java.io.IOException; +import java.util.logging.Level; import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.UnsupportedAudioFileException; @@ -56,7 +57,7 @@ public static WaveDivider getWaveDivider(AudioInputStream audioInputStream) thro return new Pcm16BitMonauralWaveDivider(new MonauralInputFilter().doFilter(audioInputStream)); } } else { -Debug.println("unsupported type: " + audioInputStream.getFormat()); +Debug.println(Level.INFO, "unsupported type: " + audioInputStream.getFormat()); throw new IllegalArgumentException("only pcm mono is supported."); } } diff --git a/src/main/java/vavi/sound/sampled/mfi/DividedMfiWithVoiceMaker.java b/src/main/java/vavi/sound/sampled/mfi/DividedMfiWithVoiceMaker.java index 460b830..de2e813 100644 --- a/src/main/java/vavi/sound/sampled/mfi/DividedMfiWithVoiceMaker.java +++ b/src/main/java/vavi/sound/sampled/mfi/DividedMfiWithVoiceMaker.java @@ -8,6 +8,7 @@ import java.io.File; import java.io.IOException; +import java.util.logging.Level; import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioSystem; @@ -93,10 +94,10 @@ public int create() throws IOException, UnsupportedAudioFileException, InvalidMf // divide Event event = new Event(); WaveDivider waveDivider = WaveDivider.Factory.getWaveDivider(sourceAis); -Debug.println("1: " + (System.currentTimeMillis() - t)); +Debug.println(Level.FINE, "1: " + (System.currentTimeMillis() - t)); t = System.currentTimeMillis(); waveDivider.divide(time, event); -Debug.println("2: " + (System.currentTimeMillis() - t)); +Debug.println(Level.FINE, "2: " + (System.currentTimeMillis() - t)); t = System.currentTimeMillis(); return event.r; } diff --git a/src/main/java/vavi/sound/sampled/mfi/MfiWithVoiceMaker.java b/src/main/java/vavi/sound/sampled/mfi/MfiWithVoiceMaker.java index 7b1122a..486928c 100644 --- a/src/main/java/vavi/sound/sampled/mfi/MfiWithVoiceMaker.java +++ b/src/main/java/vavi/sound/sampled/mfi/MfiWithVoiceMaker.java @@ -9,6 +9,7 @@ import java.io.File; import java.io.IOException; import java.util.Properties; +import java.util.logging.Level; import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioSystem; @@ -173,7 +174,7 @@ protected int createMFi(byte[] data, File file) throws InvalidMfiDataException, } int r = MfiSystem.write(sequence, VaviMfiFileFormat.FILE_TYPE, file); -Debug.println("write: " + r); +Debug.println(Level.FINE, "write: " + r); return r; } diff --git a/src/main/java/vavi/sound/sampled/smaf/DividedSmafWithVoiceMaker.java b/src/main/java/vavi/sound/sampled/smaf/DividedSmafWithVoiceMaker.java index 7a3ff00..31d485c 100644 --- a/src/main/java/vavi/sound/sampled/smaf/DividedSmafWithVoiceMaker.java +++ b/src/main/java/vavi/sound/sampled/smaf/DividedSmafWithVoiceMaker.java @@ -89,10 +89,10 @@ public int create() throws IOException, UnsupportedAudioFileException, InvalidSm // divide Event event = new Event(); WaveDivider waveDivider = WaveDivider.Factory.getWaveDivider(sourceAis); -Debug.println("1: " + (System.currentTimeMillis() - t)); +Debug.println(Level.FINE, "1: " + (System.currentTimeMillis() - t)); t = System.currentTimeMillis(); waveDivider.divide(time, event); -Debug.println("2: " + (System.currentTimeMillis() - t)); +Debug.println(Level.FINE, "2: " + (System.currentTimeMillis() - t)); t = System.currentTimeMillis(); return event.r; } diff --git a/src/main/java/vavi/sound/sampled/smaf/SmafWithVoiceMaker.java b/src/main/java/vavi/sound/sampled/smaf/SmafWithVoiceMaker.java index 6225239..6013a94 100644 --- a/src/main/java/vavi/sound/sampled/smaf/SmafWithVoiceMaker.java +++ b/src/main/java/vavi/sound/sampled/smaf/SmafWithVoiceMaker.java @@ -12,6 +12,7 @@ import java.text.SimpleDateFormat; import java.util.Date; import java.util.Properties; +import java.util.logging.Level; import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioSystem; @@ -114,7 +115,7 @@ protected SmafWithVoiceMaker(float time, int samplingRate, int bits, int channel public int create() throws IOException, UnsupportedAudioFileException, InvalidSmafDataException { long t = System.currentTimeMillis(); // divide -Debug.println("1: " + (System.currentTimeMillis() - t)); +Debug.println(Level.FINE, "1: " + (System.currentTimeMillis() - t)); t = System.currentTimeMillis(); byte[] buffer = new byte[sourceAis.available()]; int l = 0; @@ -123,7 +124,7 @@ public int create() throws IOException, UnsupportedAudioFileException, InvalidSm l += r; } int result = createSMAF(buffer, new File(filename)); -Debug.println("2: " + (System.currentTimeMillis() - t)); +Debug.println(Level.FINE, "2: " + (System.currentTimeMillis() - t)); t = System.currentTimeMillis(); return result; } @@ -159,11 +160,11 @@ protected int createSMAF(byte[] data, File file) throws InvalidSmafDataException int timeBase = 4; // [ms] -Debug.println("time: " + time + ", " + data.length); +Debug.println(Level.FINE, "time: " + time + ", " + data.length); int numberOfChunks = (int) ((time * 1000) / (NopMessage.maxSteps * timeBase)); -Debug.println("numberOfChunks: " + numberOfChunks); +Debug.println(Level.FINE, "numberOfChunks: " + numberOfChunks); int moduloOfChunks = (int) ((time * 1000) % (NopMessage.maxSteps * timeBase) / timeBase); -Debug.println("moduloOfChunks: " + moduloOfChunks); +Debug.println(Level.FINE, "moduloOfChunks: " + moduloOfChunks); int messageBytes = 0; int streamNumber = 1; @@ -200,13 +201,13 @@ protected int createSMAF(byte[] data, File file) throws InvalidSmafDataException SeekAndPhraseInfoChunk seekAndPhraseInfoChunk = new SeekAndPhraseInfoChunk(); seekAndPhraseInfoChunk.setStartPoint(0); seekAndPhraseInfoChunk.setStopPoint(messageBytes); -Debug.println("sp: " + messageBytes); +Debug.println(Level.FINE, "sp: " + messageBytes); AudioEngine audioEngine = WaveSequencer.Factory.getAudioEngine(ADPCM); int chunkSize = numberOfChunks == 0 ? 0 : data.length / numberOfChunks; -Debug.println("chunkSize: " + chunkSize); +Debug.println(Level.FINE, "chunkSize: " + chunkSize); int moduloChunkSize = numberOfChunks == 0 ? data.length : data.length % chunkSize; -Debug.println("moduloChunkSize: " + moduloChunkSize); +Debug.println(Level.FINE, "moduloChunkSize: " + moduloChunkSize); streamNumber = 1; PcmAudioTrackChunk pcmAudioTrackChunk = new PcmAudioTrackChunk(); @@ -245,7 +246,7 @@ protected int createSMAF(byte[] data, File file) throws InvalidSmafDataException } fileChunk.writeTo(Files.newOutputStream(file.toPath())); int r = fileChunk.getSize(); -Debug.println("write: " + r); +Debug.println(Level.FINE, "write: " + r); return r; } diff --git a/src/main/java/vavi/sound/smaf/MetaEventAdapter.java b/src/main/java/vavi/sound/smaf/MetaEventAdapter.java index fc11d87..3b0e27d 100644 --- a/src/main/java/vavi/sound/smaf/MetaEventAdapter.java +++ b/src/main/java/vavi/sound/smaf/MetaEventAdapter.java @@ -77,14 +77,14 @@ public void meta(javax.sound.midi.MetaMessage message) { case META_TEXT_EVENT: // テキスト・イベント case META_COPYRIGHT: // 著作権表示 case META_NAME: // シーケンス名またはトラック名 -Debug.println("meta " + message.getType() + ": " + MidiUtil.getDecodedMessage(message.getData())); +Debug.println(Level.FINE, "meta " + message.getType() + ": " + MidiUtil.getDecodedMessage(message.getData())); break; case META_END_OF_TRACK: // トラックの終わり case META_TEMPO: // テンポ設定 Debug.println(Level.FINE, "this handler ignore meta: " + message.getType()); break; default: -Debug.println("no meta sub handler: " + message.getType()); +Debug.println(Level.FINE, "no meta sub handler: " + message.getType()); break; } } diff --git a/src/main/java/vavi/sound/smaf/SmafMidiConverter.java b/src/main/java/vavi/sound/smaf/SmafMidiConverter.java index 2b3dafa..8b4ebb1 100644 --- a/src/main/java/vavi/sound/smaf/SmafMidiConverter.java +++ b/src/main/java/vavi/sound/smaf/SmafMidiConverter.java @@ -71,7 +71,7 @@ Sequence convert(vavi.sound.smaf.Sequence smafSequence) MidiContext midiContext = new MidiContext(); int resolution = midiContext.getResolution(smafTracks); -Debug.println("resolution: " + resolution); +Debug.println(Level.FINE, "resolution: " + resolution); Sequence midiSequence = new SmafVaviSequence(Sequence.PPQ, resolution, 1); javax.sound.midi.Track midiTrack = midiSequence.getTracks()[0]; @@ -100,7 +100,7 @@ Sequence convert(vavi.sound.smaf.Sequence smafSequence) !(smafMessage instanceof vavi.sound.smaf.message.PitchBendMessage) && !(smafMessage instanceof vavi.sound.smaf.message.PanMessage) && !(smafMessage instanceof vavi.sound.smaf.message.ExpressionMessage)) { - Debug.println("midi convertible(" + i + ":" + j + "): " + smafMessage); + Debug.println(Level.FINE, "midi convertible(" + i + ":" + j + "): " + smafMessage); } //if (smafMessage instanceof vavi.sound.smaf.message.NoteMessage) { // int gateTime = ((vavi.sound.smaf.message.NoteMessage) smafMessage).getGateTime(); @@ -116,9 +116,9 @@ Sequence convert(vavi.sound.smaf.Sequence smafSequence) } } } else if (smafMessage instanceof MetaMessage) { - Debug.println("meta: " + MetaMessage.class.cast(smafMessage).getType()); - Debug.println(entry.getKey() + "=" + entry.getValue()); +Debug.println(Level.FINE, "meta: " + ((MetaMessage) smafMessage).getType()); for (Map.Entry entry : ((MetaMessage) smafMessage).data.entrySet()) { +Debug.println(Level.FINE, entry.getKey() + "=" + entry.getValue()); } } else { if (!uc.contains(smafMessage.getClass())) { @@ -148,7 +148,7 @@ private void addSmafMessage(javax.sound.midi.Track midiTrack, MidiEvent midiEven midiTrack.remove(removedMidiEvent); midiTrack.add(midiEvent); midiTrack.add(removedMidiEvent); -Debug.println("★★★★★ : " + MidiUtil.paramString(midiEvent.getMessage()) + ", " + MidiUtil.paramString(removedMidiEvent.getMessage())); +Debug.println(Level.INFO, "★★★★★ : " + MidiUtil.paramString(midiEvent.getMessage()) + ", " + MidiUtil.paramString(removedMidiEvent.getMessage())); } else { midiTrack.add(midiEvent); } diff --git a/src/main/java/vavi/sound/smaf/SmafSequence.java b/src/main/java/vavi/sound/smaf/SmafSequence.java index a3b9870..ba1af34 100644 --- a/src/main/java/vavi/sound/smaf/SmafSequence.java +++ b/src/main/java/vavi/sound/smaf/SmafSequence.java @@ -7,6 +7,7 @@ package vavi.sound.smaf; import java.util.List; +import java.util.logging.Level; import vavi.sound.smaf.chunk.Chunk; import vavi.sound.smaf.chunk.FileChunk; @@ -51,7 +52,7 @@ class SmafSequence extends Sequence { String prot = "vavi"; if (fileChunk.getOptionalDataChunk() != null) { for (Chunk dataChunk : fileChunk.getOptionalDataChunk().getDataChunks()) { -Debug.println(dataChunk); +Debug.println(Level.FINE, dataChunk); // TODO } } else if (fileChunk.getContentsInfoChunk() != null) { // TODO 必須なので if 要らん diff --git a/src/main/java/vavi/sound/smaf/chunk/AudioSequenceDataChunk.java b/src/main/java/vavi/sound/smaf/chunk/AudioSequenceDataChunk.java index 0ef722e..c26b522 100644 --- a/src/main/java/vavi/sound/smaf/chunk/AudioSequenceDataChunk.java +++ b/src/main/java/vavi/sound/smaf/chunk/AudioSequenceDataChunk.java @@ -7,6 +7,7 @@ package vavi.sound.smaf.chunk; import java.io.IOException; +import java.util.logging.Level; import vavi.sound.smaf.InvalidSmafDataException; import vavi.sound.smaf.SmafMessage; @@ -28,7 +29,7 @@ public class AudioSequenceDataChunk extends SequenceDataChunk { /** */ public AudioSequenceDataChunk(byte[] id, int size) { super(id, size); -Debug.println("AudioSequenceData: " + size + " bytes"); +Debug.println(Level.FINE, "AudioSequenceData: " + size + " bytes"); } /** */ @@ -50,7 +51,7 @@ protected void init(MyDataInputStream dis, Chunk parent) default: throw new InvalidSmafDataException("FormatType: " + formatType); } -Debug.println("messages: " + messages.size()); +Debug.println(Level.FINE, "messages: " + messages.size()); } /** diff --git a/src/main/java/vavi/sound/smaf/chunk/BitmapChunk.java b/src/main/java/vavi/sound/smaf/chunk/BitmapChunk.java index 9027bb0..9cf078a 100644 --- a/src/main/java/vavi/sound/smaf/chunk/BitmapChunk.java +++ b/src/main/java/vavi/sound/smaf/chunk/BitmapChunk.java @@ -8,6 +8,7 @@ import java.io.IOException; import java.io.OutputStream; +import java.util.logging.Level; import vavi.sound.smaf.InvalidSmafDataException; import vavi.util.Debug; @@ -26,7 +27,7 @@ public class BitmapChunk extends Chunk { /** */ public BitmapChunk(byte[] id, int size) { super(id, size); -Debug.println("Bitmap: " + size + " bytes"); +Debug.println(Level.FINE, "Bitmap: " + size + " bytes"); } /** */ diff --git a/src/main/java/vavi/sound/smaf/chunk/DisplayParameterDefinitionChunk.java b/src/main/java/vavi/sound/smaf/chunk/DisplayParameterDefinitionChunk.java index e9258d5..fc61ea9 100644 --- a/src/main/java/vavi/sound/smaf/chunk/DisplayParameterDefinitionChunk.java +++ b/src/main/java/vavi/sound/smaf/chunk/DisplayParameterDefinitionChunk.java @@ -11,6 +11,7 @@ import java.io.OutputStream; import java.util.ArrayList; import java.util.List; +import java.util.logging.Level; import vavi.sound.midi.MidiUtil; import vavi.sound.smaf.InvalidSmafDataException; @@ -49,7 +50,7 @@ protected void init(MyDataInputStream dis, Chunk parent) int eventType = dis.readUnsignedByte(); Event event = new Event(); event.eventType = eventType; -Debug.println("event: " + eventType); +Debug.println(Level.FINE, "event: " + eventType); for (int j = 0; j < ((eventSize - 1) / 2); j++) { int parameterId = dis.readUnsignedByte(); int parameterValue = dis.readUnsignedByte(); @@ -57,7 +58,7 @@ protected void init(MyDataInputStream dis, Chunk parent) parameter.parameterID = ParameterID.valueOf(parameterId); parameter.value = parameterValue; event.parameters.add(parameter); -Debug.println("parameters: " + parameter); +Debug.println(Level.FINE, "parameters: " + parameter); } i += (eventSize > 127 ? 2 : 1) + eventSize; } diff --git a/src/main/java/vavi/sound/smaf/chunk/FileChunk.java b/src/main/java/vavi/sound/smaf/chunk/FileChunk.java index 7050e58..5cced57 100644 --- a/src/main/java/vavi/sound/smaf/chunk/FileChunk.java +++ b/src/main/java/vavi/sound/smaf/chunk/FileChunk.java @@ -50,7 +50,7 @@ protected void init(MyDataInputStream dis, Chunk parent) } else if (chunk instanceof OptionalDataChunk) { optionalDataChunk = chunk; } else if (chunk instanceof ScoreTrackChunk) { -Debug.println("TRACK: " + scoreTrackChunks.size()); +Debug.println(Level.FINE, "TRACK: " + scoreTrackChunks.size()); scoreTrackChunks.add((TrackChunk) chunk); } else if (chunk instanceof PcmAudioTrackChunk) { pcmAudioTrackChunks.add((TrackChunk) chunk); @@ -64,11 +64,11 @@ protected void init(MyDataInputStream dis, Chunk parent) } //Debug.println("available: " + is.available()); this.crc = dis.readUnsignedShort(); -Debug.printf("crc (orig): %04x\n", crc); +Debug.printf(Level.FINE, "crc (orig): %04x\n", crc); if (dis.available() > 4) { int kddiCrc = dis.readUnsignedShort(); int kddiMark = dis.readUnsignedShort(); -Debug.printf("has kddi crc: %04x, %04x\n", kddiCrc, kddiMark); +Debug.printf(Level.FINE, "has kddi crc: %04x, %04x\n", kddiCrc, kddiMark); } } diff --git a/src/main/java/vavi/sound/smaf/chunk/GraphicsSetupDataChunk.java b/src/main/java/vavi/sound/smaf/chunk/GraphicsSetupDataChunk.java index 104c452..f7b8a46 100644 --- a/src/main/java/vavi/sound/smaf/chunk/GraphicsSetupDataChunk.java +++ b/src/main/java/vavi/sound/smaf/chunk/GraphicsSetupDataChunk.java @@ -28,7 +28,7 @@ public class GraphicsSetupDataChunk extends Chunk { /** */ public GraphicsSetupDataChunk(byte[] id, int size) { super(id, size); -Debug.println("GraphicsSetupData: " + size + " bytes"); +Debug.println(Level.FINE, "GraphicsSetupData: " + size + " bytes"); } /** */ diff --git a/src/main/java/vavi/sound/smaf/chunk/GraphicsTrackChunk.java b/src/main/java/vavi/sound/smaf/chunk/GraphicsTrackChunk.java index 5b6f11e..d8c141f 100644 --- a/src/main/java/vavi/sound/smaf/chunk/GraphicsTrackChunk.java +++ b/src/main/java/vavi/sound/smaf/chunk/GraphicsTrackChunk.java @@ -44,7 +44,7 @@ public class GraphicsTrackChunk extends TrackChunk { /** */ public GraphicsTrackChunk(byte[] id, int size) { super(id, size); -Debug.println("Graphics[" + trackNumber + "]: " + size); +Debug.println(Level.FINE, "Graphics[" + trackNumber + "]: " + size); } /** */ diff --git a/src/main/java/vavi/sound/smaf/chunk/GraphicsTrackSequenceDataChunk.java b/src/main/java/vavi/sound/smaf/chunk/GraphicsTrackSequenceDataChunk.java index 9357518..a2f912d 100644 --- a/src/main/java/vavi/sound/smaf/chunk/GraphicsTrackSequenceDataChunk.java +++ b/src/main/java/vavi/sound/smaf/chunk/GraphicsTrackSequenceDataChunk.java @@ -8,6 +8,7 @@ import java.io.DataInputStream; import java.io.IOException; +import java.util.logging.Level; import vavi.sound.midi.MidiUtil; import vavi.sound.smaf.InvalidSmafDataException; @@ -41,7 +42,7 @@ public GraphicsTrackSequenceDataChunk(byte[] id, int size) { super(id, size); this.sequenceNumber = id[3]; -Debug.println("GraphicsTrackSequenceData[" + sequenceNumber + "]: " + size + " bytes"); +Debug.println(Level.FINE, "GraphicsTrackSequenceData[" + sequenceNumber + "]: " + size + " bytes"); } /** */ @@ -62,7 +63,7 @@ protected void init(MyDataInputStream dis, Chunk parent) default: throw new InvalidSmafDataException("FormatType: " + formatType); } -Debug.println("messages: " + messages.size()); +Debug.println(Level.FINE, "messages: " + messages.size()); } /** formatType 0 */ @@ -113,12 +114,12 @@ protected void readHandyPhoneStandard(DataInputStream dis) byte[] data = new byte[size]; dis.readFully(data); smafMessage = new UndefinedMessage(duration); -Debug.printf("reserved: %02x\n", e1); +Debug.printf(Level.FINE, "reserved: %02x\n", e1); } break; } //Debug.println(available() + ", " + smafMessage); -Debug.println("message: " + smafMessage); +Debug.println(Level.FINE, "message: " + smafMessage); messages.add(smafMessage); } } diff --git a/src/main/java/vavi/sound/smaf/chunk/HuffmanDecodingInputStream.java b/src/main/java/vavi/sound/smaf/chunk/HuffmanDecodingInputStream.java index bc667e7..b7a30fb 100644 --- a/src/main/java/vavi/sound/smaf/chunk/HuffmanDecodingInputStream.java +++ b/src/main/java/vavi/sound/smaf/chunk/HuffmanDecodingInputStream.java @@ -9,6 +9,7 @@ import java.io.FilterInputStream; import java.io.IOException; import java.io.InputStream; +import java.util.logging.Level; import vavi.util.Debug; @@ -41,7 +42,7 @@ public HuffmanDecodingInputStream(InputStream is) throws IOException { if ((root = readTree(true)) == -1) { throw new IllegalStateException("can not initialize reading tree"); } -Debug.println("root: " + root); +Debug.println(Level.FINE, "root: " + root); } /** @@ -55,11 +56,11 @@ private int readBit() throws IOException { } bitOffset = 0; currentByte = in.read(); -Debug.println("currentByte: " + currentByte); +Debug.println(Level.FINE, "currentByte: " + currentByte); } int bit = (currentByte >> (7 - bitOffset)) & 0x01; -Debug.println("bit: " + bit + " (" + bitOffset + ")"); +Debug.println(Level.FINE, "bit: " + bit + " (" + bitOffset + ")"); bitOffset++; return bit; @@ -105,7 +106,7 @@ private int readTree(boolean init) throws IOException { } int bit = readBit(); -Debug.println("bit: " + bit); +Debug.println(Level.FINE, "bit: " + bit); if (bit == -1) { return -1; } @@ -143,7 +144,7 @@ public int read(byte[] b, int offset, int length) throws IOException { int position = 0; while (position < length) { int node = root; -Debug.println("node: " + node); +Debug.println(Level.FINE, "node: " + node); while (node >= N) { int bit = readBit(); if (bit == -1) { diff --git a/src/main/java/vavi/sound/smaf/chunk/ImageChunk.java b/src/main/java/vavi/sound/smaf/chunk/ImageChunk.java index 7950ad0..e3f383f 100644 --- a/src/main/java/vavi/sound/smaf/chunk/ImageChunk.java +++ b/src/main/java/vavi/sound/smaf/chunk/ImageChunk.java @@ -10,6 +10,7 @@ import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.OutputStream; +import java.util.logging.Level; import javax.imageio.ImageIO; @@ -35,7 +36,7 @@ public ImageChunk(byte[] id, int size) { super(id, size); this.imageNumer = id[3]; -Debug.println("Image[" + imageNumer + "]: " + size + " bytes"); +Debug.println(Level.FINE, "Image[" + imageNumer + "]: " + size + " bytes"); } /** */ @@ -51,7 +52,7 @@ protected void init(MyDataInputStream dis, Chunk parent) this.imageData = new byte[size]; dis.readFully(imageData); -Debug.println("image: " + getImage()); +Debug.println(Level.FINE, "image: " + getImage()); } /** */ diff --git a/src/main/java/vavi/sound/smaf/chunk/ImageDataChunk.java b/src/main/java/vavi/sound/smaf/chunk/ImageDataChunk.java index 4fdac79..0d9f1a0 100644 --- a/src/main/java/vavi/sound/smaf/chunk/ImageDataChunk.java +++ b/src/main/java/vavi/sound/smaf/chunk/ImageDataChunk.java @@ -29,7 +29,7 @@ public class ImageDataChunk extends Chunk { /** */ public ImageDataChunk(byte[] id, int size) { super(id, size); -Debug.println("ImageData: " + size + " bytes"); +Debug.println(Level.FINE, "ImageData: " + size + " bytes"); } /** */ @@ -54,7 +54,7 @@ protected void init(MyDataInputStream dis, Chunk parent) Debug.println(Level.WARNING, "unknown chunk: " + chunk.getClass()); } } -Debug.println("messages: " + imageDataChunks.size()); +Debug.println(Level.FINE, "messages: " + imageDataChunks.size()); } /** */ diff --git a/src/main/java/vavi/sound/smaf/chunk/LinkChunk.java b/src/main/java/vavi/sound/smaf/chunk/LinkChunk.java index 586dd9f..ee9ab08 100644 --- a/src/main/java/vavi/sound/smaf/chunk/LinkChunk.java +++ b/src/main/java/vavi/sound/smaf/chunk/LinkChunk.java @@ -8,6 +8,7 @@ import java.io.IOException; import java.io.OutputStream; +import java.util.logging.Level; import vavi.sound.smaf.InvalidSmafDataException; import vavi.util.Debug; @@ -26,7 +27,7 @@ public class LinkChunk extends Chunk { /** */ public LinkChunk(byte[] id, int size) { super(id, size); -Debug.println("Link: " + size + " bytes"); +Debug.println(Level.FINE, "Link: " + size + " bytes"); } /** */ diff --git a/src/main/java/vavi/sound/smaf/chunk/MasterTrackChunk.java b/src/main/java/vavi/sound/smaf/chunk/MasterTrackChunk.java index 9db2794..a1142da 100644 --- a/src/main/java/vavi/sound/smaf/chunk/MasterTrackChunk.java +++ b/src/main/java/vavi/sound/smaf/chunk/MasterTrackChunk.java @@ -29,7 +29,7 @@ public class MasterTrackChunk extends TrackChunk { /** */ public MasterTrackChunk(byte[] id, int size) { super(id, size); -Debug.println("MasterTrack: " + size); +Debug.println(Level.FINE, "MasterTrack: " + size); } /** */ @@ -38,7 +38,7 @@ protected void init(MyDataInputStream dis, Chunk parent) this.formatType = FormatType.values()[dis.readUnsignedByte()]; this.sequenceType = SequenceType.values()[dis.readUnsignedByte()]; -Debug.println("sequenceType: " + sequenceType); +Debug.println(Level.FINE, "sequenceType: " + sequenceType); this.durationTimeBase = dis.readUnsignedByte(); //Debug.println("durationTimeBase: " + StringUtil.toHex2(durationTimeBase)); int optionSize = dis.readUnsignedByte(); diff --git a/src/main/java/vavi/sound/smaf/chunk/MasterTrackSequenceDataChunk.java b/src/main/java/vavi/sound/smaf/chunk/MasterTrackSequenceDataChunk.java index ee270dd..4937cdf 100644 --- a/src/main/java/vavi/sound/smaf/chunk/MasterTrackSequenceDataChunk.java +++ b/src/main/java/vavi/sound/smaf/chunk/MasterTrackSequenceDataChunk.java @@ -7,6 +7,7 @@ package vavi.sound.smaf.chunk; import java.io.IOException; +import java.util.logging.Level; import vavi.sound.smaf.InvalidSmafDataException; import vavi.util.Debug; @@ -25,7 +26,7 @@ public class MasterTrackSequenceDataChunk extends SequenceDataChunk { /** */ public MasterTrackSequenceDataChunk(byte[] id, int size) { super(id, size); -Debug.println("MasterTrackSequenceData: " + size + " bytes"); +Debug.println(Level.FINE, "MasterTrackSequenceData: " + size + " bytes"); } /** TODO how to get formatType from parent chunk ??? */ diff --git a/src/main/java/vavi/sound/smaf/chunk/OptionalDataChunk.java b/src/main/java/vavi/sound/smaf/chunk/OptionalDataChunk.java index 548c83c..f780c7a 100644 --- a/src/main/java/vavi/sound/smaf/chunk/OptionalDataChunk.java +++ b/src/main/java/vavi/sound/smaf/chunk/OptionalDataChunk.java @@ -11,6 +11,7 @@ import java.io.OutputStream; import java.util.ArrayList; import java.util.List; +import java.util.logging.Level; import vavi.sound.smaf.InvalidSmafDataException; import vavi.util.Debug; @@ -29,7 +30,7 @@ public class OptionalDataChunk extends Chunk { /** */ public OptionalDataChunk(byte[] id, int size) { super(id, size); -Debug.println("OptionalData: " + size + " bytes"); +Debug.println(Level.FINE, "OptionalData: " + size + " bytes"); } /** */ diff --git a/src/main/java/vavi/sound/smaf/chunk/PcmAudioTrackChunk.java b/src/main/java/vavi/sound/smaf/chunk/PcmAudioTrackChunk.java index ff3301c..d39b5d4 100644 --- a/src/main/java/vavi/sound/smaf/chunk/PcmAudioTrackChunk.java +++ b/src/main/java/vavi/sound/smaf/chunk/PcmAudioTrackChunk.java @@ -38,7 +38,7 @@ public class PcmAudioTrackChunk extends TrackChunk { /** */ public PcmAudioTrackChunk(byte[] id, int size) { super(id, size); -Debug.println("PcmAudioTrack[" + trackNumber + "]: " + size + " bytes"); +Debug.println(Level.FINE, "PcmAudioTrack[" + trackNumber + "]: " + size + " bytes"); } /** */ @@ -53,17 +53,17 @@ protected void init(MyDataInputStream dis, Chunk parent) //skip(is, size); this.formatType = FormatType.values()[dis.readUnsignedByte()]; -Debug.println("formatType: " + formatType); +Debug.println(Level.FINE, "formatType: " + formatType); this.sequenceType = SequenceType.values()[dis.readUnsignedByte()]; -Debug.println("sequenceType: " + sequenceType); +Debug.println(Level.FINE, "sequenceType: " + sequenceType); this.waveType = new WaveType(dis.readUnsignedShort()); -Debug.println("waveType: " + waveType); +Debug.println(Level.FINE, "waveType: " + waveType); this.durationTimeBase = dis.readUnsignedByte(); -Debug.println("durationTimeBase: " + durationTimeBase + ", " + getDurationTimeBase() + " ms"); +Debug.println(Level.FINE, "durationTimeBase: " + durationTimeBase + ", " + getDurationTimeBase() + " ms"); this.gateTimeTimeBase = dis.readUnsignedByte(); -Debug.println("gateTimeTimeBase: " + gateTimeTimeBase + ", " + getGateTimeTimeBase() + " ms"); +Debug.println(Level.FINE, "gateTimeTimeBase: " + gateTimeTimeBase + ", " + getGateTimeTimeBase() + " ms"); while (dis.available() > 0) { Chunk chunk = readFrom(dis); diff --git a/src/main/java/vavi/sound/smaf/chunk/ScoreTrackChunk.java b/src/main/java/vavi/sound/smaf/chunk/ScoreTrackChunk.java index 29a25f9..159ccb4 100644 --- a/src/main/java/vavi/sound/smaf/chunk/ScoreTrackChunk.java +++ b/src/main/java/vavi/sound/smaf/chunk/ScoreTrackChunk.java @@ -46,7 +46,7 @@ public class ScoreTrackChunk extends TrackChunk { /** */ public ScoreTrackChunk(byte[] id, int size) { super(id, size); -Debug.println("ScoreTrack[" + trackNumber + "]: " + size + " bytes"); +Debug.println(Level.FINE, "ScoreTrack[" + trackNumber + "]: " + size + " bytes"); } /** */ @@ -61,11 +61,11 @@ protected void init(MyDataInputStream dis, Chunk parent) this.formatType = FormatType.values()[dis.readUnsignedByte()]; this.sequenceType = SequenceType.values()[dis.readUnsignedByte()]; -Debug.println("sequenceType: " + sequenceType); +Debug.println(Level.FINE, "sequenceType: " + sequenceType); this.durationTimeBase = dis.readUnsignedByte(); -Debug.println("durationTimeBase: " + durationTimeBase + ", " + getDurationTimeBase() + " ms"); +Debug.println(Level.FINE, "durationTimeBase: " + durationTimeBase + ", " + getDurationTimeBase() + " ms"); this.gateTimeTimeBase = dis.readUnsignedByte(); -Debug.println("gateTimeTimeBase: " + gateTimeTimeBase + ", " + getGateTimeTimeBase() + " ms"); +Debug.println(Level.FINE, "gateTimeTimeBase: " + gateTimeTimeBase + ", " + getGateTimeTimeBase() + " ms"); switch (formatType) { case HandyPhoneStandard: { @@ -94,7 +94,7 @@ protected void init(MyDataInputStream dis, Chunk parent) // TODO implement } break; } -Debug.println("formatType: " + formatType); +Debug.println(Level.FINE, "formatType: " + formatType); while (dis.available() > 0) { //Debug.println("available: " + is.available() + ", " + available()); diff --git a/src/main/java/vavi/sound/smaf/chunk/SeekAndPhraseInfoChunk.java b/src/main/java/vavi/sound/smaf/chunk/SeekAndPhraseInfoChunk.java index 9131c8e..9e6de26 100644 --- a/src/main/java/vavi/sound/smaf/chunk/SeekAndPhraseInfoChunk.java +++ b/src/main/java/vavi/sound/smaf/chunk/SeekAndPhraseInfoChunk.java @@ -13,6 +13,7 @@ import java.util.List; import java.util.Map; import java.util.TreeMap; +import java.util.logging.Level; import vavi.sound.smaf.InvalidSmafDataException; import vavi.util.Debug; @@ -45,7 +46,7 @@ protected void init(MyDataInputStream dis, Chunk parent) throws InvalidSmafDataException, IOException { byte[] data = new byte[size]; -Debug.println("SeekAndPhraseInfo: " + size + " bytes (subData)"); +Debug.println(Level.FINE, "SeekAndPhraseInfo: " + size + " bytes (subData)"); dis.readFully(data); int i = 0; @@ -53,7 +54,7 @@ protected void init(MyDataInputStream dis, Chunk parent) //Debug.println(i + " / " + option.length + "\n" + StringUtil.getDump(option, i, option.length - i)); SubData subDatum = new SubData(data, i); subData.put(subDatum.getTag(), subDatum); -Debug.println("SeekAndPhraseInfo: subData: " + subDatum); +Debug.println(Level.FINE, "SeekAndPhraseInfo: subData: " + subDatum); i += 2 + 1 + subDatum.getData().length + 1; // tag ':' data ',' //Debug.println(i + " / " + option.length + "\n" + StringUtil.getDump(option, i, option.length - i)); } diff --git a/src/main/java/vavi/sound/smaf/chunk/SequenceDataChunk.java b/src/main/java/vavi/sound/smaf/chunk/SequenceDataChunk.java index 7c02cac..07b1fe6 100644 --- a/src/main/java/vavi/sound/smaf/chunk/SequenceDataChunk.java +++ b/src/main/java/vavi/sound/smaf/chunk/SequenceDataChunk.java @@ -52,7 +52,7 @@ public class SequenceDataChunk extends Chunk { /** */ public SequenceDataChunk(byte[] id, int size) { super(id, size); -Debug.println("SequenceData: " + size + " bytes"); +Debug.println(Level.FINE, "SequenceData: " + size + " bytes"); } /** */ @@ -87,7 +87,7 @@ protected void init(MyDataInputStream dis, Chunk parent) //os2.flush(); //os2.close(); //Debug.println("data.dec created"); -Debug.println("decode: " + size + " -> " + decoded.length); +Debug.println(Level.FINE, "decode: " + size + " -> " + decoded.length); size = decoded.length; readMobileStandard(new MyDataInputStream(new ByteArrayInputStream(decoded), id, decoded.length)); break; @@ -96,7 +96,7 @@ protected void init(MyDataInputStream dis, Chunk parent) readMobileStandard(dis); break; } -Debug.println("messages: " + messages.size()); +Debug.println(Level.FINE, "messages: " + messages.size()); } /** diff --git a/src/main/java/vavi/sound/smaf/chunk/SetupDataChunk.java b/src/main/java/vavi/sound/smaf/chunk/SetupDataChunk.java index 2c4add1..0e8d1c7 100644 --- a/src/main/java/vavi/sound/smaf/chunk/SetupDataChunk.java +++ b/src/main/java/vavi/sound/smaf/chunk/SetupDataChunk.java @@ -34,7 +34,7 @@ public class SetupDataChunk extends Chunk { /** */ public SetupDataChunk(byte[] id, int size) { super(id, size); -Debug.println("SetupData: " + size + " bytes"); +Debug.println(Level.FINE, "SetupData: " + size + " bytes"); } /** */ @@ -59,7 +59,7 @@ protected void init(MyDataInputStream dis, Chunk parent) throws InvalidSmafDataE readMobileStandard(dis); break; } -Debug.println("messages: " + messages.size()); +Debug.println(Level.FINE, "messages: " + messages.size()); } /** diff --git a/src/main/java/vavi/sound/smaf/chunk/StreamPcmDataChunk.java b/src/main/java/vavi/sound/smaf/chunk/StreamPcmDataChunk.java index 2402112..43c10bf 100644 --- a/src/main/java/vavi/sound/smaf/chunk/StreamPcmDataChunk.java +++ b/src/main/java/vavi/sound/smaf/chunk/StreamPcmDataChunk.java @@ -32,7 +32,7 @@ public class StreamPcmDataChunk extends Chunk { /** */ public StreamPcmDataChunk(byte[] id, int size) { super(id, size); -Debug.println("StreamPcmData: " + size); +Debug.println(Level.FINE, "StreamPcmData: " + size); } /** */ diff --git a/src/main/java/vavi/sound/smaf/chunk/StreamWaveDataChunk.java b/src/main/java/vavi/sound/smaf/chunk/StreamWaveDataChunk.java index 35a76cd..1abcdff 100644 --- a/src/main/java/vavi/sound/smaf/chunk/StreamWaveDataChunk.java +++ b/src/main/java/vavi/sound/smaf/chunk/StreamWaveDataChunk.java @@ -7,6 +7,7 @@ package vavi.sound.smaf.chunk; import java.io.IOException; +import java.util.logging.Level; import vavi.sound.smaf.InvalidSmafDataException; import vavi.sound.smaf.SmafMessage; @@ -27,7 +28,7 @@ public class StreamWaveDataChunk extends WaveDataChunk { /** */ public StreamWaveDataChunk(byte[] id, int size) { super(id, size); -Debug.println("StreamWaveData: " + size); +Debug.println(Level.FINE, "StreamWaveData: " + size); } /** */ diff --git a/src/main/java/vavi/sound/smaf/chunk/WaveDataChunk.java b/src/main/java/vavi/sound/smaf/chunk/WaveDataChunk.java index 4721235..36673f7 100644 --- a/src/main/java/vavi/sound/smaf/chunk/WaveDataChunk.java +++ b/src/main/java/vavi/sound/smaf/chunk/WaveDataChunk.java @@ -9,6 +9,7 @@ import java.io.DataOutputStream; import java.io.IOException; import java.io.OutputStream; +import java.util.logging.Level; import vavi.sound.smaf.InvalidSmafDataException; import vavi.sound.smaf.SmafMessage; @@ -31,7 +32,7 @@ public WaveDataChunk(byte[] id, int size) { super(id, size); waveNumber = id[3] & 0xff; -Debug.println("WaveData[" + waveNumber + "]: " + size + " bytes"); +Debug.println(Level.FINE, "WaveData[" + waveNumber + "]: " + size + " bytes"); } /** */ diff --git a/src/main/java/vavi/sound/smaf/chunk/WaveType.java b/src/main/java/vavi/sound/smaf/chunk/WaveType.java index 33051c9..e446cd2 100644 --- a/src/main/java/vavi/sound/smaf/chunk/WaveType.java +++ b/src/main/java/vavi/sound/smaf/chunk/WaveType.java @@ -7,6 +7,7 @@ package vavi.sound.smaf.chunk; import java.io.IOException; +import java.util.logging.Level; import vavi.util.Debug; @@ -92,7 +93,7 @@ public class WaveType { this.waveFormat = (waveType & 0x7000) >> 12; this.waveSamplingFreq = samplingFreqs[(waveType & 0x0f00) >> 8]; this.waveBaseBit = 4 * (((waveType & 0x00f0) >> 4) + 1); -Debug.println("waveType: " + this); +Debug.println(Level.FINE, "waveType: " + this); } /** @@ -107,12 +108,12 @@ public class WaveType { * */ WaveType(byte[] waveType) throws IOException { -Debug.printf("waveType: %02x %02x %02x\n", waveType[0], waveType[1], waveType[2]); +Debug.printf(Level.FINE, "waveType: %02x %02x %02x\n", waveType[0], waveType[1], waveType[2]); this.waveChannels = (waveType[0] & 0x80) != 0 ? 2 : 1; this.waveFormat = tableForMwq[(waveType[0] & 0x70) >> 4]; this.waveBaseBit = 4 * ((waveType[0] & 0x0f) + 1); this.waveSamplingFreq = ((waveType[1] & 0xff) << 8) | waveType[2] & 0xff; -Debug.println("waveType: " + this); +Debug.println(Level.FINE, "waveType: " + this); } /** diff --git a/src/main/java/vavi/sound/smaf/message/BankSelectMessage.java b/src/main/java/vavi/sound/smaf/message/BankSelectMessage.java index db3f3cd..0bedc4b 100644 --- a/src/main/java/vavi/sound/smaf/message/BankSelectMessage.java +++ b/src/main/java/vavi/sound/smaf/message/BankSelectMessage.java @@ -6,6 +6,7 @@ package vavi.sound.smaf.message; +import java.util.logging.Level; import javax.sound.midi.InvalidMidiDataException; import javax.sound.midi.MidiEvent; import javax.sound.midi.ShortMessage; @@ -122,7 +123,7 @@ public MidiEvent[] getMidiEvents(MidiContext context) throws InvalidMidiDataException { if (significant == null) { // HandyPhoneStandard -Debug.printf("BankSelect: [%d] %dch, 0x%02x", duration, channel, bank); +Debug.printf(Level.FINE, "BankSelect: [%d] %dch, 0x%02x", duration, channel, bank); int data2; if ((bank & 0x80) != 0) { context.setDrum(channel, MidiContext.ChannelConfiguration.PERCUSSION); @@ -158,7 +159,7 @@ public MidiEvent[] getMidiEvents(MidiContext context) } else { // MobileStandard int midiChannel = context.retrieveChannel(this.channel); -Debug.println("BankSelect(" + significant + "): [" + duration + "] " + midiChannel + "ch, " + bank); +Debug.println(Level.FINE, "BankSelect(" + significant + "): [" + duration + "] " + midiChannel + "ch, " + bank); ShortMessage shortMessage = new ShortMessage(); shortMessage.setMessage(ShortMessage.CONTROL_CHANGE, midiChannel, diff --git a/src/main/java/vavi/sound/smaf/message/EndOfSequenceMessage.java b/src/main/java/vavi/sound/smaf/message/EndOfSequenceMessage.java index 4a71e84..3c34fe4 100644 --- a/src/main/java/vavi/sound/smaf/message/EndOfSequenceMessage.java +++ b/src/main/java/vavi/sound/smaf/message/EndOfSequenceMessage.java @@ -9,6 +9,7 @@ import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; import java.io.IOException; +import java.util.logging.Level; import javax.sound.midi.MidiEvent; @@ -83,7 +84,7 @@ public MidiEvent[] getMidiEvents(MidiContext context) { javax.sound.midi.Track midiTrack = context.getMidiTrack(); MidiEvent midiEvent = midiTrack.get(midiTrack.size() - 1); // should be EoT midiEvent.setTick(context.getCurrentTick()); -Debug.println("EOT: " + midiEvent.getMessage().getClass().getName()); +Debug.println(Level.FINE, "EOT: " + midiEvent.getMessage().getClass().getName()); return null; } diff --git a/src/main/java/vavi/sound/smaf/message/MidiContext.java b/src/main/java/vavi/sound/smaf/message/MidiContext.java index 2623896..7b381b2 100644 --- a/src/main/java/vavi/sound/smaf/message/MidiContext.java +++ b/src/main/java/vavi/sound/smaf/message/MidiContext.java @@ -6,6 +6,7 @@ package vavi.sound.smaf.message; +import java.util.logging.Level; import javax.sound.midi.InvalidMidiDataException; import javax.sound.midi.MetaMessage; import javax.sound.midi.MidiEvent; @@ -72,7 +73,7 @@ public void setTrack(Track smafTrack) { if (metaMessage.getType() == MetaEvent.META_MACHINE_DEPEND.number()) { // this.formatType = (FormatType) metaMessage.getData().get("formatType"); // [ms] -Debug.println("formatType: " + formatType); +Debug.println(Level.FINE, "formatType: " + formatType); for (int i = 0; i < MAX_MIDI_CHANNELS; i++) { if (formatType == FormatType.HandyPhoneStandard) { velocities[i] = 0x7f; @@ -82,7 +83,7 @@ public void setTrack(Track smafTrack) { } // ChannelStatus[] channelStatuses = (ChannelStatus[]) metaMessage.getData().get("channelStatuses"); -Debug.println("channelStatuses: " + (channelStatuses != null ? channelStatuses.length : null)); +Debug.println(Level.FINE, "channelStatuses: " + (channelStatuses != null ? channelStatuses.length : null)); if (channelStatuses != null) { for (int i = 0; i < channelStatuses.length; i++) { setDrum(i, toChannelConfiguration(getMidiChannel(i), channelStatuses[i].getType())); @@ -200,7 +201,7 @@ public void setDrum(int smafChannel, ChannelConfiguration value) { int midiChannel = getMidiChannel(smafChannel); if (drumSwapChannel != CHANNEL_UNUSED && midiChannel == drumSwapChannel) { -Debug.println("already swapped: " + midiChannel + ", " + value); +Debug.println(Level.FINE, "already swapped: " + midiChannel + ", " + value); } else { drums[midiChannel] = value; //Debug.println("temporary: " + midiChannel + ", " + value); @@ -211,14 +212,14 @@ public void setDrum(int smafChannel, ChannelConfiguration value) { for (int k = MAX_MIDI_CHANNELS - 1; k >= 0; k--) { if (k != CHANNEL_DRUM && drums[k] == ChannelConfiguration.UNUSED) { drumSwapChannel = k; -Debug.println("channel 9 -> " + k); +Debug.println(Level.FINE, "channel 9 -> " + k); break; } } if (drumSwapChannel == CHANNEL_UNUSED) { - Debug.println("cannot swap: " + midiChannel + ", " + value); + Debug.println(Level.FINE, "cannot swap: " + midiChannel + ", " + value); } -Debug.println("channel configuration: " + midiChannel + "ch, " + drums[midiChannel]); +Debug.println(Level.FINE, "channel configuration: " + midiChannel + "ch, " + drums[midiChannel]); } if (value != ChannelConfiguration.UNUSED) { StringBuilder sb1 = new StringBuilder(16); @@ -229,7 +230,7 @@ public void setDrum(int smafChannel, ChannelConfiguration value) { sb2.append(midiChannel == i ? "*" : " "); sb3.append(drums[i].name().charAt(0)); } -Debug.println("drums: " + midiChannel + "ch, " + value + "\n" + sb1 + "\n" + sb2 + "\n" + sb3); +Debug.println(Level.FINE, "drums: " + midiChannel + "ch, " + value + "\n" + sb1 + "\n" + sb2 + "\n" + sb3); } } @@ -245,7 +246,7 @@ private int getMidiChannel(int smafChannel) { return smafTrackNumber * 4 + smafChannel; } else { if (smafTrackNumber > 0) { - Debug.println("track > 0: " + smafTrackNumber); + Debug.println(Level.FINE, "track > 0: " + smafTrackNumber); } return smafTrackNumber * 16 + smafChannel; } @@ -260,7 +261,7 @@ public int setProgram(int smafChannel, int program) { if (formatType != FormatType.HandyPhoneStandard) { if (midiChannel != drumSwapChannel && drums[midiChannel] == ChannelConfiguration.PERCUSSION) { -Debug.println("drum always zero:[" + midiChannel + "]: " + program); +Debug.println(Level.FINE, "drum always zero:[" + midiChannel + "]: " + program); program = 0; } } @@ -482,7 +483,7 @@ public int getVelocity(int smafChannel) { /* */ static { -Debug.println("tempoTable: " + tempoTable.length); +Debug.println(Level.FINE, "tempoTable: " + tempoTable.length); } /** テンポの指定がない場合、SSDは 4 分音符 = 120 として扱います */ @@ -539,7 +540,7 @@ public int getResolution(Track[] smafTracks) vavi.sound.smaf.MetaMessage metaMessage = (vavi.sound.smaf.MetaMessage) message; if (metaMessage.getType() == MetaEvent.META_MACHINE_DEPEND.number()) { this.timeBase = (Integer) metaMessage.getData().get("durationTimeBase"); // [ms] -Debug.println("timebase: " + timeBase + ", (" + t + ":" + i + ")"); +Debug.println(Level.FINE, "timebase: " + timeBase + ", (" + t + ":" + i + ")"); return tempo * timeBase; } } @@ -547,7 +548,7 @@ public int getResolution(Track[] smafTracks) t++; } -Debug.println("no tempo message in track 0"); +Debug.println(Level.FINE, "no tempo message in track 0"); return 120; } } diff --git a/src/main/java/vavi/sound/smaf/message/NoteMessage.java b/src/main/java/vavi/sound/smaf/message/NoteMessage.java index e83f798..eeeaf01 100644 --- a/src/main/java/vavi/sound/smaf/message/NoteMessage.java +++ b/src/main/java/vavi/sound/smaf/message/NoteMessage.java @@ -266,7 +266,7 @@ public SmafEvent[] getSmafEvents(MidiEvent midiEvent, SmafContext context) (command == ShortMessage.NOTE_ON && data2 == 0)) { if (!context.isNoteOffEventUsed()) { -Debug.println("[" + context.getMidiEventIndex() + "] no pair of ON for: " + channel + "ch, " + data1); +Debug.println(Level.FINE, "[" + context.getMidiEventIndex() + "] no pair of ON for: " + channel + "ch, " + data1); } return null; @@ -302,12 +302,12 @@ public SmafEvent[] getSmafEvents(MidiEvent midiEvent, SmafContext context) smafMessage.setNote(context.retrievePitch(channel, data1)); smafMessage.setGateTime(i == onLength - 1 ? length % 255 : 255); if (length >= 255) { - Debug.println(channel + "ch, " + smafMessage.getNote() + ", " + smafMessage.getDuration() + ":[" + i + "]:" + (i == onLength - 1 ? length % 255 : 255) + "/" + length); + Debug.println(Level.FINE, channel + "ch, " + smafMessage.getNote() + ", " + smafMessage.getDuration() + ":[" + i + "]:" + (i == onLength - 1 ? length % 255 : 255) + "/" + length); } //Debug.println(channel + ", " + smafMessage.getVoice() + ", " + ((smafMessage.getMessage()[1] & 0xc0) >> 6)); smafEvents[i] = new SmafEvent(smafMessage, 0L); // TODO 0l if (smafEvents[i] == null) { - Debug.println("[" + i + "]: " + smafEvents[i]); + Debug.println(Level.FINE, "[" + i + "]: " + smafEvents[i]); } if (i == 0) { diff --git a/src/main/java/vavi/sound/smaf/message/SmafContext.java b/src/main/java/vavi/sound/smaf/message/SmafContext.java index 43bd2af..24214e5 100644 --- a/src/main/java/vavi/sound/smaf/message/SmafContext.java +++ b/src/main/java/vavi/sound/smaf/message/SmafContext.java @@ -95,7 +95,7 @@ public double getScale() { /** */ public void setScale(float scale) { -Debug.println("scale: " + scale); +Debug.println(Level.FINE, "scale: " + scale); this.scale = scale; } @@ -153,11 +153,11 @@ private int getAdjustedDelta(int smafTrackNumber, double floatDelta) { double rounded = floatDelta - delta; roundedSum[smafTrackNumber] += rounded; if (roundedSum[smafTrackNumber] >= 1f) { -Debug.println("rounded over 1, plus 1: " + roundedSum[smafTrackNumber] + "[" + smafTrackNumber + "]"); +Debug.println(Level.FINE, "rounded over 1, plus 1: " + roundedSum[smafTrackNumber] + "[" + smafTrackNumber + "]"); delta += 1; roundedSum[smafTrackNumber] -= 1; } else if (roundedSum[smafTrackNumber] <= -1f) { -Debug.println("rounded under -1, minus 1: " + roundedSum[smafTrackNumber] + "[" + smafTrackNumber + "]"); +Debug.println(Level.FINE, "rounded under -1, minus 1: " + roundedSum[smafTrackNumber] + "[" + smafTrackNumber + "]"); delta -= 1; roundedSum[smafTrackNumber] += 1; } @@ -207,12 +207,12 @@ public SmafEvent[] getIntervalSmafEvents() { // tempo track = smafTrackNumber; interval = retrieveDelta(track, midiEvent.getTick()); -Debug.println("interval for tempo[" + smafTrackNumber + "]: " + interval); +Debug.println(Level.FINE, "interval for tempo[" + smafTrackNumber + "]: " + interval); } else if (midiMessage instanceof MetaMessage && ((MetaMessage) midiMessage).getType() == 47) { // eot track = smafTrackNumber; interval = retrieveDelta(track, midiEvent.getTick()); -Debug.println("interval for EOT[" + smafTrackNumber + "]: " + interval); +Debug.println(Level.FINE, "interval for EOT[" + smafTrackNumber + "]: " + interval); } else if (midiMessage instanceof SysexMessage) { return null; } else { @@ -263,9 +263,9 @@ public int getDuration() { } else if (midiMessage instanceof MetaMessage && ((MetaMessage) midiMessage).getType() == 81) { // tempo delta = retrieveAdjustedDelta(smafTrackNumber, midiEvent.getTick()); // TODO smafTrackNumber でいいのか? -Debug.println("delta for tempo[" + smafTrackNumber + "]: " + delta); +Debug.println(Level.FINE, "delta for tempo[" + smafTrackNumber + "]: " + delta); } else { -Debug.println("no delta defined for: " + midiMessage); +Debug.println(Level.FINE, "no delta defined for: " + midiMessage); } if (delta > 255) { @@ -372,7 +372,7 @@ public MidiEvent getNextMidiEvent() throws NoSuchElementException { if (shortMessage.getChannel() == channel && shortMessage.getCommand() == ShortMessage.NOTE_ON && shortMessage.getData1() != data1) { -Debug.println("next: " + shortMessage.getChannel() + "ch, " + shortMessage.getData1()); +Debug.println(Level.FINE, "next: " + shortMessage.getChannel() + "ch, " + shortMessage.getData1()); return midiEvent; } } diff --git a/src/main/java/vavi/sound/smaf/message/TrackMessage.java b/src/main/java/vavi/sound/smaf/message/TrackMessage.java index 61ec89f..b953f88 100644 --- a/src/main/java/vavi/sound/smaf/message/TrackMessage.java +++ b/src/main/java/vavi/sound/smaf/message/TrackMessage.java @@ -9,6 +9,7 @@ import java.io.DataOutputStream; import java.io.IOException; import java.io.OutputStream; +import java.util.logging.Level; import vavi.sound.smaf.SmafEvent; import vavi.sound.smaf.SmafFileFormat; @@ -44,7 +45,7 @@ public void writeTo(OutputStream out) throws IOException { dos.writeBytes(getType()); dos.writeInt(getDataLength()); -Debug.println("track: " + trackNumber + ": " + getDataLength()); +Debug.println(Level.FINE, "track: " + trackNumber + ": " + getDataLength()); for (int j = 0; j < track.size(); j++) { SmafEvent event = track.get(j); SmafMessage message = event.getMessage(); diff --git a/src/main/java/vavi/sound/smaf/message/VolumeMessage.java b/src/main/java/vavi/sound/smaf/message/VolumeMessage.java index 8244a30..e9d83b5 100644 --- a/src/main/java/vavi/sound/smaf/message/VolumeMessage.java +++ b/src/main/java/vavi/sound/smaf/message/VolumeMessage.java @@ -9,6 +9,7 @@ import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; import java.io.IOException; +import java.util.logging.Level; import javax.sound.midi.InvalidMidiDataException; import javax.sound.midi.MidiEvent; @@ -126,7 +127,7 @@ public MidiEvent[] getMidiEvents(MidiContext context) context.getSmafTrackNumber() * 4 + this.channel != MidiContext.CHANNEL_DRUM) { // TODO psm は最後(最大?)?の volume を設定 -Debug.println("volume: " + volume); +Debug.println(Level.FINE, "volume: " + volume); context.setVelocity(this.channel, volume); return null; @@ -159,7 +160,7 @@ public SmafEvent[] getSmafEvents(MidiEvent midiEvent, SmafContext context) smafMessage.setDuration(context.getDuration()); smafMessage.setChannel(voice); smafMessage.setVolume(data2); -Debug.println("voice: " + voice + ", volume: " + data2); +Debug.println(Level.FINE, "voice: " + voice + ", volume: " + data2); context.setBeforeTick(track, midiEvent.getTick()); diff --git a/src/main/java/vavi/sound/smaf/message/WaveDataMessage.java b/src/main/java/vavi/sound/smaf/message/WaveDataMessage.java index 43b57cc..957dc86 100644 --- a/src/main/java/vavi/sound/smaf/message/WaveDataMessage.java +++ b/src/main/java/vavi/sound/smaf/message/WaveDataMessage.java @@ -8,6 +8,7 @@ import java.io.Serializable; import java.nio.ByteBuffer; +import java.util.logging.Level; import javax.sound.midi.InvalidMidiDataException; import javax.sound.midi.MetaMessage; @@ -113,7 +114,7 @@ public MidiEvent[] getMidiEvents(MidiContext context) /* */ public void sequence() throws InvalidSmafDataException { -Debug.println("WAVE DATA[" + number + "]: " + this); +Debug.println(Level.FINE, "WAVE DATA[" + number + "]: " + this); //try { // java.io.OutputStream os = new java.io.FileOutputStream("out.pcm"); // os.write(data); diff --git a/src/main/java/vavi/sound/smaf/message/WaveMessage.java b/src/main/java/vavi/sound/smaf/message/WaveMessage.java index 4de195f..fecccab 100644 --- a/src/main/java/vavi/sound/smaf/message/WaveMessage.java +++ b/src/main/java/vavi/sound/smaf/message/WaveMessage.java @@ -10,6 +10,7 @@ import java.io.DataOutputStream; import java.io.IOException; import java.io.Serializable; +import java.util.logging.Level; import javax.sound.midi.InvalidMidiDataException; import javax.sound.midi.MetaMessage; @@ -208,7 +209,7 @@ public MidiEvent[] getMidiEvents(MidiContext context) /* */ public void sequence() throws InvalidSmafDataException { -Debug.println("WAVE PLAY: " + number); +Debug.println(Level.FINE, "WAVE PLAY: " + number); AudioEngine engine = Factory.getAudioEngine(); engine.start(number); } 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 7fb8976..5ac9fec 100644 --- a/src/main/java/vavi/sound/smaf/message/yamaha/YamahaMessage.java +++ b/src/main/java/vavi/sound/smaf/message/yamaha/YamahaMessage.java @@ -167,13 +167,13 @@ public void sequence() throws InvalidSmafDataException { case 0x7f: switch (data[4]) { case 0x20: { // -Debug.println("YAMAHA UNKNOWN: "); +Debug.println(Level.FINE, "YAMAHA UNKNOWN: "); AudioEngine engine = WaveSequencer.Factory.getAudioEngine(); engine.start(2); break; } case 0x00: { // volume -Debug.println("YAMAHA VOLUME: "); +Debug.println(Level.FINE, "YAMAHA VOLUME: "); AudioEngine engine = WaveSequencer.Factory.getAudioEngine(); engine.start(1); break; diff --git a/src/test/java/SoundFontTest.java b/src/test/java/SoundFontTest.java index e9a846a..0e9f8c9 100644 --- a/src/test/java/SoundFontTest.java +++ b/src/test/java/SoundFontTest.java @@ -7,6 +7,7 @@ import java.io.File; import java.util.concurrent.CountDownLatch; +import java.util.logging.Level; import javax.sound.midi.MetaEventListener; import javax.sound.midi.MidiSystem; import javax.sound.midi.Sequence; @@ -33,10 +34,10 @@ public static void main(String[] args) throws Exception { File file = new File(args[0]); Sequence sequence = MidiSystem.getSequence(file); -Debug.println("sequence: " + sequence); +Debug.println(Level.FINE, "sequence: " + sequence); Synthesizer synthesizer = MidiSystem.getSynthesizer(); -Debug.println("synthesizer: " + synthesizer); +Debug.println(Level.FINE, "synthesizer: " + synthesizer); synthesizer.open(); // sf @@ -69,7 +70,7 @@ public static void main(String[] args) throws Exception { } }; Sequencer sequencer = MidiSystem.getSequencer(false); // crux -Debug.println("sequencer: " + sequencer); +Debug.println(Level.FINE, "sequencer: " + sequencer); sequencer.open(); sequencer.getTransmitter().setReceiver(synthesizer.getReceiver()); diff --git a/src/test/java/vavi/sound/adpcm/ccitt/G721InputStreamTest.java b/src/test/java/vavi/sound/adpcm/ccitt/G721InputStreamTest.java index 7225088..f62da59 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.util.logging.Level; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioSystem; import javax.sound.sampled.DataLine; @@ -43,7 +44,7 @@ public class G721InputStreamTest { public void setup() throws IOException { outFile = File.createTempFile("vavi", ".pcm"); outFile.deleteOnExit(); -Debug.println("outFile: " + outFile); +Debug.println(Level.FINE, "outFile: " + outFile); } /** */ diff --git a/src/test/java/vavi/sound/adpcm/ccitt/G721OutputStreamTest.java b/src/test/java/vavi/sound/adpcm/ccitt/G721OutputStreamTest.java index f24c8bf..4e68665 100644 --- a/src/test/java/vavi/sound/adpcm/ccitt/G721OutputStreamTest.java +++ b/src/test/java/vavi/sound/adpcm/ccitt/G721OutputStreamTest.java @@ -12,6 +12,7 @@ import java.io.OutputStream; import java.nio.ByteOrder; import java.nio.file.Files; +import java.util.logging.Level; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -39,7 +40,7 @@ public class G721OutputStreamTest { public void setup() throws IOException { outFile = File.createTempFile("vavi", ".pcm"); outFile.deleteOnExit(); -Debug.println("outFile: " + outFile); +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 243fc0e..e80a617 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.util.logging.Level; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioSystem; import javax.sound.sampled.DataLine; @@ -43,7 +44,7 @@ public class DviInputStreamTest { public void setup() throws IOException { outFile = File.createTempFile("vavi", ".pcm"); outFile.deleteOnExit(); -Debug.println("outFile: " + outFile); +Debug.println(Level.FINE, "outFile: " + outFile); } /** */ diff --git a/src/test/java/vavi/sound/adpcm/dvi/DviOutputStreamTest.java b/src/test/java/vavi/sound/adpcm/dvi/DviOutputStreamTest.java index e38f279..aec3329 100644 --- a/src/test/java/vavi/sound/adpcm/dvi/DviOutputStreamTest.java +++ b/src/test/java/vavi/sound/adpcm/dvi/DviOutputStreamTest.java @@ -7,12 +7,12 @@ package vavi.sound.adpcm.dvi; import java.io.File; -import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.nio.ByteOrder; import java.nio.file.Files; +import java.util.logging.Level; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -42,7 +42,7 @@ class DviOutputStreamTest { void setup() throws IOException { outFile = File.createTempFile("vavi", ".pcm"); outFile.deleteOnExit(); -Debug.println("outFile: " + outFile); +Debug.println(Level.FINE, "outFile: " + outFile); } /** TODO output size is double */ diff --git a/src/test/java/vavi/sound/adpcm/ima/ImaInputStreamTest.java b/src/test/java/vavi/sound/adpcm/ima/ImaInputStreamTest.java index 38ed525..cdafcbc 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.util.logging.Level; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioSystem; import javax.sound.sampled.DataLine; @@ -48,7 +49,7 @@ public class ImaInputStreamTest { public void setup() throws IOException { outFile = File.createTempFile("vavi", ".pcm"); outFile.deleteOnExit(); -Debug.println("outFile: " + outFile); +Debug.println(Level.FINE, "outFile: " + outFile); } /** @@ -70,12 +71,12 @@ public void test1() throws Exception { } LittleEndianDataInputStream ledis = new LittleEndianDataInputStream( new ByteArrayInputStream(format.getExtended())); -Debug.println("ext size: " + ledis.available()); +Debug.println("Level.FINE, ext size: " + ledis.available()); int samplesPerBlock = ledis.readShort(); ledis.close(); WAVE.data data = wave.findChildOf(WAVE.data.class); in = new ByteArrayInputStream(data.getWave()); -Debug.println("wave: " + in.available()); +Debug.println(Level.FINE, "wave: " + in.available()); //---- @@ -106,7 +107,7 @@ public void test1() throws Exception { SourceDataLine line = (SourceDataLine) AudioSystem.getLine(info); line.open(audioFormat); line.addLineListener(ev -> { -Debug.println(ev.getType()); +Debug.println(Level.FINE, ev.getType()); if (LineEvent.Type.STOP == ev.getType()) { } }); diff --git a/src/test/java/vavi/sound/adpcm/ima/ImaOutputStreamTest.java b/src/test/java/vavi/sound/adpcm/ima/ImaOutputStreamTest.java index aa89b22..682ccd3 100644 --- a/src/test/java/vavi/sound/adpcm/ima/ImaOutputStreamTest.java +++ b/src/test/java/vavi/sound/adpcm/ima/ImaOutputStreamTest.java @@ -15,6 +15,7 @@ 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; import javax.sound.sampled.DataLine; @@ -52,7 +53,7 @@ public void setup() throws IOException { outFile = File.createTempFile("vavi", ".pcm"); outFile.deleteOnExit(); // outFile = new File("src/test/resources/vavi/sound/adpcm/ima/out_vavi.adpcm"); -Debug.println("outFile: " + outFile.getCanonicalPath()); +Debug.println(Level.FINE, "outFile: " + outFile.getCanonicalPath()); } /** */ @@ -109,7 +110,7 @@ public void test1() throws Exception { line.close(); is2.close(); -Debug.println("outFile: " + outFile.length()); +Debug.println(Level.FINE, "outFile: " + outFile.length()); assertEquals(Checksum.getChecksum(getClass().getResourceAsStream(correctFile)), Checksum.getChecksum(outFile)); } @@ -174,7 +175,7 @@ public void test2() throws Exception { line.close(); is2.close(); -Debug.println("outFile: " + outFile.length()); +Debug.println(Level.FINE, "outFile: " + outFile.length()); assertEquals(Checksum.getChecksum(getClass().getResourceAsStream(inFile)), Checksum.getChecksum(outFile)); } @@ -193,7 +194,7 @@ public void test3() throws Exception { int length = in.available(); int spb = 505; int ll = 0; -Debug.println("inFile: " + length); +Debug.println(Level.FINE, "inFile: " + length); while (ll < length) { int bpb = Ima.getBytesPerBlock(1, spb); byte[] buffer = new byte[spb * 2]; @@ -258,7 +259,7 @@ public void test3() throws Exception { line.close(); is.close(); -Debug.println("outFile: " + new File(outFile).length()); +Debug.println(Level.FINE, "outFile: " + new File(outFile).length()); assertEquals(Checksum.getChecksum(getClass().getResourceAsStream(correctFile)), Checksum.getChecksum(new File(outFile))); } } diff --git a/src/test/java/vavi/sound/adpcm/ma/MaInputStreamTest.java b/src/test/java/vavi/sound/adpcm/ma/MaInputStreamTest.java index 74422eb..f05a895 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.util.logging.Level; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioSystem; import javax.sound.sampled.DataLine; @@ -45,7 +46,7 @@ public class MaInputStreamTest { public void setup() throws IOException { outFile = File.createTempFile("vavi", ".pcm"); outFile.deleteOnExit(); -Debug.println("outFile: " + outFile); +Debug.println(Level.FINE, "outFile: " + outFile); } /** */ @@ -67,7 +68,7 @@ public void test1() throws Exception { 2, sampleRate, byteOrder.equals(ByteOrder.BIG_ENDIAN)); -Debug.println(audioFormat); +Debug.println(Level.FINE, audioFormat); InputStream is = new MaInputStream(in, ByteOrder.LITTLE_ENDIAN); OutputStream os = new BufferedOutputStream(Files.newOutputStream(outFile.toPath())); @@ -76,7 +77,7 @@ public void test1() throws Exception { SourceDataLine line = (SourceDataLine) AudioSystem.getLine(info); line.open(audioFormat); line.addLineListener(ev -> { -Debug.println(ev.getType()); +Debug.println(Level.FINE, ev.getType()); if (LineEvent.Type.STOP == ev.getType()) { } }); diff --git a/src/test/java/vavi/sound/adpcm/ma/MaOutputStreamTest.java b/src/test/java/vavi/sound/adpcm/ma/MaOutputStreamTest.java index 5a8f501..d4300a1 100644 --- a/src/test/java/vavi/sound/adpcm/ma/MaOutputStreamTest.java +++ b/src/test/java/vavi/sound/adpcm/ma/MaOutputStreamTest.java @@ -12,6 +12,7 @@ import java.io.OutputStream; import java.nio.ByteOrder; import java.nio.file.Files; +import java.util.logging.Level; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -39,7 +40,7 @@ public class MaOutputStreamTest { public void setup() throws IOException { outFile = File.createTempFile("vavi", ".pcm"); outFile.deleteOnExit(); -Debug.println("outFile: " + outFile); +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 edb88f6..2a2de05 100644 --- a/src/test/java/vavi/sound/adpcm/ms/MsInputStreamTest.java +++ b/src/test/java/vavi/sound/adpcm/ms/MsInputStreamTest.java @@ -10,18 +10,17 @@ import java.io.BufferedOutputStream; import java.io.ByteArrayInputStream; import java.io.File; -import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.nio.ByteOrder; import java.nio.file.Files; +import java.util.logging.Level; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioSystem; import javax.sound.sampled.DataLine; import javax.sound.sampled.LineEvent; -import javax.sound.sampled.LineListener; import javax.sound.sampled.SourceDataLine; import org.junit.jupiter.api.BeforeEach; @@ -53,7 +52,7 @@ public class MsInputStreamTest { public void setup() throws IOException { outFile = File.createTempFile("vavi", ".pcm"); outFile.deleteOnExit(); -Debug.println("outFile: " + outFile); +Debug.println(Level.FINE, "outFile: " + outFile); } /** @@ -75,20 +74,20 @@ public void test1() throws Exception { throw new IllegalArgumentException("not Microsoft ADPCM"); } LittleEndianDataInputStream ledis = new LittleEndianDataInputStream(new ByteArrayInputStream(format.getExtended())); -Debug.println("ext size: " + ledis.available()); +Debug.println(Level.FINE, "ext size: " + ledis.available()); int samplesPerBlock = ledis.readShort(); int nCoefs = ledis.readShort(); int[][] iCoefs = new int[nCoefs][2]; for (int i = 0; i < nCoefs; i++) { for (int j = 0; j < 2; j++) { iCoefs[i][j] = ledis.readShort(); -Debug.printf("iCoef[%d][%d]: %04x: %d\n", i, j, iCoefs[i][j], iCoefs[i][j]); +Debug.printf(Level.FINE, "iCoef[%d][%d]: %04x: %d\n", i, j, iCoefs[i][j], iCoefs[i][j]); } } ledis.close(); WAVE.data data = wave.findChildOf(WAVE.data.class); in = new ByteArrayInputStream(data.getWave()); -Debug.println("wave: " + in.available()); +Debug.println(Level.FINE, "wave: " + in.available()); //---- @@ -105,7 +104,7 @@ public void test1() throws Exception { byteOrder.equals(ByteOrder.BIG_ENDIAN)); System.err.println(audioFormat); -Debug.printf("samplesPerBlock: %d, numberChannels: %d, blockSize: %d\n", samplesPerBlock, format.getNumberChannels(), format.getBlockSize()); +Debug.printf(Level.FINE, "samplesPerBlock: %d, numberChannels: %d, blockSize: %d\n", samplesPerBlock, format.getNumberChannels(), format.getBlockSize()); InputStream is = new MsInputStream(in, samplesPerBlock, nCoefs, @@ -119,7 +118,7 @@ public void test1() throws Exception { SourceDataLine line = (SourceDataLine) AudioSystem.getLine(info); line.open(audioFormat); line.addLineListener(ev -> { -Debug.println(ev.getType()); +Debug.println(Level.FINE, ev.getType()); if (LineEvent.Type.STOP == ev.getType()) { } }); diff --git a/src/test/java/vavi/sound/adpcm/ms/MsOutputStreamTest.java b/src/test/java/vavi/sound/adpcm/ms/MsOutputStreamTest.java index 9558973..c4ccbf2 100644 --- a/src/test/java/vavi/sound/adpcm/ms/MsOutputStreamTest.java +++ b/src/test/java/vavi/sound/adpcm/ms/MsOutputStreamTest.java @@ -14,11 +14,10 @@ import java.io.InputStream; import java.io.OutputStream; import java.nio.file.Files; +import java.util.logging.Level; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioSystem; import javax.sound.sampled.DataLine; -import javax.sound.sampled.LineEvent; -import javax.sound.sampled.LineListener; import javax.sound.sampled.SourceDataLine; import org.junit.jupiter.api.BeforeEach; @@ -50,7 +49,7 @@ public void setup() throws IOException { outFile = File.createTempFile("vavi", ".pcm"); outFile.deleteOnExit(); // outFile = new File("src/test/resources/vavi/sound/adpcm/ms/out_vavi.adpcm"); -Debug.println("outFile: " + outFile); +Debug.println(Level.FINE, "outFile: " + outFile); } /** */ @@ -72,7 +71,7 @@ public void test1() throws Exception { os.flush(); os.close(); -Debug.println("outFile: " + outFile.length()); +Debug.println(Level.FINE, "outFile: " + outFile.length()); assertEquals(Checksum.getChecksum(getClass().getResourceAsStream(correctFile)), Checksum.getChecksum(outFile)); } @@ -95,7 +94,7 @@ public void test2() throws Exception { os.flush(); os.close(); -Debug.println("outFile: " + outFile.length()); +Debug.println(Level.FINE, "outFile: " + outFile.length()); assertEquals(Checksum.getChecksum(getClass().getResourceAsStream(correctFile)), Checksum.getChecksum(outFile)); } @@ -115,7 +114,7 @@ public void test3() throws Exception { int length = in.available(); int spb = 500; int ll = 0; -Debug.println("inFile: " + length); +Debug.println(Level.FINE, "inFile: " + length); while (ll < length) { int bpb = Ms.getBytesPerBlock(1, spb); byte[] buffer = new byte[spb * 2]; @@ -144,7 +143,7 @@ public void test3() throws Exception { os.flush(); os.close(); -Debug.println("outFile: " + outFile.length()); +Debug.println(Level.FINE, "outFile: " + outFile.length()); InputStream is = new MsInputStream(new BufferedInputStream(Files.newInputStream(outFile.toPath())), spb, diff --git a/src/test/java/vavi/sound/adpcm/oki/OkiInputStreamTest.java b/src/test/java/vavi/sound/adpcm/oki/OkiInputStreamTest.java index d5113a2..976d863 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.util.logging.Level; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioSystem; import javax.sound.sampled.DataLine; @@ -43,7 +44,7 @@ public class OkiInputStreamTest { public void setup() throws IOException { outFile = File.createTempFile("vavi", ".pcm"); outFile.deleteOnExit(); -Debug.println("outFile: " + outFile); +Debug.println(Level.FINE, "outFile: " + outFile); } /** */ diff --git a/src/test/java/vavi/sound/adpcm/oki/OkiOutputStreamTest.java b/src/test/java/vavi/sound/adpcm/oki/OkiOutputStreamTest.java index 57e4727..f000d90 100644 --- a/src/test/java/vavi/sound/adpcm/oki/OkiOutputStreamTest.java +++ b/src/test/java/vavi/sound/adpcm/oki/OkiOutputStreamTest.java @@ -12,6 +12,7 @@ import java.io.OutputStream; import java.nio.ByteOrder; import java.nio.file.Files; +import java.util.logging.Level; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -39,7 +40,7 @@ public class OkiOutputStreamTest { public void setup() throws IOException { outFile = File.createTempFile("vavi", ".pcm"); outFile.deleteOnExit(); -Debug.println("outFile: " + outFile); +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 039a92f..cb6aa32 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.util.logging.Level; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioSystem; import javax.sound.sampled.DataLine; @@ -45,7 +46,7 @@ public class RohmInputStreamTest { public void setup() throws IOException { outFile = File.createTempFile("vavi", ".pcm"); outFile.deleteOnExit(); -Debug.println("outFile: " + outFile); +Debug.println(Level.FINE, "outFile: " + outFile); } /** */ diff --git a/src/test/java/vavi/sound/adpcm/rohm/RohmOutputStreamTest.java b/src/test/java/vavi/sound/adpcm/rohm/RohmOutputStreamTest.java index d0a7160..05b4428 100644 --- a/src/test/java/vavi/sound/adpcm/rohm/RohmOutputStreamTest.java +++ b/src/test/java/vavi/sound/adpcm/rohm/RohmOutputStreamTest.java @@ -12,6 +12,7 @@ import java.io.OutputStream; import java.nio.ByteOrder; import java.nio.file.Files; +import java.util.logging.Level; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -39,7 +40,7 @@ public class RohmOutputStreamTest { public void setup() throws IOException { outFile = File.createTempFile("vavi", ".pcm"); outFile.deleteOnExit(); -Debug.println("outFile: " + outFile); +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 6c923ad..2cd6e9c 100644 --- a/src/test/java/vavi/sound/adpcm/vox/VoxInputStreamTest.java +++ b/src/test/java/vavi/sound/adpcm/vox/VoxInputStreamTest.java @@ -14,6 +14,7 @@ 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; import javax.sound.sampled.DataLine; @@ -45,7 +46,7 @@ public class VoxInputStreamTest { public void setup() throws IOException { outFile = File.createTempFile("vavi", ".pcm"); outFile.deleteOnExit(); -Debug.println("outFile: " + outFile); +Debug.println(Level.FINE, "outFile: " + outFile); } /** */ diff --git a/src/test/java/vavi/sound/adpcm/vox/VoxOutputStreamTest.java b/src/test/java/vavi/sound/adpcm/vox/VoxOutputStreamTest.java index ab72332..551efdb 100644 --- a/src/test/java/vavi/sound/adpcm/vox/VoxOutputStreamTest.java +++ b/src/test/java/vavi/sound/adpcm/vox/VoxOutputStreamTest.java @@ -12,6 +12,7 @@ import java.io.OutputStream; import java.nio.ByteOrder; import java.nio.file.Files; +import java.util.logging.Level; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -39,7 +40,7 @@ public class VoxOutputStreamTest { public void setup() throws IOException { outFile = File.createTempFile("vavi", ".pcm"); outFile.deleteOnExit(); -Debug.println("outFile: " + outFile); +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 58d902a..a216bd0 100644 --- a/src/test/java/vavi/sound/adpcm/yamaha/YamahaInputStreamTest.java +++ b/src/test/java/vavi/sound/adpcm/yamaha/YamahaInputStreamTest.java @@ -16,6 +16,7 @@ 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; import javax.sound.sampled.DataLine; @@ -48,7 +49,7 @@ public class YamahaInputStreamTest { public void setup() throws IOException { outFile = File.createTempFile("vavi", ".pcm"); outFile.deleteOnExit(); -Debug.println("outFile: " + outFile); +Debug.println(Level.FINE, "outFile: " + outFile); } /** */ @@ -107,7 +108,7 @@ public static void main(String[] args) throws Exception { } WAVE.data data = wave.findChildOf(WAVE.data.class); in = new ByteArrayInputStream(data.getWave()); -Debug.println("wave: " + in.available()); +Debug.println(Level.FINE, "wave: " + in.available()); //---- @@ -133,7 +134,7 @@ public static void main(String[] args) throws Exception { SourceDataLine line = (SourceDataLine) AudioSystem.getLine(info); line.open(audioFormat); line.addLineListener(ev -> { -Debug.println(ev.getType()); +Debug.println(Level.FINE, ev.getType()); if (LineEvent.Type.STOP == ev.getType()) { System.exit(0); } diff --git a/src/test/java/vavi/sound/adpcm/yamaha/YamahaOutputStreamTest.java b/src/test/java/vavi/sound/adpcm/yamaha/YamahaOutputStreamTest.java index 3a02aa3..c382f6c 100644 --- a/src/test/java/vavi/sound/adpcm/yamaha/YamahaOutputStreamTest.java +++ b/src/test/java/vavi/sound/adpcm/yamaha/YamahaOutputStreamTest.java @@ -13,6 +13,7 @@ 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; import javax.sound.sampled.DataLine; @@ -45,7 +46,7 @@ public class YamahaOutputStreamTest { public void setup() throws IOException { outFile = File.createTempFile("vavi", ".pcm"); outFile.deleteOnExit(); -Debug.println("outFile: " + outFile); +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 e190abb..65f6b2a 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.util.logging.Level; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioSystem; import javax.sound.sampled.DataLine; @@ -44,7 +45,7 @@ public void setup() throws IOException { outFile = File.createTempFile("vavi", ".pcm"); outFile.deleteOnExit(); // outFile = new File("src/test/resources/vavi/sound/adpcm/ym2608/out_vavi.pcm"); -Debug.println("outFile: " + outFile); +Debug.println(Level.FINE, "outFile: " + outFile); } @Test diff --git a/src/test/java/vavi/sound/adpcm/ym2608/Ym2608OutputStreamTest.java b/src/test/java/vavi/sound/adpcm/ym2608/Ym2608OutputStreamTest.java index 00476e1..ccd8478 100644 --- a/src/test/java/vavi/sound/adpcm/ym2608/Ym2608OutputStreamTest.java +++ b/src/test/java/vavi/sound/adpcm/ym2608/Ym2608OutputStreamTest.java @@ -12,6 +12,7 @@ import java.io.OutputStream; import java.nio.ByteOrder; import java.nio.file.Files; +import java.util.logging.Level; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -40,7 +41,7 @@ public void setup() throws IOException { outFile = File.createTempFile("vavi", ".pcm"); outFile.deleteOnExit(); // outFile = new File("src/test/resources/vavi/sound/adpcm/ym2608/out_vavi.adpcm"); -Debug.println("outFile: " + outFile); +Debug.println(Level.FINE, "outFile: " + outFile); } @Test diff --git a/src/test/java/vavi/sound/mfi/MfiSystemTest.java b/src/test/java/vavi/sound/mfi/MfiSystemTest.java index adc45e0..90f6d03 100644 --- a/src/test/java/vavi/sound/mfi/MfiSystemTest.java +++ b/src/test/java/vavi/sound/mfi/MfiSystemTest.java @@ -12,6 +12,7 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.concurrent.CountDownLatch; +import java.util.logging.Level; import org.junit.jupiter.api.Test; @@ -35,7 +36,7 @@ public void test() throws Exception { Sequence sequence = MfiSystem.getSequence(new BufferedInputStream(Files.newInputStream(inPath))); sequencer.setSequence(sequence); sequencer.addMetaEventListener(meta -> { -Debug.println(meta.getType()); +Debug.println(Level.FINE, meta.getType()); if (meta.getType() == 47) { cdl.countDown(); } @@ -56,19 +57,19 @@ public static void main(String[] args) throws Exception { Sequencer sequencer = MfiSystem.getSequencer(); sequencer.open(); for (int i = 0; i < args.length; i++) { -Debug.println("START: " + args[i]); +Debug.println(Level.FINE, "START: " + args[i]); Sequence sequence = MfiSystem.getSequence(new File(args[i])); sequencer.setSequence(sequence); if (i == args.length - 1) { sequencer.addMetaEventListener(meta -> { -Debug.println(meta.getType()); +Debug.println(Level.FINE, meta.getType()); if (meta.getType() == 47) { sequencer.close(); } }); } sequencer.start(); -Debug.println("END: " + args[i]); +Debug.println(Level.FINE, "END: " + args[i]); } } } diff --git a/src/test/java/vavi/sound/mfi/vavi/MfiContextTest.java b/src/test/java/vavi/sound/mfi/vavi/MfiContextTest.java index ba15bcd..62fa80d 100644 --- a/src/test/java/vavi/sound/mfi/vavi/MfiContextTest.java +++ b/src/test/java/vavi/sound/mfi/vavi/MfiContextTest.java @@ -11,6 +11,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.logging.Level; import javax.sound.midi.MidiFileFormat; import javax.sound.midi.MidiSystem; @@ -46,11 +47,11 @@ public void test() throws Exception { javax.sound.midi.Sequence midiSequence = MidiSystem.getSequence(new BufferedInputStream(Files.newInputStream(inPath))); MidiFileFormat midiFileFormat = MidiSystem.getMidiFileFormat(new BufferedInputStream(Files.newInputStream(inPath))); int type = midiFileFormat.getType(); -Debug.println("type: " + type); +Debug.println(Level.FINE, "type: " + type); vavi.sound.mfi.Sequence mfiSequence = MfiSystem.toMfiSequence(midiSequence, type); Path outPath = dir.resolve("MfiContextTest.mld"); int r = MfiSystem.write(mfiSequence, VaviMfiFileFormat.FILE_TYPE, Files.newOutputStream(outPath)); -Debug.println("write: " + r); +Debug.println(Level.FINE, "write: " + r); } //------------------------------------------------------------------------- @@ -64,18 +65,18 @@ public void test() throws Exception { */ public static void main(String[] args) throws Exception { -Debug.println("midi in: " + args[0]); -Debug.println("mfi out: " + args[1]); +Debug.println(Level.FINE, "midi in: " + args[0]); +Debug.println(Level.FINE, "mfi out: " + args[1]); File file = new File(args[0]); javax.sound.midi.Sequence midiSequence = MidiSystem.getSequence(file); MidiFileFormat midiFileFormat = MidiSystem.getMidiFileFormat(file); int type = midiFileFormat.getType(); -Debug.println("type: " + type); +Debug.println(Level.FINE, "type: " + type); vavi.sound.mfi.Sequence mfiSequence = MfiSystem.toMfiSequence(midiSequence, type); file = new File(args[1]); int r = MfiSystem.write(mfiSequence, VaviMfiFileFormat.FILE_TYPE, file); -Debug.println("write: " + r); +Debug.println(Level.FINE, "write: " + r); System.exit(0); } diff --git a/src/test/java/vavi/sound/mfi/vavi/VaviMfiFileWriterTest.java b/src/test/java/vavi/sound/mfi/vavi/VaviMfiFileWriterTest.java index 4f67517..29bcf5a 100644 --- a/src/test/java/vavi/sound/mfi/vavi/VaviMfiFileWriterTest.java +++ b/src/test/java/vavi/sound/mfi/vavi/VaviMfiFileWriterTest.java @@ -12,6 +12,7 @@ import java.io.InputStream; import java.nio.file.Files; import java.nio.file.Paths; +import java.util.logging.Level; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -64,7 +65,7 @@ public void test1() throws Exception { throw new IllegalArgumentException("not PCM"); } WAVE.data data = wave.findChildOf(WAVE.data.class); -Debug.println("wave: " + data.getWave().length); +Debug.println(Level.FINE, "wave: " + data.getWave().length); int samplingRate = format.getSamplingRate(); int samplingBits = format.getSamplingBits(); @@ -74,10 +75,10 @@ public void test1() throws Exception { } int bytesPerSecond = samplingRate * samplingBits / 8; -Debug.println("bytesPerSecond: " + bytesPerSecond); -Debug.println("fmt.bytesPerSecond: " + format.getBytesPerSecond()); +Debug.println(Level.FINE, "bytesPerSecond: " + bytesPerSecond); +Debug.println(Level.FINE, "fmt.bytesPerSecond: " + format.getBytesPerSecond()); double time = (double) data.getWave().length / bytesPerSecond * 1000; -Debug.println("time: " + time + " ms"); +Debug.println(Level.FINE, "time: " + time + " ms"); //---- @@ -90,7 +91,7 @@ public void test1() throws Exception { double aDelta = (60d / 120d) / 120d * 1000; int delta = (int) Math.round(time / aDelta); -Debug.println("delta: " + delta); +Debug.println(Level.FINE, "delta: " + delta); message = new TempoMessage(0x00, 0xff, 0xcb, 0x78); track.add(new MfiEvent(message, 0L)); @@ -103,7 +104,7 @@ public void test1() throws Exception { int r = MfiSystem.write(sequence, VaviMfiFileFormat.FILE_TYPE, new File("tmp/out.mid")); -Debug.println("write: " + r); +Debug.println(Level.FINE, "write: " + r); } /** diff --git a/src/test/java/vavi/sound/mfi/vavi/VaviMidiConverterTest.java b/src/test/java/vavi/sound/mfi/vavi/VaviMidiConverterTest.java index 25ce599..c9751f2 100644 --- a/src/test/java/vavi/sound/mfi/vavi/VaviMidiConverterTest.java +++ b/src/test/java/vavi/sound/mfi/vavi/VaviMidiConverterTest.java @@ -12,6 +12,7 @@ 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; @@ -40,9 +41,9 @@ public void test() throws Exception { Sequence midiSequence = MfiSystem.toMidiSequence(mfiSequence); Sequencer midiSequencer = MidiSystem.getSequencer(); -Debug.println("midiSequencer: " + midiSequencer); -Debug.println("midiSequencer:T: " + midiSequencer.getTransmitter()); -Debug.println("midiSequencer:R: " + midiSequencer.getReceiver()); +Debug.println(Level.FINE, "midiSequencer: " + midiSequencer); +Debug.println(Level.FINE, "midiSequencer:T: " + midiSequencer.getTransmitter()); +Debug.println(Level.FINE, "midiSequencer:R: " + midiSequencer.getReceiver()); midiSequencer.open(); midiSequencer.setSequence(midiSequence); midiSequencer.addMetaEventListener(meta -> { @@ -84,9 +85,9 @@ public static void main(String[] args) throws Exception { Sequence midiSequence = MfiSystem.toMidiSequence(mfiSequence); Sequencer midiSequencer = MidiSystem.getSequencer(); -Debug.println("midiSequencer: " + midiSequencer); -Debug.println("midiSequencer:T: " + midiSequencer.getTransmitter()); -Debug.println("midiSequencer:R: " + midiSequencer.getReceiver()); +Debug.println(Level.FINE, "midiSequencer: " + midiSequencer); +Debug.println(Level.FINE, "midiSequencer:T: " + midiSequencer.getTransmitter()); +Debug.println(Level.FINE, "midiSequencer:R: " + midiSequencer.getReceiver()); midiSequencer.open(); midiSequencer.setSequence(midiSequence); @@ -101,18 +102,18 @@ public static void main(String[] args) throws Exception { midiSequencer.close(); if (convert) { -Debug.println("types: " + ts.length); int[] ts = MidiSystem.getMidiFileTypes(midiSequence); +Debug.println(Level.FINE, "types: " + ts.length); if (ts.length == 0) { throw new IllegalArgumentException("no support type"); } -Debug.printf("type: 0x%02x\n", ts[i]); for (int t : ts) { + Debug.printf(Level.FINE, "type: 0x%02x\n", t); } file = new File(args[2]); int r = MidiSystem.write(midiSequence, 0, file); -Debug.println("write: " + r); +Debug.println(Level.FINE, "write: " + r); } System.exit(0); diff --git a/src/test/java/vavi/sound/midi/MidiUtilTest.java b/src/test/java/vavi/sound/midi/MidiUtilTest.java index e4cbe0d..b360e24 100644 --- a/src/test/java/vavi/sound/midi/MidiUtilTest.java +++ b/src/test/java/vavi/sound/midi/MidiUtilTest.java @@ -11,6 +11,7 @@ import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.File; +import java.util.logging.Level; import javax.sound.midi.MidiSystem; import javax.sound.midi.Sequence; import javax.sound.midi.Sequencer; @@ -71,10 +72,10 @@ public static void main(String[] args) throws Exception { File file = new File(args[0]); Sequence sequence = MidiSystem.getSequence(file); -Debug.println("sequence: " + sequence); +Debug.println(Level.FINE, "sequence: " + sequence); Sequencer sequencer = MidiSystem.getSequencer(); -Debug.println("sequencer: " + sequencer); +Debug.println(Level.FINE, "sequencer: " + sequencer); sequencer.open(); sequencer.setSequence(sequence); sequencer.start(); diff --git a/src/test/java/vavi/sound/sampled/adpcm/ccitt/G721AudioFileReaderTest.java b/src/test/java/vavi/sound/sampled/adpcm/ccitt/G721AudioFileReaderTest.java index d7c57a1..41f89c8 100644 --- a/src/test/java/vavi/sound/sampled/adpcm/ccitt/G721AudioFileReaderTest.java +++ b/src/test/java/vavi/sound/sampled/adpcm/ccitt/G721AudioFileReaderTest.java @@ -12,6 +12,7 @@ import java.io.OutputStream; import java.nio.ByteOrder; import java.nio.file.Files; +import java.util.logging.Level; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioSystem; @@ -43,7 +44,7 @@ public class G721AudioFileReaderTest { public void setup() throws IOException { outFile = File.createTempFile("vavi", ".pcm"); outFile.deleteOnExit(); -Debug.println("outFile: " + outFile); +Debug.println(Level.FINE, "outFile: " + outFile); } @Test diff --git a/src/test/java/vavi/sound/sampled/adpcm/rhom/RohmAudioFileReaderTest.java b/src/test/java/vavi/sound/sampled/adpcm/rhom/RohmAudioFileReaderTest.java index 7712194..45713ce 100644 --- a/src/test/java/vavi/sound/sampled/adpcm/rhom/RohmAudioFileReaderTest.java +++ b/src/test/java/vavi/sound/sampled/adpcm/rhom/RohmAudioFileReaderTest.java @@ -12,6 +12,7 @@ import java.io.OutputStream; import java.nio.ByteOrder; import java.nio.file.Files; +import java.util.logging.Level; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioSystem; @@ -44,7 +45,7 @@ public class RohmAudioFileReaderTest { public void setup() throws IOException { outFile = File.createTempFile("vavi", ".pcm"); outFile.deleteOnExit(); -Debug.println("outFile: " + outFile); +Debug.println(Level.FINE, "outFile: " + outFile); } @Test diff --git a/src/test/java/vavi/sound/sampled/adpcm/vox/VoxAudioFileReaderTest.java b/src/test/java/vavi/sound/sampled/adpcm/vox/VoxAudioFileReaderTest.java index 1dd6344..1a01c83 100644 --- a/src/test/java/vavi/sound/sampled/adpcm/vox/VoxAudioFileReaderTest.java +++ b/src/test/java/vavi/sound/sampled/adpcm/vox/VoxAudioFileReaderTest.java @@ -12,6 +12,7 @@ import java.io.OutputStream; import java.nio.ByteOrder; import java.nio.file.Files; +import java.util.logging.Level; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioSystem; @@ -43,7 +44,7 @@ public class VoxAudioFileReaderTest { public void setup() throws IOException { outFile = File.createTempFile("vavi", ".pcm"); outFile.deleteOnExit(); -Debug.println("outFile: " + outFile); +Debug.println(Level.FINE, "outFile: " + outFile); } @Test diff --git a/src/test/java/vavi/sound/smaf/message/SmafContextTest.java b/src/test/java/vavi/sound/smaf/message/SmafContextTest.java index 7d35c5e..918e608 100644 --- a/src/test/java/vavi/sound/smaf/message/SmafContextTest.java +++ b/src/test/java/vavi/sound/smaf/message/SmafContextTest.java @@ -11,6 +11,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.logging.Level; import javax.sound.midi.MidiFileFormat; import javax.sound.midi.MidiSystem; @@ -46,12 +47,12 @@ public void test() throws Exception { javax.sound.midi.Sequence midiSequence = MidiSystem.getSequence(new BufferedInputStream(Files.newInputStream(inPath))); MidiFileFormat midiFileFormat = MidiSystem.getMidiFileFormat(new BufferedInputStream(Files.newInputStream(inPath))); int type = midiFileFormat.getType(); -Debug.println("type: " + type); +Debug.println(Level.FINE, "type: " + type); vavi.sound.smaf.Sequence smafSequence = SmafSystem.toSmafSequence(midiSequence, type); Path outPath = dir.resolve("SmafContextTest.mmf"); int r = SmafSystem.write(smafSequence, 0, Files.newOutputStream(outPath)); -Debug.println("write: " + r); +Debug.println(Level.FINE, "write: " + r); } //------------------------------------------------------------------------- diff --git a/src/test/resources/logging.properties b/src/test/resources/logging.properties index 6e1b800..276bce7 100644 --- a/src/test/resources/logging.properties +++ b/src/test/resources/logging.properties @@ -1,15 +1,7 @@ handlers=java.util.logging.ConsoleHandler -.level=ALL -# Limit the message that are printed on the console to INFO and above. +.level=INFO java.util.logging.ConsoleHandler.level=ALL -#java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter -# %1:date/time %2:className and methodName %3logName %4:level %5:message %6:errormessage -#java.util.logging.SimpleFormatter.format=%1$tY/%1$tm/%1$td %1$tH:%1$tM:%1$tS.%1$tL [%4$s] %5$s %6$s%n +java.util.logging.ConsoleHandler.formatter=vavi.util.logging.VaviFormatter -# HttpUrlConnection -#java.util.logging.ConsoleHandler.level=ALL -#sun.net.www.protocol.http.HttpURLConnection.level=ALL -org.junit.level=INFO +#vavi.util.level=FINE -java.util.logging.ConsoleHandler.formatter=vavi.util.logging.VaviFormatter -#java.util.logging.ConsoleHandler.formatter=vavi.util.logging.BetterFormatter From 36bffd850a920617bee3a42a146b0544ec839086 Mon Sep 17 00:00:00 2001 From: Naohide Sano Date: Tue, 13 Dec 2022 19:08:13 +0900 Subject: [PATCH 7/7] bump version --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 153ce11..d7c443b 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ vavi vavi-sound - 1.0.14 + 1.0.15 Vavi Sound API https://github.com/umjammer/vavi-sound @@ -157,7 +157,7 @@ TODO vavi vavi-sound-nda - 1.0.12 + 1.0.13 com.github.umjammer