Bayonne2 / Common C++ 2 Framework
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
audio2.h
Go to the documentation of this file.
1 // Copyright (C) 1999-2005 Open Source Telecom Corporation.
2 // Copyright (C) 2006-2008 David Sugar, Tycho Softworks.
3 //
4 // This file is part of GNU ccAudio2.
5 //
6 // GNU ccAudio2 is free software: you can redistribute it and/or modify
7 // it under the terms of the GNU Lesser General Public License as published
8 // by the Free Software Foundation, either version 3 of the License, or
9 // (at your option) any later version.
10 //
11 // GNU ccAudio2 is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public License
17 // along with GNU ccAudio2. If not, see <http://www.gnu.org/licenses/>.
18 
25 #ifndef CCXX_AUDIO_H_
26 #define CCXX_AUDIO_H_
27 
28 #ifndef CCXX_PACKING
29 #if defined(__GNUC__)
30 #define CCXX_PACKED
31 #elif !defined(__hpux) && !defined(_AIX)
32 #define CCXX_PACKED
33 #endif
34 #endif
35 
36 #ifndef W32
37 #if defined(_WIN32) && defined(_MSC_VER)
38 #pragma warning(disable: 4996)
39 #define W32
40 #endif
41 #if defined(__BORLANDC__) && defined(__Windows)
42 #define W32
43 #endif
44 #endif
45 
46 #if !defined(__EXPORT) && defined(W32)
47 #define __EXPORT __declspec(dllimport)
48 #endif
49 
50 #ifndef __EXPORT
51 #define __EXPORT
52 #endif
53 
54 #ifdef W32
55 #include <windows.h>
56 #ifndef ssize_t
57 #define ssize_t int
58 #endif
59 #else
60 #include <cstddef>
61 #include <cstdlib>
62 #include <sys/types.h>
63 #include <netinet/in.h>
64 #endif
65 
66 #include <ctime>
67 
68 namespace ost {
69 
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
76 
77 class __EXPORT AudioCodec;
78 class __EXPORT AudioDevice;
79 
89 {
90 public:
91 #ifdef W32
92  typedef short Sample;
93  typedef short *Linear;
94  typedef short Level;
95  typedef DWORD timeout_t;
96  typedef WORD snd16_t;
97  typedef DWORD snd32_t;
98 #else
99  typedef int16_t snd16_t;
100  typedef int32_t snd32_t;
101  typedef int16_t Level;
102  typedef int16_t Sample;
103  typedef int16_t *Linear;
104  typedef unsigned long timeout_t;
105 #endif
106 
107  static const unsigned ndata;
108 
109  typedef struct {
110  float v2;
111  float v3;
112  float fac;
114 
115  typedef struct {
116  int hit1;
117  int hit2;
118  int hit3;
119  int hit4;
120  int mhit;
121 
122  goertzel_state_t row_out[4];
123  goertzel_state_t col_out[4];
124  goertzel_state_t row_out2nd[4];
125  goertzel_state_t col_out2nd[4];
128  float energy;
129 
131  char digits[129];
135  int digit_hits[16];
136  int fax_hits;
138 
139  typedef struct {
140  float fac;
142 
143  typedef unsigned char *Encoded;
144 
148  enum Rate {
150  rate6khz = 6000,
151  rate8khz = 8000,
152  rate16khz = 16000,
153  rate32khz = 32000,
154  rate44khz = 44100
155  };
156 
157  typedef enum Rate Rate;
158 
162  enum Mode {
170 
171  modeAppend, // app specific placeholders...
172  modeCreate
173  };
174 
175  typedef enum Mode Mode;
176 
180  enum Encoding {
181  unknownEncoding = 0,
200 
201  // Please keep the PCM types at the end of the list -
202  // see the "is this PCM or not?" code in
203  // AudioFile::close for why.
212 
213  // speex codecs
214  speexVoice, // narrow band
216 
220 
221  speexNarrow = speexVoice,
222  speexWide = speexAudio,
223  g723_4bit = g721ADPCM
224  };
225  typedef enum Encoding Encoding;
226 
230  enum Format {
235  wave
236  };
237  typedef enum Format Format;
238 
242  enum DeviceMode {
245  PLAYREC
246  };
247  typedef enum DeviceMode DeviceMode;
248 
252  enum Error {
253  errSuccess = 0,
272  errNoCodec
273  };
274  typedef enum Error Error;
275 
276 
277 #ifdef CCXX_PACKED
278 #pragma pack(1)
279 #endif
280 
281  typedef struct {
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;
288 
289  unsigned char mp_priv : 1;
290  unsigned char mp_pad : 1;
291  unsigned char mp_srate : 2;
292  unsigned char mp_brate : 4;
293 
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;
299 
300 #else
301  unsigned char mp_sync1 : 8;
302 
303  unsigned char mp_sync2 : 3;
304  unsigned char mp_ver : 2;
305  unsigned char mp_layer : 2;
306  unsigned char mp_crc : 1;
307 
308  unsigned char mp_brate : 4;
309  unsigned char mp_srate : 2;
310  unsigned char mp_pad : 1;
311  unsigned char mp_priv : 1;
312 
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;
318 #endif
319  } mpeg_audio;
320 
321  typedef struct {
322  char tag_id[3];
323  char tag_title[30];
324  char tag_artist[30];
325  char tag_album[30];
326  char tag_year[4];
327  char tag_note[30];
328  unsigned char genre;
329  } mpeg_tagv1;
330 
331 #ifdef CCXX_PACKED
332 #pragma pack()
333 #endif
334 
339  {
340  public:
343  unsigned long rate;
344  unsigned long bitrate;
345  unsigned order;
346  unsigned framesize, framecount, headersize, padding;
348  char *annotation;
349 
350  Info();
351  void clear(void);
352  void set(void);
353  void setFraming(timeout_t frame);
354  void setRate(Rate rate);
355  };
356 
363  static Level tolevel(float dbm);
364 
371  static float todbm(Level power);
372 
380  static bool hasDevice(unsigned device = 0);
381 
392  static AudioDevice *getDevice(unsigned device = 0, DeviceMode mode = PLAY);
393 
399  static const char *getCodecPath(void);
400 
408  static const char *getMIME(Info &info);
409 
417  static const char *getName(Encoding encoding);
418 
426  static const char *getExtension(Encoding encoding);
427 
438  static Encoding getEncoding(const char *name);
439 
446  static Encoding getStereo(Encoding encoding);
447 
454  static Encoding getMono(Encoding encoding);
455 
462  static bool isLinear(Encoding encoding);
463 
472  static bool isBuffered(Encoding encoding);
473 
480  static bool isMono(Encoding encoding);
481 
488  static bool isStereo(Encoding encoding);
489 
497  static Rate getRate(Encoding encoding);
498 
507  static Rate getRate(Encoding e, Rate request);
508 
516  static timeout_t getFraming(Encoding encoding, timeout_t timeout = 0);
517 
525  static timeout_t getFraming(Info &info, timeout_t timeout = 0);
526 
534  static bool isEndian(Encoding encoding);
535 
543  static bool isEndian(Info &info);
544 
554  static bool swapEndian(Encoding encoding, void *buffer, unsigned number);
555 
564  static void swapEncoded(Info &info, Encoded data, size_t bytes);
565 
576  static bool swapEndian(Info &info, void *buffer, unsigned number);
577 
586  static Level getImpulse(Encoding encoding, void *buffer, unsigned number);
587 
596  static Level getImpulse(Info &info, void *buffer, unsigned number = 0);
597 
607  static Level getPeak(Encoding encoding, void *buffer, unsigned number);
608 
618  static Level getPeak(Info &info, void *buffer, unsigned number = 0);
619 
627  static void toTimestamp(timeout_t duration, char *address, size_t size);
628 
635  static timeout_t toTimeout(const char *timestamp);
636 
659  static int getFrame(Encoding encoding, int samples = 0);
660 
673  static int getCount(Encoding encoding);
674 
683  static unsigned long toSamples(Encoding encoding, size_t bytes);
684 
693  static unsigned long toSamples(Info &info, size_t bytes);
694 
703  static size_t toBytes(Info &info, unsigned long number);
704 
713  static size_t toBytes(Encoding encoding, unsigned long number);
714 
723  static void fill(unsigned char *address, int number, Encoding encoding);
724 
731  static bool loadPlugin(const char *path);
732 
740  static size_t maxFramesize(Info &info);
741 };
742 
751 {
752 protected:
753  unsigned mfact, dfact, max;
754  unsigned gpos, ppos;
755  Sample last;
756  Linear buffer;
757 
758 public:
759  AudioResample(Rate mul, Rate div);
760  ~AudioResample();
761 
762  size_t process(Linear from, Linear to, size_t count);
763  size_t estimate(size_t count);
764 };
765 
774 class __EXPORT AudioTone : public Audio
775 {
776 protected:
778  unsigned samples;
780  double df1, df2, p1, p2;
781  Level m1, m2;
782  bool silencer;
783 
787  void silence(void);
788 
792  void reset(void);
793 
797  void cleanup(void);
798 
805  void single(unsigned freq, Level level);
806 
815  void dual(unsigned f1, unsigned f2, Level l1, Level l2);
816 
817 public:
823  inline Rate getRate(void)
824  {return rate;};
825 
831  inline size_t getSamples(void)
832  {return samples;};
833 
839  bool isSilent(void);
840 
848  virtual Linear getFrame(void);
849 
858  unsigned getFrames(Linear buffer, unsigned number);
859 
866  virtual bool isComplete(void);
867 
874  AudioTone(timeout_t duration = 20, Rate rate = rate8khz);
875 
886  AudioTone(unsigned f1, unsigned f2, Level l1, Level l2,
887  timeout_t duration = 20, Rate sample = rate8khz);
888 
897  AudioTone(unsigned freq, Level level, timeout_t duration = 20, Rate sample = rate8khz);
898 
899  virtual ~AudioTone();
900 };
901 
908 class __EXPORT AudioBase : public Audio
909 {
910 protected:
912 
913 public:
917  AudioBase();
918 
924  AudioBase(Info *info);
925 
929  virtual ~AudioBase();
930 
936  inline Encoding getEncoding(void)
937  {return info.encoding;};
938 
944  inline unsigned getSampleRate(void)
945  {return info.rate;};
946 
954  virtual ssize_t putBuffer(Encoded data, size_t size) = 0;
955 
964  ssize_t putNative(Encoded data, size_t size);
965 
973  virtual ssize_t getBuffer(Encoded data, size_t size) = 0;
974 
981  inline ssize_t getPacket(Encoded data)
982  {return getBuffer(data, 0);};
983 
991  ssize_t getNative(Encoded data, size_t size);
992 };
993 
1002 {
1003 public:
1004  AudioBuffer(Info *info, size_t size = 4096);
1005  virtual ~AudioBuffer();
1006 
1014  ssize_t getBuffer(Encoded data, size_t number);
1015 
1023  ssize_t putBuffer(Encoded data, size_t number);
1024 
1025 private:
1026  char *buf;
1027  size_t size, start, len;
1029 
1030  void enter(void);
1031  void leave(void);
1032 };
1033 
1043 {
1044 protected:
1045  char *pathname;
1047  unsigned long header; // offset to start of audio
1048  unsigned long minimum; // minimum sample size required
1049  unsigned long length; // current size of file, including header
1050 
1051  void initialize(void);
1052  void getWaveFormat(int size);
1053  void mp3info(mpeg_audio *mp3);
1054 
1055  union {
1056  int fd;
1057  void *handle;
1058  } file;
1059 
1060  Mode mode;
1061  unsigned long iolimit;
1062 
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);
1066 
1067  AudioCodec *getCodec(void);
1068 
1081  virtual int afRead(unsigned char *data, unsigned size);
1082 
1094  virtual int afWrite(unsigned char *data, unsigned size);
1095 
1105  virtual bool afSeek(unsigned long pos);
1106 
1110  virtual void afClose(void);
1111 
1119  virtual char *getContinuation(void)
1120  {return NULL;};
1121 
1130  const char * getErrorStr(Error err);
1131 
1132  Error setError(Error err);
1133 
1140  inline unsigned long getHeader(void)
1141  {return header;};
1142 
1151  unsigned short getShort(unsigned char *data);
1152 
1161  void setShort(unsigned char *data, unsigned short value);
1162 
1171  unsigned long getLong(unsigned char *data);
1172 
1181  void setLong(unsigned char *data, unsigned long value);
1182 
1183 public:
1190  AudioFile(const char *name, unsigned long offset = 0);
1191 
1199  AudioFile(const char *name, Info *info, unsigned long minimum = 0);
1200 
1204  inline AudioFile()
1205  {initialize();};
1206 
1207  virtual ~AudioFile();
1208 
1219  void open(const char *name, Mode mode = modeWrite, timeout_t framing = 0);
1220 
1231  void create(const char *name, Info *info, bool exclusive = false, timeout_t framing = 0);
1232 
1239  time_t getAge(void);
1240 
1246  inline size_t getSize(void)
1247  {return maxFramesize(info);};
1248 
1254  void close(void);
1255 
1263  void clear(void);
1264 
1276  ssize_t getBuffer(Encoded buffer, size_t len = 0);
1277 
1286  unsigned getLinear(Linear buffer, unsigned request = 0);
1287 
1299  ssize_t putBuffer(Encoded buffer, size_t len = 0);
1300 
1309  unsigned putLinear(Linear buffer, unsigned request = 0);
1310 
1325  Error getSamples(void *buffer, unsigned samples = 0);
1326 
1340  Error putSamples(void *buffer, unsigned samples = 0);
1341 
1349  Error skip(long number);
1350 
1358  Error setPosition(unsigned long samples = ~0l);
1359 
1367  Error position(const char *timestamp);
1368 
1375  void getPosition(char *timestamp, size_t size);
1376 
1384  Error setLimit(unsigned long maximum = 0l);
1385 
1393  Error getInfo(Info *info);
1394 
1403  Error setMinimum(unsigned long minimum);
1404 
1414  unsigned long getAbsolutePosition(void);
1415 
1427  unsigned long getPosition(void);
1428 
1434  virtual bool isOpen(void);
1435 
1443  virtual bool hasPositioning(void)
1444  {return true;};
1445 
1451  inline Encoding getEncoding(void)
1452  {return info.encoding;};
1453 
1459  inline Format getFormat(void)
1460  {return info.format;};
1461 
1468  inline unsigned getSampleRate(void)
1469  {return info.rate;};
1470 
1476  inline char *getAnnotation(void)
1477  {return info.annotation;};
1478 
1484  inline Error getError(void)
1485  {return error;};
1486 
1487  inline bool operator!(void)
1488  {return (bool)!isOpen();};
1489 
1495  bool isSigned(void);
1496 };
1497 
1510 {
1511 protected:
1512  AudioCodec *codec; // if needed
1513  Encoded framebuf;
1516  unsigned bufferPosition;
1517  unsigned bufferChannels;
1518  Linear encBuffer, decBuffer;
1519  unsigned encSize, decSize;
1520 
1521  unsigned bufAudio(Linear samples, unsigned count, unsigned size);
1522 
1523 public:
1527  AudioStream();
1528 
1536  AudioStream(const char *name, Mode mode = modeRead, timeout_t framing = 0);
1537 
1546  AudioStream(const char *name, Info *info, bool exclusive = false, timeout_t framing = 0);
1547 
1548  virtual ~AudioStream();
1549 
1557  ssize_t getBuffer(Encoded data, size_t count);
1558 
1566  void open(const char *name, Mode mode = modeRead, timeout_t framing = 0);
1567 
1576  void create(const char *name, Info *info, bool exclusive = false, timeout_t framing = 0);
1577 
1581  void close(void);
1582 
1586  void flush(void);
1587 
1594  bool isStreamable(void);
1595 
1599  unsigned getCount(void); // frame count
1600 
1610  unsigned getEncoded(AudioCodec *codec, Encoded address, unsigned frames = 1);
1611 
1621  unsigned putEncoded(AudioCodec *codec, Encoded address, unsigned frames = 1);
1622 
1630  unsigned getEncoded(Encoded address, unsigned frames = 1);
1631 
1639  unsigned putEncoded(Encoded address, unsigned frames = 1);
1640 
1648  ssize_t getPacket(Encoded data);
1649 
1658  unsigned getMono(Linear buffer, unsigned frames = 1);
1659 
1668  unsigned getStereo(Linear buffer, unsigned frames = 1);
1669 
1678  unsigned putMono(Linear buffer, unsigned frames = 1);
1679 
1688  unsigned putStereo(Linear buffer, unsigned frames = 1);
1689 
1699  unsigned bufMono(Linear buffer, unsigned count);
1700 
1710  unsigned bufStereo(Linear buffer, unsigned count);
1711 
1717  inline AudioCodec *getCodec(void)
1718  {return codec;};
1719 };
1720 
1733 class __EXPORT AudioCodec : public Audio
1734 {
1735 protected:
1739  const char *name;
1741 
1742  AudioCodec();
1743 
1751  virtual AudioCodec *getByFormat(const char *format)
1752  {return this;};
1753 
1761  {return this;};
1762 
1763 public:
1770  AudioCodec(const char *name, Encoding encoding);
1771 
1772  virtual ~AudioCodec() {};
1773 
1780  static void endCodec(AudioCodec *codec);
1781 
1791  static AudioCodec *getCodec(Encoding encoding, const char *format = NULL, bool loaded = false);
1792 
1801  static AudioCodec *getCodec(Info &info, bool loaded = false);
1802 
1809  static bool load(const char *name);
1810 
1818  static bool load(Encoding encoding);
1819 
1828  virtual Level getImpulse(void *buffer, unsigned number = 0);
1829 
1837  virtual Level getPeak(void *buffer, unsigned number = 0);
1838 
1849  virtual bool isSilent(Level threashold, void *buffer, unsigned number = 0);
1850 
1859  virtual unsigned encode(Linear buffer, void *dest, unsigned number = 0) = 0;
1860 
1869  virtual unsigned encodeBuffered(Linear Buffer, Encoded dest, unsigned number);
1870 
1879  virtual unsigned decode(Linear buffer, void *source, unsigned number = 0) = 0;
1880 
1890  virtual unsigned decodeBuffered(Linear buffer, Encoded source, unsigned len);
1891 
1897  virtual unsigned getEstimated(void);
1898 
1904  virtual unsigned getRequired(void);
1905 
1915  virtual unsigned getPacket(Encoded destination, Encoded data, unsigned size);
1916 
1922  inline Info getInfo(void)
1923  {return info;};
1924 };
1925 
1927 {
1928 protected:
1929  bool enabled;
1930 
1931 public:
1932  virtual ~AudioDevice() {};
1933 
1941  virtual unsigned putSamples(Linear buffer, unsigned count) = 0;
1942 
1950  virtual unsigned getSamples(Linear buffer, unsigned count) = 0;
1951 
1960  virtual ssize_t putBuffer(Encoded data, size_t count);
1961 
1970  virtual ssize_t getBuffer(Encoded data, size_t count);
1971 
1979  virtual bool setEncoded(Info &info)
1980  {return false;};
1981 
1990  virtual bool setAudio(Rate rate = rate8khz, bool stereo = false, timeout_t framing = 20) = 0;
1991 
1998  virtual void sync(void)
1999  {return;};
2000 
2004  virtual void flush(void) = 0;
2005 
2015  unsigned bufMono(Linear buffer, unsigned count);
2016 
2026  unsigned bufStereo(Linear buffer, unsigned count);
2027 
2033  inline Info *getInfo(void)
2034  {return &info;};
2035 
2044  inline bool isEnabled(void)
2045  {return enabled;};
2046 };
2047 
2057 {
2058 public:
2059  typedef struct _tonedef {
2060  struct _tonedef *next;
2061  timeout_t duration, silence;
2062  unsigned count;
2063  unsigned short f1, f2;
2064  } tonedef_t;
2065 
2066  typedef struct _tonekey {
2067  struct _tonekey *next;
2068  struct _tonedef *first;
2069  struct _tonedef *last;
2070  char id[1];
2071  } tonekey_t;
2072 
2081  TelTone(tonekey_t *key, Level level, timeout_t frame = 20);
2082  ~TelTone();
2083 
2090  Linear getFrame(void);
2091 
2098  bool isComplete(void);
2099 
2100 
2108  static bool load(const char *pathname, const char *locale = NULL);
2109 
2117  static tonekey_t *find(const char *tone, const char *locale = NULL);
2118 
2119 protected:
2122  unsigned remaining, silent, count;
2125  bool complete;
2126 };
2127 
2138 {
2139 protected:
2140  unsigned remaining, dtmfframes;
2142  const char *digits;
2144  bool complete;
2145 
2146 public:
2155  DTMFTones(const char *digits, Level level, timeout_t duration = 20, timeout_t interdigit = 60);
2156 
2157  ~DTMFTones();
2158 
2159  Linear getFrame(void);
2160  bool isComplete(void);
2161 };
2162 
2173 {
2174 protected:
2175  unsigned remaining, mfframes;
2177  const char *digits;
2179  bool complete, kflag;
2180 
2181 public:
2190  MFTones(const char *digits, Level level, timeout_t duration = 20, timeout_t interdigit = 60);
2191 
2192  ~MFTones();
2193 
2194  Linear getFrame(void);
2195  bool isComplete(void);
2196 };
2197 
2198 
2203 class __EXPORT DTMFDetect : public Audio
2204 {
2205 public:
2206  DTMFDetect();
2207  ~DTMFDetect();
2208 
2217  int putSamples(Linear buffer, int count);
2218 
2225  int getResult(char *data, int size);
2226 
2227 protected:
2228  void goertzelInit(goertzel_state_t *s, tone_detection_descriptor_t *t);
2229  void goertzelUpdate(goertzel_state_t *s, Sample x[], int samples);
2230  float goertzelResult(goertzel_state_t *s);
2231 
2232 private:
2233  dtmf_detect_state_t *state;
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];
2238  tone_detection_descriptor_t fax_detect;
2239  tone_detection_descriptor_t fax_detect_2nd;
2240 };
2241 
2242 }
2243 
2244 #endif
2245 
Mode
File processing mode, whether to skip missing files, etc.
Definition: audio2.h:162
Level m2
Definition: audio2.h:781
AudioFile()
Construct an audio file without attaching to the filesystem.
Definition: audio2.h:1204
tonedef_t * def
Definition: audio2.h:2121
void * handle
Definition: audio2.h:1057
Generic audio class to hold master data types and various useful class encapsulated friend functions ...
Definition: audio2.h:88
AudioStream accesses AudioFile base class content as fixed frames of streaming linear samples...
Definition: audio2.h:1509
int16_t Level
Definition: audio2.h:101
char * getAnnotation(void)
Get annotation extracted from header of containing file.
Definition: audio2.h:1476
virtual ~AudioCodec()
Definition: audio2.h:1772
virtual AudioCodec * getByInfo(Info &info)
get a codec by audio source info descriptor.
Definition: audio2.h:1760
unsigned char * Encoded
Definition: audio2.h:143
Error getError(void)
Get last error code.
Definition: audio2.h:1484
Encoding
Audio encoding formats.
Definition: audio2.h:180
Encoding encoding
Definition: audio2.h:342
bool kflag
Definition: audio2.h:2179
Level level
Definition: audio2.h:2124
__EXPORT AppLog & error(AppLog &sl)
Manipulator for error level.
Definition: applog.h:541
char * annotation
Definition: audio2.h:348
Rate
Audio encoding rate, samples per second.
Definition: audio2.h:148
unsigned getSampleRate(void)
Get audio encoding sample rate, in samples per second, for this audio file.
Definition: audio2.h:1468
The codec class is a virtual used for transcoding audio samples between linear frames (or other known...
Definition: audio2.h:1733
unsigned long getHeader(void)
Get number of bytes in the file header.
Definition: audio2.h:1140
AudioCodec * codec
Definition: audio2.h:1512
unsigned padding
Definition: audio2.h:346
struct _tonedef * last
Definition: audio2.h:2069
int16_t * Linear
Definition: audio2.h:103
unsigned short f2
Definition: audio2.h:2063
__EXPORT AppLog & info(AppLog &sl)
Manipulator for info level.
Definition: applog.h:581
struct _tonekey * next
Definition: audio2.h:2067
Linear encBuffer
Definition: audio2.h:1518
virtual ~AudioDevice()
Definition: audio2.h:1932
The AudioResample class is used to manage linear intropolation buffering for rate conversions...
Definition: audio2.h:750
size_t getSize(void)
Get maximum size of frame buffer for data use.
Definition: audio2.h:1246
dtmf_detect_state_t * state
Definition: audio2.h:2233
size_t start
Definition: audio2.h:1027
MFTones is used to generate a series of mf audio data from a "telephone" number passed as an ASCII st...
Definition: audio2.h:2172
Format format
Definition: audio2.h:341
__EXPORT char * find(const char *cs, char *str, size_t len=0)
Audio source description.
Definition: audio2.h:338
unsigned long iolimit
Definition: audio2.h:1061
static AudioCodec * first
Definition: audio2.h:1736
The AudioBuffer class is for mixing one-to-one soft joins.
Definition: audio2.h:1001
ssize_t getPacket(Encoded data)
Get's a packet of audio data.
Definition: audio2.h:981
Linear bufferFrame
Definition: audio2.h:1515
tone_detection_descriptor_t fax_detect
Definition: audio2.h:2238
unsigned long timeout_t
Definition: thread.h:74
size_t getSamples(void)
Get the frame size for the number of audio samples generated.
Definition: audio2.h:831
Level level
Definition: audio2.h:2143
const char * digits
Definition: audio2.h:2142
struct _tonedef * next
Definition: audio2.h:2060
Level level
Definition: audio2.h:2178
unsigned long header
Definition: audio2.h:1047
Encoding getEncoding(void)
Generic get encoding.
Definition: audio2.h:936
A class used to manipulate audio data.
Definition: audio2.h:1042
bool complete
Definition: audio2.h:2144
The buffer class represents an IPC service that is built upon a buffer of fixed capacity that can be ...
Definition: buffer.h:81
virtual void sync(void)
Synchronize timing for audio device to next audio frame.
Definition: audio2.h:1998
AudioBase base class for many other audio classes which stream data.
Definition: audio2.h:908
Info * getInfo(void)
Get audio device source descriptor in effect for the device.
Definition: audio2.h:2033
timeout_t framing
Definition: audio2.h:347
int32_t snd32_t
Definition: audio2.h:100
timeout_t frametime
Definition: audio2.h:2176
AudioCodec * next
Definition: audio2.h:1737
Encoded framebuf
Definition: audio2.h:1513
unsigned mfact
Definition: audio2.h:753
Info getInfo(void)
Get an info description for this codec.
Definition: audio2.h:1922
unsigned ppos
Definition: audio2.h:754
unsigned remaining
Definition: audio2.h:2175
unsigned encSize
Definition: audio2.h:1519
Error error
Definition: audio2.h:1046
unsigned remaining
Definition: audio2.h:2140
double p2
Definition: audio2.h:780
static const unsigned ndata
Definition: audio2.h:107
unsigned samples
Definition: audio2.h:778
Encoding getEncoding(void)
Return audio encoding format for this audio file.
Definition: audio2.h:1451
virtual AudioCodec * getByFormat(const char *format)
often used to create a "new" codec of a subtype based on encoding format, default returns the current...
Definition: audio2.h:1751
Format
Audio container file format.
Definition: audio2.h:230
bool complete
Definition: audio2.h:2125
unsigned long bitrate
Definition: audio2.h:344
unsigned silent
Definition: audio2.h:2122
virtual char * getContinuation(void)
This function is used to splice multiple audio files together into a single stream of continues audio...
Definition: audio2.h:1119
AudioCodec * getCodec(void)
Return the codec being used if there is one.
Definition: audio2.h:1717
unsigned long rate
Definition: audio2.h:343
The AudioTone class is used to create a frame of audio encoded single or dualtones.
Definition: audio2.h:774
tone_detection_descriptor_t fax_detect_2nd
Definition: audio2.h:2239
tonekey_t * tone
Definition: audio2.h:2120
#define __EXPORT
Definition: audio2.h:51
unsigned getSampleRate(void)
Generic sample rate.
Definition: audio2.h:944
Encoding encoding
Definition: audio2.h:1738
bool silencer
Definition: audio2.h:782
struct _tonedef * first
Definition: audio2.h:2068
timeout_t frametime
Definition: audio2.h:2141
bool operator!(void)
Definition: audio2.h:1487
An object that is used to sequence and extract telephony tones based on a telephony tone descriptor r...
Definition: audio2.h:2056
DeviceMode
Audio device access mode.
Definition: audio2.h:242
const char * digits
Definition: audio2.h:2177
unsigned bufferChannels
Definition: audio2.h:1517
virtual bool setEncoded(Info &info)
Use encoding source descriptor to select the audio encoding format the audio device should be using...
Definition: audio2.h:1979
unsigned bufferPosition
Definition: audio2.h:1516
unsigned long length
Definition: audio2.h:1049
Format getFormat(void)
Return base file format of containing audio file.
Definition: audio2.h:1459
unsigned char genre
Definition: audio2.h:328
goertzel_state_t fax_tone
Definition: audio2.h:126
goertzel_state_t fax_tone2nd
Definition: audio2.h:127
timeout_t framing
Definition: audio2.h:2123
Linear frame
Definition: audio2.h:779
void * mutexObject
Definition: audio2.h:1028
bool isEnabled(void)
Whether device is currently enabled.
Definition: audio2.h:2044
char * pathname
Definition: audio2.h:1045
DTMFDetect is used for detecting DTMF tones in a stream of audio.
Definition: audio2.h:2203
virtual bool hasPositioning(void)
Return true if underlying derived class supports direct access to file positioning.
Definition: audio2.h:1443
unsigned long timeout_t
Definition: audio2.h:104
Rate getRate(void)
Get the sample encoding rate being used for the tone generator.
Definition: audio2.h:823
Error
Audio error conditions.
Definition: audio2.h:252
const char * name
Definition: audio2.h:1739
unsigned order
Definition: audio2.h:345
DTMFTones is used to generate a series of dtmf audio data from a "telephone" number passed as an ASCI...
Definition: audio2.h:2137
int16_t snd16_t
Definition: audio2.h:99
int16_t Sample
Definition: audio2.h:102
unsigned long minimum
Definition: audio2.h:1048