Blender V2.61 - r43446
|
00001 /* 00002 * ***** BEGIN GPL LICENSE BLOCK ***** 00003 * 00004 * Copyright 2009-2011 Jörg Hermann Müller 00005 * 00006 * This file is part of AudaSpace. 00007 * 00008 * Audaspace is free software; you can redistribute it and/or modify 00009 * it under the terms of the GNU General Public License as published by 00010 * the Free Software Foundation; either version 2 of the License, or 00011 * (at your option) any later version. 00012 * 00013 * AudaSpace is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU General Public License 00019 * along with Audaspace; if not, write to the Free Software Foundation, 00020 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00021 * 00022 * ***** END GPL LICENSE BLOCK ***** 00023 */ 00024 00030 #include "AUD_ConverterReader.h" 00031 00032 AUD_ConverterReader::AUD_ConverterReader(AUD_Reference<AUD_IReader> reader, 00033 AUD_DeviceSpecs specs) : 00034 AUD_EffectReader(reader), 00035 m_format(specs.format) 00036 { 00037 switch(m_format) 00038 { 00039 case AUD_FORMAT_U8: 00040 m_convert = AUD_convert_float_u8; 00041 break; 00042 case AUD_FORMAT_S16: 00043 m_convert = AUD_convert_float_s16; 00044 break; 00045 case AUD_FORMAT_S24: 00046 #ifdef __BIG_ENDIAN__ 00047 m_convert = AUD_convert_float_s24_be; 00048 #else 00049 m_convert = AUD_convert_float_s24_le; 00050 #endif 00051 break; 00052 case AUD_FORMAT_S32: 00053 m_convert = AUD_convert_float_s32; 00054 break; 00055 case AUD_FORMAT_FLOAT32: 00056 m_convert = AUD_convert_copy<float>; 00057 break; 00058 case AUD_FORMAT_FLOAT64: 00059 m_convert = AUD_convert_float_double; 00060 break; 00061 default: 00062 break; 00063 } 00064 } 00065 00066 void AUD_ConverterReader::read(int& length, bool& eos, sample_t* buffer) 00067 { 00068 AUD_Specs specs = m_reader->getSpecs(); 00069 int samplesize = AUD_SAMPLE_SIZE(specs); 00070 00071 m_buffer.assureSize(length * samplesize); 00072 00073 m_reader->read(length, eos, m_buffer.getBuffer()); 00074 00075 m_convert((data_t*)buffer, (data_t*)m_buffer.getBuffer(), 00076 length * specs.channels); 00077 }