// Fragment 10 jSlider1StateChanged User is changing the K-Pro volume, or the max default synth velocity value. jButton12ActionPerformed Turn the metronome on and off. jTextField1ActionPerformed User entered a new value for the metronome Beats per Minute. jTextField1ActionPerformed User changed the value for the keyboard bottom note. Later, when I have an actual keyboard, this field will be made read-only. jTextField4ActionPerformed User entered a new value of keyboard key spacing. This allows the keyboard to cover more than one octave. jButton35ActionPerformed Adding new patch to the ArrayList. Check for duplicate names or blank name. jButton36ActionPerformed Deleting patch. If all of the patches are removed, we start getting null pointers exceptions, so force the use to keep at least one patch at all times. jTextField7ActionPerformed User entering new patch name. Pressing Enter is the same as clicking the Add Patch button. jComboBox4ActionPerformed User selecting patch from combo box. Transfer the settings of the selected patch into all of the jButton and jTextField components. // Change synth volume. private void jSlider1StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jSlider1StateChanged ShortMessage myMsg = new ShortMessage(); // Changing volume with slider control Receiver rcvr = null; if(kProDevice != null) { try { rcvr = kProDevice.getReceiver(); } catch (MidiUnavailableException e) { } try { long timeStamp = -1; myMsg.setMessage(ShortMessage.CONTROL_CHANGE, midiPorts.kProChannelNo, 94, jSlider1.getValue()); rcvr.send(myMsg, timeStamp); } catch (javax.sound.midi.InvalidMidiDataException e) { } } else { keyboardVolume = jSlider1.getValue(); } }//GEN-LAST:event_jSlider1StateChanged // User turned the metronome on or off. private void jButton12ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton12ActionPerformed if(met.state) { // Turn metronome on and off met.tmr = -1; met.cntr = 1; jButton12.setText(" "); } else { met.bpmTotal = 1000 * 60 / met.bpm; met.tmr = 0; } met.state = (! met.state); }//GEN-LAST:event_jButton12ActionPerformed // User entered a Beats Per Minute value to the textfield for the metronome. private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField1ActionPerformed int timerState = met.tmr; if(isInt(jTextField1.getText())) { met.tmr = -1; // Change metronome BPM met.bpm = Integer.parseInt(jTextField1.getText()); met.bpmTotal = 1000 * 60 / met.bpm; met.cntr = 1; jButton12.setText(" "); met.state = false; met.tmr = timerState; } else { jTextArea1.append(jTextField1.getText() + " is not a number.\n"); } }//GEN-LAST:event_jTextField1ActionPerformed // User entered a number for the bottom note of the keyboard. Later, I'll replace this function with a MIDI read from an actual // keyboard. For right now,it lets me play some rudimentary tunes with the gate arp turned on. When either jTextField3 (base note) // or jTextField5 change, update the contents of jTextField2, the gate arp base note field (which is display-only right now. private void jTextField3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField3ActionPerformed if(isInt(jTextField3.getText())) { keyboardBottomNote = Integer.parseInt(jTextField3.getText()); jTextField2.setText(Integer.toString(keyboardBottomNote + keyboardKey * keyboardSpacing)); // bottomNote = Integer.parseInt(jTextField3.getText()); // Keyboard bottom note // Right now, arpBottom note is being used to set the start point of the arpeggiator pattern. // However, when a keyboard is added eventually, jTextField3 will be used to offset the base note of the keyboard // and jTextField4 will be used to set the spacing between keys. This will produced a "current note being pressed" // which will then replace the arpeggiator bottom note text field. } else { jTextArea1.append(jTextField3.getText() + " is not a number.\n"); } }//GEN-LAST:event_jTextField3ActionPerformed // User changed the keyboard note spacing. Update the gate arp base note display. private void jTextField4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField4ActionPerformed if(isInt(jTextField4.getText())) { keyboardSpacing = Integer.parseInt(jTextField4.getText()); // Changing keyboard note spacing jTextField2.setText(Integer.toString(keyboardBottomNote + keyboardKey * keyboardSpacing)); } else { jTextArea1.append(jTextField4.getText() + " is not a number.\n"); } }//GEN-LAST:event_jTextField4ActionPerformed // User is attempting to add a new patch (all of the screen settings in one patch object) to the combo box. Fail if a patch // with the same name already exists. private void jButton35ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton35ActionPerformed patch newPatch = new patch(); // Clicked Add Patch boolean isInList = false; if(jTextField7.getText().isEmpty()) { jTextArea1.append("Please give a name for the patch.\n"); } else { for(patch p : patchList) { if(p.name.equals(jTextField7.getText())) { isInList = true; } } if(isInList) { jTextArea1.append("Patch name already assigned. Please pick a new name.\n"); } else { newPatch.gatherPatch(); jComboBox4.addItem(newPatch.name); patchList.add(newPatch); suppressUpdate = true; jComboBox4.setSelectedIndex(jComboBox4.getItemCount() - 1); } } }//GEN-LAST:event_jButton35ActionPerformed // User is attempting to delete the selected patch from the combo box. Fail if there's only one patch left. private void jButton36ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton36ActionPerformed int sel = jComboBox4.getSelectedIndex(); // Clicked Delete Patch if(sel == -1) { jTextArea1.append("Please select a patch to delete.\n"); } else { if(patchList.size() > 1) { patchList.remove(sel); suppressUpdate = false; jComboBox4.removeItemAt(sel); } else { jTextArea1.append("Deleting all patches will cause a system error. Please append at least one new patch first."); } } }//GEN-LAST:event_jButton36ActionPerformed // User entered the patch name in the jTextField7 component. Treat it as if they clicked the Add Patch button. private void jTextField7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField7ActionPerformed jButton35.doClick(); // Pressing Enter in Patch Name field is same as Add Patch }//GEN-LAST:event_jTextField7ActionPerformed // User selected a patch from the combo box. Load it and update all the buttons. private void jComboBox4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox4ActionPerformed int sel = jComboBox4.getSelectedIndex(); // Select a patch to load if(suppressUpdate) { // Because Add and Delete Patch select a new patch in the suppressUpdate = false; // Combo Box, the Combo Box will try loading the } else { // Patch as Select Patch. Suppress this loading. patchList.get(sel).loadPatch(); jTextArea1.append("Patch " + patchList.get(sel).name + " loaded.\n"); jTextField7.setText(patchList.get(sel).name); } }//GEN-LAST:event_jComboBox4ActionPerformed