Skip to content

Commit

Permalink
Added dynamic generation of neuron buttons, added neuron preview
Browse files Browse the repository at this point in the history
  • Loading branch information
Zachary Kim committed May 7, 2009
1 parent 79fa223 commit c7dd80c
Show file tree
Hide file tree
Showing 7 changed files with 217 additions and 189 deletions.
21 changes: 17 additions & 4 deletions neurons
Expand Up @@ -9,8 +9,8 @@
</color> </color>
<mediaFile>./neuron_media_files/thalamus.wav</mediaFile> <mediaFile>./neuron_media_files/thalamus.wav</mediaFile>
<location class="java.awt.geom.Point2D$Double"> <location class="java.awt.geom.Point2D$Double">
<x>46.468766858290735</x> <x>-5.531233141709265</x>
<y>-187.97748109104162</y> <y>8.022518908958375</y>
</location> </location>
</napplelabs.dbssim.neuron.NeuronPathRep> </napplelabs.dbssim.neuron.NeuronPathRep>
<napplelabs.dbssim.neuron.NeuronPathRep> <napplelabs.dbssim.neuron.NeuronPathRep>
Expand All @@ -22,8 +22,21 @@
</color> </color>
<mediaFile>./neuron_media_files/stn.wav</mediaFile> <mediaFile>./neuron_media_files/stn.wav</mediaFile>
<location class="java.awt.geom.Point2D$Double"> <location class="java.awt.geom.Point2D$Double">
<x>69.30791570133613</x> <x>-31.692084298663872</x>
<y>-184.2738353327099</y> <y>104.7261646672901</y>
</location>
</napplelabs.dbssim.neuron.NeuronPathRep>
<napplelabs.dbssim.neuron.NeuronPathRep>
<color>
<red>0</red>
<green>0</green>
<blue>255</blue>
<alpha>255</alpha>
</color>
<mediaFile>./neuron_media_files/thalamus.wav</mediaFile>
<location class="java.awt.geom.Point2D$Double">
<x>8.0</x>
<y>-15.5</y>
</location> </location>
</napplelabs.dbssim.neuron.NeuronPathRep> </napplelabs.dbssim.neuron.NeuronPathRep>
</list> </list>
Expand Down
6 changes: 6 additions & 0 deletions pom.xml
Expand Up @@ -117,6 +117,12 @@
<artifactId>xstream</artifactId> <artifactId>xstream</artifactId>
<version>1.3.1</version> <version>1.3.1</version>
</dependency> </dependency>

<dependency>
<groupId>com.google.collections</groupId>
<artifactId>google-collections</artifactId>
<version>1.0-rc1</version>
</dependency>
</dependencies> </dependencies>


<build> <build>
Expand Down
97 changes: 42 additions & 55 deletions src/main/groovy/napplelabs/dbssim/NeuronPlayer.java
@@ -1,83 +1,70 @@
package napplelabs.dbssim; package napplelabs.dbssim;


