Mercurial > hg > mep
changeset 10:3dd7636ca811
Add facility for printing out debugging info.
Ignore-this: 8073cadd49dcc4a7e7cc81dd25f90e89
author | Marcus Pearce <m.pearce@gold.ac.uk> |
---|---|
date | Fri, 04 Nov 2011 17:44:38 +0000 |
parents | 46c6d604e32c |
children | 85b03f084d63 |
files | Block.java Experiment.java ExperimentController.java ExperimentGui.java MelodyResults.java |
diffstat | 5 files changed, 46 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/Block.java Fri Nov 04 16:53:17 2011 +0000 +++ b/Block.java Fri Nov 04 17:44:38 2011 +0000 @@ -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-11-25 11:10:05 marcusp> + * Time-stamp: <2011-11-04 17:36:02 marcusp> *============================================================================= */ @@ -86,7 +86,9 @@ mp = new MidiPlayer(exp.getMidiDirectory().concat(filename), exp.getMidiDeviceNumber()); // Set up the melody structure and the probe positions setupSong(); - setupProbes(); + setupProbes(); + if (exp.getDebug()) + printProbes(); // Set up the results object for this melody mResults = new MelodyResults(filename, probes, onsets, iois, durations, pitches); @@ -105,7 +107,9 @@ durations = mp.getDurations(); iois = mp.getInterOnsetIntervals(); pitches = mp.getPitches(); - tatum = mp.getTatum(); + tatum = mp.getTatum(); + if (exp.getDebug()) + System.out.println("Tatum = " + tatum); } private void setupProbes() { @@ -122,7 +126,6 @@ for (int i = 0; i < probePos.size(); i++) probeValues.add(ProbeID.PROBE); Iterator pvi = probeValues.iterator(); - // Set up probes probes = new ArrayList(onsets.size()); @@ -130,7 +133,9 @@ probes.add(ProbeID.NOT_PROBE); while(ppi.hasNext()) { - int probe = ((Integer)ppi.next()).intValue(); + int probe = ((Integer)ppi.next()).intValue(); + if (exp.getDebug()) + System.out.println("Probe at " + probe); // probes.set(probe - numEvents, ProbeID.START_CLOCK); probes.set(probe - 1, ProbeID.BEFORE_PROBE); probes.set(probe, (ProbeID)pvi.next()); @@ -144,7 +149,9 @@ for (int i = 0; i < probePos.size(); i++) { int ppos = ((Integer)probePos.get(i)).intValue(); long onset = ((Long)(onsets.get(ppos))).longValue(); - clockStartTimes.add(onset - clockTimeInMicroseconds); + clockStartTimes.add(onset - clockTimeInMicroseconds); + if (exp.getDebug()) + System.out.println("ppos = " + ppos + "; onset = " + onset + "; clockTimeInMicroseconds = " + clockTimeInMicroseconds); } try { Collections.sort(clockStartTimes);
--- a/Experiment.java Fri Nov 04 16:53:17 2011 +0000 +++ b/Experiment.java Fri Nov 04 17:44:38 2011 +0000 @@ -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: <2011-11-04 16:52:49 marcusp> + * Time-stamp: <2011-11-04 17:42:17 marcusp> *============================================================================= */ @@ -71,7 +71,11 @@ /* the midi device */ private int midiDevice; + /* debugging */ + private boolean debug = false; + /* accessors */ + public boolean getDebug() { return debug; } public boolean getAskLiking() { return askLiking; } public boolean getAskFamiliarity() { return askFamiliarity; } public boolean getFinalQuestionnaire() { return finalQuestionnaire; } @@ -129,9 +133,6 @@ finalQuestionnaire = false; else finalQuestionnaire = true; - - - // Initialise the experiment Block practice = new Block(this, gui, PRACTICE_MIDIFILELIST_FILE,
--- a/ExperimentController.java Fri Nov 04 16:53:17 2011 +0000 +++ b/ExperimentController.java Fri Nov 04 17:44:38 2011 +0000 @@ -2,7 +2,7 @@ * File: ExperimentController.java * Author: Marcus Pearce <m.pearce@gold.ac.uk> * Created: <2007-12-14 12:06:10 marcusp> - * Time-stamp: <2011-07-19 15:26:30 marcusp> + * Time-stamp: <2011-11-04 17:31:28 marcusp> *============================================================================= */ @@ -182,7 +182,8 @@ for (int i = 0; i < rButtons.length; i++) { //System.out.println("Char = " + Character.forDigit(i+1, 10)); if (e.getKeyChar() == Character.forDigit(i+1, 10)) { - //System.out.println("Got rating: " + (i + 1)); + if (exp.getDebug()) + System.out.println("Got rating: " + (i + 1)); block.addResponse(i+1, time); gui.setAcceptingResponses(false); }
--- a/ExperimentGui.java Fri Nov 04 16:53:17 2011 +0000 +++ b/ExperimentGui.java Fri Nov 04 17:44:38 2011 +0000 @@ -2,7 +2,7 @@ * File: ExperimentGui.java * Author: Marcus Pearce <m.pearce@gold.ac.uk> * Created: <2007-02-14 16:42:31 marcusp> - * Time-stamp: <2010-11-18 11:46:46 marcusp> + * Time-stamp: <2011-11-04 17:41:45 marcusp> *============================================================================= */ @@ -31,7 +31,11 @@ /* accessors */ public Boolean getAcceptingResponses() { return acceptingResponses; } - public void setAcceptingResponses(Boolean b) { acceptingResponses = b; } + public void setAcceptingResponses(Boolean b) { + if (exp.getDebug()) + System.out.println("Changing acceptingResponses from " + acceptingResponses + " to " + b); + acceptingResponses = b; + } public Experiment getExperiment() { return exp; } public InstructionsPanel getInstructionsPanel() { return instructionsPanel; } public StimulusPanel getStimulusPanel() { return stimulusPanel; } @@ -157,8 +161,13 @@ boolean clockTicking = false; while(oi.hasNext()) { - //System.out.println("Ticking = " + clockTicking + - // "; clockUnit = " + clockUnit); + if (exp.getDebug()) + System.out.println("Ticking = " + clockTicking + + "; clockUnit = " + clockUnit + + "; currentOnset = " + currentOnset + + "; nextEventOnset = " + nextEventOnset + + "; nextClockStartTime = " + nextClockStartTime + + "; probe = " + probe); if (clockTicking == true && clockUnit == 0) tick(nMinutes); @@ -184,20 +193,22 @@ //tick(nMinutes); break; case BEFORE_PROBE: - //System.out.println("BEFORE_PROBE: acceptingResponses = " + - // acceptingResponses); + if (exp.getDebug()) + System.out.println("BEFORE_PROBE: acceptingResponses = " + + acceptingResponses); if (acceptingResponses == true) exp.getCurrentBlock().addResponse(0, System.nanoTime()); else - acceptingResponses = true; + setAcceptingResponses(true); //tick(nMinutes); clockTicking = false; break; case PROBE: case PROBE_EX: case PROBE_UNEX: - //System.out.println("PROBE_{UN,}EX: acceptingResponses = " - // + acceptingResponses); + if (exp.getDebug()) + System.out.println("PROBE_{UN,}EX: acceptingResponses = " + + acceptingResponses); clock.showFullClock = false; clock.repaint(); break; @@ -212,6 +223,8 @@ } // Update probe identifier and onset probe = (ProbeID)pi.next(); + if (exp.getDebug()) + System.out.println("Next probe = " + probe); nextEventOnset =((Long)(oi.next())).longValue(); } // sleep for a tatum
--- a/MelodyResults.java Fri Nov 04 16:53:17 2011 +0000 +++ b/MelodyResults.java Fri Nov 04 17:44:38 2011 +0000 @@ -2,7 +2,7 @@ * File: MelodyResults.java * Author: Marcus Pearce <m.pearce@gold.ac.uk> * Created: <2007-02-14 11:28:27 marcusp> - * Time-stamp: <2010-06-14 13:00:50 marcusp> + * Time-stamp: <2011-11-04 17:35:30 marcusp> *============================================================================= */ @@ -57,7 +57,8 @@ /* add a reponse i and time t (nanoseconds) */ public void addResponse(int i, long t) { - //System.out.println("addResponse(" + i + ", " + t + ")"); + //if (exp.getDebug()) + // System.out.println("addResponse(" + i + ", " + t + ")"); responses.add(i); responseTimes.add(t); }