*/
public class ChordDisplayLabel extends JLabel {
private String defaultString = null;
+ private String defaultToolTip = null;
private Chord chord = null;
private int noteNumber = -1;
private boolean isDark = false;
/**
* 和音表示ラベルを構築します。
* @param defaultString 初期表示する文字列
+ * @param defaultToolTip 初期設定するツールチップ
* @param chordMatrix このラベルをクリックしたときに鳴らす和音ボタンマトリクス
* @param keyboard このラベルをクリックしたときに鳴らす鍵盤
*/
- public ChordDisplayLabel(String defaultString, ChordMatrix chordMatrix, PianoKeyboard keyboard) {
+ public ChordDisplayLabel(String defaultString, String defaultToolTip, ChordMatrix chordMatrix, PianoKeyboard keyboard) {
super(defaultString, JLabel.CENTER);
this.defaultString = defaultString;
+ setToolTipText(this.defaultToolTip = defaultToolTip);
if( chordMatrix == null ) return;
addMouseListener(new MouseAdapter() {
@Override
this.noteNumber = -1;
if( (this.chord = chord) == null ) {
setText(defaultString);
- setToolTipText(null);
+ setToolTipText(defaultToolTip);
}
else {
setChordText();
* バージョン情報
*/
public static class VersionInfo {
- public static final String NAME = "MIDI Chord Helper";
- public static final String VERSION = "Ver.20170111.1";
- public static final String COPYRIGHT = "Copyright (C) 2004-2017";
- public static final String AUTHER = "@きよし - Akiyoshi Kamide";
- public static final String URL = "http://www.yk.rim.or.jp/~kamide/music/chordhelper/";
- /**
- * バージョン情報を返します。
- * @return バージョン情報
- */
- public static String getInfo() {
- return NAME + " " + VERSION + " " + COPYRIGHT + " " + AUTHER + " " + URL;
- }
+ public static final String NAME = "MIDI Chord Helper";
+ public static final String VERSION = "Ver.20170112.1";
+ public static final String COPYRIGHT = "Copyright (C) 2004-2017";
+ public static final String AUTHER = "@きよし - Akiyoshi Kamide";
+ public static final String URL = "http://www.yk.rim.or.jp/~kamide/music/chordhelper/";
}
@Override
- public String getAppletInfo() { return VersionInfo.getInfo(); }
+ public String getAppletInfo() {
+ return VersionInfo.NAME
+ + " " + VersionInfo.VERSION
+ + " " + VersionInfo.COPYRIGHT
+ + " " + VersionInfo.AUTHER
+ + " " + VersionInfo.URL;
+ }
private class AboutMessagePane extends JEditorPane {
- URI uri = null;
- public AboutMessagePane() { this(true); }
- public AboutMessagePane(boolean link_enabled) {
- super( "text/html", "" );
- String link_string, tooltip = null;
- if( link_enabled && Desktop.isDesktopSupported() ) {
+ URI uri;
+ public AboutMessagePane() {
+ super("text/html", "");
+ boolean linkEnabled = Desktop.isDesktopSupported();
+ String linkString = VersionInfo.URL;
+ String tooltip = null;
+ if( linkEnabled ) {
tooltip = "Click this URL to open with your web browser - URLをクリックしてWebブラウザで開く";
- link_string =
- "<a href=\"" + VersionInfo.URL + "\" title=\"" +
- tooltip + "\">" + VersionInfo.URL + "</a>" ;
+ linkString = "<a href=\""+linkString+"\" title=\""+tooltip+"\">"+linkString+"</a>";
}
- else {
- link_enabled = false; link_string = VersionInfo.URL;
- }
- setText(
- "<html><center><font size=\"+1\">" + VersionInfo.NAME + "</font> " +
- VersionInfo.VERSION + "<br/><br/>" +
- VersionInfo.COPYRIGHT + " " + VersionInfo.AUTHER + "<br/>" +
- link_string + "</center></html>"
- );
+ setText("<html><center><font size=\"+1\">" +
+ VersionInfo.NAME + "</font> " +
+ VersionInfo.VERSION + "<br/><br/>" +
+ VersionInfo.COPYRIGHT + " " +
+ VersionInfo.AUTHER + "<br/>" +
+ linkString + "</center></html>");
setToolTipText(tooltip);
setOpaque(false);
putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
// メッセージ内の <a href=""> ~ </a> によるリンクを
// 実際に機能させる(ブラウザで表示されるようにする)ための設定
//
- if( ! link_enabled ) return;
+ if( ! linkEnabled ) return;
try {
uri = new URI(VersionInfo.URL);
}catch( URISyntaxException use ) {
}
addHyperlinkListener(new HyperlinkListener() {
public void hyperlinkUpdate(HyperlinkEvent e) {
- if(e.getEventType()==HyperlinkEvent.EventType.ACTIVATED) {
+ if( e.getEventType() == HyperlinkEvent.EventType.ACTIVATED ) {
try{
Desktop.getDesktop().browse(uri);
}catch(IOException ioe) {
msg = tickIndex.lastMetaMessageAt(
SequenceTickIndex.MetaMessageType.KEY_SIGNATURE, tickPos
);
- if( msg == null ) {
- keysigLabel.clear();
- }
- else {
- setKeySignature(new Key(msg.getData()));
- }
+ if(msg == null) keysigLabel.clear();
+ else setKeySignature(new Key(msg.getData()));
}
}
}
* コードダイアグラムのタイトルラベル
*/
public ChordDisplayLabel titleLabel =
- new ChordDisplayLabel("Chord Diagram",null,null) {
+ new ChordDisplayLabel(
+ "<html><span style=\"font-size: 170%\">N.C.</span></html>",
+ "Non Chord",null,null
+ ) {
{
setHorizontalAlignment(SwingConstants.CENTER);
setVerticalAlignment(SwingConstants.BOTTOM);
/** コードボタン */
public ChordLabel chordLabels[] = new ChordLabel[N_COLUMNS * CHORD_BUTTON_ROWS];
/** コードボタンの下のコード表示部 */
- public ChordDisplayLabel chordDisplay = new ChordDisplayLabel("Chord Pad", this, null);
+ public ChordDisplayLabel chordDisplay = new ChordDisplayLabel("Chord Pad", null, this, null);
private NoteWeight noteWeightArray[] = new NoteWeight[Note.SEMITONES_PER_OCTAVE];
/**
int i; String s;
// チャンネルメッセージ
for( i = 0x80; i <= 0xE0 ; i += 0x10 ) {
- if( (s = MIDISpec.getStatusName(i)) == null )
- continue;
+ if((s = MIDISpec.getStatusName(i)) == null) continue;
addElement(String.format("0x%02X : %s", i, s));
}
// チャンネルを持たない SysEx やメタメッセージなど
for( i = 0xF0; i <= 0xFF ; i++ ) {
- if( (s = MIDISpec.getStatusName(i)) == null )
- continue;
+ if((s = MIDISpec.getStatusName(i)) == null) continue;
addElement(String.format("0x%02X : %s", i, s));
}
}
private ComboBoxModel<String> noteComboBoxModel =
new DefaultComboBoxModel<String>() {
{
- for( int i = 0; i<=0x7F; i++ ) addElement(
- String.format("0x%02X : %d : %s", i, i, Note.noteNumberToSymbol(i))
- );
+ for(int i=0; i<=0x7F; i++)
+ addElement(String.format("0x%02X : %d : %s", i, i, Note.noteNumberToSymbol(i)));
// Center note C
setSelectedItem(getElementAt(60));
}
private ComboBoxModel<String> percussionComboBoxModel =
new DefaultComboBoxModel<String>() {
{
- for( int i = 0; i<=0x7F; i++ ) addElement(
- String.format(
- "0x%02X : %d : %s", i, i, MIDISpec.getPercussionName(i)
- )
- );
+ for( int i = 0; i<=0x7F; i++ )
+ addElement(String.format("0x%02X : %d : %s", i, i, MIDISpec.getPercussionName(i)));
setSelectedItem(getElementAt(35)); // Acoustic Bass Drum
}
};
{
String s;
for( int i = 0; i<=0x7F; i++ ) {
- if( (s = MIDISpec.getControllerName(i)) == null )
- continue;
+ if((s = MIDISpec.getControllerName(i)) == null) continue;
addElement(String.format("0x%02X : %d : %s", i, i, s));
}
}
private ComboBoxModel<String> instrumentComboBoxModel =
new DefaultComboBoxModel<String>() {
{
- for( int i = 0; i<=0x7F; i++ ) addElement(
- String.format(
- "0x%02X : %s", i, MIDISpec.instrumentNames[i]
- )
- );
+ for(int i = 0; i<=0x7F; i++)
+ addElement(String.format("0x%02X : %s", i, MIDISpec.instrumentNames[i]));
}
};
/**
new DefaultComboBoxModel<String>() {
{
String s;
- String initial_type_string = null;
- for( int type = 0; type < 0x80 ; type++ ) {
- if( (s = MIDISpec.getMetaName(type)) == null ) {
- continue;
- }
- s = String.format("0x%02X : %s", type, s);
- addElement(s);
- if( type == 0x51 )
- initial_type_string = s; // Tempo
+ String initialTypeString = null;
+ for(int type=0; type < 0x80 ; type++) {
+ if((s = MIDISpec.getMetaName(type)) == null) continue;
+ addElement(s = String.format("0x%02X : %s", type, s));
+ if( type == 0x51 ) initialTypeString = s; // Tempo
}
- setSelectedItem(initial_type_string);
+ setSelectedItem(initialTypeString);
}
};
/**
private ComboBoxModel<String> hexData1ComboBoxModel =
new DefaultComboBoxModel<String>() {
{
- for( int i = 0; i<=0x7F; i++ ) {
- addElement(String.format("0x%02X : %d", i, i ));
- }
+ for(int i=0; i<=0x7F; i++) addElement(String.format("0x%02X : %d", i, i));
}
};
/**
private ComboBoxModel<String> hexData2ComboBoxModel =
new DefaultComboBoxModel<String>() {
{
- for( int i = 0; i<=0x7F; i++ ) {
- addElement(String.format("0x%02X : %d", i, i ));
- }
+ for(int i=0; i<=0x7F; i++) addElement(String.format("0x%02X : %d", i, i));
}
};
// データ選択操作部
private HexSelecter statusText = new HexSelecter("Status/Command");
private HexSelecter data1Text = new HexSelecter("[Data1] ");
private HexSelecter data2Text = new HexSelecter("[Data2] ");
- MidiChannelComboSelecter channelText =
- new MidiChannelComboSelecter("MIDI Channel");
+ MidiChannelComboSelecter channelText = new MidiChannelComboSelecter("MIDI Channel");
private JComboBox<String> statusComboBox = statusText.getComboBox();
private JComboBox<String> data1ComboBox = data1Text.getComboBox();
new PianoKeyboardAdapter() {
public void pianoKeyPressed(int n, InputEvent e) {
data1Text.setValue(n);
- if( midiChannels != null )
- midiChannels[channelText.getSelectedChannel()].
- noteOn( n, data2Text.getValue() );
+ if( midiChannels == null ) return;
+ midiChannels[channelText.getSelectedChannel()].noteOn(n, data2Text.getValue());
}
public void pianoKeyReleased(int n, InputEvent e) {
- if( midiChannels != null ) {
- midiChannels[channelText.getSelectedChannel()].
- noteOff( n, data2Text.getValue() );
- }
+ if( midiChannels == null ) return;
+ midiChannels[channelText.getSelectedChannel()].noteOff(n, data2Text.getValue());
}
}
);
*/
private TempoSelecter tempoSelecter = new TempoSelecter() {
{
- tempoSpinnerModel.addChangeListener(
- new ChangeListener() {
- @Override
- public void stateChanged(ChangeEvent e) {
- dataText.setValue(getTempoByteArray());
- }
+ tempoSpinnerModel.addChangeListener(new ChangeListener() {
+ @Override
+ public void stateChanged(ChangeEvent e) {
+ dataText.setValue(getTempoByteArray());
}
- );
+ });
}
};
/**
*/
private TimeSignatureSelecter timesigSelecter = new TimeSignatureSelecter() {
{
- upperTimesigSpinnerModel.addChangeListener(
- new ChangeListener() {
- @Override
- public void stateChanged(ChangeEvent e) {
- dataText.setValue(getByteArray());
- }
- }
- );
- lowerTimesigCombobox.addActionListener(
- new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- dataText.setValue(getByteArray());
- }
- }
- );
+ upperTimesigModel.addChangeListener(new ChangeListener() {
+ @Override
+ public void stateChanged(ChangeEvent e) { update(); }
+ });
+ lowerTimesigView.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) { update(); }
+ });
}
+ private void update() { dataText.setValue(getByteArray()); }
};
/**
* 調号選択
statusComboBox.addActionListener(this);
channelComboBox.addActionListener(this);
data1ComboBox.addActionListener(this);
- setLayout(new BoxLayout( this, BoxLayout.Y_AXIS ));
+ setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
add(new JPanel() {{ add(statusText); add(channelText); }});
add(durationForm);
add(new JPanel() {{ add(data1Text); add(keyboardPanel); }});
add(new JPanel() {{ add(data2Text); }});
- add( tempoSelecter );
- add( timesigSelecter );
- add( keysigSelecter );
- add( dataText );
+ add(tempoSelecter);
+ add(timesigSelecter);
+ add(keysigSelecter);
+ add(dataText);
updateVisible();
}
@Override
/**
* このMIDIメッセージフォームにMIDIチャンネルを設定します。
*
- * <p>設定したMIDIチャンネルには、
- * ダイアログ内のピアノキーボードで音階を入力したときに
+ * <p>設定したMIDIチャンネルには、ダイアログ内のピアノキーボードで音階を入力したときに
* ノートON/OFFが出力されます。これにより実際に音として聞けるようになります。
* </p>
*
* @param midiChannels MIDIチャンネル
*/
- public void setOutputMidiChannels( MidiChannel midiChannels[] ) {
+ public void setOutputMidiChannels(MidiChannel midiChannels[]) {
this.midiChannels = midiChannels;
}
/**
* @param isVisible trueで表示、falseで非表示
*/
public void setDurationVisible(boolean isVisible) {
- isDurationVisible = isVisible;
- updateVisible();
+ isDurationVisible = isVisible; updateVisible();
}
/**
* 時間間隔入力の表示状態を返します。
* @return true:表示中 false:非表示中
*/
- public boolean isDurationVisible() {
- return isDurationVisible;
- }
+ public boolean isDurationVisible() { return isDurationVisible; }
/**
* 各入力欄の表示状態を更新します。
*/
data1Text.setTitle("[Data1] MetaEvent Type");
data1ComboBox.setModel(metaTypeComboBoxModel);
int msgType = data1Text.getValue();
- tempoSelecter.setVisible( msgType == 0x51 );
- timesigSelecter.setVisible( msgType == 0x58 );
- keysigSelecter.setVisible( msgType == 0x59 );
- //
+ tempoSelecter.setVisible(msgType == 0x51);
+ timesigSelecter.setVisible(msgType == 0x58);
+ keysigSelecter.setVisible(msgType == 0x59);
if( MIDISpec.isEOT(msgType) ) {
dataText.clear();
dataText.setVisible(false);
}
- else {
- dataText.setTitle(MIDISpec.hasMetaMessageText(msgType)?"Text:":"Data:");
- }
+ else dataText.setTitle(MIDISpec.hasMetaMessageText(msgType)?"Text:":"Data:");
}
else {
data1Text.setTitle("[Data1] ");
msgData = new byte[0];
}
else {
- if( (msgData = dataText.getBytes() ) == null ) {
- return null;
- }
+ if( (msgData = dataText.getBytes() ) == null ) return null;
}
MetaMessage msg = new MetaMessage();
try {
int msgData2 = data2Text.getValue();
if( msgData2 < 0 ) msgData2 = 0;
try {
- if( MIDISpec.isChannelMessage(msgStatus) ) {
+ if( MIDISpec.isChannelMessage(msgStatus) )
msg.setMessage((msgStatus & 0xF0), channelText.getSelectedChannel(), msgData1, msgData2);
- }
- else {
+ else
msg.setMessage(msgStatus, msgData1, msgData2);
- }
} catch( InvalidMidiDataException e ) {
e.printStackTrace();
return null;
msgStatus = smsg.getCommand();
msgChannel = smsg.getChannel();
}
- statusText.setValue( msgStatus );
- channelText.setSelectedChannel( msgChannel );
- data1Text.setValue( smsg.getData1() );
- data2Text.setValue( smsg.getData2() );
+ statusText.setValue(msgStatus);
+ channelText.setSelectedChannel(msgChannel);
+ data1Text.setValue(smsg.getData1());
+ data2Text.setValue(smsg.getData2());
}
else if( msg instanceof SysexMessage ) {
SysexMessage sysexMsg = (SysexMessage)msg;
- statusText.setValue( sysexMsg.getStatus() );
- dataText.setValue( sysexMsg.getData() );
+ statusText.setValue(sysexMsg.getStatus());
+ dataText.setValue(sysexMsg.getData());
}
else if( msg instanceof MetaMessage ) {
MetaMessage metaMsg = (MetaMessage)msg;
int msgType = metaMsg.getType();
byte data[] = metaMsg.getData();
- statusText.setValue( 0xFF );
+ statusText.setValue(0xFF);
data1Text.setValue(msgType);
switch(msgType) {
case 0x51: tempoSelecter.setTempo(data); break;
case 0x59: keysigSelecter.setSelectedKey(new Key(data)); break;
default: break;
}
- if( MIDISpec.hasMetaMessageText(msgType) ) {
+ if( MIDISpec.hasMetaMessageText(msgType) )
dataText.setString(new String(data,charset));
- }
- else {
+ else
dataText.setValue(data);
- }
updateVisible();
}
}
* 入力内容がノートメッセージかどうか調べます。
* @return ノートメッセージのときtrue
*/
- public boolean isNote() {
- return isNote(statusText.getValue());
- }
+ public boolean isNote() { return isNote(statusText.getValue()); }
/**
* 入力内容がノートメッセージかどうか調べます。
* @param status MIDIメッセージのステータス
}});
add("Track", trackSpecPanel);
}});
- setBounds( 250, 200, 600, 540 );
+ setBounds(250,200,600,540);
}
/**
* 新しいコード進行を生成して返します。
* 拍子選択ビュー
*/
public class TimeSignatureSelecter extends JPanel {
- SpinnerNumberModel upperTimesigSpinnerModel = new SpinnerNumberModel(4, 1, 32, 1);
- private JSpinner upperTimesigSpinner = new JSpinner(upperTimesigSpinnerModel) {
- {
- setToolTipText("Time signature (upper digit) - 拍子の分子");
- }
+ protected SpinnerNumberModel upperTimesigModel = new SpinnerNumberModel(4, 1, 32, 1);
+ private JSpinner upperTimesigView = new JSpinner(upperTimesigModel) {
+ { setToolTipText("Time signature (upper digit) - 拍子の分子"); }
};
- JComboBox<String> lowerTimesigCombobox = new JComboBox<String>() {
+ protected JComboBox<String> lowerTimesigView = new JComboBox<String>() {
{
setToolTipText("Time signature (lower digit) - 拍子の分母");
- for( int i=0; i<6; i++ ) addItem( "/" + (1<<i) );
- setSelectedIndex(2);
+ for(int i=0; i<6; i++) addItem("/"+(1<<i)); setSelectedIndex(2);
}
};
- private class TimeSignatureLabel extends JLabel {
+ private static class TimeSignatureLabel extends JLabel {
+ { setToolTipText("Time signature - 拍子"); }
private byte upper = -1;
- private byte lower_index = -1;
- {
- setToolTipText("Time signature - 拍子");
- }
- public void setTimeSignature(byte upper, byte lower_index) {
- if( this.upper == upper && this.lower_index == lower_index ) {
- return;
- }
- setText("<html><font size=\"+1\">" + upper + "/" + (1 << lower_index) + "</font></html>");
+ private byte lowerIndex = -1;
+ public void setTimeSignature(byte upper, byte lowerIndex) {
+ if( this.upper == upper && this.lowerIndex == lowerIndex ) return;
+ setText("<html><font size=\"+1\">"+upper+"/"+(1<<lowerIndex)+"</font></html>");
+ this.upper = upper;
+ this.lowerIndex = lowerIndex;
}
}
private TimeSignatureLabel timesigValueLabel = new TimeSignatureLabel();
- private boolean editable;
public TimeSignatureSelecter() {
- add(upperTimesigSpinner);
- add(lowerTimesigCombobox);
+ add(upperTimesigView);
+ add(lowerTimesigView);
add(timesigValueLabel);
setEditable(true);
}
public void clear() {
- upperTimesigSpinnerModel.setValue(4);
- lowerTimesigCombobox.setSelectedIndex(2);
- }
- public int getUpperValue() {
- return upperTimesigSpinnerModel.getNumber().intValue();
- }
- public byte getUpperByte() {
- return upperTimesigSpinnerModel.getNumber().byteValue();
- }
- public int getLowerValueIndex() {
- return lowerTimesigCombobox.getSelectedIndex();
- }
- public byte getLowerByte() {
- return (byte)getLowerValueIndex();
+ upperTimesigModel.setValue(4);
+ lowerTimesigView.setSelectedIndex(2);
}
public byte[] getByteArray() {
- byte[] data = new byte[4];
- data[0] = getUpperByte();
- data[1] = getLowerByte();
- data[2] = (byte)( 96 >> getLowerValueIndex() );
- data[3] = 8;
- return data;
+ byte upper = upperTimesigModel.getNumber().byteValue();
+ byte lowerIndex = (byte)lowerTimesigView.getSelectedIndex();
+ return new byte[] { upper, lowerIndex, (byte)(96 >> lowerIndex), 8 };
}
public void setValue(byte upper, byte lowerIndex) {
- upperTimesigSpinnerModel.setValue( upper );
- lowerTimesigCombobox.setSelectedIndex( lowerIndex );
- timesigValueLabel.setTimeSignature( upper, lowerIndex );
+ upperTimesigModel.setValue(upper);
+ lowerTimesigView.setSelectedIndex(lowerIndex);
+ timesigValueLabel.setTimeSignature(upper, lowerIndex);
}
public void setValue(byte[] data) {
- if(data == null)
- clear();
- else
- setValue(data[0], data[1]);
+ if(data == null) clear(); else setValue(data[0], data[1]);
}
+ private boolean editable;
public boolean isEditable() { return editable; }
- public void setEditable( boolean editable ) {
+ public void setEditable(boolean editable) {
this.editable = editable;
- upperTimesigSpinner.setVisible(editable);
- lowerTimesigCombobox.setVisible(editable);
+ upperTimesigView.setVisible(editable);
+ lowerTimesigView.setVisible(editable);
timesigValueLabel.setVisible(!editable);
- if( !editable ) {
- timesigValueLabel.setTimeSignature(getUpperByte(), getLowerByte());
- }
+ if(!editable) timesigValueLabel.setTimeSignature(
+ upperTimesigModel.getNumber().byteValue(),
+ (byte)lowerTimesigView.getSelectedIndex()
+ );
}
}
\ No newline at end of file
* @return コード名のHTML
*/
public String toHtmlString(String colorName) {
- String span = "<span style=\"font-size: 120%\">";
+ String smallSpan = "<span style=\"font-size: 120%\">";
String endSpan = "</span>";
String root = rootNoteSymbol.toString();
- String formattedRoot = (root.length() == 1) ? root + span :
- root.replace("#",span+"<sup>#</sup>").
- replace("b",span+"<sup>b</sup>").
- replace("x",span+"<sup>x</sup>");
+ String formattedRoot = (root.length() == 1) ? root + smallSpan :
+ root.replace("#",smallSpan+"<sup>#</sup>").
+ replace("b",smallSpan+"<sup>b</sup>").
+ replace("x",smallSpan+"<sup>x</sup>");
String formattedBass = "";
if( ! rootNoteSymbol.equals(bassNoteSymbol) ) {
String bass = bassNoteSymbol.toString();
- formattedBass = (bass.length() == 1) ? bass + span :
- bass.replace("#",span+"<sup>#</sup>").
- replace("b",span+"<sup>b</sup>").
- replace("x",span+"<sup>x</sup>");
+ formattedBass = (bass.length() == 1) ? bass + smallSpan :
+ bass.replace("#",smallSpan+"<sup>#</sup>").
+ replace("b",smallSpan+"<sup>b</sup>").
+ replace("x",smallSpan+"<sup>x</sup>");
formattedBass = "/" + formattedBass + endSpan;
}
String suffix = symbolSuffix().
* 調号が空(C/Am ハ長調またはイ短調)で、メジャー・マイナーの区別のない調
*/
public static final Key C_MAJOR_OR_A_MINOR = new Key();
- private Key() { }
/**
* キー指定(メジャー/マイナー/両方)
*/
normalize();
}
/**
- * MIDIの調データ(メタメッセージ2byteの配列)から調を構築します。
+ * MIDIの調データ(メタメッセージ2byte配列)から調を構築します。
+ * <p>デフォルト値は、ハ長調またはイ短調(両者の区別なし)です。
+ * 引数から取得できた値だけが、デフォルト値から変更されます。
+ * 例えば次のような場合、取得できなかった値はデフォルト値のままとなります。
+ * </p>
* <ul>
- * <li>長さ0の配列が与えられた場合は{@link #Key() 引数のないコンストラクタ}と同じ動作になります。</li>
- * <li>メジャー・マイナーの区別を表す有効な値が見つからなかった場合、区別なしとして構築されます。</li>
+ * <li>引数がnull</li>
+ * <li>引数の配列が2byteに満たない</li>
+ * <li>長調・短調の区別が不明確(配列インデックス1の値が、0:長調、1:短調、のどちらでもない)</li>
* </ul>
- *
* @param midiData MIDIの調データ
*/
- public Key(byte midiData[]) {
- if( midiData.length == 0 ) return;
+ public Key(byte ... midiData) {
+ if( midiData == null || midiData.length == 0 ) return;
co5 = midiData[0];
if( midiData.length > 1 ) {
switch(midiData[1]) {
}
/**
* MIDIの調データ(メタメッセージ2byte)を生成して返します。
- * @return MIDIの調データ
+ * @return MIDIの調データ
*/
public byte[] getBytes() {
return new byte[] {(byte) co5, (byte) ((majorMinor == MajorMinor.MINOR) ? 1 : 0)};
keyboardCenterPanel = new PianoKeyboardPanel();
keyboardCenterPanel.keyboard.chordMatrix = chordMatrix;
keyboardCenterPanel.keyboard.chordDisplay =
- new ChordDisplayLabel("MIDI Keyboard", chordMatrix, keyboardCenterPanel.keyboard);
+ new ChordDisplayLabel("MIDI Keyboard", null, chordMatrix, keyboardCenterPanel.keyboard);
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
add(keyboardChordPanel = new JPanel() {
{