/* /*
MockDBS: Deep Brain Stimulation Simulator MockDBS: Deep Brain Stimulation Simulator
Copyright (C) 2009 Zachary Kim Copyright (C) 2009 Zachary Kim
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.io.File;
import javax.sound.sampled.AudioFormat; You should have received a copy of the GNU General Public License along
import javax.sound.sampled.AudioSystem; with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
import javax.sound.sampled.LineUnavailableException; 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.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;


import processing.core.PApplet; import processing.core.PApplet;

import ddf.minim.AudioOutput; import ddf.minim.AudioOutput;
import ddf.minim.AudioPlayer;
import ddf.minim.Minim; import ddf.minim.Minim;
import ddf.minim.signals.PinkNoise; import ddf.minim.signals.PinkNoise;
import ddf.minim.signals.SineWave; import ddf.minim.signals.SineWave;


public class NeuronPlayer { public class NeuronPlayer {

private PinkNoise pink; private PinkNoise pink;
private SineWave sin; private SineWave sin;
private AudioOutput out; private AudioOutput out;


public NeuronPlayer() throws LineUnavailableException, InterruptedException { public NeuronPlayer() throws LineUnavailableException, InterruptedException {

JFrame frame = new JFrame(""); JFrame frame = new JFrame("");
frame.setSize(500, 300); frame.setSize(500, 300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

Minim minim = new Minim(new PApplet()); Minim minim = new Minim(new PApplet());
out = minim.getLineOut(Minim.MONO); // out = minim.getLineOut(Minim.MONO);
pink = new PinkNoise(0.2f); // pink = new PinkNoise(0.2f);


//out.addSignal(pink); // out.addSignal(pink);



// File file = new

// File("/Users/zkim/Desktop/Rage Against The Machine - rage against the machine - 06 - Know Your Enemy.mp3");

// AudioPlayer player = minim.loadFile(file.getAbsolutePath());
File file = new File("/Users/zkim/Desktop/Rage Against The Machine - rage against the machine - 06 - Know Your Enemy.mp3");
AudioPlayer player = minim.loadFile(file.getAbsolutePath()); // player.play();


player.play(); // TracePanel panel = new TracePanel(out);

// frame.setContentPane(panel);



//TracePanel panel = new TracePanel(out);
//frame.setContentPane(panel);

frame.setVisible(true); frame.setVisible(true);


//new Thread(panel).start(); // new Thread(panel).start();
}

private void stuff(final String mine) {
System.out.println("asdf");
} }


public static void main(String[] args) throws LineUnavailableException, InterruptedException { public static void main(final String[] args)
throws LineUnavailableException, InterruptedException {
new NeuronPlayer(); new NeuronPlayer();
} }
} }
17 changes: 12 additions & 5 deletions src/main/groovy/napplelabs/dbssim/canvasviews/NeuronPath.java
Expand Up @@ -21,9 +21,9 @@


import java.awt.Color; import java.awt.Color;


import napplelabs.dbssim.neuron.NeuronType;
import ddf.minim.AudioPlayer; import ddf.minim.AudioPlayer;
import ddf.minim.Minim; import ddf.minim.Minim;

import edu.umd.cs.piccolo.PNode; import edu.umd.cs.piccolo.PNode;
import edu.umd.cs.piccolo.nodes.PPath; import edu.umd.cs.piccolo.nodes.PPath;


Expand All @@ -34,13 +34,20 @@ public class NeuronPath extends PNode {
private AudioPlayer player; private AudioPlayer player;
private PPath path; private PPath path;


public NeuronPath(Color color, String mediaFile, Minim minim) { public NeuronPath(final Color color, final String mediaFile, final Minim minim) {
this.color = color; this.color = color;
this.mediaFile = mediaFile; this.mediaFile = mediaFile;
this.minim = minim; this.minim = minim;
init(); init();
} }


public NeuronPath(final NeuronType nt, final Minim minim) {
this.mediaFile = nt.getMediaPath();
this.minim = minim;
this.color = nt.getColor();
init();
}

public void init() { public void init() {
float d = 50f; float d = 50f;
path = PPath.createEllipse(-d/2, -d/2, d, d); path = PPath.createEllipse(-d/2, -d/2, d, d);
Expand All @@ -58,11 +65,11 @@ public void init() {
//player.play(); //player.play();
} }


public void setLevel(float level) { public void setLevel(final float level) {
float gain = (level * (80 + 14)) - 80; float gain = (level * (80 + 14)) - 80;
player.setGain(gain); player.setGain(gain);
} }
public void setPlaying(boolean playing) { public void setPlaying(final boolean playing) {
if(playing) if(playing)
player.play(); player.play();
else else
Expand All @@ -72,7 +79,7 @@ public boolean isPlaying() {
return player.isPlaying(); return player.isPlaying();
} }


public void setPath(PPath path) { public void setPath(final PPath path) {
this.path = path; this.path = path;
} }


Expand Down

0 comments on commit c7dd80c

Please sign in to comment.