OSDN Git Service

Java8で新設されたBase64クラスを使うようにし、apache commons codec ライブラリの使用をとりやめた。
authorAkiyoshi Kamide <kamide@yk.rim.or.jp>
Thu, 22 Sep 2016 12:18:52 +0000 (21:18 +0900)
committerAkiyoshi Kamide <kamide@yk.rim.or.jp>
Thu, 22 Sep 2016 12:18:52 +0000 (21:18 +0900)
16 files changed:
.classpath
.settings/de.loskutov.anyedit.AnyEditTools.prefs [new file with mode: 0644]
.settings/org.eclipse.jdt.core.prefs
.settings/org.eclipse.ltk.core.refactoring.prefs [new file with mode: 0644]
lib/commons-codec-1.4.jar [deleted file]
src/camidion/chordhelper/ChordHelperApplet.java
src/camidion/chordhelper/chordmatrix/package-info.java
src/camidion/chordhelper/mididevice/package-info.java
src/camidion/chordhelper/midieditor/Base64Dialog.java
src/camidion/chordhelper/midieditor/MidiSequenceEditorDialog.java
src/camidion/chordhelper/music/AbstractNoteTrackSpec.java
src/camidion/chordhelper/music/AbstractTrackSpec.java
src/camidion/chordhelper/music/ChordProgression.java
src/camidion/chordhelper/music/DrumTrackSpec.java
src/camidion/chordhelper/music/FirstTrackSpec.java
src/camidion/chordhelper/music/MelodyTrackSpec.java

index 70858d0..fceb480 100644 (file)
@@ -2,6 +2,5 @@
 <classpath>
        <classpathentry kind="src" path="src"/>
        <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
-       <classpathentry kind="lib" path="lib/commons-codec-1.4.jar"/>
        <classpathentry kind="output" path="bin"/>
 </classpath>
diff --git a/.settings/de.loskutov.anyedit.AnyEditTools.prefs b/.settings/de.loskutov.anyedit.AnyEditTools.prefs
new file mode 100644 (file)
index 0000000..c9ca2a9
--- /dev/null
@@ -0,0 +1,18 @@
+activeContentFilterList=*.makefile,makefile,*.Makefile,Makefile,Makefile.*,*.mk,MANIFEST.MF,.project
+addNewLine=true
+convertActionOnSaave=AnyEdit.CnvrtTabToSpaces
+eclipse.preferences.version=1
+fixLineDelimiters=false
+ignoreBlankLinesWhenTrimming=false
+inActiveContentFilterList=
+javaTabWidthForJava=true
+org.eclipse.jdt.ui.editor.tab.width=2
+projectPropsEnabled=false
+removeTrailingSpaces=true
+replaceAllSpaces=false
+replaceAllTabs=false
+saveAndAddLine=false
+saveAndConvert=false
+saveAndFixLineDelimiters=false
+saveAndTrim=true
+useModulo4Tabs=false
index 0c68a61..a698e59 100644 (file)
@@ -1,7 +1,12 @@
 eclipse.preferences.version=1
 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
 org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
 org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
 org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
 org.eclipse.jdt.core.compiler.source=1.8
diff --git a/.settings/org.eclipse.ltk.core.refactoring.prefs b/.settings/org.eclipse.ltk.core.refactoring.prefs
new file mode 100644 (file)
index 0000000..b196c64
--- /dev/null
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false
diff --git a/lib/commons-codec-1.4.jar b/lib/commons-codec-1.4.jar
deleted file mode 100644 (file)
index 458d432..0000000
Binary files a/lib/commons-codec-1.4.jar and /dev/null differ
index e480e34..9278f74 100644 (file)
@@ -148,9 +148,9 @@ public class ChordHelperApplet extends JApplet {
                d.setBase64Data(base64EncodedText);
                try {
                        return playlistModel.addSequence(d.getMIDIData(), filename);
-               } catch (IOException | InvalidMidiDataException e) {
+               } catch (Exception e) {
                        e.printStackTrace();
-                       midiEditor.showWarning(e.getMessage());
+                       midiEditor.showWarning(e.toString());
                        return -1;
                }
        }
