Package SoundRecorder
Interface RecorderStorage
- All Known Implementing Classes:
PamAudioFileStorage
,WavFileStorage
public interface RecorderStorage
Writes audio data into a file.
The PamRecorder process blocks the data from multiple channels and sends it to PamAudioFileStorage as an array of double arrays.
- Author:
- Doug Gillespie
-
Method Summary
Modifier and TypeMethodDescriptionboolean
addData
(long dataTimeMillis, double[][] newData) Adds data to the store.boolean
Closes the storage (and stops recording).long
Get the number of frames in the current file.long
Get the file length in millisecondsGets the store file name.long
Get the file size in bytes/ Note that this is the physical size of the file which may not relate to the file length if a compressed recording system is used.long
Get the time the current file started at.long
Get the absolute maximum file size in bytes for this type of storageboolean
openStorage
(AudioFileFormat.Type fileType, long recordingStart, float sampleRate, int nChannels, int bitDepth) Open audio file storageboolean
reOpenStorage
(long recordingStart) Reopens the recording storage in a new file (if appropriate) This is done in the RecorderStorage class rather than as separate calls to closeStorage and openStorage in
-
Method Details
-
openStorage
boolean openStorage(AudioFileFormat.Type fileType, long recordingStart, float sampleRate, int nChannels, int bitDepth) Open audio file storage- Parameters:
fileType
- Type of file storage (e.g. AU, AIFF, WAVE)recordingStart
- Start time of recording in milliseconds. The storage system should base a file name on the timesampleRate
- Sample rate for the recordingnChannels
- Number of channels in the recordingbitDepth
- Number of bits (e.g. 8, 16, 24)- Returns:
- true if OK
-
reOpenStorage
boolean reOpenStorage(long recordingStart) Reopens the recording storage in a new file (if appropriate) This is done in the RecorderStorage class rather than as separate calls to closeStorage and openStorage in- Parameters:
recordingStart
- new recording start time in milliseconds- Returns:
- true if OK/
-
addData
boolean addData(long dataTimeMillis, double[][] newData) Adds data to the store. Data are in a double array newData[channels][samples]. The number of channels must match the number of channels in the call to openStorage and the number of samples must be the same for all channels.- Parameters:
dataTimeMillis
- the time of the datanewData
- array of arrays of double data arranged by channel and sample- Returns:
- true if OK.
-
closeStorage
boolean closeStorage()Closes the storage (and stops recording). The input and output data streams are flushed and closed. This automatically causes the write thread to terminate.- Returns:
- true if OK
-
getFileName
String getFileName()Gets the store file name. The file name must be set to null when the file is closed.- Returns:
- file name (or name of other store type)
-
getFileSizeBytes
long getFileSizeBytes()Get the file size in bytes/ Note that this is the physical size of the file which may not relate to the file length if a compressed recording system is used.- Returns:
- file size in bytes
-
getFileFrames
long getFileFrames()Get the number of frames in the current file.- Returns:
- the number of frames in the current file.
-
getFileMilliSeconds
long getFileMilliSeconds()Get the file length in milliseconds- Returns:
- the file length in milliseconds.
-
getFileStartTime
long getFileStartTime()Get the time the current file started at.- Returns:
- time file started at or -1 if no current file.
-
getMaxFileSizeBytes
long getMaxFileSizeBytes()Get the absolute maximum file size in bytes for this type of storage- Returns:
- Maximum size. Return Long.MAX_VALUE if it's indefinite.
-