|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectdanger.audio.Sound
public abstract class Sound
| Field Summary | |
|---|---|
static int |
MAX_SAMPLE_RATE
max sample rate = 48 kHz |
static int |
MIN_LOOP_SIZE
min number of loop samples that can be processed |
static int |
MIN_SAMPLE_RATE
min sample rate = 1 kHz |
static int |
SAMPLE_RATE_11K
|
static int |
SAMPLE_RATE_22K
|
static int |
SAMPLE_RATE_44K
|
static int |
SAMPLE_RATE_8K
common sample rates |
| Fields inherited from interface danger.media.PlayableMedia |
|---|
DEFAULT_PRIORITY, PRIORITY_1, PRIORITY_2, PRIORITY_3, PRIORITY_4, PRIORITY_5 |
| Constructor Summary | |
|---|---|
Sound()
|
|
| Method Summary | |
|---|---|
void |
destroy()
free internal resources for this object |
abstract void |
fadeFromToInTime(int sourceVolume,
int destVolume,
int timeInMiliseconds)
fade from source volume, to dest volume in time miliseconds. |
int |
framesToMicroseconds(int frames)
Given sample frames, return microseconds. |
int |
getCurrentLoopNumber()
Gets the number of times the looped media has looped back to the loop start. |
abstract byte[] |
getData()
return audio data formatted as file. |
abstract int |
getLoopCount()
Gets the loop count; which is the total number of times an object is played. |
abstract int |
getLoops()
Deprecated. - use getLoopCount() instead. |
int |
getMarkerCount()
Gets the number of markers contained by the currently loaded media. |
int |
getMarkerID(int index)
Return the integer ID associated with the marker at the given index. |
String |
getMarkerName(int index)
Return the name associated with the marker at the given index. |
int |
getMarkerPosition(int index)
Return the position in milliseconds of the marker at the given index. |
int |
getMediaType()
Returns file type of media. |
int |
getMicrosecondLength()
Deprecated. - use getMillisecondLength() instead. |
int |
getMicrosecondPosition()
Deprecated. - use getMillisecondPosition() instead. |
int |
getMillisecondLength()
get length in milliseconds of object |
abstract int |
getMillisecondPosition()
get the current playback position of a sound in milliseconds |
abstract int |
getPlaybackLength()
get playback length in sample frames |
abstract int |
getPlaybackPosition()
Get the position in sample frames |
int |
getPlaybackRate()
Get the playback rate of the media. 100 is default rate. |
abstract int |
getPriority()
Get sound priority level. |
abstract int |
getRate()
|
abstract int |
getSampleEndLoopPoint()
|
abstract int |
getSampleStartLoopPoint()
Get the current loop points in sample frames |
int |
getStereoPosition()
Returns current stereo position. |
int |
getTranspose()
Return tuning in semitones. |
int |
getTuning()
Return tuning in cents (1200 is down an octave, -1200 is up an octave) This interacts with PlayableAudio.setTranspose(int) and PlayableAudio.getTranspose() |
int |
getUniqueID()
return runtime ID. |
abstract int |
getVolume()
Returns current volume in percent. |
int |
getVolumeClass()
Get the current volume class. |
abstract boolean |
isDone()
Returns true if done playing |
abstract boolean |
isLoaded()
is sound loaded |
boolean |
isLoopingEnabled()
Return whether looping is enabled (set by a call to PlayableMedia.setLoopingEnabled(boolean)). |
boolean |
isMuted()
Return true if the audio is muted |
abstract boolean |
isPaused()
pause, resume and test sound object |
boolean |
isPlaying()
Returns true if object is playing. |
static Sound |
load(byte[] data)
Given an array of bytes, try and load a Sound (Can be a WAV, AIF file) Will return null if data is invalid. |
static Sound |
load(byte[] data,
boolean autoDelete)
Given an array of bytes, try and load a Sound (Can be a WAV, AIF file) Will return null if data is invalid. |
static Sound |
load(File f)
Given a sound file, try and load it (Can be WAV, AIF, MP3) Will return null if file data is invalid. |
static Sound |
load(File f,
boolean autoDelete)
Given a sound file, try and load it (Can be WAV, AIF, MP3) Will return null if file data is invalid. |
static Sound |
load(int resourceID)
Given an reousrce ID, try and load a Sound (Can be a WAV, AIF file) Will return null if data is invalid. |
static Sound |
load(int resourceID,
boolean autoDelete)
Given an reousrce ID, try and load a Sound (Can be a WAV, AIF file) Will return null if data is invalid. |
abstract boolean |
loadFromCustom16bit(short[] data,
int channels,
int rate,
int loopStart,
int loopEnd)
load a sample from a raw pointer. |
abstract boolean |
loadFromCustom8bit(byte[] data,
int channels,
int rate,
int loopStart,
int loopEnd)
load a sample from a raw pointer. |
abstract boolean |
loadFromFile(byte[] data)
Pass in data formatted as a AIF, WAV file. |
abstract boolean |
loadFromFrequency(int frequency,
int lengthInMS,
int channels,
int rate)
load a sample by creating a sine wave using a particular frequency. |
boolean |
loadFromResource(int id)
pass and ID, and read data from the application resource file. |
boolean |
loadFromResource(int id,
Application app)
|
int |
microsecondsToFrames(int micros)
Given microseconds, return sample frames. |
abstract void |
pause()
Will pause object |
void |
play()
Given a sound, start it playing, and auto delete it when done playing. |
static Sound |
play(byte[] data)
Given an array of bytes load a sound file, start it playing, and auto delete it when done playing. |
static Sound |
play(byte[] data,
boolean autoDelete)
Given an array of bytes load a sound file, start it playing, and auto delete it when done playing if requested. |
static Sound |
play(File f)
Given a sound file, start it playing, and auto delete it when done playing. |
static Sound |
play(File f,
boolean autoDelete)
Given a sound file, start it playing, and auto delete it when done playing if requested. |
static Sound |
play(int resourceID)
method to load a sound file from a resource, start it playing, and auto delete it when done playing. |
static Sound |
play(int resourceID,
int filter)
method to load a sound file from a resource, start it playing, and auto delete it when done playing. |
abstract void |
resume()
Will resume object if paused. |
abstract void |
setBuzzFlash(boolean buzzOn,
boolean flashOn)
Set auto generate buzz/flash on or off |
abstract void |
setBuzzFlashEnable(boolean buzzOn,
boolean flashOn)
Set buzz/flash enable or off. |
void |
setDoneCallbackEvent(Event done)
Set the event that is called when this media is finished. |
void |
setDoneCallbackEvent(Event done,
boolean doEventOnce)
Set the event that is called when this media is finished. |
abstract void |
setLoopCount(int loopCount)
Sets the loop count; which is the total number of times an object is played. |
void |
setLoopingEnabled(boolean on)
Enable looping. |
abstract void |
setLoops(int loops)
Deprecated. - use setLoopCount(int) instead. |
void |
setMicrosecondPosition(int ticks)
Deprecated. - use setMillisecondPosition(int) instead. |
abstract void |
setMillisecondPosition(int pos)
set the current playback position of sound in milliseconds |
void |
setMute(boolean mute)
Mute or unmute the audio. |
abstract void |
setPlaybackPosition(int sampleFrame)
Set the position in sample frames |
void |
setPlaybackRate(int newRate)
Set the playback rate of the media. |
void |
setPositionCallbackEvent(Event event,
int position)
Set an event that is called when this media reaches the given position during playback. |
void |
setPositionToMarker(int markerID)
Set the media playback position to the position associated with the marker with the given markerID |
abstract void |
setPriority(int priority)
Set sound priority level. |
abstract void |
setRate(int newRate)
get/set the sample rate of an object |
abstract void |
setRouteBus(int routeBus)
|
abstract boolean |
setSampleLoopPoints(int start,
int end)
set the loop points in sample frames. |
void |
setStereoPosition(int position)
Set the stereo position of sound. |
void |
setStoppedCallbackEvent(Event stopped)
Set the event that is called when this media is stopped by stop(). |
void |
setStoppedCallbackEvent(Event stopped,
boolean doEventOnce)
Set the event that is called when this media is stopped by stop(). |
void |
setTranspose(int semitones)
Set tuning in semitones. |
void |
setTuning(int cents)
Set tuning in cents (1200 is down an octave, -1200 is up an octave) This interacts with PlayableAudio.setTranspose(int) and PlayableAudio.getTranspose() |
abstract void |
setVolume(int volume)
get/set playback volume of object. |
void |
setVolumeClass(int volumeClass)
Set the volume class. |
boolean |
start()
start sound playing, will return false if failed to start |
boolean |
start(int sampleFrameStart)
start sound playing. |
boolean |
start(int sampleFrameStart,
int filter)
start a sound playing, but filter content types from ToneFilter. |
boolean |
startAtOffset(int startOffset)
|
boolean |
startDefault()
Start Sound with defaults Returns true if started NOTE: This is the same as start(). |
void |
startPlaying()
Start media playback with default attributes. |
void |
startPlaying(int attributes)
Start media playback with specified attributes. |
boolean |
startWithFilter(int filter)
Start Sound with a filter Returns true if started NOTE: This is implemented in Playable OS 2.3 |
void |
stop()
Will stop the object and reset to begining |
void |
stopPlaying()
Stop media playback |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int MIN_SAMPLE_RATE
public static final int MAX_SAMPLE_RATE
public static final int SAMPLE_RATE_8K
public static final int SAMPLE_RATE_11K
public static final int SAMPLE_RATE_22K
public static final int SAMPLE_RATE_44K
public static final int MIN_LOOP_SIZE
| Constructor Detail |
|---|
public Sound()
| Method Detail |
|---|
public void destroy()
destroy in interface Playabledestroy in interface PlayableMedia
public static Sound load(byte[] data,
boolean autoDelete)
public static Sound load(byte[] data)
public static Sound play(byte[] data,
boolean autoDelete)
public static Sound play(byte[] data)
public static Sound load(int resourceID,
boolean autoDelete)
public static Sound load(int resourceID)
public static Sound play(int resourceID)
public static Sound play(int resourceID,
int filter)
public static Sound load(File f,
boolean autoDelete)
public static Sound load(File f)
public static Sound play(File f,
boolean autoDelete)
public static Sound play(File f)
public void play()
public abstract byte[] getData()
public abstract boolean loadFromFile(byte[] data)
public boolean loadFromResource(int id)
public boolean loadFromResource(int id,
Application app)
public abstract boolean loadFromFrequency(int frequency,
int lengthInMS,
int channels,
int rate)
public abstract boolean loadFromCustom8bit(byte[] data,
int channels,
int rate,
int loopStart,
int loopEnd)
public abstract boolean loadFromCustom16bit(short[] data,
int channels,
int rate,
int loopStart,
int loopEnd)
public abstract boolean setSampleLoopPoints(int start,
int end)
public abstract int getSampleStartLoopPoint()
public abstract int getSampleEndLoopPoint()
public abstract void setRouteBus(int routeBus)
public abstract void setVolume(int volume)
public abstract int getVolume()
Playable
public abstract void setPriority(int priority)
priority - - priority level for mediapublic abstract int getPriority()
public abstract int getPlaybackLength()
public abstract int getPlaybackPosition()
public abstract void setPlaybackPosition(int sampleFrame)
public abstract void setMillisecondPosition(int pos)
pos - - position in media to seek topublic abstract int getMillisecondPosition()
public int getMicrosecondLength()
getMillisecondLength() instead.
Playable
public void setMicrosecondPosition(int ticks)
setMillisecondPosition(int) instead.
Playable
public int getMicrosecondPosition()
getMillisecondPosition() instead.
Playable
public int microsecondsToFrames(int micros)
public int framesToMicroseconds(int frames)
public int getMillisecondLength()
public abstract boolean isDone()
public abstract void setLoops(int loops)
setLoopCount(int) instead.
public abstract int getLoops()
getLoopCount() instead.
public abstract void setLoopCount(int loopCount)
loopCount - - total number of times to play; 0 means loop forever.public abstract int getLoopCount()
public abstract void setRate(int newRate)
public abstract int getRate()
public boolean startWithFilter(int filter)
public boolean startDefault()
public boolean start()
public boolean start(int sampleFrameStart)
public boolean start(int sampleFrameStart,
int filter)
public abstract void setBuzzFlashEnable(boolean buzzOn,
boolean flashOn)
public abstract void setBuzzFlash(boolean buzzOn,
boolean flashOn)
public abstract void fadeFromToInTime(int sourceVolume,
int destVolume,
int timeInMiliseconds)
public abstract boolean isLoaded()
public abstract boolean isPaused()
public abstract void pause()
Playable
public abstract void resume()
Playable
public int getUniqueID()
Playable
getUniqueID in interface PlayablegetUniqueID in interface PlayableMediapublic int getMediaType()
PlayableMedia
getMediaType in interface PlayableMediapublic void setVolumeClass(int volumeClass)
PlayableAudio
setVolumeClass in interface PlayableAudiopublic int getVolumeClass()
PlayableAudio
getVolumeClass in interface PlayableAudiopublic void setLoopingEnabled(boolean on)
PlayableMediaPlayableMedia.setLoopCount(int) or is 0 (loop forever) by default.
setLoopingEnabled in interface PlayableMediaon - - enable or disable looping.public boolean isLoopingEnabled()
PlayableMediaPlayableMedia.setLoopingEnabled(boolean)).
isLoopingEnabled in interface PlayableMediapublic int getCurrentLoopNumber()
PlayableMedia
getCurrentLoopNumber in interface PlayableMediapublic int getMarkerCount()
PlayableMedia
getMarkerCount in interface PlayableMediapublic int getMarkerID(int index)
PlayableMedia
getMarkerID in interface PlayableMediapublic String getMarkerName(int index)
PlayableMedia
getMarkerName in interface PlayableMediapublic int getMarkerPosition(int index)
PlayableMedia
getMarkerPosition in interface PlayableMediapublic void setPositionToMarker(int markerID)
PlayableMedia
setPositionToMarker in interface PlayableMediamarkerID - - integer ID of the marker (retrieved via PlayableMedia.getMarkerID(int))public void setStereoPosition(int position)
PlayableAudio
setStereoPosition in interface PlayableAudiopublic int getStereoPosition()
PlayableAudio
getStereoPosition in interface PlayableAudiopublic void setMute(boolean mute)
PlayableAudio
setMute in interface PlayableAudiopublic boolean isMuted()
PlayableAudio
isMuted in interface PlayableAudiopublic void startPlaying()
PlayableMedia
startPlaying in interface PlayableMediapublic void startPlaying(int attributes)
PlayableMedia
startPlaying in interface PlayableMediaattributes - - class-specific attributes applied to this playbackpublic boolean isPlaying()
PlayableMedia
isPlaying in interface PlayableMediapublic void stopPlaying()
PlayableMedia
stopPlaying in interface PlayableMediapublic void setPlaybackRate(int newRate)
PlayableMedia
setPlaybackRate in interface PlayableMedianewRate - - new playback rate; 100 is default rate.public int getPlaybackRate()
PlayableMedia
getPlaybackRate in interface PlayableMediapublic void setTranspose(int semitones)
PlayableAudioPlayableAudio.setTuning(int) and PlayableAudio.getTuning()
setTranspose in interface PlayableAudiopublic int getTranspose()
PlayableAudioPlayableAudio.setTuning(int) has been called, This will truncate actual value to nearest 100 cents
getTranspose in interface PlayableAudiopublic void setTuning(int cents)
PlayableAudioPlayableAudio.setTranspose(int) and PlayableAudio.getTranspose()
setTuning in interface PlayableAudiopublic int getTuning()
PlayableAudioPlayableAudio.setTranspose(int) and PlayableAudio.getTranspose()
getTuning in interface PlayableAudio
public void setPositionCallbackEvent(Event event,
int position)
PlayableMedia
setPositionCallbackEvent in interface PlayableMediaevent - - event to be postedposition - - time in milliseconds at which the event should be postedpublic void setDoneCallbackEvent(Event done)
PlayableMedia
setDoneCallbackEvent in interface PlayableMediadone - - event to be posted
public void setDoneCallbackEvent(Event done,
boolean doEventOnce)
PlayableMedia
setDoneCallbackEvent in interface PlayableMediadone - - event to be posteddoEventOnce - - if true, callback only called once for a given playbackpublic void setStoppedCallbackEvent(Event stopped)
PlayableMedia
setStoppedCallbackEvent in interface PlayableMediastopped - - event to be posted
public void setStoppedCallbackEvent(Event stopped,
boolean doEventOnce)
PlayableMedia
setStoppedCallbackEvent in interface PlayableMediastopped - - event to be posteddoEventOnce - - if true, callback only called once for a given playbackpublic boolean startAtOffset(int startOffset)
public void stop()
Playable
stop in interface Playable
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||