1 //----------------------------------------------------------------------------- 2 // Copyright (c) 2015-2018 Marcelo Fernandez 3 // 4 // Permission is hereby granted, free of charge, to any person obtaining a copy 5 // of this software and associated documentation files (the "Software"), to 6 // deal in the Software without restriction, including without limitation the 7 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 8 // sell copies of the Software, and to permit persons to whom the Software is 9 // furnished to do so, subject to the following conditions: 10 // 11 // The above copyright notice and this permission notice shall be included in 12 // all copies or substantial portions of the Software. 13 // 14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 // IN THE SOFTWARE. 21 //----------------------------------------------------------------------------- 22 23 #ifndef __AUDIOFILE_H__ 24 #define __AUDIOFILE_H__ 25 26 enum { 27 AF_FORMAT_SINT8, 28 AF_FORMAT_SINT16, 29 AF_FORMAT_SINT24, 30 AF_FORMAT_SINT32, 31 AF_FORMAT_FLOAT32 32 }; 33 34 class audioFile { 35 protected: 36 oamlFileCallbacks *fcbs; 37 38 void *fd; 39 40 public: 41 42 audioFile(oamlFileCallbacks *cbs); 43 virtual ~audioFile(); 44 45 virtual int GetFormat() const = 0; 46 virtual int GetChannels() const = 0; 47 virtual int GetSamplesPerSec() const = 0; 48 virtual int GetBytesPerSample() const = 0; 49 virtual int GetTotalSamples() const = 0; 50 51 virtual int Open(const char *filename) = 0; 52 virtual int Read(char *, int size) = 0; 53 54 virtual void WriteToFile(const char *filename, ByteBuffer *buffer, int channels, unsigned int sampleRate, int bytesPerSample) = 0; 55 56 virtual void Close() = 0; 57 GetFileCallbacks()58 oamlFileCallbacks* GetFileCallbacks() const { return fcbs; } GetFD()59 void* GetFD() const { return fd; } 60 }; 61 62 #endif /* __AUDIOFILE_H__ */ 63