31 #elif !defined(__hpux) && !defined(_AIX)
37 #if defined(_WIN32) && defined(_MSC_VER)
38 #pragma warning(disable: 4996)
41 #if defined(__BORLANDC__) && defined(__Windows)
46 #if !defined(__EXPORT) && defined(W32)
47 #define __EXPORT __declspec(dllimport)
62 #include <sys/types.h>
63 #include <netinet/in.h>
70 #define AUDIO_SIGNED_LINEAR_RAW 1
71 #define AUDIO_LINEAR_CONVERSION 1
72 #define AUDIO_CODEC_MODULES 1
73 #define AUDIO_LINEAR_FRAMING 1
74 #define AUDIO_NATIVE_METHODS 1
75 #define AUDIO_RATE_RESAMPLER 1
221 speexNarrow = speexVoice,
222 speexWide = speexAudio,
223 g723_4bit = g721ADPCM
282 #if __BYTE_ORDER == __LITTLE_ENDIAN
283 unsigned char mp_sync1 : 8;
284 unsigned char mp_crc : 1;
285 unsigned char mp_layer : 2;
286 unsigned char mp_ver : 2;
287 unsigned char mp_sync2 : 3;
289 unsigned char mp_priv : 1;
290 unsigned char mp_pad : 1;
291 unsigned char mp_srate : 2;
292 unsigned char mp_brate : 4;
294 unsigned char mp_emp : 2;
295 unsigned char mp_original : 1;
296 unsigned char mp_copyright: 1;
297 unsigned char mp_extend : 2;
298 unsigned char mp_channels : 2;
301 unsigned char mp_sync1 : 8;
303 unsigned char mp_sync2 : 3;
304 unsigned char mp_ver : 2;
305 unsigned char mp_layer : 2;
306 unsigned char mp_crc : 1;
308 unsigned char mp_brate : 4;
309 unsigned char mp_srate : 2;
310 unsigned char mp_pad : 1;
311 unsigned char mp_priv : 1;
313 unsigned char mp_channels : 2;
314 unsigned char mp_extend : 2;
315 unsigned char mp_copyright : 1;
316 unsigned char mp_original : 1;
317 unsigned char mp_emp : 2;
346 unsigned framesize, framecount, headersize,
padding;
354 void setRate(
Rate rate);
363 static Level tolevel(
float dbm);
371 static float todbm(
Level power);
380 static bool hasDevice(
unsigned device = 0);
399 static const char *getCodecPath(
void);
408 static const char *getMIME(
Info &
info);
417 static const char *getName(
Encoding encoding);
426 static const char *getExtension(
Encoding encoding);
438 static Encoding getEncoding(
const char *name);
462 static bool isLinear(
Encoding encoding);
472 static bool isBuffered(
Encoding encoding);
480 static bool isMono(
Encoding encoding);
488 static bool isStereo(
Encoding encoding);
534 static bool isEndian(
Encoding encoding);
554 static bool swapEndian(
Encoding encoding,
void *buffer,
unsigned number);
576 static bool swapEndian(
Info &
info,
void *buffer,
unsigned number);
586 static Level getImpulse(
Encoding encoding,
void *buffer,
unsigned number);
596 static Level getImpulse(
Info &
info,
void *buffer,
unsigned number = 0);
607 static Level getPeak(
Encoding encoding,
void *buffer,
unsigned number);
618 static Level getPeak(
Info &
info,
void *buffer,
unsigned number = 0);
627 static void toTimestamp(
timeout_t duration,
char *address,
size_t size);
635 static timeout_t toTimeout(
const char *timestamp);
659 static int getFrame(
Encoding encoding,
int samples = 0);
673 static int getCount(
Encoding encoding);
683 static unsigned long toSamples(
Encoding encoding,
size_t bytes);
693 static unsigned long toSamples(
Info &
info,
size_t bytes);
703 static size_t toBytes(
Info &
info,
unsigned long number);
713 static size_t toBytes(
Encoding encoding,
unsigned long number);
723 static void fill(
unsigned char *address,
int number,
Encoding encoding);
731 static bool loadPlugin(
const char *path);
740 static size_t maxFramesize(
Info &
info);
762 size_t process(Linear from, Linear to,
size_t count);
763 size_t estimate(
size_t count);
780 double df1, df2, p1,
p2;
805 void single(
unsigned freq,
Level level);
815 void dual(
unsigned f1,
unsigned f2,
Level l1,
Level l2);
848 virtual Linear getFrame(
void);
858 unsigned getFrames(Linear buffer,
unsigned number);
866 virtual bool isComplete(
void);
886 AudioTone(
unsigned f1,
unsigned f2, Level l1, Level l2,
887 timeout_t duration = 20, Rate sample = rate8khz);
897 AudioTone(
unsigned freq, Level level,
timeout_t duration = 20, Rate sample = rate8khz);
937 {
return info.encoding;};
954 virtual ssize_t putBuffer(Encoded data,
size_t size) = 0;
964 ssize_t putNative(Encoded data,
size_t size);
973 virtual ssize_t getBuffer(Encoded data,
size_t size) = 0;
982 {
return getBuffer(data, 0);};
991 ssize_t getNative(Encoded data,
size_t size);
1014 ssize_t getBuffer(
Encoded data,
size_t number);
1023 ssize_t putBuffer(
Encoded data,
size_t number);
1051 void initialize(
void);
1052 void getWaveFormat(
int size);
1063 virtual bool afCreate(
const char *path,
bool exclusive =
false);
1064 virtual bool afOpen(
const char *path, Mode m = modeWrite);
1065 virtual bool afPeek(
unsigned char *data,
unsigned size);
1081 virtual int afRead(
unsigned char *data,
unsigned size);
1094 virtual int afWrite(
unsigned char *data,
unsigned size);
1105 virtual bool afSeek(
unsigned long pos);
1110 virtual void afClose(
void);
1130 const char * getErrorStr(Error err);
1132 Error setError(Error err);
1151 unsigned short getShort(
unsigned char *data);
1161 void setShort(
unsigned char *data,
unsigned short value);
1171 unsigned long getLong(
unsigned char *data);
1181 void setLong(
unsigned char *data,
unsigned long value);
1190 AudioFile(
const char *name,
unsigned long offset = 0);
1219 void open(
const char *name, Mode mode = modeWrite,
timeout_t framing = 0);
1231 void create(
const char *name,
Info *
info,
bool exclusive =
false,
timeout_t framing = 0);
1239 time_t getAge(
void);
1247 {
return maxFramesize(
info);};
1276 ssize_t getBuffer(Encoded buffer,
size_t len = 0);
1286 unsigned getLinear(Linear buffer,
unsigned request = 0);
1299 ssize_t putBuffer(Encoded buffer,
size_t len = 0);
1309 unsigned putLinear(Linear buffer,
unsigned request = 0);
1325 Error getSamples(
void *buffer,
unsigned samples = 0);
1340 Error putSamples(
void *buffer,
unsigned samples = 0);
1349 Error skip(
long number);
1358 Error setPosition(
unsigned long samples = ~0l);
1367 Error position(
const char *timestamp);
1375 void getPosition(
char *timestamp,
size_t size);
1384 Error setLimit(
unsigned long maximum = 0l);
1403 Error setMinimum(
unsigned long minimum);
1414 unsigned long getAbsolutePosition(
void);
1427 unsigned long getPosition(
void);
1434 virtual bool isOpen(
void);
1452 {
return info.encoding;};
1460 {
return info.format;};
1469 {
return info.rate;};
1477 {
return info.annotation;};
1488 {
return (
bool)!isOpen();};
1495 bool isSigned(
void);
1521 unsigned bufAudio(
Linear samples,
unsigned count,
unsigned size);
1557 ssize_t getBuffer(Encoded data,
size_t count);
1566 void open(
const char *name,
Mode mode = modeRead,
timeout_t framing = 0);
1576 void create(
const char *name,
Info *
info,
bool exclusive =
false,
timeout_t framing = 0);
1594 bool isStreamable(
void);
1599 unsigned getCount(
void);
1610 unsigned getEncoded(
AudioCodec *codec, Encoded address,
unsigned frames = 1);
1621 unsigned putEncoded(
AudioCodec *codec, Encoded address,
unsigned frames = 1);
1630 unsigned getEncoded(Encoded address,
unsigned frames = 1);
1639 unsigned putEncoded(Encoded address,
unsigned frames = 1);
1648 ssize_t getPacket(Encoded data);
1658 unsigned getMono(
Linear buffer,
unsigned frames = 1);
1668 unsigned getStereo(
Linear buffer,
unsigned frames = 1);
1678 unsigned putMono(
Linear buffer,
unsigned frames = 1);
1688 unsigned putStereo(
Linear buffer,
unsigned frames = 1);
1699 unsigned bufMono(
Linear buffer,
unsigned count);
1710 unsigned bufStereo(
Linear buffer,
unsigned count);
1770 AudioCodec(
const char *name, Encoding encoding);
1791 static AudioCodec *getCodec(Encoding encoding,
const char *format = NULL,
bool loaded =
false);
1809 static bool load(
const char *name);
1818 static bool load(Encoding encoding);
1828 virtual Level getImpulse(
void *buffer,
unsigned number = 0);
1837 virtual Level getPeak(
void *buffer,
unsigned number = 0);
1849 virtual bool isSilent(Level threashold,
void *buffer,
unsigned number = 0);
1859 virtual unsigned encode(Linear buffer,
void *dest,
unsigned number = 0) = 0;
1869 virtual unsigned encodeBuffered(Linear
Buffer, Encoded dest,
unsigned number);
1879 virtual unsigned decode(Linear buffer,
void *source,
unsigned number = 0) = 0;
1890 virtual unsigned decodeBuffered(Linear buffer, Encoded source,
unsigned len);
1897 virtual unsigned getEstimated(
void);
1904 virtual unsigned getRequired(
void);
1915 virtual unsigned getPacket(Encoded destination, Encoded data,
unsigned size);
1941 virtual unsigned putSamples(Linear buffer,
unsigned count) = 0;
1950 virtual unsigned getSamples(Linear buffer,
unsigned count) = 0;
1960 virtual ssize_t putBuffer(Encoded data,
size_t count);
1970 virtual ssize_t getBuffer(Encoded data,
size_t count);
1990 virtual bool setAudio(Rate rate = rate8khz,
bool stereo =
false,
timeout_t framing = 20) = 0;
2004 virtual void flush(
void) = 0;
2015 unsigned bufMono(Linear buffer,
unsigned count);
2026 unsigned bufStereo(Linear buffer,
unsigned count);
2098 bool isComplete(
void);
2108 static bool load(
const char *pathname,
const char *locale = NULL);
2117 static tonekey_t *
find(
const char *tone,
const char *locale = NULL);
2160 bool isComplete(
void);
2195 bool isComplete(
void);
2217 int putSamples(
Linear buffer,
int count);
2225 int getResult(
char *data,
int size);
2234 tone_detection_descriptor_t dtmf_detect_row[4];
2235 tone_detection_descriptor_t dtmf_detect_col[4];
2236 tone_detection_descriptor_t dtmf_detect_row_2nd[4];
2237 tone_detection_descriptor_t dtmf_detect_col_2nd[4];
Mode
File processing mode, whether to skip missing files, etc.
AudioFile()
Construct an audio file without attaching to the filesystem.
Generic audio class to hold master data types and various useful class encapsulated friend functions ...
AudioStream accesses AudioFile base class content as fixed frames of streaming linear samples...
char * getAnnotation(void)
Get annotation extracted from header of containing file.
virtual AudioCodec * getByInfo(Info &info)
get a codec by audio source info descriptor.
Error getError(void)
Get last error code.
Encoding
Audio encoding formats.
__EXPORT AppLog & error(AppLog &sl)
Manipulator for error level.
Rate
Audio encoding rate, samples per second.
unsigned getSampleRate(void)
Get audio encoding sample rate, in samples per second, for this audio file.
The codec class is a virtual used for transcoding audio samples between linear frames (or other known...
unsigned long getHeader(void)
Get number of bytes in the file header.
__EXPORT AppLog & info(AppLog &sl)
Manipulator for info level.
The AudioResample class is used to manage linear intropolation buffering for rate conversions...
size_t getSize(void)
Get maximum size of frame buffer for data use.
dtmf_detect_state_t * state
MFTones is used to generate a series of mf audio data from a "telephone" number passed as an ASCII st...
__EXPORT char * find(const char *cs, char *str, size_t len=0)
Audio source description.
static AudioCodec * first
The AudioBuffer class is for mixing one-to-one soft joins.
ssize_t getPacket(Encoded data)
Get's a packet of audio data.
tone_detection_descriptor_t fax_detect
size_t getSamples(void)
Get the frame size for the number of audio samples generated.
Encoding getEncoding(void)
Generic get encoding.
A class used to manipulate audio data.
The buffer class represents an IPC service that is built upon a buffer of fixed capacity that can be ...
virtual void sync(void)
Synchronize timing for audio device to next audio frame.
AudioBase base class for many other audio classes which stream data.
Info * getInfo(void)
Get audio device source descriptor in effect for the device.
Info getInfo(void)
Get an info description for this codec.
static const unsigned ndata
Encoding getEncoding(void)
Return audio encoding format for this audio file.
virtual AudioCodec * getByFormat(const char *format)
often used to create a "new" codec of a subtype based on encoding format, default returns the current...
Format
Audio container file format.
virtual char * getContinuation(void)
This function is used to splice multiple audio files together into a single stream of continues audio...
AudioCodec * getCodec(void)
Return the codec being used if there is one.
The AudioTone class is used to create a frame of audio encoded single or dualtones.
tone_detection_descriptor_t fax_detect_2nd
unsigned getSampleRate(void)
Generic sample rate.
An object that is used to sequence and extract telephony tones based on a telephony tone descriptor r...
DeviceMode
Audio device access mode.
virtual bool setEncoded(Info &info)
Use encoding source descriptor to select the audio encoding format the audio device should be using...
Format getFormat(void)
Return base file format of containing audio file.
goertzel_state_t fax_tone
goertzel_state_t fax_tone2nd
bool isEnabled(void)
Whether device is currently enabled.
DTMFDetect is used for detecting DTMF tones in a stream of audio.
virtual bool hasPositioning(void)
Return true if underlying derived class supports direct access to file positioning.
Rate getRate(void)
Get the sample encoding rate being used for the tone generator.
Error
Audio error conditions.
DTMFTones is used to generate a series of dtmf audio data from a "telephone" number passed as an ASCI...