/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/*
* ExternalMIDIToSample.java
*
* Created on 17 févr. 2010, 21:13:58
*/
package TomatEpsilon;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File;
import java.util.Vector;
import javax.sound.midi.MidiDevice;
import javax.sound.midi.MidiSystem;
import javax.sound.midi.MidiUnavailableException;
import javax.sound.midi.Synthesizer;
import javax.swing.JFrame;
/**
*
* @author frederickhannouf
*/
public class ExternalMIDIToSamples extends javax.swing.JPanel implements ActionListener, ControlContext {
/** Creates new form ExternalMIDIToSample */
public ExternalMIDIToSamples() {
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jPanel1 = new javax.swing.JPanel();
fDieseNoteButton = new javax.swing.JToggleButton();
aDieseNoteButton = new javax.swing.JToggleButton();
cDieseNoteButton = new javax.swing.JToggleButton();
gDieseNoteButton = new javax.swing.JToggleButton();
aNoteButton = new javax.swing.JToggleButton();
dDieseNoteButton = new javax.swing.JToggleButton();
gNoteButton = new javax.swing.JToggleButton();
fNoteButton = new javax.swing.JToggleButton();
dNoteButton = new javax.swing.JToggleButton();
cNoteButton = new javax.swing.JToggleButton();
bNoteButton = new javax.swing.JToggleButton();
eNoteButton = new javax.swing.JToggleButton();
jPanel2 = new javax.swing.JPanel();
twoOctaveButton = new javax.swing.JToggleButton();
threeOctaveButton3 = new javax.swing.JToggleButton();
FourOctaveButton = new javax.swing.JToggleButton();
fiveOctaveButton = new javax.swing.JToggleButton();
sixOctaveButton = new javax.swing.JToggleButton();
sevenOctaveButton = new javax.swing.JToggleButton();
eightOctaveButton = new javax.swing.JToggleButton();
nineOctaveButton = new javax.swing.JToggleButton();
oneOctaveButton = new javax.swing.JToggleButton();
zeroOctaveButton = new javax.swing.JToggleButton();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
directoryButton = new javax.swing.JButton();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
jLabel9 = new javax.swing.JLabel();
jComboBox1 = new javax.swing.JComboBox();
jLabel10 = new javax.swing.JLabel();
jLabel11 = new javax.swing.JLabel();
jComboBox2 = new javax.swing.JComboBox();
durationField = new javax.swing.JTextField();
jLabel12 = new javax.swing.JLabel();
pauseField = new javax.swing.JTextField();
jLabel13 = new javax.swing.JLabel();
jLabel14 = new javax.swing.JLabel();
jLabel15 = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
logTextArea = new javax.swing.JTextArea();
jLabel16 = new javax.swing.JLabel();
jLabel17 = new javax.swing.JLabel();
clearButton = new javax.swing.JButton();
startButton = new javax.swing.JButton();
setMaximumSize(new java.awt.Dimension(640, 480));
setMinimumSize(new java.awt.Dimension(640, 480));
setOpaque(false);
setPreferredSize(new java.awt.Dimension(640, 480));
jLabel1.setFont(new java.awt.Font("Lucida Grande", 3, 18));
jLabel1.setText("External MIDI To Samples");
fDieseNoteButton.setText("F#");
fDieseNoteButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
fDieseNoteButtonActionPerformed(evt);
}
});
aDieseNoteButton.setText("A#");
aDieseNoteButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
aDieseNoteButtonActionPerformed(evt);
}
});
cDieseNoteButton.setText("C#");
cDieseNoteButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cDieseNoteButtonActionPerformed(evt);
}
});
gDieseNoteButton.setText("G#");
gDieseNoteButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
gDieseNoteButtonActionPerformed(evt);
}
});
aNoteButton.setText("A");
aNoteButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
aNoteButtonActionPerformed(evt);
}
});
dDieseNoteButton.setText("D#");
dDieseNoteButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
dDieseNoteButtonActionPerformed(evt);
}
});
gNoteButton.setText("G");
gNoteButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
gNoteButtonActionPerformed(evt);
}
});
fNoteButton.setText("F");
fNoteButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
fNoteButtonActionPerformed(evt);
}
});
dNoteButton.setText("D");
dNoteButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
dNoteButtonActionPerformed(evt);
}
});
cNoteButton.setText("C");
cNoteButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cNoteButtonActionPerformed(evt);
}
});
bNoteButton.setText("B");
bNoteButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
bNoteButtonActionPerformed(evt);
}
});
eNoteButton.setText("E");
eNoteButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
eNoteButtonActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(cNoteButton, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(dNoteButton, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(eNoteButton, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(fNoteButton, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(gNoteButton, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(aNoteButton, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(bNoteButton, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(17, 17, 17)
.addComponent(cDieseNoteButton, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(dDieseNoteButton, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(41, 41, 41)
.addComponent(fDieseNoteButton, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(gDieseNoteButton, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(aDieseNoteButton, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(fDieseNoteButton)
.addComponent(gDieseNoteButton)
.addComponent(cDieseNoteButton)
.addComponent(dDieseNoteButton)
.addComponent(aDieseNoteButton))
.addGap(3, 3, 3)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cNoteButton)
.addComponent(dNoteButton)
.addComponent(eNoteButton)
.addComponent(fNoteButton)
.addComponent(gNoteButton)
.addComponent(aNoteButton)
.addComponent(bNoteButton))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
twoOctaveButton.setText("2");
twoOctaveButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
twoOctaveButtonActionPerformed(evt);
}
});
threeOctaveButton3.setText("3");
threeOctaveButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
threeOctaveButton3ActionPerformed(evt);
}
});
FourOctaveButton.setText("4");
FourOctaveButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
FourOctaveButtonActionPerformed(evt);
}
});
fiveOctaveButton.setText("5");
fiveOctaveButton.setOpaque(true);
fiveOctaveButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
fiveOctaveButtonActionPerformed(evt);
}
});
sixOctaveButton.setText("6");
sixOctaveButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
sixOctaveButtonActionPerformed(evt);
}
});
sevenOctaveButton.setText("7");
sevenOctaveButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
sevenOctaveButtonActionPerformed(evt);
}
});
eightOctaveButton.setText("8");
eightOctaveButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
eightOctaveButtonActionPerformed(evt);
}
});
nineOctaveButton.setText("9");
nineOctaveButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
nineOctaveButtonActionPerformed(evt);
}
});
oneOctaveButton.setText("1");
oneOctaveButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
oneOctaveButtonActionPerformed(evt);
}
});
zeroOctaveButton.setText("0");
zeroOctaveButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
zeroOctaveButtonActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(zeroOctaveButton, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(oneOctaveButton, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(twoOctaveButton, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(threeOctaveButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(FourOctaveButton, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(fiveOctaveButton, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(sixOctaveButton, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(sevenOctaveButton, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(eightOctaveButton, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(nineOctaveButton, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(oneOctaveButton)
.addComponent(twoOctaveButton)
.addComponent(threeOctaveButton3)
.addComponent(FourOctaveButton)
.addComponent(zeroOctaveButton))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(sixOctaveButton, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(sevenOctaveButton)
.addComponent(eightOctaveButton)
.addComponent(nineOctaveButton)
.addComponent(fiveOctaveButton))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jLabel2.setFont(new java.awt.Font("Lucida Grande", 0, 14));
jLabel2.setText("Step 1");
jLabel3.setText("a directory that will contain samples.");
directoryButton.setText("Choose");
directoryButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
directoryButtonActionPerformed(evt);
}
});
jLabel4.setFont(new java.awt.Font("Lucida Grande", 0, 14));
jLabel4.setText("Step 2");
jLabel5.setText("Choose the notes and octaves you want to sample.");
jLabel6.setText("Note(s)");
jLabel7.setText("Octave(s)");
jLabel8.setFont(new java.awt.Font("Lucida Grande", 0, 14));
jLabel8.setText("Step 3");
jLabel9.setText("Choose your MIDI interface and the MIDI channel.");
jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
jLabel10.setText("Send MIDI Note On/Off messages through");
jLabel11.setText("on");
jComboBox2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Channel 1", "Channel 2", "Channel 3", "Channel 4", "Channel 5", "Channel 6", "Channel 7", "Channel 8", "Channel 9", "Channel 10", "Channel 11", "Channel 12", "Channel 13", "Channel 14", "Channel 15", "Channel 16" }));
durationField.setText("4");
durationField.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
durationFieldActionPerformed(evt);
}
});
jLabel12.setText("Note Duration");
pauseField.setText("2");
jLabel13.setText("Pause");
jLabel14.setText("seconds");
jLabel15.setText("seconds");
logTextArea.setColumns(20);
logTextArea.setEditable(false);
logTextArea.setRows(5);
jScrollPane1.setViewportView(logTextArea);
jLabel16.setText("Check if everything is all right in the log, and you're done :-)");
jLabel17.setFont(new java.awt.Font("Lucida Grande", 0, 14));
jLabel17.setText("Step 4");
clearButton.setText("Clear log");
clearButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
clearButtonActionPerformed(evt);
}
});
startButton.setText("Start");
startButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
startButtonActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 308, Short.MAX_VALUE)
.addGap(469, 469, 469))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 114, Short.MAX_VALUE)
.addGap(663, 663, 663))
.addGroup(layout.createSequentialGroup()
.addComponent(directoryButton, javax.swing.GroupLayout.DEFAULT_SIZE, 127, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, 355, Short.MAX_VALUE)
.addGap(289, 289, 289))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, 114, Short.MAX_VALUE)
.addGap(663, 663, 663))
.addGroup(layout.createSequentialGroup()
.addGap(6, 6, 6)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, 113, Short.MAX_VALUE)
.addGap(172, 172, 172))
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel7)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel13, javax.swing.GroupLayout.DEFAULT_SIZE, 103, Short.MAX_VALUE)
.addGap(196, 196, 196))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(pauseField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 125, Short.MAX_VALUE)
.addComponent(durationField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 125, Short.MAX_VALUE)
.addComponent(jLabel12, javax.swing.GroupLayout.DEFAULT_SIZE, 125, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel15, javax.swing.GroupLayout.DEFAULT_SIZE, 168, Short.MAX_VALUE)
.addComponent(jLabel14, javax.swing.GroupLayout.DEFAULT_SIZE, 168, Short.MAX_VALUE))))))
.addGap(10, 10, 10))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, 391, Short.MAX_VALUE)
.addGap(396, 396, 396))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel8, javax.swing.GroupLayout.DEFAULT_SIZE, 114, Short.MAX_VALUE)
.addGap(649, 649, 649))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addComponent(startButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel16)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 137, Short.MAX_VALUE)
.addComponent(clearButton, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addComponent(jLabel10)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 228, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel11)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, 172, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING))
.addGap(63, 63, 63)))
.addGap(24, 24, 24))
.addComponent(jLabel17)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGap(475, 475, 475))))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 24, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 19, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(directoryButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel3))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, 19, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, 17, Short.MAX_VALUE)
.addGap(12, 12, 12)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel12, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel7)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(durationField)
.addComponent(jLabel14, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel13, javax.swing.GroupLayout.DEFAULT_SIZE, 16, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(pauseField)
.addComponent(jLabel15, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(11, 11, 11)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jLabel8, javax.swing.GroupLayout.DEFAULT_SIZE, 17, Short.MAX_VALUE))
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel17)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(startButton)
.addComponent(jLabel16)
.addComponent(clearButton))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
}// </editor-fold>//GEN-END:initComponents
private void cNoteButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cNoteButtonActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_cNoteButtonActionPerformed
private void dNoteButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dNoteButtonActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_dNoteButtonActionPerformed
private void fNoteButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fNoteButtonActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_fNoteButtonActionPerformed
private void eNoteButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_eNoteButtonActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_eNoteButtonActionPerformed
private void bNoteButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bNoteButtonActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_bNoteButtonActionPerformed
private void gNoteButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_gNoteButtonActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_gNoteButtonActionPerformed
private void aNoteButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_aNoteButtonActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_aNoteButtonActionPerformed
private void dDieseNoteButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dDieseNoteButtonActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_dDieseNoteButtonActionPerformed
private void cDieseNoteButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cDieseNoteButtonActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_cDieseNoteButtonActionPerformed
private void gDieseNoteButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_gDieseNoteButtonActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_gDieseNoteButtonActionPerformed
private void fDieseNoteButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fDieseNoteButtonActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_fDieseNoteButtonActionPerformed
private void aDieseNoteButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_aDieseNoteButtonActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_aDieseNoteButtonActionPerformed
private void zeroOctaveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_zeroOctaveButtonActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_zeroOctaveButtonActionPerformed
private void oneOctaveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_oneOctaveButtonActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_oneOctaveButtonActionPerformed
private void twoOctaveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_twoOctaveButtonActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_twoOctaveButtonActionPerformed
private void threeOctaveButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_threeOctaveButton3ActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_threeOctaveButton3ActionPerformed
private void FourOctaveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_FourOctaveButtonActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_FourOctaveButtonActionPerformed
private void fiveOctaveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fiveOctaveButtonActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_fiveOctaveButtonActionPerformed
private void sixOctaveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sixOctaveButtonActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_sixOctaveButtonActionPerformed
private void sevenOctaveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sevenOctaveButtonActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_sevenOctaveButtonActionPerformed
private void eightOctaveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_eightOctaveButtonActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_eightOctaveButtonActionPerformed
private void nineOctaveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nineOctaveButtonActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_nineOctaveButtonActionPerformed
private void directoryButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_directoryButtonActionPerformed
// try {
// File file;
// if(directoryField.getText().equals("")){
// file = new File(System.getProperty("user.home"));
// }else{
// file = new File(directoryField.getText());
// }
//
// JFileChooser fc = new JFileChooser(file);
// fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
// if (fc.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
// String selectedDir = (fc.getSelectedFile().isDirectory()) ? (fc.getSelectedFile().getPath()) : (fc.getSelectedFile().getParent());
//
// directoryField.setText(selectedDir);
//
// }
// } catch (SecurityException ex) {
// Tomate.showInfoDialog();
// ex.printStackTrace();
// } catch (Exception ex) {
// ex.printStackTrace();
// }
}//GEN-LAST:event_directoryButtonActionPerformed
private void clearButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_clearButtonActionPerformed
logTextArea.setText(null);
}//GEN-LAST:event_clearButtonActionPerformed
private void startButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_startButtonActionPerformed
// worker = new SwingWorker() {
// public void batch(){
//
// // Tableau associatif contenant toutes les familles d'instruments et les notes
// HashMap instruments = new HashMap();
// String workingDirAbsolutePath;
// Vector wavFileNames;
// Vector allNotesArray;
// Vector groupNameVector;
// File[] wavFiles;
// boolean success;
//
// workingDirAbsolutePath=directoryField.getText();
//
// File srcDirectory=new File(workingDirAbsolutePath);
//
// // Initialisation du tableau des notes
// allNotesArray=buildAllNotes(0,9);
//
// appendLog("Scanning: " + workingDirAbsolutePath + "." + newline);
//
// // Remplissage du vecteur avec les noms des fichiers
// wavFileNames=new Vector();
// wavFiles=srcDirectory.listFiles();
// for( File wavFile : wavFiles){
// String waveFileName = wavFile.getName();
// wavFileNames.add(waveFileName);
// appendLog("Found : "+waveFileName+ newline);
// }
//
// // Parcours de tous les noms de fichiers trouvés
// for ( Object wavFileNameObj : wavFileNames){
//
// // Nettoyage et explosion du nom de fichier
// String wavFileName = wavFileNameObj.toString();
//
// // Suppression de l'extension
// wavFileName=wavFileName.substring(0, wavFileName.length()-4);
//
// wavFileName=wavFileName.replaceAll("[.]", " ");
// wavFileName=wavFileName.replaceAll("[_]", " ");
// wavFileName=wavFileName.replaceAll("[ ]+", "/");
// String[] nameSplit = wavFileName.split("/");
//
// String instrumentName = new String();
// int instrumentNoteIndex = -1;
// String currentNote = new String();
// Vector instrument;
//
// // Parcours des parties du nom de fichier
// groupNameVector = new Vector();
// for (String part : nameSplit){
// // Si une note est trouvée
// currentNote=findNote(part,allNotesArray);
// if (!currentNote.equals("none")){
// // On stocke son index dans la table des notes
// instrumentNoteIndex=allNotesArray.indexOf(currentNote);
// }else{
// // Sinon c'est qu'on est en présence d'un morceau du nom de l'instrument
// groupNameVector.add(part);
// }
// }
//
// // Implosion du nom de l'instrument
// instrumentName=joinStrings(groupNameVector,"-");
//
// // Si le nom du sample contient une note
// if (instrumentNoteIndex>-1){
// // Si la famille d'instruments existe, on la récupère
// if (instruments.containsKey(instrumentName)){
// instrument = (Vector) instruments.get(instrumentName);
// //appendLog("Known Instrument : "+instrumentName+ newline);
// }else{
// // Sinon, on instancie un vecteur pour regrouper cette nouvelle famille
// instrument = new Vector();
// appendLog("New Instrument : " + instrumentName+ newline);
// }
//
// // Creation d'un nouveau couple note-sample
// Vector couple = new Vector();
// couple.add(instrumentNoteIndex);
// couple.add(wavFileNameObj.toString());
// instrument.add(couple);
// appendLog("Adding : " + wavFileNameObj.toString() + newline);
//
// // On dépose les informations de l'instrument dans le vecteur qui les regroupe tous
// instruments.put(instrumentName, instrument);
// }
// }
//
//
// // Affichage de chacune des entrées de la HashMap
// String instrumentName = new String();
// Set instrumentsFamily = instruments.keySet();
// Iterator i = instrumentsFamily.iterator();
// while (i.hasNext()){
// instrumentName=i.next().toString();
// Vector instrumentCouples = (Vector) instruments.get(instrumentName);
// Iterator i2 = instrumentCouples.iterator();
// while (i2.hasNext()){
// Vector instrumentCouple = (Vector) i2.next();
// //appendLog("Note id : "+instrumentCouple.get(0)+", sample : "+instrumentCouple.get(1)+newline);
// //System.out.print("Note id : "+instrumentCouple.get(0)+" sample : "+instrumentCouple.get(1)+",");
// }
// //System.out.println();
//
// // Construction et affichage du XML résultant
// buildXRNI(instrumentName,instrumentCouples,workingDirAbsolutePath);
// }
// }
//
// public String doInBackground() {
// try {
// batch();
// }catch (Exception e) {
// e.printStackTrace();
// }
// return null;
// }
//
// @Override
// public void done() {
// System.out.println("done");
// }
// };
// worker.execute();
}//GEN-LAST:event_startButtonActionPerformed
private void durationFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_durationFieldActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_durationFieldActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JToggleButton FourOctaveButton;
private javax.swing.JToggleButton aDieseNoteButton;
private javax.swing.JToggleButton aNoteButton;
private javax.swing.JToggleButton bNoteButton;
private javax.swing.JToggleButton cDieseNoteButton;
private javax.swing.JToggleButton cNoteButton;
private javax.swing.JButton clearButton;
private javax.swing.JToggleButton dDieseNoteButton;
private javax.swing.JToggleButton dNoteButton;
private javax.swing.JButton directoryButton;
private javax.swing.JTextField durationField;
private javax.swing.JToggleButton eNoteButton;
private javax.swing.JToggleButton eightOctaveButton;
private javax.swing.JToggleButton fDieseNoteButton;
private javax.swing.JToggleButton fNoteButton;
private javax.swing.JToggleButton fiveOctaveButton;
private javax.swing.JToggleButton gDieseNoteButton;
private javax.swing.JToggleButton gNoteButton;
private javax.swing.JComboBox jComboBox1;
private javax.swing.JComboBox jComboBox2;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel14;
private javax.swing.JLabel jLabel15;
private javax.swing.JLabel jLabel16;
private javax.swing.JLabel jLabel17;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextArea logTextArea;
private javax.swing.JToggleButton nineOctaveButton;
private javax.swing.JToggleButton oneOctaveButton;
private javax.swing.JTextField pauseField;
private javax.swing.JToggleButton sevenOctaveButton;
private javax.swing.JToggleButton sixOctaveButton;
private javax.swing.JButton startButton;
private javax.swing.JToggleButton threeOctaveButton3;
private javax.swing.JToggleButton twoOctaveButton;
private javax.swing.JToggleButton zeroOctaveButton;
// End of variables declaration//GEN-END:variables
public static void main(String s[]) {
// Instanciation of our class
ExternalMIDIToSamples externalMIDIToSamplesPanel = new ExternalMIDIToSamples();
externalMIDIToSamplesPanel.open();
// Creation of a new frame
JFrame f = new JFrame("ExternalMIDIToSamples");
// Handling of close event
f.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) { System.exit(0); }
});
f.getContentPane().add("Center", externalMIDIToSamplesPanel);
f.pack();
Misc.initComponentSize(f);
System.out.println(listMidiDevices().toString());
}
public static Vector listMidiDevices(){
// Obtain information about all the installed synthesizers.
Vector synthInfos = null;
MidiDevice.Info[] infos = MidiSystem.getMidiDeviceInfo();
System.out.println(infos.length);
for (int i = 0; i < infos.length; i++) {
MidiDevice device = null;
System.out.println(i);
try {
device = MidiSystem.getMidiDevice(infos[i]);
} catch (MidiUnavailableException e) {
// Handle or throw exception...
System.out.println("bla");
}
if (device instanceof Synthesizer) {
synthInfos.add(infos[i]);
}else{
System.out.println("blabla*");
}
}
// Now, display strings from synthInfos list in GUI.
return synthInfos;
}
public void actionPerformed(ActionEvent e) {
throw new UnsupportedOperationException("Not supported yet.");
}
public void open() {
Misc.initComponentSize(this);
}
public void close() {
}
}