Skip to content

Commit

Permalink
final release
Browse files Browse the repository at this point in the history
  • Loading branch information
Minusome committed Mar 8, 2019
1 parent f9b662f commit a3b29fd
Show file tree
Hide file tree
Showing 66 changed files with 771 additions and 823 deletions.
31 changes: 0 additions & 31 deletions .classpath

This file was deleted.

23 changes: 0 additions & 23 deletions .project

This file was deleted.

5 changes: 0 additions & 5 deletions .settings/org.eclipse.jdt.core.prefs

This file was deleted.

4 changes: 0 additions & 4 deletions .settings/org.eclipse.m2e.core.prefs

This file was deleted.

Binary file removed src/main/.DS_Store
Binary file not shown.
4 changes: 0 additions & 4 deletions src/main/java/namesayer/Main.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
package namesayer;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.stage.Stage;
import namesayer.persist.NameStorageManager;
import namesayer.persist.SessionStorageManager;
import namesayer.persist.StatsManager;


import static namesayer.util.Screen.MAIN_MENU;


public class Main extends Application {
//TODO Implement Rewards screen
//TODO Make the card number display actually work

@Override
public void start(Stage primaryStage) throws Exception {
Expand Down
29 changes: 14 additions & 15 deletions src/main/java/namesayer/model/CompositeName.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package namesayer.model;

import javafx.application.Platform;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;

Expand All @@ -14,16 +12,16 @@
import java.util.ArrayList;
import java.util.List;

import static namesayer.persist.Config.BUFFER_TIME;
import static namesayer.persist.Config.USER_ATTEMPTS;
import static namesayer.persist.Config.WAV_EXTENSION;
import static namesayer.persist.Config.*;


/**
* Represents a full-name created by the user.
* This name combines various PartialNames which come bundled with the Names Corpus Database.
*/

public class CompositeName extends Name implements Serializable {

/**
* These recordings are permanently associated with this name
* NameStorageManager accesses this list, any other class will only be able to see an empty list
*/

private List<CompositeRecording> userAttempts = new ArrayList<>();
private Exemplar exemplar;
Expand All @@ -48,8 +46,14 @@ public void setExemplar(Exemplar exemplar) {
this.exemplar = exemplar;
}

/**
* Creates a new recording for this name using FFmpeg.
* This command is executed by a bash shell in a separate thread.
*
*
* @param onFinished The EventHandler executed after recording is complete
*/
public void makeNewRecording(EventHandler<ActionEvent> onFinished) {
//TODO Assume that the name provided is in a suitable format, will provide need regex to check later
String temp = "se206_" +
LocalDateTime.now().format(DateTimeFormatter.ofPattern("d-M-yyyy_HH:mm:ss")) +
" " +
Expand All @@ -75,9 +79,4 @@ public void makeNewRecording(EventHandler<ActionEvent> onFinished) {
thread.start();
}

public void makeNewRecording() {
this.makeNewRecording(event -> {});
}


}
5 changes: 5 additions & 0 deletions src/main/java/namesayer/model/CompositeRecording.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@
import java.nio.file.Path;
import java.time.LocalDateTime;

/**
* Represents an audio file of a CompositeName
*/

public class CompositeRecording extends Recording {

//Default rating is 3.0
private double rating = 3.0;

private LocalDateTime timeStamp;
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/namesayer/model/Exemplar.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
import java.io.Serializable;
import java.util.List;


/**
* Represents the exemplar of a CompositeName
* This Exemplar is created by extracting PartialNames from the Names Corpus Database
*/

public class Exemplar implements Serializable {

private List<PartialRecording> exemplarComponents;
Expand All @@ -11,11 +17,15 @@ public Exemplar(List<PartialRecording> exemplarComponents) {
this.exemplarComponents = exemplarComponents;
}

/**
* Plays the exemplar on a new thread
*/
public void playAudio() {
new Thread(() -> {
for (PartialRecording recording : exemplarComponents) {
recording.playAudio();
try {
//Wait for the PartialRecording to finish playing before playing the next one
Thread.sleep((long) (recording.getLength() * 1000));
} catch (InterruptedException e) {
e.printStackTrace();
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/namesayer/model/Name.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import java.io.Serializable;

/**
* Abstract base class for any type of Name
*/
public abstract class Name implements Comparable<Name>, Serializable {

protected String name;
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/namesayer/model/PartialName.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package namesayer.model;

import javafx.collections.FXCollections;
import javafx.collections.ObservableList;

import java.util.ArrayList;
import java.util.List;

/**
* PartialNames are those which came bundled with the Names Corpus DB.
*/

public class PartialName extends Name {

//Ony-to-many relationship PartialNames and PartialRecordings
private List<PartialRecording> partialRecordings = new ArrayList<>();

public PartialName(String name) {
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/namesayer/model/PartialRecording.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

import java.nio.file.Path;

/**
* Represents the audio file of a PartialName
*/

public class PartialRecording extends Recording {

private boolean isBadQuality = false;
Expand Down
13 changes: 11 additions & 2 deletions src/main/java/namesayer/model/Recording.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
import java.nio.file.Path;
import java.nio.file.Paths;

/**
* Abstract base class of any type of Recording
* Represents a WAV audio file
*/

public abstract class Recording implements Serializable {

private String recordingPath;
Expand All @@ -21,7 +26,9 @@ public Recording(Path recordingPath) {
}


//Play audio using bash command
/**
* Play audio using FFplay in separate thread
*/
public void playAudio() {
Thread thread = new Thread(() -> {
String command = "ffplay -nodisp -autoexit -loglevel quiet \"" + recordingPath + "\"";
Expand All @@ -45,7 +52,9 @@ public void setRecordingPath(Path newPath) {
}


//Calculates the length
/**
* Calculates the length using Java AudioStream API
*/
public double getLength() {
double durationInSeconds = 0.0;
try {
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/namesayer/persist/CompositeNamesLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

import static namesayer.persist.Config.SAVED_RECORDINGS;

/**
* Responsible for loading CompositeNames which have been saved in the generated database.
*/

public class CompositeNamesLoader extends NamesLoader<CompositeName, CompositeRecording> {

@Override
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/namesayer/persist/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import java.nio.file.Paths;

/**
* Defines constants which are mainly folder names
* Defines constants which describe the required folder structure
*/
public class Config {
public static final Path DATABASE_FOLDER = Paths.get("database");
Expand All @@ -18,6 +18,8 @@ public class Config {
public static final Path BAD_QUALITY_FILE = GENERATED_FOLDER.resolve("bad_quality_names.txt");
public static final Path STATS_FOLDER = GENERATED_FOLDER.resolve("stats");
public static final Path STATS_FILE = STATS_FOLDER.resolve("data.ser");
public static final Path SCRIPT_FILE = Paths.get("script").resolve("VolumeEdit.sh");

public static final double BUFFER_TIME = 1;

public static final double BUFFER_TIME = 0.5;
}
Loading

0 comments on commit a3b29fd

Please sign in to comment.