Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Working on NeuronSignal, it now adapts a signal held by a float buffe…
…r to an output buffer of any length, it basically keeps track of where in the signal the last chunk was taken out, and starts there for the next chunk.
- Loading branch information
Showing
30 changed files
with
267 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,12 @@ | ||
#Tue Jan 13 23:25:56 MST 2009 | ||
#Wed Jan 14 13:54:56 MST 2009 | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2 | ||
org.eclipse.jdt.core.compiler.compliance=1.4 | ||
org.eclipse.jdt.core.compiler.source=1.3 | ||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 | ||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve | ||
org.eclipse.jdt.core.compiler.compliance=1.5 | ||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate | ||
org.eclipse.jdt.core.compiler.debug.localVariable=generate | ||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate | ||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error | ||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error | ||
org.eclipse.jdt.core.compiler.source=1.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
#Tue Jan 13 23:25:56 MST 2009 | ||
#Wed Jan 14 00:14:16 MST 2009 | ||
activeProfiles= | ||
eclipse.preferences.version=1 | ||
fullBuildGoals=process-test-resources | ||
includeModules=false | ||
resolveWorkspaceProjects=true | ||
includeModules=true | ||
resolveWorkspaceProjects=false | ||
resourceFilterGoals=process-resources resources\:testResources | ||
version=1 |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,51 @@ | ||
package napplelabs.dbssim; | ||
|
||
import java.awt.Color; | ||
import java.awt.Graphics; | ||
import java.awt.Graphics2D; | ||
|
||
import javax.sound.sampled.AudioFormat; | ||
import javax.sound.sampled.AudioSystem; | ||
import javax.sound.sampled.LineUnavailableException; | ||
import javax.sound.sampled.SourceDataLine; | ||
import javax.sound.sampled.TargetDataLine; | ||
import javax.sound.sampled.DataLine.Info; | ||
import javax.swing.JFrame; | ||
import javax.swing.JPanel; | ||
import javax.swing.SwingUtilities; | ||
|
||
import ddf.minim.AudioOutput; | ||
import ddf.minim.Minim; | ||
import ddf.minim.signals.PinkNoise; | ||
import ddf.minim.signals.SineWave; | ||
|
||
public class NeuronPlayer { | ||
|
||
public NeuronPlayer() throws LineUnavailableException { | ||
Info info = new Info(SourceDataLine.class, new AudioFormat(22050f, 8, 1, true, false)); | ||
SourceDataLine line = (SourceDataLine) AudioSystem.getLine(info); | ||
|
||
System.out.println("Supported: " + AudioSystem.isLineSupported(info)); | ||
|
||
int buff_size = 22100; | ||
|
||
PinkNoise noise = new PinkNoise(1, 5); | ||
private PinkNoise pink; | ||
private SineWave sin; | ||
private AudioOutput out; | ||
|
||
public NeuronPlayer() throws LineUnavailableException, InterruptedException { | ||
|
||
line.open(); | ||
line.start(); | ||
|
||
byte[] buffer = new byte[buff_size]; | ||
for(int i=0; i < buff_size; i++) { | ||
buffer[i] = (byte) ((noise.nextValue() * 255) - 127); | ||
} | ||
JFrame frame = new JFrame(""); | ||
frame.setSize(500, 300); | ||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | ||
|
||
line.write(buffer, 0, buff_size); | ||
Minim minim = new Minim(null); | ||
out = minim.getLineOut(Minim.MONO); | ||
pink = new PinkNoise(0.2f); | ||
|
||
out.addSignal(pink); | ||
|
||
TracePanel panel = new TracePanel(out); | ||
frame.setContentPane(panel); | ||
|
||
line.drain(); | ||
frame.setVisible(true); | ||
|
||
line.stop(); | ||
line.close(); | ||
new Thread(panel).start(); | ||
} | ||
|
||
public static void main(String[] args) throws LineUnavailableException { | ||
public static void main(String[] args) throws LineUnavailableException, InterruptedException { | ||
new NeuronPlayer(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package napplelabs.dbssim; | ||
|
||
import ddf.minim.AudioOutput; | ||
import ddf.minim.AudioSignal; | ||
|
||
|
||
/** | ||
* Neuron signal provides a mechanism for pushing chunks of a neural | ||
* signal out to a float buffer. It abstracts away the need to | ||
* think about the specifics of the target buffer (length), and | ||
* concentrate on the neuronal signal. | ||
* | ||
* Usage: | ||
* float[] signal = new float[signal_length] | ||
* for(int i=0; i<signal_length; i++) { | ||
* // Fill signal | ||
* } | ||
* | ||
* NeuronSignal ns = new NeuronSignal(signal); | ||
* | ||
* float[] first_chunk = new float[100]; //notice different array sizes | ||
* float[] second_chunk = new float[39]; | ||
* | ||
* ns.generate(first_chunk); // gets first chunk | ||
* ns.generate(second_chunk); // gets second chunk | ||
* | ||
* //Send first and second chunk to output | ||
* @author zkim | ||
* | ||
*/ | ||
public class NeuronSignal implements AudioSignal { | ||
|
||
|
||
private float[] spike; | ||
private int counter = 0; | ||
|
||
public NeuronSignal(float[] spike) { | ||
this.spike = spike; | ||
} | ||
|
||
public void generate(float[] signal) { | ||
for(int i=0; i < signal.length; i++) { | ||
signal[i] = spike[counter]; | ||
|
||
counter++; | ||
if(counter >= spike.length) counter = 0; | ||
} | ||
} | ||
|
||
public void generate(float[] left, float[] right) { | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.