Skip to content

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
dsabsay committed Dec 10, 2016
1 parent fd757ab commit 6d631d1
Showing 34 changed files with 26 additions and 690 deletions.
Binary file modified .DS_Store
Binary file not shown.
Binary file modified essentia/performance.wav
Binary file not shown.
Binary file modified src/.DS_Store
Binary file not shown.
Binary file modified src/main/.DS_Store
Binary file not shown.
Binary file modified src/main/java/.DS_Store
Binary file not shown.
16 changes: 0 additions & 16 deletions src/main/java/com/dsabsay/application/MainMenuController.java
Original file line number Diff line number Diff line change
@@ -38,14 +38,6 @@ void initialize() {
settingsButton.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
/*
if (mainController == null) {
System.out.println("mainController not set in MainMenuController!");
System.exit(1);
}
mainController.startSettings();
*/

try {
MainController.getInstance().startSettings();
} catch (ControllerException ex) {
@@ -59,14 +51,6 @@ public void handle(ActionEvent event) {
rhythmButton.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
System.out.println("Practice sight singing!");
/*
if (mainController == null) {
System.out.println("mainController not set in MainMenuController!");
System.exit(1);
}
mainController.startRhythmPracticeView();
*/
try {
MainController.getInstance().startRhythmPracticeView();
} catch (ControllerException ex) {
2 changes: 0 additions & 2 deletions src/main/java/com/dsabsay/application/NotationWebView.java
Original file line number Diff line number Diff line change
@@ -2,8 +2,6 @@

import com.dsabsay.model.InvalidVexTabException;
import com.dsabsay.model.VexTabExercise;
import com.dsabsay.model.VexTabExerciseAbstractClass;

import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.concurrent.Worker.State;
69 changes: 1 addition & 68 deletions src/main/java/com/dsabsay/application/PracticeController.java
Original file line number Diff line number Diff line change
@@ -117,17 +117,9 @@ public void handle(ActionEvent event) {

NotationWebView notationWebView = new NotationWebView(webView);

//String path = "src/main/resources/testRhythm2.txt";
//VexTabRhythmExercise exercise = new VexTabRhythmExercise(1, "test", path);

//UserConfiguration config = new UserConfiguration();
//config.setRhythmsPath("src/main/exercises/rhythmExercises");

//TODO
//this should be an ExercisesRepo to make it more flexible
//VexTabExercisesRepo repo = null;
ExercisesRepo repo = null;

//this just creates a VexTabRhythmExercisesRepo. could be generalized
try {
repo = new VexTabRhythmExercisesRepo(MainController.getInstance().getUserConfiguration());
} catch (ControllerException | IOException | InvalidVexTabException ex) {
@@ -154,43 +146,6 @@ public void handle(ActionEvent event) {
exerciseTypeLabel.setText(this.currentExercise.getType());
exerciseNameLabel.setText(this.currentExercise.getName());

/*
String options = "options font-size=14 space=15";
String tabstave = "tabstave notation=true tablature=false time=4/4 clef=percussion";
//String notes = "notes :2S Bd/4 :qS Bd/4 :q ## | :8S Bd/4 Bu/4 :qS Bd-Bu-Bd/4 ^3^";
String notes = "notes :2S B/4 :qS B/4 :q ## | :8S B/4 B/4 :qS B-B-B/4 ^3^";
//String notes = "notes :1S B/4 :qS B/4 :q ## | :8S B/4 B/4 :qS B-B-B/4 ^3^";
String notation = "\n options font-size=14 space=15"
+ "\n tabstave notation=true tablature=false"
+ "\n time=4/4 clef=percussion "
+ "\n notes :2S Bd/4 :qS Bd/4 :q ## | :8S Bd/4 Bu/4 :qS Bd-Bu-Bd/4 ^3^ "
+ "\n text :w, G Maj7, |, Am " + "\n options space=10\n";
System.out.println("notation: " + notation);
System.out.println("notationWebView:" + notationWebView);
WebEngine webEngine = notationWebView.getEngine();
ClassLoader classLoader = this.getClass().getClassLoader();
String url = classLoader.getResource("notation.html").toExternalForm();
// String url = Main.class.getResource("/src/main/VexFlow/notation.html").toExternalForm();
notationWebView.setZoom(0.75);
// need to set appropriate zoom
// get size of div, compare with size of webview, then scale appropriately
webEngine.getLoadWorker().stateProperty().addListener(new ChangeListener<State>() {
public void changed(ObservableValue ov, State oldState, State newState) {
if (newState == State.SUCCEEDED) {
// webEngine.executeScript("notate()");
// webEngine.executeScript("notate('" + notation + "')");
webEngine.executeScript("notateVexTab('" + notes + "')");
}
}
});
webEngine.load(url);
*/

/*
webEngine
.load("/Users/danielsabsay/Documents/workspace/javafxtest/src/application/notation.html");
*/
}

private void startRecording() {
@@ -258,28 +213,6 @@ private void showAlertAndWait(String title, String content) {
alert.showAndWait();
}

/*
private void gradePerformance(String filename) {
//errorMargin (in beats)
final float errorMargin = (float) 0.20;
RhythmExtractor extractor = new RhythmExtractor();
RhythmExtractorResults results;
try {
results = extractor.processPerformance(filename);
} catch (ExtractorException ex) {
// TODO Auto-generated catch block
ex.printStackTrace();
showAlertAndWait("Extractor Exception", "An error occured while processing the performance.");
}
SimpleRhythmGrader grader = new SimpleRhythmGrader();
PerformanceScore score = grader.evaluatePerformanceSimpler(this.currentExercise,
results, errorMargin);
}
*/

@FXML
private void recordCircleMouseEntered() {
recordCircle.setFill(Paint.valueOf("#cc7c7c"));
18 changes: 11 additions & 7 deletions src/main/java/com/dsabsay/grader/EssentiaExtractorLauncher.java
Original file line number Diff line number Diff line change
@@ -95,8 +95,10 @@ private String[] getCommand(String extractorPath, String filename) {
* Runs the Essentia extractor in a new process
* @param filename Filename of recorded performance.
* The path is relative to ESSENTIA_WORKING_DIRECTORY.
* @throws ExtractorException if the extractor exits with an exit code != EXIT_SUCCESS
*/
protected String processRhythmPerformance(String[] cmd) throws IOException, InterruptedException {
protected String processRhythmPerformance(String[] cmd) throws IOException, InterruptedException,
ExtractorException {
Runtime runtime = Runtime.getRuntime();

File dir = new File(ESSENTIA_WORKING_DIRECTORY);
@@ -107,12 +109,14 @@ protected String processRhythmPerformance(String[] cmd) throws IOException, Inte
InputStream error = extractor.getErrorStream();

//wait for process to terminate
if (extractor.waitFor() != EXIT_SUCCESS) {
System.out.println("extractor exited with failure");
Scanner scanner = new Scanner(error).useDelimiter("\\A");
String string = scanner.hasNext() ? scanner.next() : "";
scanner.close();
System.out.println("error: " + string);
int exit;
if ((exit = extractor.waitFor()) != EXIT_SUCCESS) {
throw new ExtractorException("Extractor exited with: " + exit);
//System.out.println("extractor exited with failure");
//Scanner scanner = new Scanner(error).useDelimiter("\\A");
//String string = scanner.hasNext() ? scanner.next() : "";
//scanner.close();
//System.out.println("error: " + string);
}

error.close();
5 changes: 0 additions & 5 deletions src/main/java/com/dsabsay/grader/ExtractorResults.java

This file was deleted.

6 changes: 3 additions & 3 deletions src/main/java/com/dsabsay/grader/RhythmExtractor.java
Original file line number Diff line number Diff line change
@@ -95,14 +95,14 @@ private void parseOnsetExtractorOutput(String onsetExtractorOutput) throws Extra

ArrayList<Float> onsets = new ArrayList<Float>();

System.out.println("Parse onsets:");
//System.out.println("Parse onsets:");

for (String s : onsetsListString) {
onsets.add(Float.parseFloat(s));
System.out.print(s + ", ");
//System.out.print(s + ", ");
}

System.out.println();
//System.out.println();

this.results.setOnsets(onsets);
}
90 changes: 1 addition & 89 deletions src/main/java/com/dsabsay/grader/RhythmExtractorResults.java
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@

import java.util.List;

public class RhythmExtractorResults extends ExtractorResults {
public class RhythmExtractorResults {
private float bpm;
private List<Float> ticks;
private List<Float> onsets;
@@ -23,19 +23,6 @@ public RhythmExtractorResults() {

}

/**
* Creates RhythmExtractorResults from extractor output.
* @param rhythmExtractorOutput output from the rhythm extractor
* @param onsetExtractorOutput output from the onset extractor
*/
/*
public RhythmExtractorResults(String rhythmExtractorOutput, String onsetExtractorOutput) {
parseRhythmExtractorOutput(rhythmExtractorOutput);
parseOnsetExtractorOutput(onsetExtractorOutput);
//System.out.println("ticks: " + this.ticks);
}
*/

public List<Float> getOnsets() {
return onsets;
}
@@ -47,41 +34,6 @@ public void setOnsets(List<Float> onsets) {
public void setTicks(List<Float> ticks) {
this.ticks = ticks;
}

/*
private void parseRhythmExtractorOutput(String rhythmExtractorOutput) {
String[] lines = rhythmExtractorOutput.split("\\n|\\r");
String bpmLine = lines[4];
this.bpm = Float.parseFloat(bpmLine.split(":\\s+")[1]);
//System.out.println("bpm: " + this.bpm);
String ticksLine = lines[5];
this.ticks = new ArrayList<Float>();
String ticksList = ticksLine.split("\\[|\\]")[1];
List<String> ticksListString = Arrays.asList(ticksList.split(",\\s*+"));
for (String s : ticksListString) {
this.ticks.add(Float.parseFloat(s));
}
}
*/

/*
private void parseOnsetExtractorOutput(String onsetExtractorOutput) {
String[] lines = onsetExtractorOutput.split("\\n|\\r");
String onsetTimes = lines[5];
String onsetsList = onsetTimes.split("\\[|\\]")[1];
List<String> onsetsListString = Arrays.asList(onsetsList.split(",\\s*+"));
this.onsets = new ArrayList<Float>();
for (String s : onsetsListString) {
this.onsets.add(Float.parseFloat(s));
}
}
*/

public float getBpm() {
return bpm;
@@ -91,46 +43,6 @@ public void setBpm(float bpm) {
this.bpm = bpm;
}

/**
* Converts the ticks to a list of Note.
* @return list of Note objects representing the notes of the performance
*/
/*
public List<Float> ticksToNotes() {
//List<Note> notes = new ArrayList<Note>();
List<Float> notes = new ArrayList<Float>();
//first tick is first note
//use bpm estimate for now?
//loop through list of ticks, don't calculate duration for last tick
for (int i = 0; i < this.ticks.size() - 1; i++) {
float duration = this.ticks.get(i + 1) - this.ticks.get(i);
int beats = tickToBeats(duration);
//interprets all durations as being a note (any rests will simply get added to the preceding
//note's duration
//notes.add(new Note(beats, iDontKnow, false));
//notes.add(beats);
}
return notes;
}
*/

//converts a float duration to number of beats (based on the bpm)
//assumes duration is measured in seconds
/*
private int tickToBeats(float duration) {
float beatsPerSecond = this.bpm / 60;
float beats = duration * beatsPerSecond;
//need to round the beats
int roundedBeats = Math.round(beats);
return roundedBeats;
}
*/

public List<Float> getTicks() {
return ticks;
}
9 changes: 0 additions & 9 deletions src/main/java/com/dsabsay/grader/RhythmGrader.java

This file was deleted.

Loading

0 comments on commit 6d631d1

Please sign in to comment.