/* Author: James Pate Williams (c) 2001 Guitar chord computer usage: java Chord1 java Chord1 instrument where instrument is from 0 to 127 24 Nylon Str Guitar 25 Steel String Guitar 26 Jazz Electric Gtr 27 Clean Guitar 28 Muted Guitar 39 Overdrive Guitar 30 Distortion Guitar 31 Guitar Harmonics Strings 1E 2B 3G 4D 5A 6E are indexed by 0 1 2 3 4 5 Frets 1 - 13 are indexed by 0 1 2 ... 12 Assume a right-handed guitar (picks right-handed) */ import java.awt.*; import java.awt.event.*; import java.util.*; import javax.sound.midi.*; import javax.swing.*; import javax.swing.border.*; import javax.swing.event.*; class Chord2Panel extends JPanel { boolean black; double alpha, beta; double[] deltaX; int deltaY, n, number; int x0, x1, y0, y1; int[] frets, strings; public Chord2Panel(int iWidth, int iHeight) { int i; n = 13; deltaX = new double[n]; x0 = iWidth / 8; x1 = 6 * x0; y0 = iHeight / 16; y1 = 4 * y0; alpha = 8.0 * (x1 - x0) / 126.0; beta = (double) x0; deltaY = (y1 - y0) / 5; frets = strings = null; number = 0; for (i = 0; i < 5; i++) deltaX[i] = 14.0 / 8.0; deltaX[5] = deltaX[6] = 1.0; for (i = 7; i < 11; i++) deltaX[i] = 7.0 / 8.0; deltaX[11] = deltaX[12] = 6.0 / 8.0; // linear transformation x = alpha * z + beta // where x is from x0 to x1 in screen coordinates // and z is from 0.0 to 126.0 / 8.0 } public void paintComponent(Graphics g) { double z; int i, j, x, y; super.paintComponent(g); y = y0 + 1; for (i = 0; i < 6; i++) { g.drawLine(x0, y, x1 + x0, y); y += deltaY; } z = 0.0; g.drawLine(x0, y0, x0, y1); for (i = 0; i < n; i++) { z += deltaX[i]; x = (int) (alpha * z + beta); g.drawLine(x - 1, y0, x - 1, y1); g.drawLine(x, y0, x, y1); g.drawLine(x + 1, y0, x + 1, y1); } // 3rd fret pearloid z = deltaX[0] + deltaX[1] + deltaX[2] / 2; x = (int) (alpha * z + beta); y = y0 + (y1 - y0) / 2; g.drawArc(x - 8, y - 8, 16, 16, 0, 360); // 5th fret double pearloid z = deltaX[0] + deltaX[1] + deltaX[2] + deltaX[3] + deltaX[4] / 2; x = (int) (alpha * z + beta); y = y0 + deltaY + deltaY / 2; g.drawArc(x - 8, y - 8, 16, 16, 0, 360); y = y0 + 3 * deltaY + deltaY / 2; g.drawArc(x - 8, y - 8, 16, 16, 0, 360); // 7th fret pearloid z = deltaX[0] + deltaX[1] + deltaX[2] + deltaX[3] + deltaX[4] + deltaX[5] + deltaX[6] / 2; x = (int) (alpha * z + beta); y = y0 + (y1 - y0) / 2; g.drawArc(x - 8, y - 8, 16, 16, 0, 360); // 9th fret pearloid z = deltaX[0] + deltaX[1] + deltaX[2] + deltaX[3] + deltaX[4] + deltaX[5] + deltaX[6] + deltaX[7] + deltaX[8] / 2; x = (int) (alpha * z + beta); y = y0 + (y1 - y0) / 2; g.drawArc(x - 8, y - 8, 16, 16, 0, 360); // 12th fret double pearloid z = deltaX[0] + deltaX[1] + deltaX[2] + deltaX[3] + deltaX[4] + deltaX[5] + deltaX[6] + deltaX[7] + deltaX[8] + deltaX[9] + deltaX[10] + deltaX[11] / 2; x = (int) (alpha * z + beta); y = y0 + deltaY + deltaY / 2; g.drawArc(x - 8, y - 8, 16, 16, 0, 360); y = y0 + 3 * deltaY + deltaY / 2; g.drawArc(x - 8, y - 8, 16, 16, 0, 360); if (frets != null && strings != null) { if (black) g.setColor(Color.blue); else g.setColor(Color.red); for (i = 0; i < number; i++) { z = 0.0; for (j = 0; j <= frets[i]; j++) z += deltaX[j]; x = (int) (alpha * z + beta); y = strings[i] * deltaY + y0 - 8; g.fillArc(x - 16, y, 16, 16, 0, 360); } } } public void drawChord(boolean b, int num, int[] f, int[] s) { black = b; number = num; frets = new int[number]; strings = new int[number]; for (int i = 0; i < number; i++) { frets[i] = f[i]; strings[i] = s[i]; } paintComponent(getGraphics()); } } class Chord2Frame extends JFrame implements ChangeListener { boolean record = false; char[] buffer; final int BufferSize = 3, RecordedChordsBufferSize = 1024; int count, iWidth, iHeight, number, recordedChords, volume; int beatsPerMinute, recordedChordsRepeatCounter; int[] frets, strings, recordedNumber; int[][] recordedFrets, recordedStrings; BorderLayout borderLayout = new BorderLayout(); Chord2Panel chord2Panel; JButton jButton1 = new JButton(); JButton jButton2 = new JButton(); JButton jButton3 = new JButton(); JButton jButton4 = new JButton(); JButton jButton5 = new JButton(); JButton jButton6 = new JButton(); JButton jButton7 = new JButton(); JButton jButton8 = new JButton(); JButton jButton9 = new JButton(); JButton jButtonA = new JButton(); JButton jButtonB = new JButton(); JButton jButtonC = new JButton(); JButton jButtonD = new JButton(); JButton jButtonE = new JButton(); JButton jButtonF = new JButton(); JButton jButtonb = new JButton(); JButton jButtonG = new JButton(); JButton jButtons = new JButton(); JButton jButtonX = new JButton(); JButton jButtonY = new JButton(); JButton jButtonZ = new JButton(); JButton jButtonJ = new JButton(); JButton jButtonK = new JButton(); JButton jButtonL = new JButton(); JPanel jPanel = new JPanel(); Receiver synthesizerReceiver; Synthesizer synthesizer; // step 3 - percentage size the window void setDesktopSize(JFrame frame, int wPerc, int hPerc) { Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); iWidth = screen.width * wPerc / 100; iHeight = screen.height * hPerc / 100; frame.setSize(iWidth, iHeight); } // step 4 - center the window void centerOnScreen(JFrame frame) { Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); Dimension window = frame.getSize(); int iCenterX = screen.width / 2; int iCenterY = screen.height / 2; frame.setLocation(iCenterX - window.width / 2, iCenterY - window.height / 2); } public Chord2Frame(int guitar) { count = recordedChords = 0; volume = 64; buffer = new char[BufferSize + 1]; recordedNumber = new int[RecordedChordsBufferSize]; recordedFrets = new int[RecordedChordsBufferSize][6]; recordedStrings = new int[RecordedChordsBufferSize][6]; String title = "Chord by James Pate Williams, Jr. (c) 2001"; this.getContentPane().setLayout(borderLayout); setTitle(title); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent event) { try { if (synthesizer != null) synthesizer.close(); } catch (Exception exception) { } System.exit(0); } }); jButton1.setToolTipText("some helpful information"); jButton1.setText("user instructions"); jButton1.setVerticalAlignment(SwingConstants.BOTTOM); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jButton1_actionPerformed(e); } }); jButton2.setToolTipText("carry out chord computation"); jButton2.setText("compute"); jButton2.setVerticalAlignment(SwingConstants.BOTTOM); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jButton2_actionPerformed(e); } }); jButton3.setToolTipText("major chord"); jButton3.setText("major"); jButton3.setVerticalAlignment(SwingConstants.BOTTOM); jButton3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jButton3_actionPerformed(e); } }); jButton4.setToolTipText("minor chord"); jButton4.setText("minor"); jButton4.setVerticalAlignment(SwingConstants.BOTTOM); jButton4.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jButton4_actionPerformed(e); } }); jButton5.setToolTipText("augmented chord"); jButton5.setText("augmented"); jButton5.setVerticalAlignment(SwingConstants.BOTTOM); jButton5.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jButton5_actionPerformed(e); } }); jButton6.setToolTipText("diminished chord"); jButton6.setText("diminished"); jButton6.setVerticalAlignment(SwingConstants.BOTTOM); jButton6.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jButton6_actionPerformed(e); } }); jButton7.setToolTipText("6th chord"); jButton7.setText("6th"); jButton7.setVerticalAlignment(SwingConstants.BOTTOM); jButton7.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jButton7_actionPerformed(e); } }); jButton8.setToolTipText("7th chord"); jButton8.setText("7th"); jButton8.setVerticalAlignment(SwingConstants.BOTTOM); jButton8.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jButton8_actionPerformed(e); } }); jButton9.setToolTipText("9th chord"); jButton9.setText("9th"); jButton9.setVerticalAlignment(SwingConstants.BOTTOM); jButton9.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jButton9_actionPerformed(e); } }); jButtonA.setToolTipText("A chord"); jButtonA.setText("A"); jButtonA.setVerticalAlignment(SwingConstants.BOTTOM); jButtonA.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jButtonA_actionPerformed(e); } }); jButtonB.setToolTipText("B chord"); jButtonB.setText("B"); jButtonB.setVerticalAlignment(SwingConstants.BOTTOM); jButtonB.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jButtonB_actionPerformed(e); } }); jButtonC.setToolTipText("C chord"); jButtonC.setText("C"); jButtonC.setVerticalAlignment(SwingConstants.BOTTOM); jButtonC.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jButtonC_actionPerformed(e); } }); jButtonD.setToolTipText("D chord"); jButtonD.setText("D"); jButtonD.setVerticalAlignment(SwingConstants.BOTTOM); jButtonD.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jButtonD_actionPerformed(e); } }); jButtonE.setToolTipText("E chord"); jButtonE.setText("E"); jButtonE.setVerticalAlignment(SwingConstants.BOTTOM); jButtonE.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jButtonE_actionPerformed(e); } }); jButtonF.setToolTipText("F chord"); jButtonF.setText("F"); jButtonF.setVerticalAlignment(SwingConstants.BOTTOM); jButtonF.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jButtonF_actionPerformed(e); } }); jButtonb.setToolTipText("flat chord"); jButtonb.setText("b"); jButtonb.setVerticalAlignment(SwingConstants.BOTTOM); jButtonb.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jButtonb_actionPerformed(e); } }); jButtonG.setToolTipText("G chord"); jButtonG.setText("G"); jButtonG.setVerticalAlignment(SwingConstants.BOTTOM); jButtonG.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jButtonG_actionPerformed(e); } }); jButtons.setToolTipText("sharp chord"); jButtons.setText("#"); jButtons.setVerticalAlignment(SwingConstants.BOTTOM); jButtons.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jButtons_actionPerformed(e); } }); jButtonX.setToolTipText("increase volume"); jButtonX.setText("+"); jButtonX.setVerticalAlignment(SwingConstants.BOTTOM); jButtonX.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jButtonX_actionPerformed(e); } }); jButtonY.setText("play chord"); jButtonY.setVerticalAlignment(SwingConstants.BOTTOM); jButtonY.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jButtonY_actionPerformed(e); } }); try { synthesizer = MidiSystem.getSynthesizer(); synthesizer.open(); //Soundbank soundBank = synthesizer.getDefaultSoundbank(); //Instrument[] instruments; //if (soundBank != null) { //instruments = synthesizer.getDefaultSoundbank().getInstruments(); //synthesizer.loadInstrument(instruments[guitar]); MidiChannel midiChannels[] = synthesizer.getChannels(); for (int i = 0; i < midiChannels.length; i++) midiChannels[i].programChange(guitar); synthesizerReceiver = synthesizer.getReceiver(); jButtonY.setToolTipText("plays recorded chords"); //} } catch (Exception exception) { jButtonX.setEnabled(false); jButtonY.setEnabled(false); jButtonZ.setEnabled(false); } jButtonZ.setToolTipText("decrease volume"); jButtonZ.setText("-"); jButtonZ.setVerticalAlignment(SwingConstants.BOTTOM); jButtonZ.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jButtonZ_actionPerformed(e); } }); jButtonJ.setToolTipText("record chords"); jButtonJ.setText("record"); jButtonJ.setVerticalAlignment(SwingConstants.BOTTOM); jButtonJ.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jButtonJ_actionPerformed(e); } }); jButtonK.setToolTipText("play chords"); jButtonK.setText("play"); jButtonK.setVerticalAlignment(SwingConstants.BOTTOM); jButtonK.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jButtonK_actionPerformed(e); } }); jButtonL.setToolTipText("clear recorded chords"); jButtonL.setText("clear"); jButtonL.setVerticalAlignment(SwingConstants.BOTTOM); jButtonL.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jButtonL_actionPerformed(e); } }); jPanel.setLayout(new GridLayout(9, 3)); jPanel.add(jButton1); jPanel.add(jButton2); jPanel.add(jButton3); jPanel.add(jButton4); jPanel.add(jButton5); jPanel.add(jButton6); jPanel.add(jButton7); jPanel.add(jButton8); jPanel.add(jButton9); jPanel.add(jButtonA); jPanel.add(jButtonB); jPanel.add(jButtonC); jPanel.add(jButtonD); jPanel.add(jButtonE); jPanel.add(jButtonF); jPanel.add(jButtonb); jPanel.add(jButtonG); jPanel.add(jButtons); jPanel.add(jButtonX); jPanel.add(jButtonY); jPanel.add(jButtonZ); jPanel.add(jButtonJ); jPanel.add(jButtonK); jPanel.add(jButtonL); beatsPerMinute = 108; recordedChordsRepeatCounter = 1; JSlider beatsPerMinuteS = createSlider("beats per minute", 40, 208, beatsPerMinute); JSlider recordedChordsRepeatCounterS = createSlider("recorded chords repeat counter", 1, 16, recordedChordsRepeatCounter); jPanel.add(beatsPerMinuteS); jPanel.add(recordedChordsRepeatCounterS); setDesktopSize(this, 100, 100); centerOnScreen(this); Container contentPane = getContentPane(); contentPane.add(jPanel, BorderLayout.SOUTH); chord2Panel = new Chord2Panel(iWidth, iHeight); contentPane.add(chord2Panel, BorderLayout.CENTER); this.show(); } void testCount() { if (count == BufferSize + 1) { JOptionPane.showMessageDialog(this, "Buffer Overflow", "Error Message", JOptionPane.ERROR_MESSAGE); count = 0; } } void majorChord(int fsIndex) { if (fsIndex == - 1) { switch (buffer[0]) { case 'A': number = 3; frets = new int[number]; strings = new int[number]; frets[0] = 1; frets[1] = 1; frets[2] = 1; strings[0] = 1; strings[1] = 2; strings[2] = 3; break; case 'B': number = 5; frets = new int[number]; strings = new int[number]; frets[0] = 1; frets[1] = 1; frets[2] = 3; frets[3] = 3; frets[4] = 3; strings[0] = 4; strings[1] = 0; strings[2] = 3; strings[3] = 2; strings[4] = 1; break; case 'C': number = 3; frets = new int[number]; strings = new int[number]; frets[0] = 0; frets[1] = 1; frets[2] = 2; strings[0] = 1; strings[1] = 3; strings[2] = 4; break; case 'D': number = 3; frets = new int[number]; strings = new int[number]; frets[0] = 1; frets[1] = 2; frets[2] = 1; strings[0] = 0; strings[1] = 1; strings[2] = 2; break; case 'E': number = 3; frets = new int[number]; strings = new int[number]; frets[0] = 0; frets[1] = 1; frets[2] = 1; strings[0] = 2; strings[1] = 3; strings[2] = 4; break; case 'F': number = 6; frets = new int[number]; strings = new int[number]; frets[0] = 0; frets[1] = 0; frets[2] = 0; frets[3] = 1; frets[4] = 2; frets[5] = 2; strings[0] = 0; strings[1] = 1; strings[2] = 5; strings[3] = 2; strings[4] = 3; strings[5] = 4; break; case 'G': number = 3; frets = new int[number]; strings = new int[number]; frets[0] = 1; frets[1] = 2; frets[2] = 2; strings[0] = 4; strings[1] = 5; strings[2] = 0; break; } } else if (buffer[1] == 'b') { // flat (b) switch (buffer[0]) { case 'A': number = 6; frets = new int[number]; strings = new int[number]; frets[0] = 3; frets[1] = 3; frets[2] = 3; frets[3] = 4; frets[4] = 5; frets[5] = 5; strings[0] = 0; strings[1] = 1; strings[2] = 5; strings[3] = 2; strings[4] = 3; strings[5] = 4; break; case 'B': number = 6; frets = new int[number]; strings = new int[number]; frets[0] = 0; frets[1] = 0; frets[2] = 0; frets[3] = 2; frets[4] = 2; frets[5] = 2; strings[0] = 0; strings[1] = 4; strings[2] = 5; strings[3] = 1; strings[4] = 2; strings[5] = 3; break; case 'C': number = 6; frets = new int[number]; strings = new int[number]; frets[0] = 1; frets[1] = 1; frets[2] = 1; frets[3] = 3; frets[4] = 3; frets[5] = 3; strings[0] = 0; strings[1] = 4; strings[2] = 5; strings[3] = 1; strings[4] = 2; strings[5] = 3; break; case 'D': number = 5; frets = new int[number]; strings = new int[number]; frets[0] = 0; frets[1] = 1; frets[2] = 0; frets[3] = 2; frets[4] = 3; strings[0] = 0; strings[1] = 1; strings[2] = 2; strings[3] = 3; strings[4] = 4; break; case 'E': number = 5; frets = new int[number]; strings = new int[number]; frets[0] = 2; frets[1] = 3; frets[2] = 2; frets[3] = 4; frets[4] = 5; strings[0] = 0; strings[1] = 1; strings[2] = 2; strings[3] = 3; strings[4] = 4; break; case 'F': number = 3; frets = new int[number]; strings = new int[number]; frets[0] = 0; frets[1] = 1; frets[2] = 1; strings[0] = 2; strings[1] = 3; strings[2] = 4; break; case 'G': number = 6; frets = new int[number]; strings = new int[number]; frets[0] = 1; frets[1] = 1; frets[2] = 1; frets[3] = 2; frets[4] = 3; frets[5] = 3; strings[0] = 0; strings[1] = 1; strings[2] = 5; strings[3] = 2; strings[4] = 3; strings[5] = 4; break; } } else { // sharp (#) switch (buffer[0]) { case 'A': number = 6; frets = new int[number]; strings = new int[number]; frets[0] = 0; frets[1] = 0; frets[2] = 0; frets[3] = 2; frets[4] = 2; frets[5] = 2; strings[0] = 0; strings[1] = 4; strings[2] = 5; strings[3] = 1; strings[4] = 2; strings[5] = 3; break; case 'B': number = 3; frets = new int[number]; strings = new int[number]; frets[0] = 0; frets[1] = 1; frets[2] = 2; strings[0] = 1; strings[1] = 3; strings[2] = 4; break; case 'C': number = 5; frets = new int[number]; strings = new int[number]; frets[0] = 0; frets[1] = 1; frets[2] = 0; frets[3] = 2; frets[4] = 3; strings[0] = 0; strings[1] = 1; strings[2] = 2; strings[3] = 3; strings[4] = 4; break; case 'D': number = 5; frets = new int[number]; strings = new int[number]; frets[0] = 2; frets[1] = 3; frets[2] = 2; frets[3] = 4; frets[4] = 5; strings[0] = 0; strings[1] = 1; strings[2] = 2; strings[3] = 3; strings[4] = 4; break; case 'E': number = 6; frets = new int[number]; strings = new int[number]; frets[0] = 0; frets[1] = 0; frets[2] = 0; frets[3] = 1; frets[4] = 2; frets[5] = 2; strings[0] = 0; strings[1] = 1; strings[2] = 5; strings[3] = 2; strings[4] = 3; strings[5] = 4; break; case 'F': number = 6; frets = new int[number]; strings = new int[number]; frets[0] = 1; frets[1] = 1; frets[2] = 1; frets[3] = 2; frets[4] = 3; frets[5] = 3; strings[0] = 0; strings[1] = 1; strings[2] = 5; strings[3] = 2; strings[4] = 3; strings[5] = 4; break; case 'G': number = 6; frets = new int[number]; strings = new int[number]; frets[0] = 3; frets[1] = 3; frets[2] = 3; frets[3] = 4; frets[4] = 5; frets[5] = 5; strings[0] = 0; strings[1] = 1; strings[2] = 5; strings[3] = 2; strings[4] = 3; strings[5] = 4; break; } } } void minorChord(int fsIndex) { if (fsIndex == - 1) { switch (buffer[0]) { case 'A': number = 3; frets = new int[number]; strings = new int[number]; frets[0] = 0; frets[1] = 1; frets[2] = 1; strings[0] = 1; strings[1] = 2; strings[2] = 3; break; case 'B': number = 6; frets = new int[number]; strings = new int[number]; frets[0] = 6; frets[1] = 6; frets[2] = 6; frets[3] = 8; frets[4] = 8; frets[5] = 8; strings[0] = 0; strings[1] = 1; strings[2] = 5; strings[3] = 2; strings[4] = 3; strings[5] = 4; break; case 'C': number = 3; frets = new int[number]; strings = new int[number]; frets[0] = 0; frets[1] = 0; frets[2] = 2; strings[0] = 1; strings[1] = 3; strings[2] = 4; break; case 'D': number = 3; frets = new int[number]; strings = new int[number]; frets[0] = 0; frets[1] = 1; frets[2] = 2; strings[0] = 0; strings[1] = 2; strings[2] = 1; break; case 'E': number = 2; frets = new int[number]; strings = new int[number]; frets[0] = 1; frets[1] = 1; strings[0] = 3; strings[1] = 4; break; case 'F': number = 6; frets = new int[number]; strings = new int[number]; frets[0] = 0; frets[1] = 0; frets[2] = 0; frets[3] = 0; frets[4] = 2; frets[5] = 2; strings[0] = 0; strings[1] = 1; strings[2] = 2; strings[3] = 5; strings[4] = 3; strings[5] = 4; break; case 'G': number = 6; frets = new int[number]; strings = new int[number]; frets[0] = 2; frets[1] = 2; frets[2] = 2; frets[3] = 2; frets[4] = 4; frets[5] = 4; strings[0] = 0; strings[1] = 1; strings[2] = 2; strings[3] = 5; strings[4] = 3; strings[5] = 4; break; } } else if (buffer[1] == 'b') { // flat (b) switch (buffer[0]) { case 'A': number = 6; frets = new int[number]; strings = new int[number]; frets[0] = 3; frets[1] = 3; frets[2] = 3; frets[3] = 3; frets[4] = 5; frets[5] = 5; strings[0] = 0; strings[1] = 1; strings[2] = 2; strings[3] = 5; strings[4] = 3; strings[5] = 4; break; case 'B': number = 6; frets = new int[number]; strings = new int[number]; frets[0] = 5; frets[1] = 5; frets[2] = 5; frets[3] = 5; frets[4] = 7; frets[5] = 7; strings[0] = 0; strings[1] = 1; strings[2] = 2; strings[3] = 5; strings[4] = 3; strings[5] = 4; break; case 'C': number = 6; frets = new int[number]; strings = new int[number]; frets[0] = 6; frets[1] = 6; frets[2] = 6; frets[3] = 6; frets[4] = 8; frets[5] = 8; strings[0] = 0; strings[1] = 1; strings[2] = 2; strings[3] = 5; strings[4] = 3; strings[5] = 4; break; case 'D': number = 3; frets = new int[number]; strings = new int[number]; frets[0] = 1; frets[1] = 0; frets[2] = 1; strings[0] = 1; strings[1] = 2; strings[2] = 3; break; case 'E': number = 6; frets = new int[number]; strings = new int[number]; frets[0] = 5; frets[1] = 5; frets[2] = 5; frets[3] = 6; frets[4] = 7; frets[5] = 7; strings[0] = 0; strings[1] = 4; strings[2] = 5; strings[3] = 1; strings[4] = 2; strings[5] = 3; break; case 'F': number = 2; frets = new int[number]; strings = new int[number]; frets[0] = 1; frets[1] = 1; strings[0] = 3; strings[1] = 4; break; case 'G': number = 6; frets = new int[number]; strings = new int[number]; frets[0] = 1; frets[1] = 1; frets[2] = 1; frets[3] = 1; frets[4] = 3; frets[5] = 3; strings[0] = 0; strings[1] = 1; strings[2] = 2; strings[3] = 5; strings[4] = 3; strings[5] = 4; break; } } else { // sharp (#) switch (buffer[0]) { case 'A': number = 6; frets = new int[number]; strings = new int[number]; frets[0] = 5; frets[1] = 5; frets[2] = 5; frets[3] = 5; frets[4] = 7; frets[5] = 7; strings[0] = 0; strings[1] = 1; strings[2] = 2; strings[3] = 5; strings[4] = 3; strings[5] = 4; break; case 'B': number = 3; frets = new int[number]; strings = new int[number]; frets[0] = 0; frets[1] = 0; frets[2] = 2; strings[0] = 1; strings[1] = 3; strings[2] = 4; break; case 'C': number = 3; frets = new int[number]; strings = new int[number]; frets[0] = 1; frets[1] = 0; frets[2] = 1; strings[0] = 1; strings[1] = 2; strings[2] = 3; break; case 'D': number = 6; frets = new int[number]; strings = new int[number]; frets[0] = 5; frets[1] = 5; frets[2] = 5; frets[3] = 6; frets[4] = 7; frets[5] = 7; strings[0] = 0; strings[1] = 4; strings[2] = 5; strings[3] = 1; strings[4] = 2; strings[5] = 3; break; case 'E': number = 6; frets = new int[number]; strings = new int[number]; frets[0] = 0; frets[1] = 0; frets[2] = 0; frets[3] = 0; frets[4] = 2; frets[5] = 2; strings[0] = 0; strings[1] = 1; strings[2] = 2; strings[3] = 5; strings[4] = 3; strings[5] = 4; break; case 'F': number = 6; frets = new int[number]; strings = new int[number]; frets[0] = 1; frets[1] = 1; frets[2] = 1; frets[3] = 1; frets[4] = 3; frets[5] = 3; strings[0] = 0; strings[1] = 1; strings[2] = 2; strings[3] = 5; strings[4] = 3; strings[5] = 4; break; case 'G': number = 6; frets = new int[number]; strings = new int[number]; frets[0] = 3; frets[1] = 3; frets[2] = 3; frets[3] = 3; frets[4] = 5; frets[5] = 5; strings[0] = 0; strings[1] = 1; strings[2] = 2; strings[3] = 5; strings[4] = 3; strings[5] = 4; break; } } } void dominantChord(int fsIndex) { } void augmentedChord(int fsIndex) { if (fsIndex == - 1) { switch (buffer[0]) { case 'A': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 4; frets[1] = 5; frets[2] = 5; frets[3] = 6; strings[0] = 0; strings[1] = 1; strings[2] = 2; strings[3] = 3; break; case 'B': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 6; frets[1] = 7; frets[2] = 7; frets[3] = 8; strings[0] = 0; strings[1] = 1; strings[2] = 2; strings[3] = 3; break; case 'C': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 7; frets[1] = 8; frets[2] = 8; frets[3] = 9; strings[0] = 0; strings[1] = 1; strings[2] = 2; strings[3] = 3; break; case 'D': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 2; frets[1] = 2; frets[2] = 3; frets[3] = 4; strings[0] = 1; strings[1] = 2; strings[2] = 3; strings[3] = 4; break; case 'E': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 4; frets[1] = 4; frets[2] = 5; frets[3] = 6; strings[0] = 1; strings[1] = 2; strings[2] = 3; strings[3] = 4; break; case 'F': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 0; frets[1] = 1; frets[2] = 1; frets[3] = 2; strings[0] = 0; strings[1] = 1; strings[2] = 2; strings[3] = 3; break; case 'G': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 2; frets[1] = 3; frets[2] = 3; frets[3] = 4; strings[0] = 0; strings[1] = 1; strings[2] = 2; strings[3] = 3; break; } } else if (buffer[1] == 'b') { // flat (b) switch (buffer[0]) { case 'A': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 3; frets[1] = 4; frets[2] = 4; frets[3] = 5; strings[0] = 0; strings[1] = 1; strings[2] = 2; strings[3] = 3; break; case 'B': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 5; frets[1] = 6; frets[2] = 6; frets[3] = 7; strings[0] = 0; strings[1] = 1; strings[2] = 2; strings[3] = 3; break; case 'C': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 6; frets[1] = 7; frets[2] = 7; frets[3] = 8; strings[0] = 0; strings[1] = 1; strings[2] = 2; strings[3] = 3; break; case 'D': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 1; frets[1] = 1; frets[2] = 2; frets[3] = 3; strings[0] = 1; strings[1] = 2; strings[2] = 3; strings[3] = 4; break; case 'E': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 3; frets[1] = 3; frets[2] = 4; frets[3] = 5; strings[0] = 1; strings[1] = 2; strings[2] = 3; strings[3] = 4; break; case 'F': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 4; frets[1] = 4; frets[2] = 5; frets[3] = 6; strings[0] = 1; strings[1] = 2; strings[2] = 3; strings[3] = 4; break; case 'G': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 1; frets[1] = 2; frets[2] = 2; frets[3] = 3; strings[0] = 0; strings[1] = 1; strings[2] = 2; strings[3] = 3; break; } } else { // sharp (#) switch (buffer[0]) { case 'A': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 5; frets[1] = 6; frets[2] = 6; frets[3] = 7; strings[0] = 0; strings[1] = 1; strings[2] = 2; strings[3] = 3; break; case 'B': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 7; frets[1] = 8; frets[2] = 8; frets[3] = 9; strings[0] = 0; strings[1] = 1; strings[2] = 2; strings[3] = 3; break; case 'C': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 1; frets[1] = 1; frets[2] = 2; frets[3] = 3; strings[0] = 1; strings[1] = 2; strings[2] = 3; strings[3] = 4; break; case 'D': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 3; frets[1] = 3; frets[2] = 4; frets[3] = 5; strings[0] = 1; strings[1] = 2; strings[2] = 3; strings[3] = 4; break; case 'E': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 0; frets[1] = 1; frets[2] = 1; frets[3] = 2; strings[0] = 0; strings[1] = 1; strings[2] = 2; strings[3] = 3; break; case 'F': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 1; frets[1] = 2; frets[2] = 2; frets[3] = 3; strings[0] = 0; strings[1] = 1; strings[2] = 2; strings[3] = 3; break; case 'G': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 3; frets[1] = 4; frets[2] = 4; frets[3] = 5; strings[0] = 0; strings[1] = 1; strings[2] = 2; strings[3] = 3; break; } } } void diminishedChord(int fsIndex) { if (fsIndex == - 1) { switch (buffer[0]) { case 'A': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 3; frets[1] = 4; frets[2] = 4; frets[3] = 5; strings[0] = 3; strings[1] = 2; strings[2] = 5; strings[3] = 4; break; case 'B': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 5; frets[1] = 6; frets[2] = 6; frets[3] = 7; strings[0] = 3; strings[1] = 2; strings[2] = 5; strings[3] = 4; break; case 'C': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 1; frets[1] = 2; frets[2] = 3; frets[3] = 3; strings[0] = 2; strings[1] = 4; strings[2] = 1; strings[3] = 3; break; case 'D': number = 2; frets = new int[number]; strings = new int[number]; frets[0] = 0; frets[1] = 0; strings[0] = 0; strings[1] = 2; break; case 'E': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 1; frets[1] = 1; frets[2] = 2; frets[3] = 2; strings[0] = 1; strings[1] = 3; strings[2] = 0; strings[3] = 2; break; case 'F': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 2; frets[1] = 2; frets[2] = 3; frets[3] = 3; strings[0] = 1; strings[1] = 3; strings[2] = 0; strings[3] = 2; break; case 'G': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 1; frets[1] = 2; frets[2] = 2; frets[3] = 3; strings[0] = 3; strings[1] = 2; strings[2] = 5; strings[3] = 4; break; } } else if (buffer[1] == 'b') { // flat (b) switch (buffer[0]) { case 'A': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 2; frets[1] = 3; frets[2] = 3; frets[3] = 4; strings[0] = 3; strings[1] = 2; strings[2] = 5; strings[3] = 4; break; case 'B': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 4; frets[1] = 5; frets[2] = 5; frets[3] = 6; strings[0] = 3; strings[1] = 2; strings[2] = 5; strings[3] = 4; break; case 'C': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 5; frets[1] = 6; frets[2] = 6; frets[3] = 7; strings[0] = 3; strings[1] = 2; strings[2] = 5; strings[3] = 4; break; case 'D': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 2; frets[1] = 3; frets[2] = 4; frets[3] = 4; strings[0] = 2; strings[1] = 4; strings[2] = 3; strings[3] = 1; break; case 'E': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 0; frets[1] = 0; frets[2] = 1; frets[3] = 1; strings[0] = 1; strings[1] = 3; strings[2] = 0; strings[3] = 2; break; case 'F': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 1; frets[1] = 1; frets[2] = 2; frets[3] = 2; strings[0] = 1; strings[1] = 3; strings[2] = 0; strings[3] = 2; break; case 'G': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 3; frets[1] = 3; frets[2] = 4; frets[3] = 4; strings[0] = 1; strings[1] = 3; strings[2] = 0; strings[3] = 2; break; } } else { // sharp (#) switch (buffer[0]) { case 'A': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 4; frets[1] = 5; frets[2] = 5; frets[3] = 6; strings[0] = 3; strings[1] = 2; strings[2] = 5; strings[3] = 4; break; case 'B': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 1; frets[1] = 2; frets[2] = 3; frets[3] = 3; strings[0] = 2; strings[1] = 4; strings[2] = 1; strings[3] = 3; break; case 'C': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 2; frets[1] = 3; frets[2] = 4; frets[3] = 4; strings[0] = 2; strings[1] = 4; strings[2] = 1; strings[3] = 3; break; case 'D': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 0; frets[1] = 0; frets[2] = 1; frets[3] = 1; strings[0] = 1; strings[1] = 3; strings[2] = 0; strings[3] = 2; break; case 'E': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 2; frets[1] = 2; frets[2] = 3; frets[3] = 3; strings[0] = 1; strings[1] = 3; strings[2] = 0; strings[3] = 2; break; case 'F': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 3; frets[1] = 3; frets[2] = 4; frets[3] = 4; strings[0] = 1; strings[1] = 3; strings[2] = 0; strings[3] = 2; break; case 'G': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 2; frets[1] = 3; frets[2] = 3; frets[3] = 4; strings[0] = 3; strings[1] = 2; strings[2] = 5; strings[3] = 4; break; } } } void sixthChord(int fsIndex) { if (fsIndex == - 1) { switch (buffer[0]) { case 'A': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 1; frets[1] = 1; frets[2] = 1; frets[3] = 1; strings[0] = 0; strings[1] = 1; strings[2] = 2; strings[3] = 3; break; case 'B': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 0; frets[1] = 0; frets[2] = 1; frets[3] = 1; strings[0] = 2; strings[1] = 3; strings[2] = 4; strings[3] = 5; break; case 'C': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 0; frets[1] = 1; frets[2] = 1; frets[3] = 2; strings[0] = 1; strings[1] = 2; strings[2] = 3; strings[3] = 4; break; case 'D': number = 2; frets = new int[number]; strings = new int[number]; frets[0] = 1; frets[1] = 1; strings[0] = 0; strings[1] = 2; break; case 'E': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 0; frets[1] = 1; frets[2] = 1; frets[3] = 1; strings[0] = 2; strings[1] = 1; strings[2] = 3; strings[3] = 4; break; case 'F': number = 3; frets = new int[number]; strings = new int[number]; frets[0] = 0; frets[1] = 0; frets[2] = 1; strings[0] = 1; strings[1] = 5; strings[2] = 2; break; case 'G': number = 2; frets = new int[number]; strings = new int[number]; frets[0] = 1; frets[1] = 2; strings[0] = 4; strings[1] = 5; break; } } else if (buffer[1] == 'b') { // flat (b) switch (buffer[0]) { case 'A': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 2; frets[1] = 3; frets[2] = 3; frets[3] = 4; strings[0] = 3; strings[1] = 1; strings[2] = 5; strings[3] = 2; break; case 'B': number = 6; frets = new int[number]; strings = new int[number]; frets[0] = 0; frets[1] = 0; frets[2] = 2; frets[3] = 2; frets[4] = 2; frets[5] = 2; strings[0] = 4; strings[1] = 5; strings[2] = 0; strings[3] = 1; strings[4] = 2; strings[5] = 3; break; case 'C': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 0; frets[1] = 0; frets[2] = 1; frets[3] = 1; strings[0] = 2; strings[1] = 3; strings[2] = 4; strings[3] = 5; break; case 'D': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 1; frets[1] = 2; frets[2] = 2; frets[3] = 3; strings[0] = 1; strings[1] = 2; strings[2] = 3; strings[3] = 4; break; case 'E': number = 6; frets = new int[number]; strings = new int[number]; frets[0] = 5; frets[1] = 5; frets[2] = 7; frets[3] = 7; frets[4] = 7; frets[5] = 7; strings[0] = 4; strings[1] = 5; strings[2] = 0; strings[3] = 1; strings[4] = 2; strings[5] = 3; break; case 'F': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 0; frets[1] = 1; frets[2] = 1; frets[3] = 1; strings[0] = 2; strings[1] = 1; strings[2] = 3; strings[3] = 4; break; case 'G': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 0; frets[1] = 1; frets[2] = 1; frets[3] = 2; strings[0] = 3; strings[1] = 1; strings[2] = 5; strings[3] = 2; break; } } else { // sharp (#) switch (buffer[0]) { case 'A': number = 6; frets = new int[number]; strings = new int[number]; frets[0] = 0; frets[1] = 0; frets[2] = 2; frets[3] = 2; frets[4] = 2; frets[5] = 2; strings[0] = 4; strings[1] = 5; strings[2] = 0; strings[3] = 1; strings[4] = 2; strings[5] = 3; break; case 'B': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 0; frets[1] = 1; frets[2] = 1; frets[3] = 2; strings[0] = 1; strings[1] = 2; strings[2] = 3; strings[3] = 4; break; case 'C': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 1; frets[1] = 2; frets[2] = 2; frets[3] = 3; strings[0] = 1; strings[1] = 2; strings[2] = 3; strings[3] = 4; break; case 'D': number = 6; frets = new int[number]; strings = new int[number]; frets[0] = 5; frets[1] = 5; frets[2] = 7; frets[3] = 7; frets[4] = 7; frets[5] = 7; strings[0] = 4; strings[1] = 5; strings[2] = 0; strings[3] = 1; strings[4] = 2; strings[5] = 3; break; case 'E': number = 3; frets = new int[number]; strings = new int[number]; frets[0] = 0; frets[1] = 0; frets[2] = 1; strings[0] = 1; strings[1] = 5; strings[2] = 2; break; case 'F': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 0; frets[1] = 1; frets[2] = 1; frets[3] = 2; strings[0] = 3; strings[1] = 1; strings[2] = 5; strings[3] = 2; break; case 'G': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 2; frets[1] = 3; frets[2] = 3; frets[3] = 4; strings[0] = 3; strings[1] = 1; strings[2] = 5; strings[3] = 2; break; } } } void seventhChord(int fsIndex) { if (fsIndex == - 1) { switch (buffer[0]) { case 'A': number = 2; frets = new int[number]; strings = new int[number]; frets[0] = 1; frets[1] = 1; strings[0] = 1; strings[1] = 3; break; case 'B': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 0; frets[1] = 1; frets[2] = 1; frets[3] = 1; strings[0] = 3; strings[1] = 0; strings[2] = 2; strings[3] = 4; break; case 'C': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 0; frets[1] = 1; frets[2] = 2; frets[3] = 2; strings[0] = 1; strings[1] = 3; strings[2] = 2; strings[3] = 4; break; case 'D': number = 3; frets = new int[number]; strings = new int[number]; frets[0] = 0; frets[1] = 1; frets[2] = 1; strings[0] = 1; strings[1] = 0; strings[2] = 2; break; case 'E': number = 2; frets = new int[number]; strings = new int[number]; frets[0] = 0; frets[1] = 1; strings[0] = 2; strings[1] = 4; break; case 'F': number = 6; frets = new int[number]; strings = new int[number]; frets[0] = 0; frets[1] = 0; frets[2] = 0; frets[3] = 1; frets[4] = 2; frets[5] = 3; strings[0] = 0; strings[1] = 3; strings[2] = 5; strings[3] = 2; strings[4] = 4; strings[5] = 1; break; case 'G': number = 3; frets = new int[number]; strings = new int[number]; frets[0] = 0; frets[1] = 1; frets[2] = 2; strings[0] = 0; strings[1] = 4; strings[2] = 5; break; } } else if (buffer[1] == 'b') { // flat (b) switch (buffer[0]) { case 'A': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 0; frets[1] = 0; frets[2] = 0; frets[3] = 1; strings[0] = 1; strings[1] = 2; strings[2] = 3; strings[3] = 0; break; case 'B': number = 6; frets = new int[number]; strings = new int[number]; frets[0] = 0; frets[1] = 0; frets[2] = 0; frets[3] = 0; frets[4] = 2; frets[5] = 2; strings[0] = 0; strings[1] = 2; strings[2] = 4; strings[3] = 5; strings[4] = 1; strings[5] = 3; break; case 'C': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 0; frets[1] = 1; frets[2] = 1; frets[3] = 1; strings[0] = 3; strings[1] = 0; strings[2] = 2; strings[3] = 4; break; case 'D': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 1; frets[1] = 2; frets[2] = 3; frets[3] = 3; strings[0] = 1; strings[1] = 3; strings[2] = 2; strings[3] = 4; break; case 'E': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 3; frets[1] = 4; frets[2] = 5; frets[3] = 5; strings[0] = 1; strings[1] = 3; strings[2] = 2; strings[3] = 4; break; case 'F': number = 2; frets = new int[number]; strings = new int[number]; frets[0] = 0; frets[1] = 1; strings[0] = 2; strings[1] = 4; break; case 'G': number = 6; frets = new int[number]; strings = new int[number]; frets[0] = 1; frets[1] = 1; frets[2] = 1; frets[3] = 2; frets[4] = 3; frets[5] = 4; strings[0] = 0; strings[1] = 3; strings[2] = 5; strings[3] = 2; strings[4] = 4; strings[5] = 1; break; } } else { // sharp (#) switch (buffer[0]) { case 'A': number = 6; frets = new int[number]; strings = new int[number]; frets[0] = 0; frets[1] = 0; frets[2] = 0; frets[3] = 0; frets[4] = 2; frets[5] = 2; strings[0] = 0; strings[1] = 2; strings[2] = 4; strings[3] = 5; strings[4] = 1; strings[5] = 3; break; case 'B': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 0; frets[1] = 1; frets[2] = 2; frets[3] = 2; strings[0] = 1; strings[1] = 3; strings[2] = 2; strings[3] = 4; break; case 'C': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 1; frets[1] = 2; frets[2] = 3; frets[3] = 3; strings[0] = 1; strings[1] = 3; strings[2] = 2; strings[3] = 4; break; case 'D': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 3; frets[1] = 4; frets[2] = 5; frets[3] = 5; strings[0] = 1; strings[1] = 3; strings[2] = 2; strings[3] = 4; break; case 'E': number = 6; frets = new int[number]; strings = new int[number]; frets[0] = 0; frets[1] = 0; frets[2] = 0; frets[3] = 1; frets[4] = 2; frets[5] = 3; strings[0] = 0; strings[1] = 3; strings[2] = 5; strings[3] = 2; strings[4] = 4; strings[5] = 1; break; case 'F': number = 6; frets = new int[number]; strings = new int[number]; frets[0] = 1; frets[1] = 1; frets[2] = 1; frets[3] = 2; frets[4] = 3; frets[5] = 4; strings[0] = 0; strings[1] = 3; strings[2] = 5; strings[3] = 2; strings[4] = 4; strings[5] = 1; break; case 'G': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 0; frets[1] = 0; frets[2] = 0; frets[3] = 1; strings[0] = 1; strings[1] = 2; strings[2] = 3; strings[3] = 0; break; } } } void ninthChord(int fsIndex) { if (fsIndex == - 1) { switch (buffer[0]) { case 'A': number = 4; frets = new int[number]; strings = new int[number]; frets[0] = 1; frets[1] = 1; frets[2] = 2; frets[3] = 3; strings[0] = 1; strings[1] = 3; strings[2] = 0; strings[3] = 2; break; case 'B': number = 6; frets = new int[number]; strings = new int[number]; frets[0] = 0; frets[1] = 1; frets[2] = 1; frets[3] = 1; frets[4] = 1; frets[5] = 1; strings[0] = 3; strings[1] = 0; strings[2] = 1; strings[3] = 2; strings[4] = 4; strings[5] = 5; break; case 'C': number = 6; frets = new int[number]; strings = new int[number]; frets[0] = 1; frets[1] = 2; frets[2] = 2; frets[3] = 2; frets[4] = 2; frets[5] = 2; strings[0] = 3; strings[1] = 0; strings[2] = 1; strings[3] = 2; strings[4] = 4; strings[5] = 5; break; case 'D': number = 3; frets = new int[number]; strings = new int[number]; frets[0] = 0; frets[1] = 1; frets[2] = 3; strings[0] = 1; strings[1] = 2; strings[2] = 3; break; case 'E': number = 3; frets = new int[number]; strings = new int[number]; frets[0] = 0; frets[1] = 1; frets[2] = 1; strings[0] = 2; strings[1] = 0; strings[2] = 4; break; case 'F': number = 6; frets = new int[number]; strings = new int[number]; frets[0] = 6; frets[1] = 7; frets[2] = 7; frets[3] = 7; frets[4] = 7; frets[5] = 7; strings[0] = 3; strings[1] = 0; strings[2] = 1; strings[3] = 2; strings[4] = 4; strings[5] = 5; break; case 'G': number = 6; frets = new int[number]; strings = new int[number]; frets[0] = 8; frets[1] = 9; frets[2] = 9; frets[3] = 9; frets[4] = 9; frets[5] = 9; strings[0] = 3; strings[1] = 0; strings[2] = 1; strings[3] = 2; strings[4] = 4; strings[5] = 5; break; } } else if (buffer[1] == 'b') { // flat (b) switch (buffer[0]) { case 'A': number = 6; frets = new int[number]; strings = new int[number]; frets[0] = 9; frets[1] = 10; frets[2] = 10; frets[3] = 10; frets[4] = 10; frets[5] = 10; strings[0] = 3; strings[1] = 0; strings[2] = 1; strings[3] = 2; strings[4] = 4; strings[5] = 5; break; case 'B': number = 6; frets = new int[number]; strings = new int[number]; frets[0] = 5; frets[1] = 5; frets[2] = 5; frets[3] = 6; frets[4] = 7; frets[5] = 7; strings[0] = 1; strings[1] = 3; strings[2] = 5; strings[3] = 2; strings[4] = 0; strings[5] = 4; break; case 'C': number = 6; frets = new int[number]; strings = new int[number]; frets[0] = 0; frets[1] = 1; frets[2] = 1; frets[3] = 1; frets[4] = 1; frets[5] = 1; strings[0] = 3; strings[1] = 0; strings[2] = 1; strings[3] = 2; strings[4] = 4; strings[5] = 5; break; case 'D': number = 6; frets = new int[number]; strings = new int[number]; frets[0] = 2; frets[1] = 3; frets[2] = 3; frets[3] = 3; frets[4] = 3; frets[5] = 3; strings[0] = 3; strings[1] = 0; strings[2] = 1; strings[3] = 2; strings[4] = 4; strings[5] = 5; break; case 'E': number = 6; frets = new int[number]; strings = new int[number]; frets[0] = 4; frets[1] = 5; frets[2] = 5; frets[3] = 5; frets[4] = 5; frets[5] = 5; strings[0] = 3; strings[1] = 0; strings[2] = 1; strings[3] = 2; strings[4] = 4; strings[5] = 5; break; case 'F': number = 3; frets = new int[number]; strings = new int[number]; frets[0] = 0; frets[1] = 1; frets[2] = 1; strings[0] = 2; strings[1] = 0; strings[2] = 4; break; case 'G': number = 6; frets = new int[number]; strings = new int[number]; frets[0] = 7; frets[1] = 8; frets[2] = 8; frets[3] = 8; frets[4] = 8; frets[5] = 8; strings[0] = 3; strings[1] = 0; strings[2] = 1; strings[3] = 2; strings[4] = 4; strings[5] = 5; break; } } else if (buffer[1] == '#') { // flat (#) switch (buffer[0]) { case 'A': number = 6; frets = new int[number]; strings = new int[number]; frets[0] = 5; frets[1] = 5; frets[2] = 5; frets[3] = 6; frets[4] = 7; frets[5] = 7; strings[0] = 1; strings[1] = 3; strings[2] = 5; strings[3] = 2; strings[4] = 0; strings[5] = 4; break; case 'B': number = 6; frets = new int[number]; strings = new int[number]; frets[0] = 1; frets[1] = 2; frets[2] = 2; frets[3] = 2; frets[4] = 2; frets[5] = 2; strings[0] = 3; strings[1] = 0; strings[2] = 1; strings[3] = 2; strings[4] = 4; strings[5] = 5; break; case 'C': number = 6; frets = new int[number]; strings = new int[number]; frets[0] = 2; frets[1] = 3; frets[2] = 3; frets[3] = 3; frets[4] = 3; frets[5] = 3; strings[0] = 3; strings[1] = 0; strings[2] = 1; strings[3] = 2; strings[4] = 4; strings[5] = 5; break; case 'D': number = 6; frets = new int[number]; strings = new int[number]; frets[0] = 4; frets[1] = 5; frets[2] = 5; frets[3] = 5; frets[4] = 5; frets[5] = 5; strings[0] = 3; strings[1] = 0; strings[2] = 1; strings[3] = 2; strings[4] = 4; strings[5] = 5; break; case 'E': number = 6; frets = new int[number]; strings = new int[number]; frets[0] = 6; frets[1] = 7; frets[2] = 7; frets[3] = 7; frets[4] = 7; frets[5] = 7; strings[0] = 3; strings[1] = 0; strings[2] = 1; strings[3] = 2; strings[4] = 4; strings[5] = 5; break; case 'F': number = 6; frets = new int[number]; strings = new int[number]; frets[0] = 7; frets[1] = 8; frets[2] = 8; frets[3] = 8; frets[4] = 8; frets[5] = 8; strings[0] = 3; strings[1] = 0; strings[2] = 1; strings[3] = 2; strings[4] = 4; strings[5] = 5; break; case 'G': number = 6; frets = new int[number]; strings = new int[number]; frets[0] = 9; frets[1] = 10; frets[2] = 10; frets[3] = 10; frets[4] = 10; frets[5] = 10; strings[0] = 3; strings[1] = 0; strings[2] = 1; strings[3] = 2; strings[4] = 4; strings[5] = 5; break; } } } JSlider createSlider(String name, int min, int max, int value) { JSlider slider = new JSlider(JSlider.HORIZONTAL, min, max, value); slider.addChangeListener(this); TitledBorder tb = new TitledBorder(new EtchedBorder()); tb.setTitle(name + " = " + Integer.toString(value)); slider.setBorder(tb); return slider; } public void stateChanged(ChangeEvent e) { JSlider slider = (JSlider) e.getSource(); int value = slider.getValue(); TitledBorder tb = (TitledBorder) slider.getBorder(); String s = tb.getTitle(); tb.setTitle(s.substring(0, s.indexOf('=') + 1) + s.valueOf(value)); if (s.startsWith("beats per minute")) beatsPerMinute = value; else if (s.startsWith("recorded chords repeat counter")) recordedChordsRepeatCounter = value; slider.repaint(); } void jButton1_actionPerformed(ActionEvent e) { String message1 = new String("Enter 'A' to 'G' first then if desired 'b' for flat or '#' for sharp"); String message2 = new String("then either 'major' to '9th' and finally 'compute'. Currently, some"); String message3 = new String("commands such as 'A' 'major' '6th' 'compute' are allowed but do not"); String message4 = new String("produce the desired effect. If 'play chord' is enabled it plays the"); String message5 = new String("currently displayed chord. '+' if enabled increases the volume. '-'"); String message6 = new String("if enabled decreases the volume. If a chord is displayed and you"); String message7 = new String("hear nothing after 'play chord' then increase the volume again."); String message = new String(); message = message1 + "\n" + message2 + "\n" + message3 + "\n" + message4 + "\n" + message5 + "\n" + message6 + "\n" + message7; JOptionPane.showMessageDialog(this, message, "Helpful Hints", JOptionPane.INFORMATION_MESSAGE); count = 0; } void jButton2_actionPerformed(ActionEvent e) { int fsIndex = - 1, i, j, next; if (buffer[0] != 'A' && buffer[0] != 'B' && buffer[0] != 'C' && buffer[0] != 'D' && buffer[0] != 'E' && buffer[0] != 'F' && buffer[0] != 'G') { JOptionPane.showMessageDialog(this, "Must start with 'A' to 'G'", "Error Message", JOptionPane.ERROR_MESSAGE); count = 0; return; } for (i = 1; i < count; i++) if (buffer[i] == 'b' || buffer[i] == '#') fsIndex = i; if (fsIndex != - 1 && fsIndex != 1) { JOptionPane.showMessageDialog(this, "Flat (b) or sharp (#) must be after 'A' to 'G'", "Error Message", JOptionPane.ERROR_MESSAGE); count = 0; return; } next = fsIndex == - 1 ? 1 : 2; if (next == count) { JOptionPane.showMessageDialog(this, "'major' to '9th' required", "Error Message", JOptionPane.ERROR_MESSAGE); count = 0; return; } if (buffer[next] < '1' || buffer[next] > '7') { JOptionPane.showMessageDialog(this, "'major' to '9th' expected", "Error Message", JOptionPane.ERROR_MESSAGE); count = 0; return; } switch (buffer[next]) { case '1': majorChord(fsIndex); break; case '2': minorChord(fsIndex); break; case '3': augmentedChord(fsIndex); break; case '4': diminishedChord(fsIndex); break; case '5': sixthChord(fsIndex); break; case '6': seventhChord(fsIndex); break; case '7': ninthChord(fsIndex); break; } chord2Panel.drawChord(true, number, frets, strings); count = 0; if (record) { if (recordedChords + recordedChordsRepeatCounter < RecordedChordsBufferSize) { for (i = 0; i < recordedChordsRepeatCounter; i++) { for (j = 0; j < number; j++) { recordedFrets[recordedChords][j] = frets[j]; recordedStrings[recordedChords][j] = strings[j]; } recordedNumber[recordedChords++] = number; } } else JOptionPane.showMessageDialog(this, "Recording chord buffer overrun, try pressing 'clear'", "Error Message", JOptionPane.ERROR_MESSAGE); } } void jButton3_actionPerformed(ActionEvent e) { buffer[count++] = '1'; testCount(); } void jButton4_actionPerformed(ActionEvent e) { buffer[count++] = '2'; testCount(); } void jButton5_actionPerformed(ActionEvent e) { buffer[count++] = '3'; testCount(); } void jButton6_actionPerformed(ActionEvent e) { buffer[count++] = '4'; testCount(); } void jButton7_actionPerformed(ActionEvent e) { buffer[count++] = '5'; testCount(); } void jButton8_actionPerformed(ActionEvent e) { buffer[count++] = '6'; testCount(); } void jButton9_actionPerformed(ActionEvent e) { buffer[count++] = '7'; testCount(); } void jButtonA_actionPerformed(ActionEvent e) { buffer[count++] = 'A'; testCount(); } void jButtonB_actionPerformed(ActionEvent e) { buffer[count++] = 'B'; testCount(); } void jButtonC_actionPerformed(ActionEvent e) { buffer[count++] = 'C'; testCount(); } void jButtonD_actionPerformed(ActionEvent e) { buffer[count++] = 'D'; testCount(); } void jButtonE_actionPerformed(ActionEvent e) { buffer[count++] = 'E'; testCount(); } void jButtonF_actionPerformed(ActionEvent e) { buffer[count++] = 'F'; testCount(); } void jButtonb_actionPerformed(ActionEvent e) { buffer[count++] = 'b'; testCount(); } void jButtonG_actionPerformed(ActionEvent e) { buffer[count++] = 'G'; testCount(); } void jButtons_actionPerformed(ActionEvent e) { buffer[count++] = '#'; testCount(); } void jButtonX_actionPerformed(ActionEvent e) { volume = (volume + 10) % 128; } void jButtonY_actionPerformed(ActionEvent e) { int i; int[][] stringNotes = new int[6][13]; ShortMessage[] shortMessage; for (i = 0; i < 13; i++) { stringNotes[5][i] = 40 + i; // E stringNotes[4][i] = 45 + i; // A stringNotes[3][i] = 50 + i; // D stringNotes[2][i] = 55 + i; // G below middle C = 60 stringNotes[1][i] = 59 + i; // B below middle C = 60 stringNotes[0][i] = 64 + i; // E above middle C = 60 } shortMessage = new ShortMessage[number]; try { for (i = 0; i < number; i++) { shortMessage[i] = new ShortMessage(); shortMessage[i].setMessage(ShortMessage.NOTE_ON, i, stringNotes[strings[i]][frets[i]], volume); synthesizerReceiver.send(shortMessage[i], - 1); } int time = (int) (60000.0 / beatsPerMinute); Thread.sleep(time); for (i = 0; i < number; i++) { shortMessage[i] = new ShortMessage(); shortMessage[i].setMessage(ShortMessage.NOTE_OFF, i, stringNotes[strings[i]][frets[i]], volume); synthesizerReceiver.send(shortMessage[i], - 1); } } catch (Exception exception) { } count = 0; } void jButtonZ_actionPerformed(ActionEvent e) { volume = (volume - 10) % 128; if (volume < 0) volume += 128; } void jButtonJ_actionPerformed(ActionEvent e) { if (record) { record = false; jButtonJ.setToolTipText("record chords"); jButtonJ.setText("record"); } else { record = true; jButtonJ.setToolTipText("stop recording chords"); jButtonJ.setText("stop"); } } void jButtonK_actionPerformed(ActionEvent e) { int i, j; int[][] stringNotes = new int[6][13]; ShortMessage[] shortMessage; for (i = 0; i < 13; i++) { stringNotes[5][i] = 40 + i; // E stringNotes[4][i] = 45 + i; // A stringNotes[3][i] = 50 + i; // D stringNotes[2][i] = 55 + i; // G below middle C = 60 stringNotes[1][i] = 59 + i; // B below middle C = 60 stringNotes[0][i] = 64 + i; // E above middle C = 60 } try { for (i = 0; i < recordedChords; i++) { shortMessage = new ShortMessage[recordedNumber[i]]; for (j = 0; j < recordedNumber[i]; j++) { shortMessage[j] = new ShortMessage(); shortMessage[j].setMessage(ShortMessage.NOTE_ON, j, stringNotes[recordedStrings[i][j]][recordedFrets[i][j]], volume); synthesizerReceiver.send(shortMessage[j], - 1); } chord2Panel.drawChord(false, recordedNumber[i], recordedFrets[i], recordedStrings[i]); int time = (int) (60000.0 / beatsPerMinute); Thread.sleep(time); for (j = 0; j < recordedNumber[i]; j++) { shortMessage[j] = new ShortMessage(); shortMessage[j].setMessage(ShortMessage.NOTE_OFF, j, stringNotes[recordedStrings[i][j]][recordedFrets[i][j]], volume); synthesizerReceiver.send(shortMessage[j], - 1); } chord2Panel.drawChord(true, recordedNumber[i], recordedFrets[i], recordedStrings[i]); } } catch (Exception exception) { } } void jButtonL_actionPerformed(ActionEvent e) { recordedChords = 0; } } class Chord2 { public static void main(String[] args) { int guitar = 30; if (args.length == 1) { Integer integer = new Integer(args[0]); guitar = integer.intValue(); if (guitar < 0 || guitar > 127) guitar = 30; } new Chord2Frame(guitar); } }