Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Minor formatting tweaks. GuiMiniHost does not work in Windows.

  • Loading branch information...
commit 38d4e38f121fc5dfbecfaa62bf906c7c7ca8072d 1 parent 967a2a9
@mhroth authored
View
BIN  JVstHost.jar
Binary file not shown
View
4 src/com/synthbot/minihost/GuiMiniHost.java
@@ -37,14 +37,12 @@
private GuiMiniHostListener stringGui;
private int channel = 0;
- private int velocity = 127;
public GuiMiniHost(File vstFile) {
vst = null;
stringGui = new PluginStringGui(this);
try {
- System.out.println("GuiMiniHost... about ot load ! "+vstFile.toString());
vst = new JVstHost(vstFile, sampleRate, blockSize);
} catch (JVstLoadException jvle) {
jvle.printStackTrace(System.err);
@@ -82,7 +80,7 @@ public String getProgramName(){
public synchronized void playNote(int note, int velocity){
try {
ShortMessage midiMessage = new ShortMessage();
- midiMessage.setMessage(ShortMessage.NOTE_ON, 0, note, velocity);
+ midiMessage.setMessage(ShortMessage.NOTE_ON, channel, note, velocity);
audioThread.addMidiMessages(midiMessage);
} catch (InvalidMidiDataException imde) {
imde.printStackTrace(System.err);
View
112 src/com/synthbot/minihost/PluginStringGui.java
@@ -21,7 +21,6 @@
package com.synthbot.minihost;
-
import java.awt.Dimension;
import java.awt.Container;
import javax.swing.BoxLayout;
@@ -43,7 +42,7 @@
import javax.swing.ImageIcon;
import javax.swing.JComboBox;
-public class PluginStringGui extends JFrame implements GuiMiniHostListener {
+public class PluginStringGui extends JFrame implements GuiMiniHostListener {
private final PluginStringGuiListener host;
@@ -52,19 +51,19 @@
private JSlider[] sliders;
private JButton setEvolutionMaskButton;
- // private static final String EVOLUTION_MASK = "Set Evoution Mask";
+ // private static final String EVOLUTION_MASK = "Set Evoution Mask";
private static final String SYNTHBOT_STRING_GUI = "SynthBot String GUI";
- //private static final String NO_EVOLVE = "Don't Evolve";
+ // private static final String NO_EVOLVE = "Don't Evolve";
private static final String PARAMETER_VALUE = "Parameter Value";
private static final String PARAMETER_DISPLAY = "Parameter Display";
private static final String PARAMETER_NAME = "Parameter Name";
- public PluginStringGui(PluginStringGuiListener pluginHost){
+ public PluginStringGui(PluginStringGuiListener pluginHost) {
super(SYNTHBOT_STRING_GUI);
this.host = pluginHost;
}
- public void generateGui(){
+ public void generateGui() {
// configure the gui based on this host
int colWidth = 240;
int colHeight = 25;
@@ -84,10 +83,7 @@ public void generateGui(){
displays[i] = host.getParameterDisplay(i);
names[i] = host.getParameterName(i);
labels[i] = host.getParameterLabel(i);
- System.out.println("GuiMiniHost: label is "+labels[i]);
}
-
-
// this is the top level container with the 3 cols plus the keyboard
Container globalContainer = new Container();
@@ -117,12 +113,8 @@ public void generateGui(){
sliders = new JSlider[numParameters];
for (int i = 0; i < numParameters; i++) {
- //System.out.println("PluginStringGUI... adding para "+names[i]);
JLabel nameLabel = new JLabel(i + ": " + names[i] + " (" + labels[i] + ") ", JLabel.RIGHT);
-
- final JSlider slider = new JSlider(0, 127, (int) (values[i] * 127f)); // set
- // initial
- // value?
+ final JSlider slider = new JSlider(0, 127, (int) (values[i] * 127f)); // set initial value
slider.setValue((int) (values[i] * 127f));
slider.setFocusable(false);
sliders[i] = slider;
@@ -140,12 +132,11 @@ public void generateGui(){
final int index = i;
slider.addChangeListener(new ChangeListener() {
- public void stateChanged(ChangeEvent event) {
- String displayString = host.setParameter(index,
- ((float) slider.getValue()) / 127f);
- valueLabel.setText(displayString);
- }
- });
+ public void stateChanged(ChangeEvent event) {
+ String displayString = host.setParameter(index, ((float) slider.getValue()) / 127f);
+ valueLabel.setText(displayString);
+ }
+ });
// tell it not to fuck about with the sizes
widgets.setMinimumSize(new Dimension(colWidth, colHeight));
widgets.setPreferredSize(new Dimension(colWidth, colHeight));
@@ -196,11 +187,11 @@ public void stateChanged(ChangeEvent event) {
}
key.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent event) {
- //host.playNote(48 + note, 96, synthbot.onGetCurrentParameters());
- host.playNote(48 + note, 96);
- }
- });
+ public void actionPerformed(ActionEvent event) {
+ // host.playNote(48 + note, 96, synthbot.onGetCurrentParameters());
+ host.playNote(48 + note, 96);
+ }
+ });
keyboard.add(key);
}
@@ -220,53 +211,48 @@ public void actionPerformed(ActionEvent event) {
JComboBox progList = new JComboBox(progNames);
progList.setSelectedIndex(0);
progList.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- JComboBox cb = (JComboBox) e.getSource();
- int index = cb.getSelectedIndex();
- String progName = (String) cb.getSelectedItem();
- float[] program;
- // System.out.println("PluginStringGUI: you selected program
- // "+progName+" index "+index);
- host.setProgram(index);
- // now update the sliders...
- //program = host.getCurrentParameters();
-
- for (int i = 0; i < numParameters; i++) {
- // System.out.println("PluginStringGUI: updating param "+i+" to
- // "+program[i]);
- sliders[i].setValue((int) (host.getParameter(i) * 127f));
- }
- }
- });
+ public void actionPerformed(ActionEvent e) {
+ JComboBox cb = (JComboBox) e.getSource();
+ int index = cb.getSelectedIndex();
+ String progName = (String) cb.getSelectedItem();
+ float[] program;
+ host.setProgram(index);
+ // now update the sliders...
+ // program = host.getCurrentParameters();
+
+ for (int i = 0; i < numParameters; i++) {
+ sliders[i].setValue((int) (host.getParameter(i) * 127f));
+ }
+ }
+ });
globalContainer.add(scrollPane);
globalContainer.add(keyboard);
globalContainer.add(progList);
this.add(globalContainer);
-
// container.add(playSound);
this.addKeyListener(new KeyListener() {
- public void keyPressed(KeyEvent event) {
- }
-
- public void keyReleased(KeyEvent event) {
- }
-
- public void keyTyped(KeyEvent event) {
- switch (event.getKeyChar()) {
- case ' ':
- // TODO play a sound here
- break;
- case 'w':
- // TODO close the frame
- break;
- default:
- break;
- }
- }
- });
+ public void keyPressed(KeyEvent event) {
+ }
+
+ public void keyReleased(KeyEvent event) {
+ }
+
+ public void keyTyped(KeyEvent event) {
+ switch (event.getKeyChar()) {
+ case ' ':
+ // TODO play a sound here
+ break;
+ case 'w':
+ // TODO close the frame
+ break;
+ default:
+ break;
+ }
+ }
+ });
this.setFocusable(true);
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
View
7 src/com/synthbot/minihost/PluginStringGuiListener.java
@@ -30,18 +30,13 @@
* @version 1.0
*/
public interface PluginStringGuiListener{
-
public String setParameter(int index, float value);
public float getParameter(int index);
public int getNumParameters();
public String getParameterDisplay(int index);
public String getParameterName(int index);
public String getParameterLabel(int index);
-
public void setProgram(int index);
- public String getProgramName();
-
+ public String getProgramName();
public void playNote(int noteNumber, int velocity);
-
-
}
View
3  src/com/synthbot/minihost/RandomMiniHost.java
@@ -27,6 +27,9 @@
import javax.sound.midi.ShortMessage;
import javax.sound.midi.InvalidMidiDataException;
+/**
+ * Plays a random note every 1 second.
+ */
public class RandomMiniHost {
private static final float sampleRate = 44100f;
Please sign in to comment.
Something went wrong with that request. Please try again.