-
public class FileDataLoader
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public enumFileDataLoader.FileType
-
Constructor Summary
Constructors Constructor Description FileDataLoader(Context context, FileDataLoader.FileType fileType, CallConstants.AudioSampleRate sampleRate)Constructs the loader by reading the file asset into memory.
-
Method Summary
-
-
Constructor Detail
-
FileDataLoader
FileDataLoader(Context context, FileDataLoader.FileType fileType, CallConstants.AudioSampleRate sampleRate)
Constructs the loader by reading the file asset into memory.- Parameters:
context- the Android contextfileType- which file type to loadsampleRate- the audio sample rate to choose the correct asset
-
-
Method Detail
-
read
int read(Array<short> buffer, int offset, int length)
Reads a number of samples into the provided short buffer.
The audio file is treated as a circular buffer. When the end is reached, it wraps around.For sample rates that need resampling (24000, 32000), the 8000 Hz data is upscaled using SpeexResampler.
- Parameters:
buffer- the destination array of shortsoffset- the start offset in the destination arraylength- the number of shorts to read
-
close
void close()
Closes the loader and releases resources.
Releases the SpeexResampler if it was initialized.The file data is held in memory so there is no stream to close.
-
-
-
-