Skip to content

Commit

Permalink
Basic organization changes and initial Cue implementations
Browse files Browse the repository at this point in the history
  • Loading branch information
nlowe committed Dec 5, 2016
1 parent 206a78d commit b15709b
Show file tree
Hide file tree
Showing 15 changed files with 719 additions and 37 deletions.
1 change: 1 addition & 0 deletions Soundclip.Core/src/main/java/soundclip/core/CueList.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package soundclip.core;

import soundclip.core.cues.ICue;
import soundclip.core.interop.Signal;

import java.util.*;
Expand Down
24 changes: 19 additions & 5 deletions Soundclip.Core/src/main/java/soundclip/core/CueSupportFlags.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,34 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package soundclip.core;

import soundclip.core.cues.ICue;

/**
* Various flags to detect what features that different cue implementations support
*/
public abstract class CueSupportFlags
public final class CueSupportFlags
{

/** Indicates that the cue implementation supports pausing and resuming */
public static final int RESUME = 0b001;
public static final int RESUME = 0b0000001;
/** Indicates that the cue implementation supports fading in */
public static final int FADE_IN = 0b010;
public static final int FADE_IN = 0b0000010;
/** Indicates that the cue implementation supports fading out */
public static final int FADE_OUT = 0b100;
public static final int FADE_OUT = 0b0000100;
/** Indicates that the cue implementation supports fading in both directions */
public static final int FADE = FADE_IN | FADE_OUT;
public static final int FADE = FADE_IN | FADE_OUT;
/** Indicates that the cue implementation supports seeking relative to the current playhead position */
public static final int SEEK_RELATIVE = 0b0001000;
/** Indicates that the cue implementation supports seeking directly to a certain offset */
public static final int SEEK_ABSOLUTE = 0b0010000;
/** Indicates that the cue implementation supports both relative and absolute seeking */
public static final int SEEK = SEEK_RELATIVE | SEEK_ABSOLUTE;
/** Indicates that the cue implementation supports adjusting the pitch */
public static final int AUDIO_PITCH = 0b0100000;
/** Indicates that the cue implementation supports adjusting the L/R pan */
public static final int AUDIO_PAN = 0b1000000;

private CueSupportFlags() { throw new AssertionError("Don't do this"); }

/**
* Determines if the specified feature is supported by the implementation of the specified cue
Expand Down
25 changes: 0 additions & 25 deletions Soundclip.Core/src/main/java/soundclip/core/ICue.java

This file was deleted.

8 changes: 4 additions & 4 deletions Soundclip.Core/src/main/java/soundclip/core/Project.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import soundclip.core.interop.Signal;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.LinkedList;
Expand All @@ -31,8 +32,7 @@ public class Project implements Iterable<CueList>
private String name;
private Date lastModified;

// TODO: Create a way to re-order this. The underlying data structure may need to change
private final LinkedList<CueList> cueLists;
private final ArrayList<CueList> cueLists;

/** A signal triggered when a cue list is added */
public final Signal<CueList> onCueListAdded = new Signal<>();
Expand All @@ -47,7 +47,7 @@ public Project()
projectPath = null;
name = "Untitled Project";
lastModified = null;
cueLists = new LinkedList<>();
cueLists = new ArrayList<>();
}

/**
Expand All @@ -68,7 +68,7 @@ public CueList appendCueList(String name)
{
CueList c = new CueList(name);

cueLists.addLast(c);
cueLists.add(c);
onCueListAdded.post(c);

return c;
Expand Down
50 changes: 50 additions & 0 deletions Soundclip.Core/src/main/java/soundclip/core/cues/ICue.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package soundclip.core.cues;

import soundclip.core.CueNumber;
import soundclip.core.CueSupportFlags;

import java.time.Duration;
import java.util.List;

/**
* The basic cue interface
*/
public interface ICue
{
/** @return the number of the cue */
CueNumber getNumber();
/** Set the number of the cue */
void setNumber(CueNumber number);

/** @return the name of the cue */
String getName();
/** Set the name of the cue */
void setName(String name);

/** @return the notes associated with the cue */
String getNotes();
/** Sets the notes for the cue */
void setNotes(String notes);

/** @return the duration of the cue */
Duration getDuration();

/** @return the features supported by the cue. One or more of {@link CueSupportFlags} */
int getSupportedOperations();

/** @return A list of validation problems with the cue. Return an empty list if there are none */
List<String> getValidationErrors();

/** Triggers the main action of the cue */
void go();

/** Pauses the cue. Stops the cue instead if the implementation does not support resuming */
void pause();

/** Resume the cue from where it was paused */
void resume();

/** Stops the cue and resets the playback state */
void stop();

}
44 changes: 44 additions & 0 deletions Soundclip.Core/src/main/java/soundclip/core/cues/IFadeableCue.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package soundclip.core.cues;

import java.time.Duration;

/**
* A cue that can fade in or out (or both).
*
* Ensure that {@link #getSupportedOperations()} has one (or both) of the following flags set:
* <ul>
* <li>{@link soundclip.core.CueSupportFlags#FADE_IN}</li>
* <li>{@link soundclip.core.CueSupportFlags#FADE_OUT}</li>
* </ul>
*
* Note you can also specify {@link soundclip.core.CueSupportFlags#FADE} if the implementation
* supports both fading in and fading out.
*/
public interface IFadeableCue extends ICue
{
/** @return the duration to fade in over when {@link #fadeIn()} is called */
Duration getFadeInDuration();

/**
* Set the duration to fade in over when {@link #fadeIn()} is called
*
* @param duration the duration to fade in over
*/
void setFadeInDuration(Duration duration);

/** @return the duration to fade out over when {@link #fadeOut()} is called */
Duration getFadeOutDuration();

/**
* Set the duration to fade out over when {@link #fadeOut()} is called
*
* @param duration the duration to fade out over
*/
void setFadeOutDuration(Duration duration);

/** Triggers the cue from the start with a gradual fade-in over {@link #getFadeInDuration()} */
void fadeIn();

/** If the cue is currently playing, fade it out over {@link #getFadeOutDuration()} */
void fadeOut();
}
32 changes: 32 additions & 0 deletions Soundclip.Core/src/main/java/soundclip/core/cues/ISeekableCue.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package soundclip.core.cues;

import java.time.Duration;

/**
* A cue that can seek the playhead to a different location
*
* Ensure that {@link #getSupportedOperations()} has one (or both) of the following flags set:
* <ul>
* <li>{@link soundclip.core.CueSupportFlags#SEEK_ABSOLUTE}</li>
* <li>{@link soundclip.core.CueSupportFlags#SEEK_RELATIVE}</li>
* </ul>
*
* Note you can also specify {@link soundclip.core.CueSupportFlags#SEEK} if the implementation
* supports both relative and absolute seeks.
*/
public interface ISeekableCue extends ICue
{
/**
* Seek the playhead by the specified offset
*
* @param offset the offset to seek by
*/
void seekRelative(Duration offset);

/**
* Seek the playhead to the specified offset
*
* @param duration the offset to seek to
*/
void seekAbsolute(Duration duration);
}
Loading

0 comments on commit b15709b

Please sign in to comment.