danger.audio
Class Recorder

java.lang.Object
  extended by danger.audio.Recorder


public abstract class Recorder
extends Object


Nested Class Summary
static interface Recorder.Errors
          Status values.
 
Field Summary
static int DEFAULT_MAX_RECORD_TIME
          default max recording time.
static boolean NO_TRIM
          Constant used with stop(boolean)
static boolean TRIM
          Constant used with stop(boolean)
 
Constructor Summary
Recorder()
           
 
Method Summary
abstract  void abort()
           
abstract  void destroy()
          Deletes previous recording.
abstract  int getAvailableFileRecordSeconds(String volumePath, int format, int sampleRate, int channels)
          Return the available time in seconds that can be recorded to this volume given these record parameters.
abstract  int getCurrentDuration()
           
abstract  byte[] getData()
          Always return a Format.Type.WAV formatted file
static Recorder getInstance()
          return an instance of the Recorder class.
abstract  int getMaxDuration()
           
abstract  int getRecordMonitorLevel()
           
abstract  boolean isPaused()
           
abstract  boolean isRecording()
           
abstract  void pause()
           
abstract  void resume()
           
abstract  void setMaxDuration(int milliseconds)
           
 int start()
          Start recording audio to memory, formatted as Format.RecordType.WAV at 8 kHz, monaural 16 bit.
 int start(File recordFile)
          Start recording audio to SD card, formatted as Format.RecordType.WAV at 22.05 kHz, monaural 16 bit.
abstract  int start(int format, int sampleRate, int channels)
          Start recording to memory.
abstract  int start(String filePath, int format, int sampleRate, int channels)
          Record to SD card.
 void stop()
           
abstract  void stop(boolean trim)
          Stop recording.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_MAX_RECORD_TIME

public static final int DEFAULT_MAX_RECORD_TIME
default max recording time. This can change based upon carrier configuration.

See Also:
Constant Field Values

TRIM

public static final boolean TRIM
Constant used with stop(boolean)

Since:
4.0
See Also:
Constant Field Values

NO_TRIM

public static final boolean NO_TRIM
Constant used with stop(boolean)

Since:
4.0
See Also:
Constant Field Values
Constructor Detail

Recorder

public Recorder()
Method Detail

destroy

public abstract void destroy()
Deletes previous recording. getData() will return null. Does NOT destroy the Recorder object.


getInstance

public static final Recorder getInstance()
                                  throws AudioException
return an instance of the Recorder class.

Throws:
AudioException - if audio recording is not implemented.
Since:
4.5

start

public int start()
Start recording audio to memory, formatted as Format.RecordType.WAV at 8 kHz, monaural 16 bit. Will destroy the previous recording, if there was one.

Returns:
Recorder.Errors

start

public int start(File recordFile)
Start recording audio to SD card, formatted as Format.RecordType.WAV at 22.05 kHz, monaural 16 bit.

Parameters:
recordFile - Path to output file.
Returns:
Recorder.Errors

start

public abstract int start(int format,
                          int sampleRate,
                          int channels)
Start recording to memory. Will delete the previous recording, if there was one.

Parameters:
format - one of Format.RecordType
sampleRate - between 8000 and 44100
channels - 1 or 2
Returns:
Recorder.Errors

getAvailableFileRecordSeconds

public abstract int getAvailableFileRecordSeconds(String volumePath,
                                                  int format,
                                                  int sampleRate,
                                                  int channels)
Return the available time in seconds that can be recorded to this volume given these record parameters.

Parameters:
volumePath - - volume name including path (i.e. '/volumeName').
format - - record encoding see Format.RecordType.
sampleRate - - must be between 8 kHz and 44.1 kHz.
channels - - currently only 1 is supported.
Returns:
time - in seconds available for recording.
Throws:
IllegalArgumentException - parameter values are invalid.
NullPointerException - if volumePath is null.
Since:
4.0

start

public abstract int start(String filePath,
                          int format,
                          int sampleRate,
                          int channels)
Record to SD card.

Parameters:
filePath - - full path to output file (i.e. '/volumeName/this/here/file').
format - - record encoding see Format.RecordType.
sampleRate - - must be between 8 kHz and 44.1 kHz.
channels - - currently only 1 is supported.
Returns:
- 0 for success, -1 for error.
Throws:
NullPointerException - if filePath is null.
Since:
2.5

stop

public void stop()

stop

public abstract void stop(boolean trim)
Stop recording. This will stop the recording and preserve it. If a physical button was pressed to stop the recording, there may be button noise at the end of the recording, so a trim parameter is provided. This will trim approximately 1/2 to 1 second off the end of the recording.

Parameters:
trim - - whether to trim the end of the recording. Use TRIM or NO_TRIM
Since:
4.0

pause

public abstract void pause()

resume

public abstract void resume()

abort

public abstract void abort()

isRecording

public abstract boolean isRecording()

isPaused

public abstract boolean isPaused()

getRecordMonitorLevel

public abstract int getRecordMonitorLevel()

setMaxDuration

public abstract void setMaxDuration(int milliseconds)

getMaxDuration

public abstract int getMaxDuration()

getCurrentDuration

public abstract int getCurrentDuration()

getData

public abstract byte[] getData()
Always return a Format.Type.WAV formatted file