changeset 1:93ed757b9871

Add midi device as a command line parameter. Ignore-this: a6c745a4b262ed92195abba61880f758
author Marcus Pearce <m.pearce@gold.ac.uk>
date Tue, 08 Jun 2010 17:30:07 +0100
parents 4031cbb02f08
children 1fe7ac28a3ca
files Block.java Experiment.java MidiPlayer.java README runExperiment.bat
diffstat 5 files changed, 29 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/Block.java	Tue May 18 11:37:10 2010 +0100
+++ b/Block.java	Tue Jun 08 17:30:07 2010 +0100
@@ -2,7 +2,7 @@
  * File:       Block.java
  * Author:     Marcus Pearce <m.pearce@gold.ac.uk>
  * Created:    <2008-01-07 10:38:45 marcusp>
- * Time-stamp: <2010-05-17 11:42:23 marcusp>
+ * Time-stamp: <2010-06-08 16:13:27 marcusp>
  *=============================================================================
  */
 
@@ -82,7 +82,7 @@
     /* initialise the block */ 
     public void initialiseBlock() { 
         // Initialise the Midiplayer 
-        mp = new MidiPlayer(exp.getMidiDirectory().concat(filename)); 
+        mp = new MidiPlayer(exp.getMidiDirectory().concat(filename), exp.getMidiDeviceNumber()); 
         // Set up the melody structure and the probe positions 
         setupSong(); 
         setupProbes(); 
@@ -216,7 +216,7 @@
             File outputFile = new File(outFile); 
             
             MidiPlayer midip = 
-                new MidiPlayer(exp.getMidiDirectory().concat(midiFile)); 
+                new MidiPlayer(exp.getMidiDirectory().concat(midiFile), exp.getMidiDeviceNumber()); 
 
             // Setup the probes 
             ArrayList probePos = filelist.currentProbes(); 
--- a/Experiment.java	Tue May 18 11:37:10 2010 +0100
+++ b/Experiment.java	Tue Jun 08 17:30:07 2010 +0100
@@ -2,7 +2,7 @@
  * File:       Experiment.java
  * Author:     Marcus Pearce <m.pearce@gold.ac.uk>
  * Created:    <2007-02-14 11:28:27 marcusp>
- * Time-stamp: <2010-05-18 11:13:42 marcusp>
+ * Time-stamp: <2010-06-08 16:18:32 marcusp>
  *=============================================================================
  */
 
@@ -58,7 +58,11 @@
     private String lowAnchor;
     private String highAnchor;
 
+    /* the midi device */
+    private int midiDevice;
+
     /* accessors */ 
+    public int getMidiDeviceNumber() { return midiDevice; }
     public int getScaleLength() { return scaleLength; }
     public String getLowAnchor() { return lowAnchor; }
     public String getHighAnchor() { return highAnchor; }
@@ -79,13 +83,14 @@
     }
 
     /* Constructor */ 
-    public Experiment (int cu, int nu, int sl, String la, String ha) { 
+    public Experiment (int cu, int nu, int sl, int md, String la, String ha) { 
         
         // Setup variables 
         results = new SubjectResults(this); 
         clockUnits = cu; 
         numUnits = nu; 
         scaleLength = sl;
+        midiDevice = md;
         lowAnchor = la;
         highAnchor = ha;
 
@@ -133,8 +138,8 @@
     public static void main(String[] args) {
         if (args.length == 0) {
             System.out.println("Usage: " + "\t" + "java Experiment " + 
-                               "<clock units> <number of units> <scale length>" + 
-                               "<low anchor> <high anchor>"); 
+                               "<clock units> <number of units> <midi device>" + 
+                               "<scale length> <midi device> <low anchor> <high anchor>"); 
             System.exit(1);
         }
         
@@ -142,12 +147,13 @@
         int n = 0; 
         int cu = Integer.parseInt(args[n++]); 
         int nu = Integer.parseInt(args[n++]); 
+        int md = Integer.parseInt(args[n++]); 
         int sl = Integer.parseInt(args[n++]); 
         String la = args[n++];
         String ha = args[n++];
 
         // Create experiment 
-        Experiment exp = new Experiment(cu, nu, sl, la, ha); 
+        Experiment exp = new Experiment(cu, nu, sl, md, la, ha);
         
         // Show the GUI 
         int width=(int)Toolkit.getDefaultToolkit().getScreenSize().getWidth();
--- a/MidiPlayer.java	Tue May 18 11:37:10 2010 +0100
+++ b/MidiPlayer.java	Tue Jun 08 17:30:07 2010 +0100
@@ -2,7 +2,7 @@
  * File:       MidiPlayer.java
  * Author:     Marcus Pearce <m.pearce@gold.ac.uk>
  * Created:    <2007-02-14 12:13:56 marcusp>
- * Time-stamp: <2008-10-20 16:52:05 marcusp>
+ * Time-stamp: <2010-06-08 16:12:05 marcusp>
  *=============================================================================
  */
 
@@ -48,8 +48,9 @@
     public Sequencer getSequencer() { return sequencer; }
 
     /* Constructor */ 
-    public MidiPlayer(String path) { 
+    public MidiPlayer(String path, int deviceNumber) { 
         File midiFile = new File(path);
+        midiDevice = deviceNumber;
 
         // Get sequence 
         try { sequence = MidiSystem.getSequence(midiFile); }
--- a/README	Tue May 18 11:37:10 2010 +0100
+++ b/README	Tue Jun 08 17:30:07 2010 +0100
@@ -5,14 +5,20 @@
 
 USAGE 
 
-  java Experiment <multiple> <n> <scale length> <low anchor> <high anchor>
+  java Experiment <multiple> <n> <midi device> <scale length> <low anchor> <high anchor>
 
 where <multiple> and <n> are integers: the clock runs for <n> time
 units before a probed event where the time unit is a multiple of the
-tatum as specified by <multiple>. <scale length> is the number of
-levels of the rating scale and <low anchor> and <high anchor> are its
-high and low anchors respectively (e.g., "highly unexpected", "highly
-expected" with a scale length of 7). See runExperiment.bat for an example.
+tatum as specified by <multiple>. 
+
+<midi device> is an integer specifying the midi device to use (usually 0).
+
+<scale length> is the number of levels of the rating scale and <low
+anchor> and <high anchor> are its high and low anchors respectively
+(e.g., "highly unexpected", "highly expected" with a scale length of
+7). 
+
+See runExperiment.bat for an example.
 
 To use in a study:
 
--- a/runExperiment.bat	Tue May 18 11:37:10 2010 +0100
+++ b/runExperiment.bat	Tue Jun 08 17:30:07 2010 +0100
@@ -1,1 +1,1 @@
-java Experiment 1 4 7 "Highly unexpected" "Highly expected"
+java Experiment 1 4 0 7 "Highly unexpected" "Highly expected"