-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
abd7b0b
commit 243cdb0
Showing
19 changed files
with
359 additions
and
26 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
src/main/java/com/jblend/media/smaf/phrase/AudioPhrase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.jblend.media.smaf.phrase; | ||
|
||
public class AudioPhrase extends PhraseBase { | ||
public AudioPhrase(byte[] data) { | ||
super(data); | ||
} | ||
|
||
public AudioPhrase(String url) { | ||
super(url); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/com/jblend/media/smaf/phrase/AudioPhraseTrack.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.jblend.media.smaf.phrase; | ||
|
||
public class AudioPhraseTrack extends PhraseTrackBase { | ||
private AudioPhrase phrase; | ||
|
||
public AudioPhraseTrack(int id) { | ||
super(id); | ||
} | ||
|
||
public void setPhrase(AudioPhrase p) { | ||
phrase = p; | ||
} | ||
|
||
public AudioPhrase getPhrase() { | ||
return phrase; | ||
} | ||
|
||
public void removePhrase() { | ||
phrase = null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.jblend.media.smaf.phrase; | ||
|
||
public class Phrase extends PhraseBase { | ||
public Phrase(byte[] data) { | ||
super(data); | ||
} | ||
|
||
public Phrase(String url) { | ||
super(url); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/com/jblend/media/smaf/phrase/PhraseBase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.jblend.media.smaf.phrase; | ||
|
||
public abstract class PhraseBase { | ||
public PhraseBase(byte[] data) { | ||
|
||
} | ||
|
||
public PhraseBase(String url) { | ||
|
||
} | ||
|
||
public int getSize() { | ||
return 0; | ||
} | ||
|
||
public int getUseTracks() { | ||
return 1; | ||
} | ||
} |
87 changes: 87 additions & 0 deletions
87
src/main/java/com/jblend/media/smaf/phrase/PhrasePlayer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package com.jblend.media.smaf.phrase; | ||
|
||
public class PhrasePlayer { | ||
private static final PhrasePlayer instance = new PhrasePlayer(); | ||
|
||
private static final int NUM_TRACKS = 8; | ||
private static final int NUM_AUDIO_TRACKS = 8; | ||
|
||
private static final PhraseTrack[] tracks = new PhraseTrack[NUM_TRACKS]; | ||
private static final AudioPhraseTrack[] audioTracks = new AudioPhraseTrack[NUM_AUDIO_TRACKS]; | ||
|
||
static { | ||
for (int i = 0; i < NUM_TRACKS; i++) { | ||
tracks[i] = new PhraseTrack(i); | ||
} | ||
for (int i = 0; i < NUM_AUDIO_TRACKS; i++) { | ||
audioTracks[i] = new AudioPhraseTrack(i); | ||
} | ||
} | ||
|
||
public static PhrasePlayer getPlayer() { | ||
return instance; | ||
} | ||
|
||
public void disposePlayer() { | ||
kill(); | ||
} | ||
|
||
public PhraseTrack getTrack() { | ||
for (int i = NUM_TRACKS - 1; i >= 0; i--) { | ||
if (tracks[i].isClaimed()) continue; | ||
return getTrack(i); | ||
} | ||
throw new IllegalStateException("no free tracks"); | ||
} | ||
|
||
public AudioPhraseTrack getAudioTrack() { | ||
for (int i = NUM_AUDIO_TRACKS - 1; i >= 0; i--) { | ||
if (audioTracks[i].isClaimed()) continue; | ||
return getAudioTrack(i); | ||
} | ||
throw new IllegalStateException("no free audio tracks"); | ||
} | ||
|
||
public int getTrackCount() { | ||
return NUM_TRACKS; | ||
} | ||
|
||
public int getAudioTrackCount() { | ||
return NUM_AUDIO_TRACKS; | ||
} | ||
|
||
public PhraseTrack getTrack(int i) { | ||
PhraseTrack track = tracks[i]; | ||
track.setClaimed(true); | ||
return track; | ||
} | ||
|
||
public AudioPhraseTrack getAudioTrack(int i) { | ||
AudioPhraseTrack audioTrack = audioTracks[i]; | ||
audioTrack.setClaimed(true); | ||
return audioTrack; | ||
} | ||
|
||
public void disposeTrack(PhraseTrack t) { | ||
t.setClaimed(false); | ||
} | ||
|
||
public void disposeAudioTrack(AudioPhraseTrack t) { | ||
t.setClaimed(false); | ||
} | ||
|
||
public void kill() { | ||
pause(); | ||
for (int i = 0; i < NUM_TRACKS; i++) { | ||
tracks[i].setClaimed(false); | ||
} | ||
} | ||
|
||
public void pause() { | ||
|
||
} | ||
|
||
public void resume() { | ||
|
||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/main/java/com/jblend/media/smaf/phrase/PhraseTrack.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.jblend.media.smaf.phrase; | ||
|
||
public class PhraseTrack extends PhraseTrackBase { | ||
private PhraseTrack syncMaster; | ||
private Phrase phrase; | ||
|
||
public PhraseTrack(int id) { | ||
super(id); | ||
} | ||
|
||
public void setPhrase(Phrase p) { | ||
phrase = p; | ||
} | ||
|
||
public Phrase getPhrase() { | ||
return phrase; | ||
} | ||
|
||
public void removePhrase() { | ||
phrase = null; | ||
} | ||
|
||
public void setSubjectTo(PhraseTrack master) { | ||
syncMaster = master; | ||
} | ||
|
||
public PhraseTrack getSyncMaster() { | ||
return syncMaster; | ||
} | ||
} |
78 changes: 78 additions & 0 deletions
78
src/main/java/com/jblend/media/smaf/phrase/PhraseTrackBase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package com.jblend.media.smaf.phrase; | ||
|
||
public class PhraseTrackBase { | ||
private final int id; | ||
private boolean isClaimed = false; | ||
|
||
private int volume = 127; | ||
private int panpot = 64; | ||
private boolean mute = false; | ||
|
||
public PhraseTrackBase(int id) { | ||
this.id = id; | ||
} | ||
|
||
public int getID() { | ||
return id; | ||
} | ||
|
||
public void setClaimed(boolean value) { | ||
isClaimed = value; | ||
} | ||
|
||
public boolean isClaimed() { | ||
return isClaimed; | ||
} | ||
|
||
public void play() { | ||
|
||
} | ||
|
||
public void play(int loop) { | ||
|
||
} | ||
|
||
public void stop() { | ||
|
||
} | ||
|
||
public void pause() { | ||
|
||
} | ||
|
||
public void resume() { | ||
|
||
} | ||
|
||
public int getState() { | ||
throw new UnsupportedOperationException("Not supported yet."); | ||
} | ||
|
||
public void setVolume(int value) { | ||
volume = value; | ||
} | ||
|
||
public int getVolume() { | ||
return volume; | ||
} | ||
|
||
public void setPanpot(int value) { | ||
panpot = value; | ||
} | ||
|
||
public int getPanpot() { | ||
return panpot; | ||
} | ||
|
||
public void mute(boolean mute) { | ||
this.mute = mute; | ||
} | ||
|
||
public boolean isMute() { | ||
return mute; | ||
} | ||
|
||
public void setEventListener(PhraseTrackListener l) { | ||
|
||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
src/main/java/com/jblend/media/smaf/phrase/PhraseTrackListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.jblend.media.smaf.phrase; | ||
|
||
public interface PhraseTrackListener { | ||
void eventOccurred(int event); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.