Compare commits
	
		
			5 Commits
		
	
	
		
			v1.0.2
			...
			1e745b6d1c
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | 1e745b6d1c | ||
|   | e0720d56d0 | ||
|   | eb392746ed | ||
|   | dc9840b6e5 | ||
|   | 69e9fa695c | 
| @@ -5,7 +5,7 @@ FreqSample is a tool made in Java that will play a frequency. | |||||||
|  |  | ||||||
| ### Compiling | ### Compiling | ||||||
| Make sure you have the JDK installed along with Apache Ant. Then go to the root directory of this project and run: | Make sure you have the JDK installed along with Apache Ant. Then go to the root directory of this project and run: | ||||||
| ``` | ```bash | ||||||
| $ ant | $ ant | ||||||
| ``` | ``` | ||||||
|  |  | ||||||
|   | |||||||
| @@ -12,7 +12,7 @@ import javax.sound.sampled.*; | |||||||
|  *  |  *  | ||||||
|  */ |  */ | ||||||
| public class FreqSample { | public class FreqSample { | ||||||
| 	private static final String version = "v1.0.2"; | 	private static final String version = "v1.1.1"; | ||||||
| 	private JFrame frame; | 	private JFrame frame; | ||||||
| 	private JPanel panel; | 	private JPanel panel; | ||||||
| 	private JTextField hzField, msField; | 	private JTextField hzField, msField; | ||||||
| @@ -80,6 +80,7 @@ public class FreqSample { | |||||||
| 				new Window("About", | 				new Window("About", | ||||||
| 					"FreqSample " + version + "\n" + | 					"FreqSample " + version + "\n" + | ||||||
| 					"Copyright (C) 2014 Nicolás A. Ortega\n" + | 					"Copyright (C) 2014 Nicolás A. Ortega\n" + | ||||||
|  | 					"License: GNU GPLv3\n" + | ||||||
| 					"Contact: nicolas.ortega.froysa@gmail.com\n" + | 					"Contact: nicolas.ortega.froysa@gmail.com\n" + | ||||||
| 					"Source-Code: https://github.com/Deathsbreed/FreqSample\n" + | 					"Source-Code: https://github.com/Deathsbreed/FreqSample\n" + | ||||||
| 					"Developers: Nicolás Ortega\n\n"); | 					"Developers: Nicolás Ortega\n\n"); | ||||||
|   | |||||||
| @@ -21,6 +21,7 @@ public class Generator { | |||||||
|  |  | ||||||
| 		double fCyclePosition = 0; | 		double fCyclePosition = 0; | ||||||
|  |  | ||||||
|  | 		// Open Audio Device | ||||||
| 		AudioFormat af = new AudioFormat(SAMPLE_RATE, 16, 1, true, true); | 		AudioFormat af = new AudioFormat(SAMPLE_RATE, 16, 1, true, true); | ||||||
| 		DataLine.Info info = new DataLine.Info(SourceDataLine.class, af); | 		DataLine.Info info = new DataLine.Info(SourceDataLine.class, af); | ||||||
|  |  | ||||||
| @@ -33,16 +34,21 @@ public class Generator { | |||||||
| 		line.open(af); | 		line.open(af); | ||||||
| 		line.start(); | 		line.start(); | ||||||
|  |  | ||||||
|  | 		// The audio bytebuffer | ||||||
| 		ByteBuffer cBuf = ByteBuffer.allocate(line.getBufferSize()); | 		ByteBuffer cBuf = ByteBuffer.allocate(line.getBufferSize()); | ||||||
|  |  | ||||||
|  | 		// Set the total samples to loop through | ||||||
|  | 		if(msecs < 150) msecs = 150; | ||||||
| 		int ctSamplesTotal = (int)(SAMPLE_RATE * (msecs / 1000)); | 		int ctSamplesTotal = (int)(SAMPLE_RATE * (msecs / 1000)); | ||||||
| 		if(ctSamplesTotal < 150) ctSamplesTotal = 150; |  | ||||||
|  |  | ||||||
| 		while(ctSamplesTotal > 0) { | 		while(ctSamplesTotal > 0) { | ||||||
|  | 			// Define the frequency at the given sample rate | ||||||
| 			double fCycleInc = fFreq/SAMPLE_RATE; | 			double fCycleInc = fFreq/SAMPLE_RATE; | ||||||
|  |  | ||||||
|  | 			// Clear the buffer | ||||||
| 			cBuf.clear(); | 			cBuf.clear(); | ||||||
|  |  | ||||||
|  | 			// Play the frequency | ||||||
| 			int ctSamplesThisPass = line.available() / SAMPLE_SIZE; | 			int ctSamplesThisPass = line.available() / SAMPLE_SIZE; | ||||||
| 			for(int i = 0; i < ctSamplesThisPass; i++) { | 			for(int i = 0; i < ctSamplesThisPass; i++) { | ||||||
| 				cBuf.putShort((short)(Short.MAX_VALUE * Math.sin(2 * Math.PI * fCyclePosition))); | 				cBuf.putShort((short)(Short.MAX_VALUE * Math.sin(2 * Math.PI * fCyclePosition))); | ||||||
| @@ -57,6 +63,7 @@ public class Generator { | |||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|  | 		// Close the audioline | ||||||
| 		line.drain(); | 		line.drain(); | ||||||
| 		line.close(); | 		line.close(); | ||||||
| 	} | 	} | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user