|
Blender
V2.59
|
00001 /* 00002 * $Id: AUD_SndFileReader.h 35141 2011-02-25 10:21:56Z jesterking $ 00003 * 00004 * ***** BEGIN GPL LICENSE BLOCK ***** 00005 * 00006 * Copyright 2009-2011 Jörg Hermann Müller 00007 * 00008 * This file is part of AudaSpace. 00009 * 00010 * Audaspace is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. 00014 * 00015 * AudaSpace is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 * GNU General Public License for more details. 00019 * 00020 * You should have received a copy of the GNU General Public License 00021 * along with Audaspace; if not, write to the Free Software Foundation, 00022 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00023 * 00024 * ***** END GPL LICENSE BLOCK ***** 00025 */ 00026 00032 #ifndef AUD_SNDFILEREADER 00033 #define AUD_SNDFILEREADER 00034 00035 #include "AUD_IReader.h" 00036 #include "AUD_Reference.h" 00037 #include "AUD_Buffer.h" 00038 00039 #include <string> 00040 #include <sndfile.h> 00041 00042 typedef sf_count_t (*sf_read_f)(SNDFILE *sndfile, void *ptr, sf_count_t frames); 00043 00047 class AUD_SndFileReader : public AUD_IReader 00048 { 00049 private: 00053 int m_position; 00054 00058 int m_length; 00059 00063 bool m_seekable; 00064 00068 AUD_Specs m_specs; 00069 00073 AUD_Buffer m_buffer; 00074 00078 SNDFILE* m_sndfile; 00079 00083 SF_VIRTUAL_IO m_vio; 00084 00088 AUD_Reference<AUD_Buffer> m_membuffer; 00089 00093 int m_memoffset; 00094 00095 // Functions for libsndfile virtual IO functionality 00096 static sf_count_t vio_get_filelen(void *user_data); 00097 static sf_count_t vio_seek(sf_count_t offset, int whence, void *user_data); 00098 static sf_count_t vio_read(void *ptr, sf_count_t count, void *user_data); 00099 static sf_count_t vio_tell(void *user_data); 00100 00101 // hide copy constructor and operator= 00102 AUD_SndFileReader(const AUD_SndFileReader&); 00103 AUD_SndFileReader& operator=(const AUD_SndFileReader&); 00104 00105 public: 00112 AUD_SndFileReader(std::string filename); 00113 00120 AUD_SndFileReader(AUD_Reference<AUD_Buffer> buffer); 00121 00125 virtual ~AUD_SndFileReader(); 00126 00127 virtual bool isSeekable() const; 00128 virtual void seek(int position); 00129 virtual int getLength() const; 00130 virtual int getPosition() const; 00131 virtual AUD_Specs getSpecs() const; 00132 virtual void read(int & length, sample_t* & buffer); 00133 }; 00134 00135 #endif //AUD_SNDFILEREADER