*/
public static class VersionInfo {
public static final String NAME = "MIDI Chord Helper";
- public static final String VERSION = "Ver.20170410.1";
+ public static final String VERSION = "Ver.20170411.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/";
//シーケンサーの時間スライダーの値が変わったときのリスナーを登録
JLabel songTitleLabel = new JLabel();
sequencerModel.addChangeListener(e->{
- SequenceTrackListTableModel sequenceTrackListTableModel = sequencerModel.getSequenceTrackListTableModel();
+ SequenceTrackListTableModel sequenceModel = sequencerModel.getSequenceTrackListTableModel();
int loadedSequenceIndex = playlistModel.indexOfSequenceOnSequencer();
songTitleLabel.setText("<html>"+(
loadedSequenceIndex < 0 ? "[No MIDI file loaded]" :
"MIDI file " + loadedSequenceIndex + ": " + (
- sequenceTrackListTableModel == null ||
- sequenceTrackListTableModel.toString().isEmpty() ?
+ sequenceModel == null || sequenceModel.toString().isEmpty() ?
"[Untitled]" :
- "<font color=maroon>"+sequenceTrackListTableModel+"</font>"
+ "<font color=maroon>"+sequenceModel+"</font>"
)
)+"</html>");
Sequencer sequencer = sequencerModel.getSequencer();
chordMatrix.setPlaying(sequencer.isRunning());
- if( sequenceTrackListTableModel != null ) {
- SequenceTickIndex tickIndex = sequenceTrackListTableModel.getSequenceTickIndex();
+ if( sequenceModel != null ) {
+ SequenceTickIndex tickIndex = sequenceModel.getSequenceTickIndex();
long tickPos = sequencer.getTickPosition();
tickIndex.tickToMeasure(tickPos);
chordMatrix.setBeat(tickIndex);
/**
* MIDI Chord Helper を Java アプリとして起動します。
*/
-public class MidiChordHelper {
+public class MidiChordHelper extends JFrame implements AppletStub, AppletContext {
/**
* MIDI Chord Helper を Java アプリとして起動します。
* @param args コマンドライン引数
* @throws Exception 何らかの異常が発生した場合にスローされる
*/
public static void main(String[] args) throws Exception {
- List<File> fileList = Arrays.asList(args).stream().map(arg -> new File(arg)).collect(Collectors.toList());
- SwingUtilities.invokeLater(()->new AppletFrame(new ChordHelperApplet(), fileList));
+ List<File> fileList = Arrays.asList(args).stream()
+ .map(arg -> new File(arg))
+ .collect(Collectors.toList());
+ SwingUtilities.invokeLater(()->new MidiChordHelper(fileList));
}
- private static class AppletFrame extends JFrame implements AppletStub, AppletContext {
- private JLabel status_ = new JLabel("Welcome to "+ChordHelperApplet.VersionInfo.NAME) {
- { setFont(getFont().deriveFont(Font.PLAIN)); }
- };
- private void updateFilename(SequenceTrackListTableModel sequence) {
- String title = ChordHelperApplet.VersionInfo.NAME;
- if( sequence != null ) {
- String filename = sequence.getFilename();
- if( filename != null && ! filename.isEmpty() )
- title = filename+" - "+title;
- }
- setTitle(title);
- }
- private void updateFilename(MidiSequencerModel sequencer) {
- updateFilename(sequencer.getSequenceTrackListTableModel());
- }
- private void updateFilename(TableModelEvent event) {
- if( ! PlaylistTableModel.filenameChanged(event) ) return;
- updateFilename(((PlaylistTableModel)event.getSource()).getSequencerModel());
- }
- public AppletFrame(ChordHelperApplet applet, List<File> fileList) {
- add(applet, BorderLayout.CENTER);
- add(status_, BorderLayout.SOUTH);
- applet.setStub(this);
- applet.init();
- setIconImage(applet.getIconImage());
- pack();
- setLocationRelativeTo(null);
- setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
- addWindowListener(new WindowAdapter() {
- @Override
- public void windowClosing(WindowEvent event) {
- if( applet.isModified() && ! confirmBeforeExit() ) return;
- applet.destroy();
- System.exit(0);
- }
- });
- PlaylistTableModel playlistModel = applet.midiEditor.sequenceListTable.getModel();
- playlistModel.getSequencerModel().addChangeListener(e->updateFilename((MidiSequencerModel)e.getSource()));
- playlistModel.addTableModelListener(e->updateFilename(e));
- updateFilename(playlistModel.getSequencerModel());
- setVisible(true);
- applet.start();
- applet.midiEditor.play(fileList);
- }
- private boolean confirmBeforeExit() {
- String message = "MIDI file not saved, exit anyway ?\n"+
- "MIDIファイルが保存されていません。終了してよろしいですか?";
- return JOptionPane.showConfirmDialog(
- null, message, ChordHelperApplet.VersionInfo.NAME,
- JOptionPane.YES_NO_OPTION,
- JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION ;
- }
- @Override
- public boolean isActive() { return true; }
- @Override
- public URL getDocumentBase() { return null; }
- @Override
- public URL getCodeBase() { return null; }
- @Override
- public String getParameter(String name) { return null; }
- @Override
- public AppletContext getAppletContext() { return this; }
- @Override
- public void appletResize(int width, int height) {}
- @Override
- public AudioClip getAudioClip(URL url) { return null; }
- @Override
- public Image getImage(URL url) {
- return Toolkit.getDefaultToolkit().getImage(url);
+ private static boolean confirmBeforeExit() {
+ String message = "MIDI file not saved, exit anyway ?\n"+
+ "MIDIファイルが保存されていません。終了してよろしいですか?";
+ return JOptionPane.showConfirmDialog(
+ null, message, ChordHelperApplet.VersionInfo.NAME,
+ JOptionPane.YES_NO_OPTION,
+ JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION ;
+ }
+ private JLabel statusBar = new JLabel("Welcome to "+ChordHelperApplet.VersionInfo.NAME) {
+ { setFont(getFont().deriveFont(Font.PLAIN)); }
+ };
+ private void updateFilename(SequenceTrackListTableModel sequence) {
+ String title = ChordHelperApplet.VersionInfo.NAME;
+ if( sequence != null ) {
+ String filename = sequence.getFilename();
+ if( filename != null && ! filename.isEmpty() )
+ title = filename+" - "+title;
}
- @Override
- public Applet getApplet(String name) { return null; }
- @Override
- public Enumeration<Applet> getApplets() { return (null); }
- @Override
- public void showDocument(URL url) {}
- @Override
- public void showDocument(URL url, String target) {}
- @Override
- public void showStatus(String status) { status_.setText(status); }
- @Override
- public InputStream getStream(String key) { return null; }
- @Override
- public Iterator<String> getStreamKeys() { return null; }
- @Override
- public void setStream(String key, InputStream stream) throws IOException {}
+ setTitle(title);
+ }
+ private void updateFilename(MidiSequencerModel sequencer) {
+ updateFilename(sequencer.getSequenceTrackListTableModel());
+ }
+ private void updateFilename(TableModelEvent event) {
+ if( ! PlaylistTableModel.filenameChanged(event) ) return;
+ updateFilename(((PlaylistTableModel)event.getSource()).getSequencerModel());
+ }
+ private MidiChordHelper(List<File> fileList) {
+ ChordHelperApplet applet = new ChordHelperApplet();
+ add(applet, BorderLayout.CENTER);
+ add(statusBar, BorderLayout.SOUTH);
+ applet.setStub(this);
+ applet.init();
+ setIconImage(applet.getIconImage());
+ pack();
+ setLocationRelativeTo(null);
+ setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
+ addWindowListener(new WindowAdapter() {
+ @Override
+ public void windowClosing(WindowEvent event) {
+ if( applet.isModified() && ! confirmBeforeExit() ) return;
+ applet.destroy();
+ System.exit(0);
+ }
+ });
+ PlaylistTableModel playlist = applet.midiEditor.getPlaylistModel();
+ MidiSequencerModel sequencer = playlist.getSequencerModel();
+ sequencer.addChangeListener(e->updateFilename((MidiSequencerModel)e.getSource()));
+ playlist.addTableModelListener(e->updateFilename(e));
+ updateFilename(sequencer);
+ setVisible(true);
+ applet.start();
+ applet.midiEditor.play(fileList);
+ }
+ @Override
+ public boolean isActive() { return true; }
+ @Override
+ public URL getDocumentBase() { return null; }
+ @Override
+ public URL getCodeBase() { return null; }
+ @Override
+ public String getParameter(String name) { return null; }
+ @Override
+ public AppletContext getAppletContext() { return this; }
+ @Override
+ public void appletResize(int width, int height) {}
+ @Override
+ public AudioClip getAudioClip(URL url) { return null; }
+ @Override
+ public Image getImage(URL url) {
+ return Toolkit.getDefaultToolkit().getImage(url);
}
+ @Override
+ public Applet getApplet(String name) { return null; }
+ @Override
+ public Enumeration<Applet> getApplets() { return (null); }
+ @Override
+ public void showDocument(URL url) {}
+ @Override
+ public void showDocument(URL url, String target) {}
+ @Override
+ public void showStatus(String status) { statusBar.setText(status); }
+ @Override
+ public InputStream getStream(String key) { return null; }
+ @Override
+ public Iterator<String> getStreamKeys() { return null; }
+ @Override
+ public void setStream(String key, InputStream stream) throws IOException {}
}
} catch (Exception e) { showError(e); return false; }
}
};
-
+ /**
+ * このエディタダイアログが表示しているプレイリストモデルを返します。
+ * @return プレイリストモデル
+ */
+ public PlaylistTableModel getPlaylistModel() {
+ return sequenceListTable.getModel();
+ }
/**
* 指定されたリストに格納されたMIDIファイルを読み込んで再生します。
* すでに再生されていた場合、このエディタダイアログを表示します。
* @param fileList 読み込むMIDIファイルのリスト
*/
public void play(List<File> fileList) {
- PlaylistTableModel playlist = sequenceListTable.getModel();
+ PlaylistTableModel playlist = getPlaylistModel();
int firstIndex = -1;
Iterator<File> itr = fileList.iterator();
while(itr.hasNext()) {
/**
* プレイリストビュー(シーケンスリスト)
*/
- public SequenceListTable sequenceListTable;
+ private SequenceListTable sequenceListTable;
/**
* MIDIトラックリストテーブルビュー(選択中のシーケンスの中身)
*/
add(new JButton(sequenceListTable.base64EncodeAction) {{ setMargin(ChordHelperApplet.ZERO_INSETS); }});
}
add(Box.createRigidArea(new Dimension(5, 0)));
- PlaylistTableModel playlistTableModel = sequenceListTable.getModel();
add(new JButton(playlistTableModel.getMoveToTopAction()) {
{ setMargin(ChordHelperApplet.ZERO_INSETS); }
});
add( Box.createRigidArea(new Dimension(5, 0)) );
add(new JPanel() {{
setBorder(new EtchedBorder());
- MidiSequencerModel sequencerModel = sequenceListTable.getModel().getSequencerModel();
+ MidiSequencerModel sequencerModel = getPlaylistModel().getSequencerModel();
add(new JLabel("Sync Master"));
add(new JComboBox<Sequencer.SyncMode>(sequencerModel.masterSyncModeModel));
add(new JLabel("Slave"));