danger.audio
Class Sound

java.lang.Object
  |
  +--danger.audio.Sound

public abstract class Sound
extends java.lang.Object


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.
static int SAMPLE_RATE_11K
           
static int SAMPLE_RATE_22K
           
static int SAMPLE_RATE_44K
           
static int SAMPLE_RATE_8K
          common sample rates
 
Constructor Summary
Sound()
           
 
Method Summary
abstract  void destroy()
          method to clean up memory
abstract  void fadeFromToInTime(int sourceVolume, int destVolume, int timeInMiliseconds)
          fade from source volume, to dest volume in time miliseconds.
abstract  int getPlaybackLength()
          get playback length
abstract  int getPlaybackPosition()
          Get the position in samples
abstract  int getPriority()
          Get sound priority level.
abstract  int getRate()
           
abstract  int getSampleEndLoopPoint()
           
abstract  int getSampleStartLoopPoint()
          Get the current loop points in sample frames
abstract  int getUniqueID()
          return runtime ID.
abstract  int getVolume()
           
abstract  int getVolumeClass()
           
abstract  boolean isDone()
          Returns true if done playing
abstract  boolean isLoaded()
          is sound loaded
abstract  boolean isPaused()
          pause, resume and test sound object
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, int length)
          pass in data formatted as a AIF, WAV, or au 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)
           
abstract  void pause()
           
static Sound play(byte[] data)
          method to load a sound file from a byte stream, start it playing, and auto delete it when done playing.
static Sound play(int resourceID)
          method to load a sound file from a resource, start it playing, and auto delete it when done playing.
abstract  void resume()
           
abstract  void setBuzzFlash(boolean buzzOn, boolean flashOn)
          Set auto generate buzz/flash on or off
abstract  void setPlaybackPosition(int sampleFrame)
          Set the position in samples
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.
abstract  void setVolume(int volume)
          get/set playback volume of object.
abstract  void setVolumeClass(int volumeClass)
           
 boolean start()
          start sound playing, will return false if failed to start
abstract  boolean start(int startOffset)
          start sound playing.
 boolean start(int startOffset, int filter)
          start a sound playing, but filter content types from ToneFilter.
abstract  void stop()
          stop this sound
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MIN_SAMPLE_RATE

public static final int MIN_SAMPLE_RATE
min sample rate. 1 kHz

MAX_SAMPLE_RATE

public static final int MAX_SAMPLE_RATE
max sample rate 48 kHz

SAMPLE_RATE_8K

public static final int SAMPLE_RATE_8K
common sample rates

SAMPLE_RATE_11K

public static final int SAMPLE_RATE_11K

SAMPLE_RATE_22K

public static final int SAMPLE_RATE_22K

SAMPLE_RATE_44K

public static final int SAMPLE_RATE_44K

MIN_LOOP_SIZE

public static final int MIN_LOOP_SIZE
min number of loop samples that can be processed
Constructor Detail

Sound

public Sound()
Method Detail

play

public static Sound play(byte[] data)
method to load a sound file from a byte stream, start it playing, and auto delete it when done playing.

play

public static Sound play(int resourceID)
method to load a sound file from a resource, start it playing, and auto delete it when done playing.

destroy

public abstract void destroy()
method to clean up memory

getUniqueID

public abstract int getUniqueID()
return runtime ID. Unique every time object is started

loadFromFile

public abstract boolean loadFromFile(byte[] data,
                                     int length)
pass in data formatted as a AIF, WAV, or au file. Will return false if failed to parse.

loadFromResource

public boolean loadFromResource(int id)
pass and ID, and read data from the application resource file. Parsed data is a WAV, AIF, or au data. Will return false if failed to parse.

loadFromResource

public boolean loadFromResource(int id,
                                Application app)

loadFromFrequency

public abstract boolean loadFromFrequency(int frequency,
                                          int lengthInMS,
                                          int channels,
                                          int rate)
load a sample by creating a sine wave using a particular frequency. Only creates 16 bit data.

loadFromCustom8bit

public abstract boolean loadFromCustom8bit(byte[] data,
                                           int channels,
                                           int rate,
                                           int loopStart,
                                           int loopEnd)
load a sample from a raw pointer. This will make a copy of the passed data, so you can dispose of your origial pointer once this has been called. Returns true for success Use this function for 8 bit signed data. Length is assumed from object data

loadFromCustom16bit

public abstract boolean loadFromCustom16bit(short[] data,
                                            int channels,
                                            int rate,
                                            int loopStart,
                                            int loopEnd)
load a sample from a raw pointer. This will make a copy of the passed data, so you can dispose of your origial pointer once this has been called. Returns true for success Use this function for 16 bit signed data. Length is assumed from object data

setSampleLoopPoints

public abstract boolean setSampleLoopPoints(int start,
                                            int end)
set the loop points in sample frames. Pass in start==end to remove the loop point.

getSampleStartLoopPoint

public abstract int getSampleStartLoopPoint()
Get the current loop points in sample frames

getSampleEndLoopPoint

public abstract int getSampleEndLoopPoint()

setRouteBus

public abstract void setRouteBus(int routeBus)

setVolumeClass

public abstract void setVolumeClass(int volumeClass)

getVolumeClass

public abstract int getVolumeClass()

setVolume

public abstract void setVolume(int volume)
get/set playback volume of object. 100 is 100% is normal. You can overdrive.

getVolume

public abstract int getVolume()

setPriority

public abstract void setPriority(int priority)
Set sound priority level. Higher values will allow for better voice stealing.

getPriority

public abstract int getPriority()
Get sound priority level. Higher values will allow for better voice stealing.

getPlaybackLength

public abstract int getPlaybackLength()
get playback length

getPlaybackPosition

public abstract int getPlaybackPosition()
Get the position in samples

setPlaybackPosition

public abstract void setPlaybackPosition(int sampleFrame)
Set the position in samples

isDone

public abstract boolean isDone()
Returns true if done playing

setRate

public abstract void setRate(int newRate)
get/set the sample rate of an object

getRate

public abstract int getRate()

start

public boolean start()
start sound playing, will return false if failed to start

start

public abstract boolean start(int startOffset)
start sound playing. Pass in a frame offset to start from other than the begining

start

public boolean start(int startOffset,
                     int filter)
start a sound playing, but filter content types from ToneFilter.

stop

public abstract void stop()
stop this sound

setBuzzFlash

public abstract void setBuzzFlash(boolean buzzOn,
                                  boolean flashOn)
Set auto generate buzz/flash on or off

fadeFromToInTime

public abstract void fadeFromToInTime(int sourceVolume,
                                      int destVolume,
                                      int timeInMiliseconds)
fade from source volume, to dest volume in time miliseconds. Always async

isLoaded

public abstract boolean isLoaded()
is sound loaded

isPaused

public abstract boolean isPaused()
pause, resume and test sound object

pause

public abstract void pause()

resume

public abstract void resume()


Danger Confidential. Copyright © 2000-2003, Danger Inc.