• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

MIDI Chord Helper機能追加版(GOは五度圏や碁盤の「ご」。別に移動式じゃありません)


Commit MetaInfo

Revisionda6b0481fe37a91c513d5ad893754301fd60d1b3 (tree)
Time2022-03-20 01:41:26
Authork-hatano <kent.ruffle.mgj626@gmai...>
Commiterk-hatano

Log Message

五度圏ビュー追加、5ボタンマウス対応、sus2入力対応、他

Change Summary

Incremental Difference

--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
11 $(eval SRCS := $(shell find src -name "*.java" | tr '\r' ' '))
22
33 MidiChordHelper: $(SRCS)
4- javac -encoding utf8 -d bin $^
5- jar cvfm MidiChordHelper.jar mani.mf -C bin/ .
4+ javac -encoding utf8 -d classes $^
5+ jar cvfm MidiChordHelper.jar mani.mf -C classes/ .
66
--- a/src/camidion/chordhelper/ButtonIcon.java
+++ b/src/camidion/chordhelper/ButtonIcon.java
@@ -368,22 +368,21 @@ public class ButtonIcon implements Icon {
368368
369369 case RIGHT_PANEL_CONTENT_ICON:
370370 if (is_selected) {
371- g2.drawOval(0, 0, width, HEIGHT);
372- for (int r = 0; r < 180; r += 30) {
373- g2.drawLine((int)(Math.cos(Math.PI * r / 180) * (width / 2) + (width / 2)),
374- (int)(Math.sin(Math.PI * r / 180) * (width / 2) + (width / 2)),
375- (int)(-1 * Math.cos(Math.PI * r / 180) * (width / 2) + (width / 2)),
376- (int)(-1 * Math.sin(Math.PI * r / 180) * (width / 2) + (width / 2)));
371+ for (int r = 0; r < 360; r += 30) {
372+ g2.fillOval((int)Math.round(Math.cos(Math.PI * r / 180) * (width / 2 - 2) + (width / 2) - 2),
373+ (int)Math.round(Math.sin(Math.PI * r / 180) * (width / 2 - 2) + (width / 2) - 2),
374+ 3,
375+ 3);
377376 }
378377 } else {
379- g2.drawLine( 0, HEIGHT / 5 + 1, width, HEIGHT / 5 + 1 );
380- g2.drawLine( 0, HEIGHT * 2 / 5 + 1, width, HEIGHT * 2 / 5 + 1 );
381- g2.drawLine( 0, HEIGHT * 3 / 5 + 1, width, HEIGHT * 3 / 5 + 1 );
382- g2.drawLine( 0, HEIGHT * 4 / 5 + 1, width, HEIGHT * 4 / 5 + 1 );
378+ g2.drawLine( 0, HEIGHT / 5, width, HEIGHT / 5 );
379+ g2.drawLine( 0, HEIGHT * 2 / 5, width, HEIGHT * 2 / 5 );
380+ g2.drawLine( 0, HEIGHT * 3 / 5, width, HEIGHT * 3 / 5 );
381+ g2.drawLine( 0, HEIGHT * 4 / 5, width, HEIGHT * 4 / 5 );
383382
384- g2.drawLine( width / 8, HEIGHT / 5 + 1, width / 8, HEIGHT * 4 / 5 + 1 );
385- g2.drawLine( width * 4 / 8, HEIGHT / 5 + 1, width * 4 / 8, HEIGHT * 4 / 5 + 1 );
386- g2.drawLine( width * 7 / 8, HEIGHT / 5 + 1, width * 7 / 8, HEIGHT * 4 / 5 + 1 );
383+ g2.drawLine( width / 8, HEIGHT / 5, width / 8, HEIGHT * 4 / 5 );
384+ g2.drawLine( width * 4 / 8, HEIGHT / 5, width * 4 / 8, HEIGHT * 4 / 5 );
385+ g2.drawLine( width * 7 / 8, HEIGHT / 5, width * 7 / 8, HEIGHT * 4 / 5 );
387386 }
388387 break;
389388 }
--- a/src/camidion/chordhelper/ChordHelperApplet.java
+++ b/src/camidion/chordhelper/ChordHelperApplet.java
@@ -349,6 +349,7 @@ public class ChordHelperApplet extends JApplet {
349349 capoSelecter.valueSelecter.addActionListener(e->clearChord());
350350 }
351351 };
352+ chordMatrix.chordDiagram = chordDiagram;
352353 keysigLabel = new KeySignatureLabel() {{
353354 addMouseListener(new MouseAdapter() {
354355 @Override
@@ -498,7 +499,15 @@ public class ChordHelperApplet extends JApplet {
498499 add( Box.createHorizontalStrut(5) );
499500 add( chordMatrix.capoSelecter );
500501 add( Box.createHorizontalStrut(5) );
501- add( rightPanelContentToggleButton = new JToggleButton(new ButtonIcon(ButtonIcon.RIGHT_PANEL_CONTENT_ICON)));
502+ add( rightPanelContentToggleButton = new JToggleButton(new ButtonIcon(ButtonIcon.RIGHT_PANEL_CONTENT_ICON)){{
503+ addItemListener(event->{
504+ if (((JToggleButton)event.getSource()).isSelected()) {
505+ chordDiagram.switchContent(1);
506+ } else {
507+ chordDiagram.switchContent(0);
508+ }
509+ });
510+ }});
502511 add( Box.createHorizontalStrut(2) );
503512 }};
504513 keyboardSequencerPanel = new JPanel() {{
--- a/src/camidion/chordhelper/chorddiagram/ChordDiagram.java
+++ b/src/camidion/chordhelper/chorddiagram/ChordDiagram.java
@@ -1,4 +1,5 @@
11 package camidion.chordhelper.chorddiagram;
2+import java.awt.BorderLayout;
23 import java.awt.Color;
34 import java.awt.Insets;
45 import java.util.Arrays;
@@ -17,11 +18,13 @@ import javax.swing.JRadioButton;
1718 import javax.swing.JScrollBar;
1819 import javax.swing.JToggleButton;
1920 import javax.swing.SwingConstants;
21+import javax.swing.JComponent;
2022
2123 import camidion.chordhelper.ButtonIcon;
2224 import camidion.chordhelper.ChordDisplayLabel;
2325 import camidion.chordhelper.music.Chord;
2426 import camidion.chordhelper.music.Note;
27+import camidion.chordhelper.circleoffifth.NoteCircle;
2528
2629 /**
2730 * ChordDiagram class for MIDI Chord Helper
@@ -31,6 +34,9 @@ import camidion.chordhelper.music.Note;
3134 * http://www.yk.rim.or.jp/~kamide/music/chordhelper/
3235 */
3336 public class ChordDiagram extends JPanel {
37+ private JPanel originalChordDiagram;
38+ private NoteCircle circleOfFifth;
39+
3440 /** コードダイアグラムの対象楽器を示す値 */
3541 public static enum Instrument {
3642 Ukulele("A,E,C,G"),
@@ -68,9 +74,12 @@ public class ChordDiagram extends JPanel {
6874 * @param capoComboBoxModel カポ値選択コンボボックスのデータモデル
6975 */
7076 public ChordDiagram(CapoComboBoxModel capoComboBoxModel) {
77+ originalChordDiagram = new JPanel();
78+
7179 capoSelecterView.valueSelecter.setModel(capoComboBoxModel);
72- setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
73- add(new JPanel() {
80+
81+ originalChordDiagram.setLayout(new BoxLayout(originalChordDiagram, BoxLayout.Y_AXIS));
82+ originalChordDiagram.add(new JPanel() {
7483 {
7584 setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
7685 setOpaque(false);
@@ -80,8 +89,8 @@ public class ChordDiagram extends JPanel {
8089 add(capoSelecterView);
8190 }
8291 });
83- add(Box.createHorizontalStrut(5));
84- add(new JPanel() {
92+ originalChordDiagram.add(Box.createHorizontalStrut(5));
93+ originalChordDiagram.add(new JPanel() {
8594 {
8695 setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
8796 setOpaque(false);
@@ -105,6 +114,12 @@ public class ChordDiagram extends JPanel {
105114 add(variationScrollbar);
106115 }
107116 });
117+ originalChordDiagram.setVisible(true);
118+ add(originalChordDiagram);
119+
120+ circleOfFifth = new NoteCircle();
121+ circleOfFifth.setVisible(false);
122+ add(circleOfFifth);
108123 }
109124 /**
110125 * コードをテキストに記録するボタン
@@ -204,4 +219,25 @@ public class ChordDiagram extends JPanel {
204219 public void setTargetInstrument(Instrument instrument) {
205220 instButtons.get(Objects.requireNonNull(instrument)).doClick();
206221 }
222+
223+ public final int CHORD_DIAGRAM = 0;
224+ public final int CIRCLE_OF_FIFTH = 1;
225+
226+ public void switchContent(int which) {
227+ switch (which) {
228+ case CHORD_DIAGRAM:
229+ originalChordDiagram.setVisible(true);
230+ circleOfFifth.setVisible(false);
231+ break;
232+ case CIRCLE_OF_FIFTH:
233+ originalChordDiagram.setVisible(false);
234+ circleOfFifth.setVisible(true);
235+ circleOfFifth.invalidate();
236+ break;
237+ }
238+ }
239+
240+ public void note(boolean isNoteOn, int noteNumber) {
241+ this.circleOfFifth.note(isNoteOn, noteNumber);
242+ }
207243 }
--- a/src/camidion/chordhelper/chordmatrix/ChordMatrix.java
+++ b/src/camidion/chordhelper/chordmatrix/ChordMatrix.java
@@ -31,6 +31,7 @@ import javax.swing.JPanel;
3131
3232 import camidion.chordhelper.ButtonIcon;
3333 import camidion.chordhelper.ChordDisplayLabel;
34+import camidion.chordhelper.chorddiagram.ChordDiagram;
3435 import camidion.chordhelper.chorddiagram.CapoComboBoxModel;
3536 import camidion.chordhelper.chorddiagram.CapoSelecterView;
3637 import camidion.chordhelper.midieditor.SequenceTickIndex;
@@ -60,6 +61,8 @@ public class ChordMatrix extends JPanel
6061 public ChordDisplayLabel chordDisplay = new ChordDisplayLabel("Chord Pad", null, this, null);
6162
6263 private NoteWeight noteWeightArray[] = new NoteWeight[Note.SEMITONES_PER_OCTAVE];
64+
65+ public ChordDiagram chordDiagram = null;
6366 /**
6467 * 発音中のノート表示をクリアします。
6568 */
@@ -76,6 +79,8 @@ public class ChordMatrix extends JPanel
7679 int diff = (isNoteOn ? 1 : -1);
7780 NoteWeight w = noteWeightArray[Note.mod12(noteNumber)];
7881 if( noteNumber < 49 ) w.addBass(diff); else w.add(diff);
82+
83+ chordDiagram.note(isNoteOn, noteNumber);
7984 }
8085
8186 /**
@@ -543,14 +548,14 @@ public class ChordMatrix extends JPanel
543548 else
544549 intervals.add(Chord.Interval.SEVENTH);
545550 }
546- else if( e.isShiftDown() )
551+ else if( e.isShiftDown() || (e.getButton() == 4) )
547552 intervals.add(Chord.Interval.SIXTH);
548- if( e.isControlDown() )
553+ if( e.isControlDown() || (e.getButton() == 5) )
549554 intervals.add(Chord.Interval.NINTH);
550555 else
551556 intervals.remove(Chord.Interval.NINTH);
552557
553- if( e.isAltDown() ) {
558+ if( e.isAltDown() || (e.getButton() == 2) ) {
554559 if( cl.isSus4 ) {
555560 intervals.add(Chord.Interval.MAJOR); // To cancel sus4
556561 intervals.add(Chord.Interval.SHARP5);
--- a/src/camidion/chordhelper/midieditor/MidiChannelButtonSelecter.java
+++ b/src/camidion/chordhelper/midieditor/MidiChannelButtonSelecter.java
@@ -58,7 +58,8 @@ public class MidiChannelButtonSelecter extends JList<Integer>
5858 public MyCellRenderer() {
5959 setOpaque(true);
6060 setHorizontalAlignment(CENTER);
61- setSelectionBackground(Color.yellow);
61+ setForeground(Color.lightGray);
62+ setSelectionForeground(Color.red);
6263 }
6364 @Override
6465 public Component getListCellRendererComponent(
@@ -69,7 +70,10 @@ public class MidiChannelButtonSelecter extends JList<Integer>
6970 this.cellHasFocus = cellHasFocus;
7071 setText(value.toString());
7172 if(isSelected) {
72- setBackground(list.getSelectionBackground());
73+ setBackground(
74+ keyboard != null && keyboard.countKeyOn(index) > 0 ?
75+ Color.pink : list.getBackground()
76+ );
7377 setForeground(list.getSelectionForeground());
7478 } else {
7579 setBackground(
--- a/src/camidion/chordhelper/music/Chord.java
+++ b/src/camidion/chordhelper/music/Chord.java
@@ -202,6 +202,7 @@ public class Chord {
202202 set(Interval.MINOR);
203203 }
204204 else if( outParen.matches(".*sus4.*") ) set(Interval.SUS4);
205+ else if( outParen.matches(".*sus2.*") ) set(Interval.SUS2);
205206 //
206207 // extended
207208 if( outParen.matches(".*9.*") ) {
--- /dev/null
+++ b/src/camidion/chordhelper/notecircle/NoteCircle.java
@@ -0,0 +1,144 @@
1+package camidion.chordhelper.circleoffifth;
2+import java.awt.Canvas;
3+import java.awt.Color;
4+import java.awt.Dimension;
5+import java.awt.Graphics;
6+import java.awt.Insets;
7+import java.awt.BorderLayout;
8+import java.awt.event.MouseEvent;
9+import java.awt.event.MouseListener;
10+import java.util.stream.Collectors;
11+
12+import javax.swing.ButtonGroup;
13+import javax.swing.JComponent;
14+import javax.swing.JPanel;
15+import javax.swing.JRadioButton;
16+import javax.swing.BoxLayout;
17+
18+public class NoteCircle extends JPanel {
19+ private NoteCircleComponent component;
20+ int noteWeights[] = new int[12];
21+
22+ public NoteCircle() {
23+ super();
24+ setLayout(new BorderLayout());
25+ setPreferredSize(new Dimension(140, 200));
26+
27+ component = new NoteCircleComponent();
28+ component.setSize(128, 128);
29+ add(component, BorderLayout.CENTER);
30+
31+ JPanel radioButtonsPanel = new JPanel();
32+ radioButtonsPanel.setLayout(new BoxLayout(radioButtonsPanel, BoxLayout.Y_AXIS));
33+
34+ JPanel circleTypePanel = new JPanel();
35+ ButtonGroup circleTypeGroup = new ButtonGroup();
36+ circleTypePanel.setLayout(new BoxLayout(circleTypePanel, BoxLayout.X_AXIS));
37+
38+ JRadioButton fifthsButton = new JRadioButton("Fifths");
39+ fifthsButton.setSelected(true);
40+ fifthsButton.addActionListener(event -> {
41+ component.setChromatic(false);
42+ });
43+ circleTypePanel.add(fifthsButton, BorderLayout.WEST);
44+ circleTypeGroup.add(fifthsButton);
45+
46+ JRadioButton chromaticButton = new JRadioButton("Chromatic");
47+ chromaticButton.addActionListener(event -> {
48+ component.setChromatic(true);
49+ });
50+ circleTypePanel.add(chromaticButton, BorderLayout.EAST);
51+ circleTypeGroup.add(chromaticButton);
52+
53+ radioButtonsPanel.add(circleTypePanel);
54+
55+ JPanel accidentalNotationPanel = new JPanel();
56+ ButtonGroup accidentalNotationGroup = new ButtonGroup();
57+ accidentalNotationPanel.setLayout(new BoxLayout(accidentalNotationPanel, BoxLayout.X_AXIS));
58+
59+ JRadioButton sharpButton = new JRadioButton("Sharp");
60+ sharpButton.setSelected(true);
61+ sharpButton.addActionListener(event -> {
62+ component.setFlatten(false);
63+ });
64+ accidentalNotationPanel.add(sharpButton, BorderLayout.WEST);
65+ accidentalNotationGroup.add(sharpButton);
66+
67+ JRadioButton flatButton = new JRadioButton("Flat");
68+ flatButton.addActionListener(event -> {
69+ component.setFlatten(true);
70+ });
71+ accidentalNotationPanel.add(flatButton, BorderLayout.EAST);
72+ accidentalNotationGroup.add(flatButton);
73+
74+ radioButtonsPanel.add(accidentalNotationPanel);
75+ add(radioButtonsPanel, BorderLayout.SOUTH);
76+ }
77+
78+ public void note(boolean isNoteOn, int noteNumber) {
79+ if (isNoteOn) {
80+ noteWeights[noteNumber % 12]++;
81+ } else {
82+ noteWeights[noteNumber % 12]--;
83+ if (noteWeights[noteNumber % 12] < 0) {
84+ noteWeights[noteNumber % 12] = 0;
85+ }
86+ }
87+ component.repaint();
88+ }
89+
90+ class NoteCircleComponent extends JComponent {
91+ private boolean isFlatten = false;
92+ private boolean isChromatic = false;
93+ private String notesLabelsWithSharp[] = {"C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"};
94+ private String notesLabelsWithFlat[] = {"C", "Db", "D", "Eb", "E", "F", "Gb ", "G", "Ab", "A", "Bb", "B"};
95+
96+ public void setChromatic(boolean value) {
97+ isChromatic = value;
98+ repaint();
99+ }
100+
101+ public void setFlatten(boolean value) {
102+ isFlatten = value;
103+ repaint();
104+ }
105+
106+ public void paintComponent(Graphics g) {
107+ // g.clearRect(0, 0, this.getWidth(), this.getHeight());
108+
109+ int unit = Math.min(this.getWidth(), this.getHeight()) - 28;
110+
111+ for (int i = 0; i < 12; i++) {
112+ int noteIndex;
113+ if (isChromatic) {
114+ noteIndex = i;
115+ } else {
116+ noteIndex = (i * 7) % 12;
117+ }
118+
119+ int x = (int)((Math.sin(i / 12.0 * 2 * Math.PI) / 2) * (unit)) + this.getWidth() / 2;
120+ int y = (int)((- Math.cos(i / 12.0 * 2 * Math.PI) / 2) * (unit)) + this.getHeight() / 2;
121+
122+ if (noteWeights[noteIndex] > 0) {
123+ g.setColor(Color.black);
124+ g.fillOval(x - 11, y - 11, 22, 22);
125+
126+ g.setColor(Color.white);
127+ if (isFlatten) {
128+ g.drawString(notesLabelsWithFlat[noteIndex], x - 4, y + 6);
129+ } else {
130+ g.drawString(notesLabelsWithSharp[noteIndex], x - 4, y + 6);
131+ }
132+ } else {
133+ g.setColor(Color.lightGray);
134+ g.drawOval(x - 11, y - 11, 22, 22);
135+ if (isFlatten) {
136+ g.drawString(notesLabelsWithFlat[noteIndex], x - 4, y + 6);
137+ } else {
138+ g.drawString(notesLabelsWithSharp[noteIndex], x - 4, y + 6);
139+ }
140+ }
141+ }
142+ }
143+ }
144+}
--- a/src/camidion/chordhelper/pianokeyboard/MidiKeyboardPanel.java
+++ b/src/camidion/chordhelper/pianokeyboard/MidiKeyboardPanel.java
@@ -9,6 +9,7 @@ import javax.swing.AbstractAction;
99 import javax.swing.Box;
1010 import javax.swing.BoxLayout;
1111 import javax.swing.JButton;
12+import javax.swing.JCheckBox;
1213 import javax.swing.JPanel;
1314
1415 import camidion.chordhelper.ChordDisplayLabel;
@@ -64,6 +65,9 @@ public class MidiKeyboardPanel extends JPanel {
6465 add(midiChannelCombobox = new MidiChannelComboSelecter(
6566 "MIDI Channel", keyboardCenterPanel.keyboard.midiChComboboxModel
6667 ));
68+ add(new JCheckBox("Solo"){{
69+ this.setEnabled(false);
70+ }});
6771 add(midiChannelButtons = new MidiChannelButtonSelecter(
6872 keyboardCenterPanel.keyboard
6973 ));