ccAudio
|
AudioStream accesses AudioFile base class content as fixed frames of streaming linear samples. More...
#include <audio2.h>
Public Member Functions | |
AudioStream () | |
Create a new audiostream object. | |
AudioStream (const char *name, Mode mode=modeRead, timeout_t framing=0) | |
Create an audio stream object and open an existing audio file. | |
AudioStream (const char *name, Info *info, bool exclusive=false, timeout_t framing=0) | |
Create an audio stream object and a new audio file. | |
virtual | ~AudioStream () |
ssize_t | getBuffer (Encoded data, size_t count) |
Virtual for packet i/o intercept. | |
void | open (const char *name, Mode mode=modeRead, timeout_t framing=0) |
Open existing audio file for streaming. | |
void | create (const char *name, Info *info, bool exclusive=false, timeout_t framing=0) |
Create a new audio file for streaming. | |
void | close (void) |
Close the currently open audio file for streaming. | |
void | flush (void) |
flush any unsaved buffered data to disk. | |
bool | isStreamable (void) |
Check if the audio file may be streamed. | |
unsigned | getCount (void) |
Get the number of samples expected in a frame. | |
unsigned | getEncoded (AudioCodec *codec, Encoded address, unsigned frames=1) |
Stream audio data from the file and convert into an alternate encoding based on the codec supplied. | |
unsigned | putEncoded (AudioCodec *codec, Encoded address, unsigned frames=1) |
Stream audio data in an alternate codec into the currently opened file. | |
unsigned | getEncoded (Encoded address, unsigned frames=1) |
Get data from the streamed file in it's native encoding. | |
unsigned | putEncoded (Encoded address, unsigned frames=1) |
Put data encoded in the native format of the stream file. | |
ssize_t | getPacket (Encoded data) |
Get a packet of data from the file. | |
unsigned | getMono (Linear buffer, unsigned frames=1) |
Get and automatically convert audio file data into mono linear audio samples. | |
unsigned | getStereo (Linear buffer, unsigned frames=1) |
Get and automatically convert audio file data into stereo (two channel) linear audio samples. | |
unsigned | putMono (Linear buffer, unsigned frames=1) |
Automatically convert and put mono linear audio data into the audio file. | |
unsigned | putStereo (Linear buffer, unsigned frames=1) |
Automatically convert and put stereo linear audio data into the audio file. | |
unsigned | bufMono (Linear buffer, unsigned count) |
Automatically convert and put arbitrary linear mono data into the audio file. | |
unsigned | bufStereo (Linear buffer, unsigned count) |
Automatically convert and put arbitrary linear stereo data into the audio file. | |
AudioCodec * | getCodec (void) |
Return the codec being used if there is one. | |
Protected Member Functions | |
unsigned | bufAudio (Linear samples, unsigned count, unsigned size) |
Protected Attributes | |
AudioCodec * | codec |
Encoded | framebuf |
bool | streamable |
Linear | bufferFrame |
unsigned | bufferPosition |
unsigned | bufferChannels |
Linear | encBuffer |
Linear | decBuffer |
unsigned | encSize |
unsigned | decSize |
AudioStream accesses AudioFile base class content as fixed frames of streaming linear samples.
If a codec must be assigned to perform conversion to/from linear data, AudioStream will handle conversion automatically. AudioStream will also convert between mono and stereo audio content. AudioStream uses linear samples in the native machine endian format and perform endian byte swapping as needed.
ost::AudioStream::AudioStream | ( | ) |
Create a new audiostream object.
Create an audio stream object and open an existing audio file.
name | of file to open. |
mode | of file access. |
framing | time in milliseconds. |
ost::AudioStream::AudioStream | ( | const char * | name, |
Info * | info, | ||
bool | exclusive = false , |
||
timeout_t | framing = 0 |
||
) |
Create an audio stream object and a new audio file.
name | of file to open. |
info | source description for properties of new file. |
exclusive | access if true. |
framing | time in milliseconds. |
virtual ost::AudioStream::~AudioStream | ( | ) | [virtual] |
unsigned ost::AudioStream::bufAudio | ( | Linear | samples, |
unsigned | count, | ||
unsigned | size | ||
) | [protected] |
unsigned ost::AudioStream::bufMono | ( | Linear | buffer, |
unsigned | count | ||
) |
Automatically convert and put arbitrary linear mono data into the audio file.
Convert to stereo and buffer incomplete frames as needed by the streaming file.
buffer | to save linear audio from. |
count | of linear audio to write. |
unsigned ost::AudioStream::bufStereo | ( | Linear | buffer, |
unsigned | count | ||
) |
Automatically convert and put arbitrary linear stereo data into the audio file.
Convert to mono and buffer incomplete frames as needed by the streaming file.
buffer | to save linear audio from. |
count | of linear audio to write. |
void ost::AudioStream::close | ( | void | ) |
Close the currently open audio file for streaming.
Reimplemented from ost::AudioFile.
void ost::AudioStream::create | ( | const char * | name, |
Info * | info, | ||
bool | exclusive = false , |
||
timeout_t | framing = 0 |
||
) |
Create a new audio file for streaming.
name | of file to create. |
info | source description for file properties. |
exclusive | true for exclusive access. |
framing | timing in milliseconds. |
Reimplemented from ost::AudioFile.
void ost::AudioStream::flush | ( | void | ) |
flush any unsaved buffered data to disk.
ssize_t ost::AudioStream::getBuffer | ( | Encoded | data, |
size_t | count | ||
) | [virtual] |
Virtual for packet i/o intercept.
data | encoding buffer. |
count | requested. |
Reimplemented from ost::AudioFile.
AudioCodec* ost::AudioStream::getCodec | ( | void | ) | [inline] |
unsigned ost::AudioStream::getCount | ( | void | ) |
Get the number of samples expected in a frame.
unsigned ost::AudioStream::getEncoded | ( | AudioCodec * | codec, |
Encoded | address, | ||
unsigned | frames = 1 |
||
) |
Stream audio data from the file and convert into an alternate encoding based on the codec supplied.
codec | to apply before saving. |
address | of data to save. |
frames | to stream by the codec. |
unsigned ost::AudioStream::getEncoded | ( | Encoded | address, |
unsigned | frames = 1 |
||
) |
Get data from the streamed file in it's native encoding.
address | to save encoded audio. |
frames | of audio to load. |
unsigned ost::AudioStream::getMono | ( | Linear | buffer, |
unsigned | frames = 1 |
||
) |
Get and automatically convert audio file data into mono linear audio samples.
buffer | to save linear audio into. |
frames | of audio to read. |
ssize_t ost::AudioStream::getPacket | ( | Encoded | data | ) |
Get a packet of data from the file.
This uses the codec to determine what a true packet boundry is.
buffer | to save encoded data. |
Reimplemented from ost::AudioBase.
unsigned ost::AudioStream::getStereo | ( | Linear | buffer, |
unsigned | frames = 1 |
||
) |
Get and automatically convert audio file data into stereo (two channel) linear audio samples.
buffer | to save linear audio into. |
frames | of audio to read. |
bool ost::AudioStream::isStreamable | ( | void | ) |
Check if the audio file may be streamed.
Files can be streamed if a codec is available or if they are linear.
Open existing audio file for streaming.
name | of file to open. |
mode | to use file. |
framing | timer in milliseconds. |
Reimplemented from ost::AudioFile.
unsigned ost::AudioStream::putEncoded | ( | Encoded | address, |
unsigned | frames = 1 |
||
) |
Put data encoded in the native format of the stream file.
address | to load encoded audio. |
frames | of audio to save. |
unsigned ost::AudioStream::putEncoded | ( | AudioCodec * | codec, |
Encoded | address, | ||
unsigned | frames = 1 |
||
) |
Stream audio data in an alternate codec into the currently opened file.
codec | to convert incoming data from. |
address | of data to convert and stream. |
frames | of audio to stream. |
unsigned ost::AudioStream::putMono | ( | Linear | buffer, |
unsigned | frames = 1 |
||
) |
Automatically convert and put mono linear audio data into the audio file.
Convert to stereo as needed by file format.
buffer | to save linear audio from. |
frames | of audio to write. |
unsigned ost::AudioStream::putStereo | ( | Linear | buffer, |
unsigned | frames = 1 |
||
) |
Automatically convert and put stereo linear audio data into the audio file.
Convert to mono as needed by file format.
buffer | to save linear audio from. |
frames | of audio to write. |
unsigned ost::AudioStream::bufferChannels [protected] |
Linear ost::AudioStream::bufferFrame [protected] |
unsigned ost::AudioStream::bufferPosition [protected] |
AudioCodec* ost::AudioStream::codec [protected] |
Linear ost::AudioStream::decBuffer [protected] |
unsigned ost::AudioStream::decSize [protected] |
Linear ost::AudioStream::encBuffer [protected] |
unsigned ost::AudioStream::encSize [protected] |
Encoded ost::AudioStream::framebuf [protected] |
bool ost::AudioStream::streamable [protected] |