@@ -283,7 +283,7 @@ public class ChordHelperApplet extends JApplet {
         */
        public static class VersionInfo {
                public static final String      NAME = "MIDI Chord Helper";
-               public static final String      VERSION = "Ver.20160716.1";
+               public static final String      VERSION = "Ver.20160922.1";
                public static final String      COPYRIGHT = "Copyright (C) 2004-2016";
                public static final String      AUTHER = "@きよし - Akiyoshi Kamide";
                public static final String      URL = "http://www.yk.rim.or.jp/~kamide/music/chordhelper/";
index 73cc514..8c2e1e0 100644 (file)
@@ -1,5 +1,4 @@
 /**
- * コードボタンマトリックス関連のクラスを集めたパッケージです。
- * MIDI Chord Helper の原点である、五度圏順で並んだ演奏しやすいコードボタンを実現します。
+ * 五度圏順で並んだコードボタンマトリックスに関連するクラスを集めたパッケージです。
  */
 package camidion.chordhelper.chordmatrix;
\ No newline at end of file
index 739b7f5..d599632 100644 (file)
@@ -1,9 +1,8 @@
 /**
- * MIDIデバイスのGUI操作を容易にするためのクラスを集めたパッケージです。
- *
- * <p>ドラッグ&ドロップで仮想的なMIDIケーブルを接続できる機能や、
- * MIDIデバイスの一つであるMIDIシーケンサーの録音・再生などのGUIのほか、
- * GUI画面自体をMIDIデバイスとして表示や仮想キーボードを制御できる仮想MIDIデバイスなども含まれます。
+ * MIDIデバイス関連のGUI操作を容易にするためのクラスを集めたパッケージです。
+ * <p>MIDIデバイス同士のケーブル接続をドラッグ&ドロップで操作できるクラス、
+ * コードボタン、ピアノキーボードのGUIを制御できる仮想MIDIデバイスのクラス、
+ * MIDIシーケンサのGUIと接続するクラスなどが含まれます。
  * </p>
  */
 package camidion.chordhelper.mididevice;
\ No newline at end of file
index c2fa1ff..fbb2732 100644 (file)
@@ -1,10 +1,9 @@
 package camidion.chordhelper.midieditor;
 import java.awt.Dimension;
 import java.awt.event.ActionEvent;
-import java.io.IOException;
+import java.util.Base64;
 import java.util.regex.Pattern;
 
-import javax.sound.midi.InvalidMidiDataException;
 import javax.swing.AbstractAction;
 import javax.swing.Action;
 import javax.swing.Box;
@@ -17,8 +16,6 @@ import javax.swing.JPanel;
 import javax.swing.JScrollPane;
 import javax.swing.JTextArea;
 
-import org.apache.commons.codec.binary.Base64;
-
 import camidion.chordhelper.ButtonIcon;
 import camidion.chordhelper.ChordHelperApplet;
 
@@ -35,36 +32,26 @@ public class Base64Dialog extends JDialog {
                "Base64 Decode & Add to PlayList",
                new ButtonIcon(ButtonIcon.EJECT_ICON)
        ) {
-               {
-                       putValue(
-                               Action.SHORT_DESCRIPTION,
-                               "Base64デコードして、プレイリストへ追加"
-                       );
-               }
+               { putValue(Action.SHORT_DESCRIPTION, "Base64デコードして、プレイリストへ追加"); }
                @Override
                public void actionPerformed(ActionEvent event) {
-                       byte[] data = getMIDIData();
-                       if( data == null || data.length == 0 ) {
-                               String message = "No data entered - データが入力されていません。";
-                               JOptionPane.showMessageDialog(
-                                       Base64Dialog.this, message,
-                                       ChordHelperApplet.VersionInfo.NAME,
-                                       JOptionPane.WARNING_MESSAGE
-                               );
-                               base64TextArea.requestFocusInWindow();
-                               return;
-                       }
-                       PlaylistTableModel sltm = midiEditor.sequenceListTable.getModel();
+                       String message = null;
                        try {
-                               sltm.addSequence(data, null);
-                       } catch(IOException | InvalidMidiDataException e) {
-                               String message = "例外 "+e+" が発生しました。"+e.getMessage();
+                               byte[] data = getMIDIData();
+                               if( data == null || data.length == 0 ) {
+                                       message = "No data on textbox - データが入力されていません。";
+                               } else {
+                                       midiEditor.sequenceListTable.getModel().addSequence(data, null);
+                                       setVisible(false);
+                               }
+                       } catch(Exception e) {
                                e.printStackTrace();
-                               midiEditor.showWarning(message);
-                               base64TextArea.requestFocusInWindow();
-                               return;
+                               message = "Base64デコードまたはMIDIデータの読み込みに失敗しました。\n"+e;
                        }
-                       setVisible(false);
+                       if( message == null ) return;
+                       JOptionPane.showMessageDialog(base64TextArea, (Object)message,
+                                       ChordHelperApplet.VersionInfo.NAME, JOptionPane.WARNING_MESSAGE);
+                       base64TextArea.requestFocusInWindow();
                }
        };
        /**
@@ -77,14 +64,14 @@ public class Base64Dialog extends JDialog {
                }
        };
        private static class Base64TextArea extends JTextArea {
-               private static final Pattern headerLine =
+               private static final Pattern headerLineFormat =
                        Pattern.compile( "^.*:.*$", Pattern.MULTILINE );
                public Base64TextArea(int rows, int columns) {
                        super(rows,columns);
                }
                public byte[] getBinary() {
-                       String text = headerLine.matcher(getText()).replaceAll("");
-                       return Base64.decodeBase64(text.getBytes());
+                       String text = headerLineFormat.matcher(getText()).replaceAll("");
+                       return Base64.getMimeDecoder().decode(text.getBytes());
                }
                public void setBinary(byte[] binary_data, String content_type, String filename) {
                        if( binary_data != null && binary_data.length > 0 ) {
@@ -94,7 +81,7 @@ public class Base64Dialog extends JDialog {
                                        header += "Content-Transfer-Encoding: base64\n";
                                        header += "\n";
                                }
-                               setText(header + new String(Base64.encodeBase64Chunked(binary_data)) + "\n");
+                               setText(header + Base64.getMimeEncoder().encodeToString(binary_data) + "\n");
                        }
                }
        }
@@ -105,38 +92,23 @@ public class Base64Dialog extends JDialog {
        public Base64Dialog(MidiSequenceEditorDialog midiEditor) {
                this.midiEditor = midiEditor;
                setTitle("Base64-encoded MIDI sequence - " + ChordHelperApplet.VersionInfo.NAME);
-               try {
-                       Base64.decodeBase64("".getBytes());
-                       base64Available = true;
-               } catch( NoClassDefFoundError e ) {
-                       base64Available = false;
-               }
-               if( base64Available ) {
+               add(new JPanel() {{
+                       setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
                        add(new JPanel() {{
-                               setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
-                               add(new JPanel() {{
-                                       setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));
-                                       add(new JLabel("Base64-encoded MIDI sequence:"));
-                                       add(Box.createRigidArea(new Dimension(10, 0)));
-                                       add(new JButton(addBase64Action){{setMargin(ChordHelperApplet.ZERO_INSETS);}});
-                                       add(new JButton(clearAction){{setMargin(ChordHelperApplet.ZERO_INSETS);}});
-                               }});
-                               add(new JScrollPane(base64TextArea));
+                               setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));
+                               add(new JLabel("Base64-encoded MIDI sequence:"));
+                               add(Box.createRigidArea(new Dimension(10, 0)));
+                               add(new JButton(addBase64Action){{setMargin(ChordHelperApplet.ZERO_INSETS);}});
+                               add(new JButton(clearAction){{setMargin(ChordHelperApplet.ZERO_INSETS);}});
                        }});
-               }
+                       add(new JScrollPane(base64TextArea));
+               }});
                setBounds( 300, 250, 660, 300 );
        }
-       private boolean base64Available;
-       /**
-        * {@link Base64} が使用できるかどうかを返します。
-        * @return Apache Commons Codec ライブラリが利用できる状態ならtrue
-        */
-       public boolean isBase64Available() {
-               return base64Available;
-       }
        /**
         * バイナリー形式でMIDIデータを返します。
         * @return バイナリー形式のMIDIデータ
+        * @throws IllegalArgumentException 入力されているテキストが有効なBase64スキームになっていない場合
         */
        public byte[] getMIDIData() {
                return base64TextArea.getBinary();
index ce5ed60..d78a0b4 100644 (file)
@@ -252,26 +252,24 @@ public class MidiSequenceEditorDialog extends JDialog {
                        setAutoCreateColumnsFromModel(false);
                        //
                        // Base64エンコードアクションの生成
-                       if( base64Dialog.isBase64Available() ) {
-                               base64EncodeAction = new AbstractAction("Base64") {
-                                       {
-                                               String tooltip = "Base64 text conversion - Base64テキスト変換";
-                                               putValue(Action.SHORT_DESCRIPTION, tooltip);
-                                       }
-                                       @Override
-                                       public void actionPerformed(ActionEvent e) {
-                                               SequenceTrackListTableModel mstm = getModel().getSelectedSequenceModel();
-                                               byte[] data = null;
-                                               String filename = null;
-                                               if( mstm != null ) {
-                                                       data = mstm.getMIDIdata();
-                                                       filename = mstm.getFilename();
-                                               }
-                                               base64Dialog.setMIDIData(data, filename);
-                                               base64Dialog.setVisible(true);
+                       base64EncodeAction = new AbstractAction("Base64") {
+                               {
+                                       String tooltip = "Base64 text conversion - Base64テキスト変換";
+                                       putValue(Action.SHORT_DESCRIPTION, tooltip);
+                               }
+                               @Override
+                               public void actionPerformed(ActionEvent e) {
+                                       SequenceTrackListTableModel mstm = getModel().getSelectedSequenceModel();
+                                       byte[] data = null;
+                                       String filename = null;
+                                       if( mstm != null ) {
+                                               data = mstm.getMIDIdata();
+                                               filename = mstm.getFilename();
                                        }
-                               };
-                       }
+                                       base64Dialog.setMIDIData(data, filename);
+                                       base64Dialog.setVisible(true);
+                               }
+                       };
                        TableColumnModel colModel = getColumnModel();
                        for( PlaylistTableModel.Column c : PlaylistTableModel.Column.values() ) {
                                TableColumn tc = colModel.getColumn(c.ordinal());
index 0cedf6a..ba4b3b1 100644 (file)
@@ -22,59 +22,47 @@ public abstract class AbstractNoteTrackSpec extends AbstractTrackSpec {
                midiChannel = ch;
                this.name = name;
        }
-       public AbstractNoteTrackSpec(int ch, String name, int program_no) {
+       public AbstractNoteTrackSpec(int ch, String name, int programNumber) {
                this(ch,name);
-               this.programNumber = program_no;
+               this.programNumber = programNumber;
        }
-       public AbstractNoteTrackSpec(int ch, String name, int program_no, int velocity) {
-               this(ch,name,program_no);
+       public AbstractNoteTrackSpec(int ch, String name, int programNumber, int velocity) {
+               this(ch,name,programNumber);
                this.velocity = velocity;
        }
-       public Track createTrack( Sequence seq, FirstTrackSpec first_track_spec ) {
-               Track track = super.createTrack( seq, first_track_spec );
+       public Track createTrack( Sequence seq, FirstTrackSpec firstTrackSpec ) {
+               Track track = super.createTrack( seq, firstTrackSpec );
                if( programNumber >= 0 ) addProgram( programNumber, 0 );
                return track;
        }
-       public boolean addProgram( int program_no, long tick_pos ) {
-               ShortMessage short_msg;
+       public boolean addProgram( int program_no, long tickPos ) {
+               ShortMessage shortMsg;
                try {
-                       (short_msg = new ShortMessage()).setMessage(
-                               ShortMessage.PROGRAM_CHANGE, midiChannel, program_no, 0
-                       );
+                       (shortMsg = new ShortMessage()).setMessage(ShortMessage.PROGRAM_CHANGE, midiChannel, program_no, 0);
                } catch( InvalidMidiDataException ex ) {
                        ex.printStackTrace();
                        return false;
                }
-               return track.add(new MidiEvent( (MidiMessage)short_msg, tick_pos ));
+               return track.add(new MidiEvent( (MidiMessage)shortMsg, tickPos ));
        }
-       public boolean addNote(long start_tick_pos, long end_tick_pos, int note_no) {
-               return addNote(start_tick_pos, end_tick_pos, note_no, velocity);
+       public boolean addNote(long startTickPos, long endTickPos, int noteNumber) {
+               return addNote(startTickPos, endTickPos, noteNumber, velocity);
        }
-       public boolean addNote(
-               long start_tick_pos, long end_tick_pos,
-               int note_no, int velocity
-       ) {
+       public boolean addNote(long startTickPos, long endTickPos, int noteNumber, int velocity) {
                ShortMessage short_msg;
-               //
                try {
-                       (short_msg = new ShortMessage()).setMessage(
-                               ShortMessage.NOTE_ON, midiChannel, note_no, velocity
-                       );
+                       (short_msg = new ShortMessage()).setMessage(ShortMessage.NOTE_ON, midiChannel, noteNumber, velocity);
                } catch( InvalidMidiDataException ex ) {
                        ex.printStackTrace();
                        return false;
                }
-               if( ! track.add(new MidiEvent( (MidiMessage)short_msg, start_tick_pos )) )
-                       return false;
-               //
+               if( ! track.add(new MidiEvent( (MidiMessage)short_msg, startTickPos )) ) return false;
                try {
-                       (short_msg = new ShortMessage()).setMessage(
-                                       ShortMessage.NOTE_OFF, midiChannel, note_no, velocity
-                                       );
+                       (short_msg = new ShortMessage()).setMessage(ShortMessage.NOTE_OFF, midiChannel, noteNumber, velocity);
                } catch( InvalidMidiDataException ex ) {
                        ex.printStackTrace();
                        return false;
                }
-               return track.add( new MidiEvent( (MidiMessage)short_msg, end_tick_pos ) );
+               return track.add( new MidiEvent( (MidiMessage)short_msg, endTickPos ) );
        }
 }
\ No newline at end of file
index ce7f32f..7447b1a 100644 (file)
@@ -15,10 +15,10 @@ public abstract class AbstractTrackSpec {
        // 最短の音符の長さ(四分音符を何回半分にするか)
        public String name = null;
        Track track = null;
-       FirstTrackSpec first_track_spec = null;
+       FirstTrackSpec firstTrackSpec = null;
        Sequence sequence = null;
        long minNoteTicks = 0;
-       int pre_measures = 2;
+       int preMeasures = 2;
        /**
         * トラック名なしでMIDIトラック仕様を構築します。
         */
@@ -44,7 +44,7 @@ public abstract class AbstractTrackSpec {
         * @return 生成したトラック
         */
        public Track createTrack( Sequence seq, FirstTrackSpec firstTrackSpec ) {
-               this.first_track_spec = firstTrackSpec;
+               this.firstTrackSpec = firstTrackSpec;
                track = (sequence = seq).createTrack();
                if( name != null ) addStringTo( 0x03, name, 0 );
                minNoteTicks = (long)( seq.getResolution() >> 2 );
@@ -79,13 +79,13 @@ public abstract class AbstractTrackSpec {
                return addMetaEventTo( type, str.getBytes(), tickPos );
        }
        public boolean addStringTo( int type, ChordProgression.ChordStroke cs ) {
-               return addStringTo(type, cs.chord.toString(), cs.tick_range.start_tick_pos);
+               return addStringTo(type, cs.chord.toString(), cs.tickRange.startTickPos);
        }
        public boolean addStringTo( int type, ChordProgression.Lyrics lyrics ) {
-               return addStringTo(type, lyrics.text, lyrics.start_tick_pos);
+               return addStringTo(type, lyrics.text, lyrics.startTickPos);
        }
-       public boolean addEOT( long tick_pos ) {
-               return addMetaEventTo( 0x2F, new byte[0], tick_pos );
+       public boolean addEOT( long tickPos ) {
+               return addMetaEventTo( 0x2F, new byte[0], tickPos );
        }
        public void setChordSymbolText( ChordProgression cp ) {
                cp.setChordSymbolTextTo( this );
index f157fe4..d294a96 100644 (file)
@@ -12,34 +12,34 @@ import javax.sound.midi.Sequence;
 public class ChordProgression {
 
        public class TickRange implements Cloneable {
-               long start_tick_pos = 0, end_tick_pos = 0;
+               long startTickPos = 0, end_tick_pos = 0;
                public TickRange( long tick_pos ) {
-                       end_tick_pos = start_tick_pos = tick_pos;
+                       end_tick_pos = startTickPos = tick_pos;
                }
                public TickRange( long start_tick_pos, long end_tick_pos ) {
-                       this.start_tick_pos = start_tick_pos;
+                       this.startTickPos = start_tick_pos;
                        this.end_tick_pos = end_tick_pos;
                }
                protected TickRange clone() {
-                       return new TickRange( start_tick_pos, end_tick_pos );
+                       return new TickRange( startTickPos, end_tick_pos );
                }
                public void moveForward() {
-                       start_tick_pos = end_tick_pos;
+                       startTickPos = end_tick_pos;
                }
                public void moveForward( long duration ) {
-                       start_tick_pos = end_tick_pos;
+                       startTickPos = end_tick_pos;
                        end_tick_pos += duration;
                }
                public long duration() {
-                       return end_tick_pos - start_tick_pos;
+                       return end_tick_pos - startTickPos;
                }
                public boolean contains( long tick ) {
-                       return ( tick >= start_tick_pos && tick < end_tick_pos );
+                       return ( tick >= startTickPos && tick < end_tick_pos );
                }
        }
 
        class ChordStroke {
-               Chord chord; int beat_length; TickRange tick_range = null;
+               Chord chord; int beat_length; TickRange tickRange = null;
                public ChordStroke(Chord chord) { this( chord, 1 ); }
                public ChordStroke(Chord chord, int beat_length) {
                        this.chord = chord;
@@ -55,10 +55,10 @@ public class ChordProgression {
        // 時間位置付き歌詞
        public class Lyrics {
                String text = null;
-               Long start_tick_pos = null;
+               Long startTickPos = null;
                public Lyrics(String text) { this.text = text; }
                public Lyrics(String text, long tick_pos) {
-                       this.text = text; start_tick_pos = tick_pos;
+                       this.text = text; startTickPos = tick_pos;
                }
                public String toString() { return text; }
        }
@@ -127,9 +127,9 @@ public class ChordProgression {
                                = (ChordProgression.ChordStroke)element;
                                // 小節の先頭と末尾の tick を求める
                                if( start_tick_pos < 0 ) {
-                                       start_tick_pos = chord_stroke.tick_range.start_tick_pos;
+                                       start_tick_pos = chord_stroke.tickRange.startTickPos;
                                }
-                               end_tick_pos = chord_stroke.tick_range.end_tick_pos;
+                               end_tick_pos = chord_stroke.tickRange.end_tick_pos;
                        }
                        if( start_tick_pos < 0 || end_tick_pos < 0 ) {
                                return null;
@@ -142,7 +142,7 @@ public class ChordProgression {
                                        continue;
                                ChordProgression.ChordStroke chord_stroke
                                = (ChordProgression.ChordStroke)element;
-                               if( chord_stroke.tick_range.contains(tick) ) {
+                               if( chord_stroke.tickRange.contains(tick) ) {
                                        return chord_stroke;
                                }
                        }
@@ -407,9 +407,9 @@ public class ChordProgression {
        // コード進行の中に時間軸(MIDI tick)を書き込む
        //
        public void setTickPositions( FirstTrackSpec first_track ) {
-               ticks_per_measure = first_track.ticks_per_measure;
+               ticks_per_measure = first_track.ticksPerMeasure;
                TickRange tick_range = new TickRange(
-                               first_track.pre_measures * ticks_per_measure
+                               first_track.preMeasures * ticks_per_measure
                                );
                for( Line line : lines ) { // 行単位の処理
                        for( Measure measure : line ) { // 小節単位の処理
@@ -418,13 +418,13 @@ public class ChordProgression {
                                long tpb = measure.ticks_per_beat = ticks_per_measure / n_beats ;
                                for( Object element : measure ) {
                                        if( element instanceof Lyrics ) {
-                                               ((Lyrics)element).start_tick_pos = tick_range.start_tick_pos;
+                                               ((Lyrics)element).startTickPos = tick_range.startTickPos;
                                                continue;
                                        }
                                        else if( element instanceof ChordStroke ) {
                                                ChordStroke chord_stroke = (ChordStroke)element;
                                                tick_range.moveForward( tpb * chord_stroke.beat_length );
-                                               chord_stroke.tick_range = tick_range.clone();
+                                               chord_stroke.tickRange = tick_range.clone();
                                        }
                                }
                        }
index 12ad3ff..9ab5091 100644 (file)
@@ -78,7 +78,7 @@ public class DrumTrackSpec extends AbstractNoteTrackSpec {
                                ChordProgression.TickRange range = measure.getRange();
                                int mask;
                                for(
-                                               tick = range.start_tick_pos, mask = 0x8000;
+                                               tick = range.startTickPos, mask = 0x8000;
                                                tick < range.end_tick_pos;
                                                tick += minNoteTicks, mask >>>= 1
                                                ) {
index 55008a5..1c7006f 100644 (file)
@@ -6,61 +6,45 @@ import javax.sound.midi.Track;
 // 最初のトラック専用
 //
 public class FirstTrackSpec extends AbstractTrackSpec {
-       static byte default_tempo_data[] = { 0x07, (byte)0xA1, 0x20 };  // 120[QPM]
-       static byte default_timesig_data[] = { 0x04, 0x02, 0x18, 0x08 };        // 4/4
-       byte tempo_data[] = default_tempo_data;
-       byte timesig_data[] = default_timesig_data;
+       private static final byte DEFAULT_TEMPO_DATA[] = { 0x07, (byte)0xA1, 0x20 };    // 120[QPM]
+       private static final byte DEFAULT_TIMESIG_DATA[] = { 0x04, 0x02, 0x18, 0x08 };  // 4/4
+       byte tempoData[] = DEFAULT_TEMPO_DATA;
+       byte timesigData[] = DEFAULT_TIMESIG_DATA;
        Key key = null;
-       long ticks_per_measure;
+       long ticksPerMeasure;
        public FirstTrackSpec() { }
-       public FirstTrackSpec(String name) {
+       public FirstTrackSpec(String name) { this.name = name; }
+       public FirstTrackSpec(String name, byte[] tempoData, byte[] timesigData) {
                this.name = name;
+               if( tempoData != null ) this.tempoData = tempoData;
+               if( timesigData != null ) this.timesigData = timesigData;
        }
-       public FirstTrackSpec(
-               String name, byte[] tempo_data, byte[] timesig_data
-       ) {
-               this.name = name;
-               if( tempo_data != null ) this.tempo_data = tempo_data;
-               if( timesig_data != null ) this.timesig_data = timesig_data;
-       }
-       public FirstTrackSpec(
-               String name, byte[] tempo_data, byte[] timesig_data, Key key
-       ) {
-               this(name,tempo_data,timesig_data);
+       public FirstTrackSpec(String name, byte[] tempoData, byte[] timesigData, Key key) {
+               this(name,tempoData,timesigData);
                this.key = key;
        }
        public Track createTrack(Sequence seq) {
                return createTrack( seq, 0, 0 );
        }
-       public Track createTrack(
-               Sequence seq, int start_measure_pos, int end_measure_pos
-       ) {
-               this.pre_measures = start_measure_pos - 1;
+       public Track createTrack(Sequence seq, int startMeasurePos, int endMeasurePos) {
+               preMeasures = startMeasurePos - 1;
                Track track = super.createTrack( seq, this );
-               addTempo(
-                       this.tempo_data = (
-                               tempo_data == null ? default_tempo_data : tempo_data
-                       ), 0
-               );
-               addTimeSignature(
-                       this.timesig_data = (
-                               timesig_data == null ? default_timesig_data : timesig_data
-                       ), 0
-               );
+               if( tempoData == null ) tempoData = DEFAULT_TEMPO_DATA;
+               addTempo(tempoData, 0);
+               if( timesigData == null ) timesigData = DEFAULT_TIMESIG_DATA;
+               addTimeSignature(timesigData, 0);
                if( key != null ) addKeySignature( key, 0 );
-               ticks_per_measure = (long)(
-                       ( 4 * seq.getResolution() * this.timesig_data[0] ) >> this.timesig_data[1]
-               );
-               addEOT( end_measure_pos * ticks_per_measure );
+               ticksPerMeasure = (long)(( 4 * seq.getResolution() * timesigData[0] ) >> timesigData[1]);
+               addEOT( endMeasurePos * ticksPerMeasure );
                return track;
        }
-       public boolean addKeySignature( Key key, long tick_pos ) {
-               return addMetaEventTo( 0x59, key.getBytes(), tick_pos );
+       public boolean addKeySignature( Key key, long tickPos ) {
+               return addMetaEventTo( 0x59, key.getBytes(), tickPos );
        }
-       public boolean addTempo( byte data[], long tick_pos ) {
-               return addMetaEventTo( 0x51, data, tick_pos );
+       public boolean addTempo( byte data[], long tickPos ) {
+               return addMetaEventTo( 0x51, data, tickPos );
        }
-       public boolean addTimeSignature( byte data[], long tick_pos ) {
-               return addMetaEventTo( 0x58, data, tick_pos );
+       public boolean addTimeSignature( byte data[], long tickPos ) {
+               return addMetaEventTo( 0x58, data, tickPos );
        }
-}
\ No newline at end of file
+}
index 6ebeb38..fc28aa3 100644 (file)
@@ -1,7 +1,5 @@
 package camidion.chordhelper.music;
 
-
-
 /**
  * メロディトラック仕様
  */
@@ -42,8 +40,7 @@ public class MelodyTrackSpec extends AbstractNoteTrackSpec {
         */
        public MelodyTrackSpec(int ch, String name) {
                super(ch,name);
-               range = new Range(
-                       Music.SEMITONES_PER_OCTAVE * 5, Music.SEMITONES_PER_OCTAVE * 6 );
+               range = new Range(Music.SEMITONES_PER_OCTAVE * 5, Music.SEMITONES_PER_OCTAVE * 6 );
        }
        /**
         * 音域を指定してメロディトラック仕様を構築
@@ -80,7 +77,7 @@ public class MelodyTrackSpec extends AbstractNoteTrackSpec {
                                //
                                // 各ビートごとに繰り返し
                                for(
-                                       tick = startTickPos = tickRange.start_tick_pos, mask = 0x8000;
+                                       tick = startTickPos = tickRange.startTickPos, mask = 0x8000;
                                        tick < tickRange.end_tick_pos;
                                        tick += minNoteTicks, mask >>>= 1
                                ) {
@@ -176,37 +173,25 @@ public class MelodyTrackSpec extends AbstractNoteTrackSpec {
                                                                addSysEx(nsx39SysEx, startTickPos);
                                                        }
                                                        // 決定された音符を追加
-                                                       addNote(
-                                                               startTickPos, tick + minNoteTicks,
-                                                               noteNumber, velocity
-                                                       );
+                                                       addNote(startTickPos, tick + minNoteTicks, noteNumber, velocity);
                                                        // 歌詞をテキストとして追加
                                                        addStringTo(0x05, MIDISpec.nsx39LyricElements[index], startTickPos);
                                                }
                                                else {
                                                        // 決定された音符を追加
-                                                       addNote(
-                                                               startTickPos, tick + minNoteTicks,
-                                                               noteNumber, velocity
-                                                       );
+                                                       addNote(startTickPos, tick + minNoteTicks, noteNumber, velocity);
                                                }
                                                prevNoteNumber = noteNumber;
                                        }
                                        else if( isBass ) {
                                                // ベース音を追加
                                                int note = range.invertedNoteOf(chord.bassNoteSymbol().toNoteNumber());
-                                               addNote(
-                                                       startTickPos, tick + minNoteTicks,
-                                                       note, velocity
-                                               );
+                                               addNote(startTickPos, tick + minNoteTicks, note, velocity);
                                        }
                                        else {
                                                // コード本体の音を追加
                                                for( int note : notes ) {
-                                                       addNote(
-                                                               startTickPos, tick + minNoteTicks,
-                                                               note, velocity
-                                                       );
+                                                       addNote(startTickPos, tick + minNoteTicks, note, velocity);
                                                }
                                        }
                                        isNoteOn = false;