jDrum rhythm emulator studios

 3r31220. 3r3-31. Preface: I have a studio equipped, in the studio I decided to purchase electronic midi drums, an instrument with pads from the line: medeli, akai, novation.
 3r31220.
 3r31220. Linux (Ubuntu) is installed on the computer for development, the software mentioned above devices are not supported in Linux, and there are no problems with wine and virtual machine or switching between operating systems.
 3r31220.
 3r31220. I decided to develop a simple tool for writing rhythms.
 3r31220.
 3r31220. 3r314.
 3r31220. Download and test the program can be via this link. .
 3r31220.
 3r31220. Designing 3r348.
 3r31220. Designing began with drawing the interface in NetBeans: 3r3-31208.  3r31220. 3r330.
 3r31220.
 3r31220. [b] The principle of operation 3r348.
 3r31220. The active text field for loading a sample into a line.
 3r31220. 16 buttons when you click on which plays a sample set to the line.
 3r31220. The Play button plays sounds by speakers with samples installed on them with a certain delay (if a sample is set on the line and the button is pressed).
 3r31220.
 3r31220. [b] The code is clearly

 3r31220.
 3r31220. JDrum.java This class contains:
 3r31220. 1. Run the frame.
 3r31220. 2. The main part of logic.
 3r31220. 3. Sets of variables.
 3r31220.
 3r31220. 3r31079. 3r31080. /* 3r31220. * To change this license header, choose License Headers in Project Properties. 3r31220. * To change this template file, choose Tools | Templates 3r31220. * and open the template in the editor. 3r31220. * /
package jdrum; 3r31220. 3r31220. import java.io.BufferedReader; 3r31220. import java.io.File; 3r31220. import java.io.InputStreamReader; 3r31220. import java.util.Arrays; 3r31220. import java.util.List; 3r31220. 3r31220. /** 3r31220. * 3r31220. * @author dj DNkey
* /
public class JDrum {
/** 3r31220. * pads values ​​
* /
public static int[]pads = {3r31220. ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0
}; 3r31220. 3r31220. /* 3r31220. * pads in line 1
* /
public static Integer[]line1Pads = {?????????1?1?1?1?1?1?16}; 3r31220. /** 3r31220. * pads in line 2
* /
public static Integer[]line2Pads = {1?1?1?2?2?2?2?2?2?2?2?2?2?3?3?32}; 3r31220. /** 3r31220. * pads in line 3
* /
public static Integer[]line3Pads = {3?3?3?3?3?3?3?4?4?4?4?4?4?4?4?48}; 3r31220. /** 3r31220. * pads in line 4
* /
public static Integer[]line4Pads = {4?5?5?5?5?5?5?5?5?5?5?6?6?6?6?64}; 3r31220. /** 3r31220. * pads in line 5
* /
public static Integer[]line5Pads = {6?6?6?6?6?7?7?7?7?7?7?7?7?7?7?80}; 3r31220. /** 3r31220. * pads in line 6
* /
public static Integer[]line6Pads = {8?8?8?8?8?8?8?8?8?9?9?9?9?9?9?96}; 3r31220. 3r31220. 3r31220. /** 3r31220. * pads in column 1
* /
public static int[]column1 = {?1?3?4?6?81}; 3r31220. 3r31220. /** 3r31220. * pads in column 2
* /
public static int[]column2 = {?1?3?5?6?82}; 3r31220. /** 3r31220. * pads in column 3
* /
public static int[]column3 = {?1?3?5?6?83}; 3r31220. /** 3r31220. * pads in column 4
* /
public static int[]column4 = {?2?3?5?6?84}; 3r31220. /** 3r31220. * pads in column 5
* /
public static int[]column5 = {5.2?3?5?6?85}; 3r31220. /** 3r31220. * pads in column 6
* /
public static int[]column6 = {?2?3?5?7?86}; 3r31220. /** 3r31220. * pads in column 7
* /
public static int[]column7 = {?2?3?5?7?87}; 3r31220. /** 3r31220. * pads in column 8
* /
public static int[]column8 = {?2?4?5?7?88}; 3r31220. /** 3r31220. * pads in column 9
* /
public static int[]column9 = {?2?4?5?7?89}; 3r31220. /** 3r31220. * pads in column 10
* /
public static int[]column10 = {1?2?4?5?7?90}; 3r31220. /** 3r31220. * pads in column 11
* /
public static int[]column11 = {1?2?4?5?7?91}; 3r31220. /** 3r31220. * pads in column 12
* /
public static int[]column12 = {1?2?4?6?7?92}; 3r31220. /** 3r31220. * pads in column 13
* /
public static int[]column13 = {1?2?4?6?7?93}; 3r31220. /** 3r31220. * pads in column 14
* /
public static int[]column14 = {1?3?4?6?7?94}; 3r31220. /** 3r31220. * pads in column 15
* /
public static int[]column15 = {1?3?4?6?7?95}; 3r31220. /** 3r31220. * pads in column 16
* /
public static int[]column16 = {1?3?4?6?8?96}; 3r31220. 3r31220. 3r31220. /** 3r31220. * Sound files bind on lines 1-10
* /
3r31220. public static Sound line1Sound = null; 3r31220. 3r31220. public static Sound line2Sound = null; 3r31220. 3r31220. public static Sound line3Sound = null; 3r31220. 3r31220. public static Sound line4Sound = null; 3r31220. 3r31220. public static Sound line5Sound = null; 3r31220. 3r31220. public static Sound line6Sound = null; 3r31220. 3r31220. 3r31220. 3r31220. /** 3r31220. * play speed 3r31220. * /
public static int speed = 35; 3r31220. 3r31220. 3r31220. public static boolean play = false; 3r31220. 3r31220. public static Main frame; 3r31220. 3r31220. 3r31220. 3r31220. /** 3r31220. * 3r31220. * @param args the command line arguments
* /
public static void main (String[]args) {3r31220. 3r31220. new Player (). start (); 3r31220. 3r31220. frame = new Main (); 3r31220. 3r31220. frame.setVisible (true); 3r31220. 3r31220. 3r31220.}
/** 3r31220. * Play object Sound in new Thread
* @param sound
* /
public static synchronized void play (Sound sound) {
3r31220. if (sound! = null) {
3r31220. new PlaySound (sound) .start (); 3r31220. 3r31220. 3r31220.}
3r31220.}
3r31220. public static synchronized void loadSound (File file) {
//sound
}
3r31220. /** 3r31220. * Play pressed pad
* @param padNum
* /
public static synchronized void playPad (int padNum) {
3r31220. //change pads value 1 to ? 0 to 1
3r31220. if (pads[padNum - 1]== 0) {3r31220. JDrum.pads[padNum - 1]= 1; 3r31220.} else {
JDrum.pads[padNum - 1]= 0; 3r31220.}
3r31220. /** 3r31220. * Check line 3r31220. * /
3r31220. 3r31220. if (pads[padNum - 1]== 1) {3r31220. playLine (padNum); 3r31220.}
3r31220.}
3r31220. /** 3r31220. * play sound file on line where press pad
* @param padNum
* /
public static synchronized void playLine (int padNum) {
int line = getPadLine (padNum); 3r31220. 3r31220. /** 3r31220. * Play sound from line
* /
3r31220. 3r31220. if (line == 1) {3r31220. JDrum.play (line1Sound); 3r31220.}
3r31220. if (line == 2) {3r31220. JDrum.play (line2Sound); 3r31220.}
3r31220. if (line == 3) {3r31220. JDrum.play (line3Sound); 3r31220.}
3r31220. if (line == 4) {3r31220. JDrum.play (line4Sound); 3r31220.}
3r31220. if (line == 5) {3r31220. JDrum.play (line5Sound); 3r31220.}
3r31220. if (line == 6) {3r31220. JDrum.play (line6Sound); 3r31220.}
3r31220.}
3r31220. /** 3r31220. * get line of pressed pad
* @param padNum
* @return
* /
public static synchronized int getPadLine (int padNum) {
3r31220. int line = 0; 3r31220. 3r31220. List
list; 3r31220. 3r31220. 3r31220. list = Arrays.asList (line1Pads); 3r31220. 3r31220. if (list.contains (padNum)) {3r31220.             line = 1; 3r31220.}
3r31220. 3r31220. list = Arrays.asList (line2Pads); 3r31220. 3r31220. if (list.contains (padNum)) {3r31220. line = 2; 3r31220.}
3r31220. 3r31220. list = Arrays.asList (line3Pads); 3r31220. 3r31220. if (list.contains (padNum)) {3r31220. line = 3; 3r31220.}
3r31220. 3r31220. list = Arrays.asList (line4Pads); 3r31220. 3r31220. if (list.contains (padNum)) {3r31220. line = 4; 3r31220.}
3r31220. 3r31220. list = Arrays.asList (line5Pads); 3r31220. 3r31220. if (list.contains (padNum)) {3r31220. line = 5; 3r31220.}
3r31220. 3r31220. 3r31220. list = Arrays.asList (line6Pads); 3r31220. 3r31220. if (list.contains (padNum)) {3r31220. line = 6; 3r31220.}
3r31220. return line; 3r31220.}
3r31220. /** 3r31220. * Save JDrum project to file .drum
* @param fileName
* /
public static void save (String fileName) {
3r31220. //load JDrum settings to save class
Save save = new Save (); 3r31220. 3r31220. save.pads = JDrum.pads; 3r31220. 3r31220. 3r31220. if (line1Sound! = null) {
save.line1Sound = line1Sound.file.getAbsolutePath (); 3r31220.}
3r31220. if (line2Sound! = null) {
3r31220. save.line2Sound = line2Sound.file.getAbsolutePath (); 3r31220.}
3r31220. if (line3Sound! = null) {
save.line3Sound = line3Sound.file.getAbsolutePath (); 3r31220.}
3r31220. if (line3Sound! = null) {
save.line4Sound = line4Sound.file.getAbsolutePath (); 3r31220.}
3r31220. if (line5Sound! = null) {
save.line5Sound = line5Sound.file.getAbsolutePath (); 3r31220.}
3r31220. if (line6Sound! = null) {
save.line6Sound = line6Sound.file.getAbsolutePath (); 3r31220.}
3r31220. save.save (fileName); 3r31220. 3r31220. 3r31220.}
3r31220. /** 3r31220. *
* @param filePath
* /
public static void open (String filePath) {
3r31220. Save save = new Save (); 3r31220. save = save.load (filePath); 3r31220. 3r31220. Sound sound; 3r31220. 3r31220. 3r31220. //line1Sound = new File (save.line1Sound); 3r31220. 3r31220. if (save.line1Sound! = null) {
3r31220. sound = new Sound (); 3r31220. 3r31220. sound.loadFile (new File (save.line1Sound)); 3r31220. 3r31220. line1Sound = sound; 3r31220. 3r31220. Main.jTextField1.setText (line1Sound.file.getName ()); 3r31220. 3r31220.}
3r31220. 3r31220. if (save.line2Sound! = null) {
3r31220. sound = new Sound (); 3r31220. 3r31220. sound.loadFile (new File (save.line2Sound)); 3r31220. 3r31220. line2Sound = sound; 3r31220. 3r31220. Main.jTextField2.setText (line2Sound.file.getName ()); 3r31220. 3r31220.}
3r31220. 3r31220. 3r31220. if (save.line3Sound! = null) {
3r31220. sound = new Sound (); 3r31220. 3r31220. sound.loadFile (new File (save.line3Sound)); 3r31220. 3r31220. line3Sound = sound; 3r31220. 3r31220. Main.jTextField3.setText (line3Sound.file.getName ()); 3r31220. 3r31220.}
3r31220. 3r31220. 3r31220. if (save.line4Sound! = null) {
3r31220. sound = new Sound (); 3r31220. 3r31220. sound.loadFile (new File (save.line4Sound)); 3r31220. 3r31220. line4Sound = sound; 3r31220. 3r31220. Main.jTextField4.setText (line4Sound.file.getName ()); 3r31220. 3r31220.}
3r31220. 3r31220. 3r31220. 3r31220. if (save.line5Sound! = null) {
sound = new Sound (); 3r31220. 3r31220. sound.loadFile (new File (save.line5Sound)); 3r31220. 3r31220. line5Sound = sound; 3r31220. 3r31220. Main.jTextField5.setText (line5Sound.file.getName ()); 3r31220. 3r31220.}
3r31220. 3r31220. if (save.line6Sound! = null) {
sound = new Sound (); 3r31220. 3r31220. sound.loadFile (new File (save.line6Sound)); 3r31220. 3r31220. line6Sound = sound; 3r31220. 3r31220. Main.jTextField6.setText (line6Sound.file.getName ()); 3r31220. 3r31220.}
3r31220. JDrum.pads = save.pads; 3r31220. 3r31220. frame.changeButton (JDrum.pads); 3r31220. 3r31220. 3r31220.}
3r31220. public static void startRecording () {
3r31220. String command = "audio-recorder -c start"; 3r31220. 3r31220. String output = executeCommand (command); 3r31220. 3r31220.}
3r31220. public static void stopRecording () {3r31220. 3r31220. String command = "audio-recorder -c stop"; 3r31220. 3r31220. String output = executeCommand (command); 3r31220. 3r31220.}
3r31220. public static String executeCommand (String command) {
3r31220. StringBuffer output = new StringBuffer (); 3r31220. 3r31220. Process p; 3r31220. try {3r31220. p = Runtime.getRuntime (). exec (command); 3r31220. p.waitFor (); 3r31220. BufferedReader reader =
new BufferedReader (new InputStreamReader (p.getInputStream ())); 3r31220. 3r31220. String line = ""; 3r31220. while ((line = reader.readLine ())! = null) {
output.append (line + "n"); 3r31220.}
3r31220.} catch (Exception e) {
e.printStackTrace (); 3r31220.}
3r31220. return output.toString (); 3r31220. 3r31220.}
} 3r31185.
 3r31220.
 3r31220. Player.java daemon:
 3r31220. 1. Starting sounds on the speakers, if the sample is located on the line and the button is pressed.
 3r31220. 2. Player launches PlaySound classes that work out in a separate stream.
 3r31220. 3r31079. 3r31080. /* 3r31220. * To change this license header, choose License Headers in Project Properties. 3r31220. * To change this template file, choose Tools | Templates 3r31220. * and open the template in the editor. 3r31220. * /
package jdrum; 3r31220. 3r31220. import java.lang.reflect.Field; 3r31220. import java.util.logging.Level; 3r31220. import java.util.logging.Logger; 3r31220. import static jdrum.JDrum.playLine; 3r31220. 3r31220. /** 3r31220. * 3r31220. * @author nn
* /
public class Player extends Thread {
3r31220. Field field; 3r31220. String columnName; 3r31220. 3r31220. int[]column; 3r31220. 3r31220. public int step = 1; 3r31220. 3r31220. public int stopFlag = 0; 3r31220. 3r31220. public Player () {
3r31220. setDaemon (true); 3r31220.}
3r31220. 3r31220. public static int[]column1; 3r31220. 3r31220. public static int[]column2; 3r31220. 3r31220. public static int[]column3; 3r31220. 3r31220. public static int[]column4; 3r31220. 3r31220. public static int[]column5; 3r31220. 3r31220. public static int[]column6; 3r31220. 3r31220. public static int[]column7; 3r31220. 3r31220. public static int[]column8; 3r31220. 3r31220. public static int[]column9; 3r31220. 3r31220. public static int[]column10; 3r31220. 3r31220. public static int[]column11; 3r31220. 3r31220. public static int[]column12; 3r31220. 3r31220. public static int[]column13; 3r31220. 3r31220. public static int[]column14; 3r31220. 3r31220. public static int[]column15; 3r31220. 3r31220. public static int[]column16; 3r31220. 3r31220. 3r31220. public void run () {
3r31220. while (true) {
3r31220. if (JDrum.play) {3r31220. 3r31220. try {3r31220. 3r31220. //get column from JDrum by step 1-10
columnName = "column" + step; 3r31220. 3r31220. field = JDrum.class.getDeclaredField (columnName); 3r31220. 3r31220. field.setAccessible (true); 3r31220. 3r31220. 3r31220. column = (int[]) field.get (null); 3r31220. 3r31220. 3r31220. //play pads from column
for (int i = 0; i <= 5;i++ ){
//System.out.println(columnName);
if (JDrum.pads[column[i]- 1]== 1) {
3r31220. another w3w2w247) 3r31220.} 3r31220.} 3r312203 3r31220.
//next step
(stopFlag == 2) {
JDrum.play = false;
stopFlag = 0;
}
} 3r31220.} catch (IllegalArgumentException ex) {3r31220. Logger.getLogger (Player.class.getName ()). Log (Level.SEVERE, null, ex); 3r31220.} catch (IllegalAccessException ex) {3r31220. Logger.getLogger (Player.class.getName ()). Log (Level.SEVERE, null, ex); 3r31220.} catch (NoSuchFieldException ex) {3r31220. Logger.getLogger (Player.class.getName ()). Log (Level.SEVERE, null, ex); 3r31220.} catch (SecurityException ex) {3r31220. Logger.getLogger (Player.class.getName ()). Log (Level.SEVERE, null, ex); 3r31220.}
}
3r31220. 3r31220. //speed sleep
try {3r31220. sleep (JDrum.speed * 10); 3r31220.} catch (InterruptedException e) {3r31220. //handle exception here
}
}
}
3r31220.} 3r31185.
 3r31220.
 3r31220. PlaySound.java launch of sound (class Sound) in a separate stream
 3r31220.
 3r31220. 3r31079. 3r31080. 3r31220. /* 3r31220. * To change this license header, choose License Headers in Project Properties. 3r31220. * To change this template file, choose Tools | Templates 3r31220. * and open the template in the editor. 3r31220. * /
package jdrum; 3r31220. 3r31220. /** 3r31220. * 3r31220. * @author nn
* /
public class PlaySound extends Thread {
3r31220. public sound sound; 3r31220. 3r31220. 3r31220. public PlaySound (Sound sound) {
this.sound = sound; 3r31220.}
3r31220. public void run () {
if (sound! = null) {
sound.play (); 3r31220.}
}
3r31220.}
3r31184. 3r31185.
 3r31220.
 3r31220. Sound.java class audio playback
 3r31220.
 3r31220. 3r31079. 3r31080. /* 3r31220. * To change this license header, choose License Headers in Project Properties. 3r31220. * To change this template file, choose Tools | Templates 3r31220. * and open the template in the editor. 3r31220. * /
package jdrum; 3r31220. 3r31220. import java.io.File; 3r31220. import java.io.IOException; 3r31220. import javax.sound.sampled.AudioFormat; 3r31220. import javax.sound.sampled.AudioInputStream; 3r31220. import javax.sound.sampled.AudioSystem; 3r31220. import javax.sound.sampled.Clip; 3r31220. import javax.sound.sampled.DataLine; 3r31220. import javax.sound.sampled.LineUnavailableException; 3r31220. import javax.sound.sampled.SourceDataLine; 3r31220. 3r31220. /** 3r31220. * 3r31220. * @author nn
* /
public class Sound {3r31220. 3r31220. public boolean playCompleted; 3r31220. 3r31220. 3r31220. public file file; 3r31220. public AudioInputStream stream; 3r31220. public AudioFormat format; 3r31220. public DataLine.Info info; 3r31220. public Clip clip; 3r31220. 3r31220. 3r31220. private final int BUFFER_SIZE = 128000; 3r31220. private file soundFile; 3r31220. private AudioInputStream audioStream; 3r31220. private AudioFormat audioFormat; 3r31220. private SourceDataLine sourceLine; 3r31220. 3r31220. public void loadFile (File file) {
this.file = file; 3r31220. 3r31220.}
3r31220. public void play () {
if (file! = null) {
3r31220. soundFile = file; 3r31220. 3r31220. 3r31220. try {3r31220. audioStream = AudioSystem.getAudioInputStream (soundFile); 3r31220.} catch (Exception e) {
e.printStackTrace (); 3r31220. System.exit (1); 3r31220.}
3r31220. audioFormat = audioStream.getFormat (); 3r31220. 3r31220. DataLine.Info info = new DataLine.Info (SourceDataLine.class, audioFormat); 3r31220. 3r31220. if (! AudioSystem.isLineSupported (info)) {3r31220. System.out.println ("Line not supported" + info); 3r31220.}
3r31220. try {3r31220. sourceLine = (SourceDataLine) AudioSystem.getLine (info); 3r31220. //
sourceLine.open (audioFormat); 3r31220.} catch (LineUnavailableException e) {
e.printStackTrace (); 3r31220. System.exit (1); 3r31220.} catch (Exception e) {
e.printStackTrace (); 3r31220. System.exit (1); 3r31220.}
3r31220. sourceLine.start (); 3r31220. 3r31220. 3r31220. 3r31220. int nBytesRead = 0; 3r31220. byte[]abData = new byte[BUFFER_SIZE]; 3r31220. while (nBytesRead! = -1) {
try {3r31220. nBytesRead = audioStream.read (abData, ? abData.length); 3r31220.} catch (IOException e) {
e.printStackTrace (); 3r31220.}
if (nBytesRead> = 0) {
@SuppressWarnings ("unused")
int nBytesWritten = sourceLine.write (abData, ? nBytesRead); 3r31220.}
}
3r31220. 3r31220. 3r31220. /** 3r31220. try {3r31220. Clip clip = new Clip (); 3r31220. 3r31220. int waitTime = (int) Math.ceil (clip.getMicrosecondLength () /1000.0); 3r31220. Thread.sleep (waitTime); 3r31220.} catch (InterruptedException ex) {3r31220. Logger.getLogger (Sound.class.getName ()). Log (Level.SEVERE, null, ex); 3r31220.} catch (LineUnavailableException ex) {
Logger.getLogger (Sound.class.getName ()). Log (Level.SEVERE, null, ex); 3r31220.}
** /
3r31220. sourceLine.drain (); 3r31220. sourceLine.close (); 3r31220.}
3r31220.}
3r31220. 3r31220.}
3r31184. 3r31185.
 3r31220.
 3r31220. Spreading Main.java will not be there generating interfaces using NetBeans, only some interesting points:
 3r31220.
 3r31220. 3r31079. 3r31080. public Main () {
3r31220. 3r31220. initComponents (); 3r31220. 3r31220. //bind load sample
jTextField1.addMouseListener (new SampleEvent (? this)); 3r31220. jTextField2.addMouseListener (new SampleEvent (? this)); 3r31220. jTextField3.addMouseListener (new SampleEvent (? this)); 3r31220. jTextField4.addMouseListener (new SampleEvent (? this)); 3r31220. jTextField5.addMouseListener (new SampleEvent (? this)); 3r31220. jTextField6.addMouseListener (new SampleEvent (? this)); 3r31220. 3r31220. 3r31220. 3r31220. //bind pad click
Field field; 3r31220. JButton dynamicButton; 3r31220. 3r31220. try {3r31220. 3r31220. for (int buttonNum = 1; buttonNum <= 96; buttonNum++) {
field = this.getClass (). getDeclaredField ("jButton" + buttonNum);
field.setAccessible (true);
dynamicButton = (JButton) field.get (this); current
DynamicButton.setMargin (new Insets (? ? ? 0));
DynamicButton.addMouseListener (new PadEvent (buttonNum, this)); 3r3r???; ) {
Logger.getLogger (Main.class.getName ()) log (Level.SEVERE, null, ex);
} Catch (SecurityException ex) {3r31220.         Logger.getLogger (Main.class.getName ()). Log (Level.SEVERE, null, ex); 3r31220.} catch (IllegalArgumentException ex) {3r31220. Logger.getLogger (Main.class.getName ()). Log (Level.SEVERE, null, ex); 3r31220.} catch (IllegalAccessException ex) {3r31220. Logger.getLogger (Main.class.getName ()). Log (Level.SEVERE, null, ex); 3r31220.}
3r31220.} 3r31185.
 3r31220.
 3r31220. After initializing the components, you need to assign events to the buttons:
 3r31220. 1. Events rendered in separate classes.
 3r31220. 2. For event assignment for 96 buttons, the Reflection API is applied, which assigns events in the loop by name (name + i).
 3r31220.
 3r31220. SampleEvent.java
 3r31220. 3r31079. 3r31080. /* 3r31220. * To change this license header, choose License Headers in Project Properties. 3r31220. * To change this template file, choose Tools | Templates 3r31220. * and open the template in the editor. 3r31220. * /
package jdrum; 3r31220. 3r31220. import java.awt.event.MouseEvent; 3r31220. import java.awt.event.MouseListener; 3r31220. import java.io.File; 3r31220. import java.lang.reflect.Field; 3r31220. import java.util.logging.Level; 3r31220. import java.util.logging.Logger; 3r31220. import javax.swing.JFileChooser; 3r31220. import javax.swing.JTextField; 3r31220. import javax.swing.filechooser.FileNameExtensionFilter; 3r31220. 3r31220. /** 3r31220. * 3r31220. * @author nn
* /
public class SampleEvent implements MouseListener {
3r31220. public int fieldNum; 3r31220. Main frame; 3r31220. 3r31220. public SampleEvent (int fieldNum, Main frame) {3r31220. this.fieldNum = fieldNum; 3r31220. this.frame = frame; 3r31220.}
3r31220. public void mouseClicked (MouseEvent evt) {
if (evt.getButton () == MouseEvent.BUTTON1) {
JFileChooser fileopen = new JFileChooser (); 3r31220. 3r31220. fileopen.setCurrentDirectory (new java.io.File (System.getProperty ("user.dir"))); 3r31220. 3r31220. FileNameExtensionFilter filter = new FileNameExtensionFilter ("wav", "wav"); 3r31220. fileopen.setFileFilter (filter); 3r31220. 3r31220. 3r31220. 3r31220. int ret = fileopen.showDialog (null, "Open file"); 3r31220. if (ret == JFileChooser.APPROVE_OPTION) {
3r31220. 3r31220. try {3r31220. File file = fileopen.getSelectedFile (); 3r31220. 3r31220. 3r31220. //setup file name to sample field
Field field = frame.getClass (). GetDeclaredField ("jTextField" + fieldNum); 3r31220. field.setAccessible (true); 3r31220. JTextField value = (JTextField) field.get (this); 3r31220. 3r31220. value.setText (file.getName ()); 3r31220. 3r31220. 3r31220. Sound sound = new Sound (); 3r31220. 3r31220. sound.loadFile (file); 3r31220. 3r31220. //play 3r31220. JDrum.play (sound); 3r31220. 3r31220. 3r31220. //setup path
Field f = JDrum.class.getField ("line" + fieldNum + "Sound"); 3r31220. f.setAccessible (true); 3r31220. 3r31220. f.set (null, sound); 3r31220. 3r31220. 3r31220. 3r31220. //System.out.print (JDrum.line1SoundFile); 3r31220. //set full path
3r31220. //System.out.println (file.getAbsolutePath ()); 3r31220.} catch (SecurityException | IllegalArgumentException ex) {
Logger.getLogger (Main.class.getName ()). Log (Level.SEVERE, null, ex); 3r31220.} catch (NoSuchFieldException ex) {3r31220. Logger.getLogger (Main.class.getName ()). Log (Level.SEVERE, null, ex); 3r31220.} catch (IllegalAccessException ex) {3r31220. Logger.getLogger (Main.class.getName ()). Log (Level.SEVERE, null, ex); 3r31220.}
3r31220.}
}
3r31220. if (evt.getButton () == MouseEvent.BUTTON3) {
3r31220. try {3r31220. Field field = frame.getClass (). GetDeclaredField ("jTextField" + fieldNum); 3r31220. field.setAccessible (true); 3r31220. JTextField value = (JTextField) field.get (this); 3r31220. 3r31220. value.setText (""); 3r31220. 3r31220. 3r31220. Field f = JDrum.class.getField ("line" + fieldNum + "SoundFile"); 3r31220. f.setAccessible (true); 3r31220. f.set (null, null); 3r31220. 3r31220.} catch (NoSuchFieldException ex) {3r31220. Logger.getLogger (Main.class.getName ()). Log (Level.SEVERE, null, ex); 3r31220.} catch (SecurityException ex) {3r31220. Logger.getLogger (Main.class.getName ()). Log (Level.SEVERE, null, ex); 3r31220.} catch (IllegalArgumentException ex) {3r31220. Logger.getLogger (Main.class.getName ()). Log (Level.SEVERE, null, ex); 3r31220.} catch (IllegalAccessException ex) {3r31220. Logger.getLogger (Main.class.getName ()). Log (Level.SEVERE, null, ex); 3r31220.}
3r31220. 3r31220.}
}
3r31220. @Override
public void mousePressed (MouseEvent e) {
//throw new UnsupportedOperationException ("Not supported yet."); //To change the body of generated methods, choose Tools | Templates. 3r31220.}
3r31220. @Override
public void mouseReleased (MouseEvent e) {
//throw new UnsupportedOperationException ("Not supported yet."); //To change the body of generated methods, choose Tools | Templates. 3r31220.}
3r31220. @Override
public void mouseEntered (MouseEvent e) {
//throw new UnsupportedOperationException ("Not supported yet."); //To change the body of generated methods, choose Tools | Templates. 3r31220.}
3r31220. @Override
public void mouseExited (MouseEvent e) {
//throw new UnsupportedOperationException ("Not supported yet."); //To change the body of generated methods, choose Tools | Templates. 3r31220.}
3r31220.} 3r31185.
 3r31220.
 3r31220. PadEvent.java
 3r31220.
 3r31220. 3r31079. 3r31080. /* 3r31220. * To change this license header, choose License Headers in Project Properties. 3r31220. * To change this template file, choose Tools | Templates 3r31220. * and open the template in the editor. 3r31220. * /
package jdrum; 3r31220. 3r31220. import java.awt.Color; 3r31220. import java.awt.event.ActionEvent; 3r31220. import java.awt.event.ActionListener; 3r31220. import java.awt.event.MouseEvent; 3r31220. import java.awt.event.MouseListener; 3r31220. import java.lang.reflect.Field; 3r31220. import java.util.logging.Level; 3r31220. import java.util.logging.Logger; 3r31220. import javax.swing.JButton; 3r31220. 3r31220. /** 3r31220. * 3r31220. * @author nn
* /
public class PadEvent implements MouseListener {
3r31220. public int pudNum; 3r31220. Main frame; 3r31220. 3r31220. public PadEvent (int pudNum, Main frame) {
this.pudNum = pudNum; 3r31220. this.frame = frame; 3r31220.}
3r31220. 3r31220. @Override
public void mouseClicked (MouseEvent evt) {
3r31220. if (evt.getButton () == MouseEvent.BUTTON1) {
3r31220. Field field; 3r31220. JButton dynamicButton; 3r31220. 3r31220. try {3r31220. //change pad color
field = frame.getClass (). getDeclaredField ("jButton" + pudNum); 3r31220. field.setAccessible (true); 3r31220. dynamicButton = (JButton) field.get (this); 3r31220. 3r31220. //change color and play pad
if (! dynamicButton.getBackground (). equals (new Color (14?14?145))) {
dynamicButton.setBackground (new Color (14?14?145)); 3r31220. 3r31220. 3r31220.} else {
dynamicButton.setBackground (null); 3r31220.}
//play pad 3r31220. JDrum.playPad (pudNum); 3r31220. 3r31220. 3r31220.} catch (SecurityException ex) {3r31220. Logger.getLogger (Main.class.getName ()). Log (Level.SEVERE, null, ex); 3r31220.} catch (IllegalArgumentException ex) {3r31220. Logger.getLogger (Main.class.getName ()). Log (Level.SEVERE, null, ex); 3r31220.} catch (IllegalAccessException ex) {3r31220. Logger.getLogger (Main.class.getName ()). Log (Level.SEVERE, null, ex); 3r31220.} catch (NoSuchFieldException ex) {3r31220. Logger.getLogger (PadEvent.class.getName ()). Log (Level.SEVERE, null, ex); 3r31220.}
3r31220. 3r31220. //change the pad value from 1 to 0 or from 0 to 1
//start the sound assigned to the line 3r31220. //Change the color of the cc button green to serra and from gray to green
//System.out.println("press "+ pudNum); 3r31220. 3r31220. 3r31220. //change the pad value from 1 to 0 or from 0 to 1
//start the sound assigned to the line 3r31220. //Change the color of the cc button green to serra and from gray to green
//System.out.println("press "+ pudNum); 3r31220.}
}
3r31220. @Override
public void mousePressed (MouseEvent e) {
//throw new UnsupportedOperationException ("Not supported yet."); //To change the body of generated methods, choose Tools | Templates. 3r31220.}
3r31220. @Override
public void mouseReleased (MouseEvent e) {
//throw new UnsupportedOperationException ("Not supported yet."); //To change the body of generated methods, choose Tools | Templates. 3r31220.}
3r31220. @Override
public void mouseEntered (MouseEvent e) {
//throw new UnsupportedOperationException ("Not supported yet."); //To change the body of generated methods, choose Tools | Templates. 3r31220.}
3r31220. @Override
public void mouseExited (MouseEvent e) {
//throw new UnsupportedOperationException ("Not supported yet."); //To change the body of generated methods, choose Tools | Templates. 3r31220.}
3r31220.}
3r31184. 3r31185.
 3r31220.
 3r31220. Of course, like any other alpha version of the program, errors occur: 3r3-31208.  3r31220.
 3r31220. 3r31194. javax.sound.sampled.LineUnavailableException: line with format PCM_SIGNED 44100.0 Hz, 16 bit, stereo, 4 bytes /frame, little-endian not supported. at com.sun.media.sound.DirectAudioDevice $ DirectDL.implOpen (DirectAudioDevice.javaCl3) at com.sun.media.sound.AbstractDataLine.open (AbstractDataLine.java:121) at com.sun.media.sound.AbstractDataLine .open (AbstractDataLine.java:153) at jdrum.Sound.play (Sound.java:68) at jdrum.PlaySoundThread.run (PlaySoundThread.java:24) /home/nn/.cache/netbeans/8.2/executor-snippets /run.xml:53: Java returned: 1 BUILD FAILED (total time: 1 minute 57 seconds)
 3r31220. 3r31197.
 3r31220. The error occurs as I understand it after the multi-assignment and keystrokes due to the busy line.
 3r31220.
 3r31220. I think the further development of the program will be toward: 3r3-31208.  3r31220. 1 Changing the playback of wav files on midi.
 3r31220. 2 Additions of notes.
 3r31220. 3 Add changes to sounds in the track. 3r31216. 3r31220. 3r31220. 3r3r12313. ! function (e) {function t (t, n) {if (! (n in e)) {for (var r, a = e.document, i = a.scripts, o = i.length; o-- ;) if (-1! == i[o].src.indexOf (t)) {r = i[o]; break} if (! r) {r = a.createElement ("script"), r.type = "text /jаvascript", r.async =! ? r.defer =! ? r.src = t, r.charset = "UTF-8"; var d = function () {var e = a.getElementsByTagName ("script")[0]; e.parentNode.insertBefore (r, e)}; "[object Opera]" == e.opera? a.addEventListener? a.addEventListener ("DOMContentLoaded", d,! 1): e.attachEvent ("onload", d ): d ()}}} t ("//mediator.mail.ru/script/2820404/"""_mediator") () (); 3r31214. 3r31220. 3r31216. 3r31220. 3r31220. 3r31220. 3r31220.
+ 0 -

Comments 44

Offline
morning world
morning world 4 December 2018 13:46
I think this is an  informative post and it is very useful and knowledgeable. therefore, I would  like to thank you for the efforts you have made in writing this article. job  search websites in ireland
Offline
morning world
morning world 6 December 2018 09:01
Thank you for very  usefull information.. yify
Offline
Anna Sally
Anna Sally 8 December 2018 09:22
I appreciated their genuine dedication to achieving our goals. Team was sincerely invested in our success. Their work for Laboratories Directory was exceptional.  Their helpfulness, accessibility, and attention to detail made the project possible.

Offline
morning world
morning world 8 December 2018 18:49
I am very happy to  discover your post as it will become on top in my collection of favorite  blogs to visit. 123  movies123
Offline
Anna Sally
Anna Sally 12 December 2018 18:12
I’m going to read this. I’ll be sure to come back. thanks for sharing. and also This article gives the light in which we can observe the reality. this is very nice one and gives indepth information. thanks for this nice article...gowormy.com



Wow, What  a Excellent post. I really found this to much informatics. It is what i was  searching for.I would like to suggest you that please keep sharing such type  of info.Thanks נופש  בפסח
Offline
Anna Sally
Anna Sally 13 December 2018 11:31
I just couldn't leave your website before telling you that I truly enjoyed the top quality info you present to your visitors? Will be back again frequently to check up on new posts. www.centrales-vapeur.fr
Offline
morning world
morning world 13 December 2018 15:26
Great  survey, I'm sure you're getting a great response.  rv  dealer in missouri
Offline
fuzailfaisal
fuzailfaisal 15 December 2018 15:48
I really like your  take on the issue. I now have a clear idea on what this matter is all about.. signs  of skin cancer on face
Offline
Anna Sally
Anna Sally 16 December 2018 11:35
I absolutely hate  coupon codes that don't work! The great thing about GetACode.com is that they  guarantee their codes will work (or they'll give you a gift card from Amazon) deals
Offline
Anna Sally
Anna Sally 16 December 2018 18:09
Positive site, where  did u come up with the information on this posting?I have read a few of the  articles on your website now, and I really like your style. Thanks a million  and please keep up the effective work.Used  Testing Equipment
Offline
Anna Sally
Anna Sally 17 December 2018 15:09
Thanks for picking out the time to discuss this, I feel great about it and love studying more on this topic. It is extremely helpful for me. Thanks for such a valuable help again. dampfanlagen
Offline
life time
life time 17 December 2018 19:13
Wow, cool post. I’d  like to write like this too – taking time and real hard work to make a great  article… but I put things off too much and never seem to get started. Thanks  though. bathroom  renovations melbourne
Offline
sohail khatri
sohail khatri 22 December 2018 16:04
I portt any phrase to understand this pronounce.....really i'm impressed from this publicize....the person who make this claim it became a pleasurable human..thank you for shared this in the back of than us.บอลออนไลน์
Offline
Anna Sally
Anna Sally 23 December 2018 20:34
I would like to say  that this blog really convinced me to do it! Thanks, very good post.  mediacom  speed test
Offline
Anna Sally
Anna Sally 24 December 2018 17:52
I admire this article for the well-researched content and excellent wording. I got so involved in this material that I couldn’t stop reading. I am impressed with your work and skill. Thank you so much.Zahnärzte Düsseldorf

Offline
sohail khatri
sohail khatri 26 December 2018 17:28
this is this kind of beatific resource which you are providing and you come back to an goodwill it away for forgive. I hero worship seeing weblog that acquire the price of presenting a mood useful resource for clean.토토
Offline
Anna Sally
Anna Sally 26 December 2018 18:10
Nice blog and  absolutely outstanding. You can do something much better but i still say this  perfect.Keep trying for the best.  dog  grooming miami
Offline
occult knowledge
occult knowledge 5 January 2019 16:52
Great post, and great website. Thanks for the information! occult knowledge

Offline
sohail khatri
sohail khatri 7 January 2019 21:23
whats up There. i discovered your blog the use of msn. this is a very smartly written article. sick be do to bookmark it and come supply help to to get accord of your hands on bond of into greater of your useful information. thanks for the book. unwell no evaluate repayment.cardone university review
Offline
Lopigo
Lopigo 10 January 2019 21:31
i've right of admission your weblog it is relatively pleasant to plus for me. I ache to make known way to you. i have bookmark your website online for blended updates.buy here

Offline
asd
asd 12 January 2019 16:45
whats up i'm as it should be delighted I located your blog, I absolutely located you through mistakes, whilst i used to be looking upon google for something else, anyways i am here now and will simply considering to manipulate by using thank for a exceptional say and a the entire one round funny internet site. Please entire keep happening the loud group.Back pain relief

Offline
Mehak
Mehak 16 January 2019 16:35
It was wondering if I  could use this write-up on my other website, I will link it back to your  website though.Great Thanks.justpva
Offline
Lawrence Fields
Lawrence Fields 15 February 2019 16:38
Quickly this page probably will without doubt maybe always be recognized regarding a lot of websites folks, due to the thoughtful articles or blog posts or perhaps ideas. this article
Offline
Brandon Clark
Brandon Clark 16 February 2019 13:28
Therefore dissertation web-sites as a result of online to set-up safe and sound ostensibly taped in the website.from this source
Offline
sohail khatri
sohail khatri 21 February 2019 17:17
I am impressed. I don't think Ive met anyone who knows as much about this subject as you do. You are truly well informed and very intelligent. You wrote something that people could understand and made the subject intriguing for everyone. Really, great blog you have got here.infervour
Offline
Fred Claar
Fred Claar 5 March 2019 13:27
That is why advertising which you appropriate search earlier than submitting. It'll be effortless to write down excellent write-up like that. website
Offline
Marketing Manager
Marketing Manager 6 March 2019 09:36
Their particular obtained onto your website despite the fact negotiating reputation merely several tid tad submits. Rewarding strategy for forth-coming, I am bookmarking prior to starting grab goods bottom line spgs entirely upwards. check this out
Offline
jackjohnny
jackjohnny 6 March 2019 16:17
Your content is nothing short of brilliant in many ways. I think this is engaging and eye-opening material. Thank you so much for caring about your content and your readers.<a href="https://article42093503.wordpress.com/2019/03/06/bodybuilding-supplement
s-very-best-choices-for-the-top-end-entertainers/">what is anvarol</a>


Your content is nothing short of brilliant in many ways. I think this is engaging and eye-opening material. Thank you so much for caring about your content and your readers.what is anvarol
Offline
asd
asd 6 March 2019 20:23
This is my first time i visit here. I found so many interesting stuff in your blog especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all the enjoyment here keep up the good workinfervour




thanks for this usefull article, waiting for this article like this againcara download video bokep
Offline
sohail khatri
sohail khatri 7 March 2019 16:50
You know your projects stand out of the herd. There is something special about them. It seems to me all of them are really brilliant!https://marketplace.seo-sa.com/category/banner-ads/

Add comment