live
WAVAudioFileSource.hh
Go to the documentation of this file.
1/**********
2This library is free software; you can redistribute it and/or modify it under
3the terms of the GNU Lesser General Public License as published by the
4Free Software Foundation; either version 3 of the License, or (at your
5option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
6
7This library is distributed in the hope that it will be useful, but WITHOUT
8ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
9FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
10more details.
11
12You should have received a copy of the GNU Lesser General Public License
13along with this library; if not, write to the Free Software Foundation, Inc.,
1451 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15**********/
16// "liveMedia"
17// Copyright (c) 1996-2024 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
30typedef enum {
31 WA_PCM = 0x01,
32 WA_PCMA = 0x06,
33 WA_PCMU = 0x07,
37
38
40public:
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
53protected:
55 // called only by createNew()
56
58
59 static void fileReadableHandler(WAVAudioFileSource* source, int mask);
61
62private:
63 // redefined virtual functions:
64 virtual void doGetNextFrame();
65 virtual void doStopGettingFrames();
66 virtual Boolean setInputPort(int portIndex);
67 virtual double getAverageLevel() const;
68
69protected:
71
72private:
73 FILE* fFid;
74 double fPlayTimePerSample; // useconds
76 unsigned fLastPlayTime; // useconds
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
static WAVAudioFileSource * createNew(UsageEnvironment &env, char const *fileName)
unsigned char fAudioFormat
WAVAudioFileSource(UsageEnvironment &env, FILE *fid)
unsigned char getAudioFormat()
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)