live
WAVAudioFileSource.hh
Go to the documentation of this file.
1 /**********
2 This library is free software; you can redistribute it and/or modify it under
3 the terms of the GNU Lesser General Public License as published by the
4 Free Software Foundation; either version 3 of the License, or (at your
5 option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
6 
7 This library is distributed in the hope that it will be useful, but WITHOUT
8 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
9 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
10 more details.
11 
12 You should have received a copy of the GNU Lesser General Public License
13 along with this library; if not, write to the Free Software Foundation, Inc.,
14 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15 **********/
16 // "liveMedia"
17 // Copyright (c) 1996-2021 Live Networks, Inc. All rights reserved.
18 // A WAV audio file source
19 // NOTE: Samples are returned in little-endian order (the same order in which
20 // they were stored in the file).
21 // C++ header
22 
23 #ifndef _WAV_AUDIO_FILE_SOURCE_HH
24 #define _WAV_AUDIO_FILE_SOURCE_HH
25 
26 #ifndef _AUDIO_INPUT_DEVICE_HH
27 #include "AudioInputDevice.hh"
28 #endif
29 
30 typedef enum {
31  WA_PCM = 0x01,
32  WA_PCMA = 0x06,
33  WA_PCMU = 0x07,
34  WA_IMA_ADPCM = 0x11,
37 
38 
40 public:
41 
43  char const* fileName);
44 
45  unsigned numPCMBytes() const;
46  void setScaleFactor(int scale);
47  void seekToPCMByte(unsigned byteNumber);
48  void limitNumBytesToStream(unsigned numBytesToStream);
49  // if "numBytesToStream" is >0, then we limit the stream to that number of bytes, before treating it as EOF
50 
51  unsigned char getAudioFormat();
52 
53 protected:
55  // called only by createNew()
56 
58 
59  static void fileReadableHandler(WAVAudioFileSource* source, int mask);
61 
62 private:
63  // redefined virtual functions:
64  virtual void doGetNextFrame();
65  virtual void doStopGettingFrames();
66  virtual Boolean setInputPort(int portIndex);
67  virtual double getAverageLevel() const;
68 
69 protected:
71 
72 private:
73  FILE* fFid;
74  double fPlayTimePerSample; // useconds
76  unsigned fLastPlayTime; // useconds
78  unsigned fWAVHeaderSize;
79  unsigned fFileSize;
82  unsigned fNumBytesToStream; // used iff "fLimitNumBytesToStream" is True
83  unsigned char fAudioFormat;
84 };
85 
86 #endif
unsigned char Boolean
Definition: Boolean.hh:25
WAV_AUDIO_FORMAT
@ WA_PCMA
@ WA_PCM
@ WA_UNKNOWN
@ WA_IMA_ADPCM
@ WA_PCMU
virtual double getAverageLevel() const
unsigned numPCMBytes() const
unsigned char fAudioFormat
WAVAudioFileSource(UsageEnvironment &env, FILE *fid)
unsigned char getAudioFormat()
static WAVAudioFileSource * createNew(UsageEnvironment &env, char const *fileName)
virtual Boolean setInputPort(int portIndex)
static void fileReadableHandler(WAVAudioFileSource *source, int mask)
virtual void doGetNextFrame()
virtual void doStopGettingFrames()
void limitNumBytesToStream(unsigned numBytesToStream)
virtual ~WAVAudioFileSource()
void seekToPCMByte(unsigned byteNumber)
void setScaleFactor(int scale)