|
Blender
V2.59
|
00001 /* 00002 * $Id: AUD_BaseIIRFilterReader.cpp 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 #include "AUD_BaseIIRFilterReader.h" 00033 00034 #include <cstring> 00035 00036 #define CC m_channels + m_channel 00037 00038 AUD_BaseIIRFilterReader::AUD_BaseIIRFilterReader(AUD_IReader* reader, int in, 00039 int out) : 00040 AUD_EffectReader(reader), 00041 m_channels(reader->getSpecs().channels), 00042 m_xlen(in), m_ylen(out), 00043 m_xpos(0), m_ypos(0), m_channel(0) 00044 { 00045 m_x = new sample_t[in * m_channels]; 00046 m_y = new sample_t[out * m_channels]; 00047 00048 memset(m_x, 0, sizeof(sample_t) * in * m_channels); 00049 memset(m_y, 0, sizeof(sample_t) * out * m_channels); 00050 } 00051 00052 AUD_BaseIIRFilterReader::~AUD_BaseIIRFilterReader() 00053 { 00054 delete[] m_x; 00055 delete[] m_y; 00056 } 00057 00058 void AUD_BaseIIRFilterReader::read(int & length, sample_t* & buffer) 00059 { 00060 sample_t* buf; 00061 00062 int samplesize = AUD_SAMPLE_SIZE(m_reader->getSpecs()); 00063 00064 m_reader->read(length, buf); 00065 00066 if(m_buffer.getSize() < length * samplesize) 00067 m_buffer.resize(length * samplesize); 00068 00069 buffer = m_buffer.getBuffer(); 00070 00071 for(m_channel = 0; m_channel < m_channels; m_channel++) 00072 { 00073 for(int i = 0; i < length; i++) 00074 { 00075 m_x[m_xpos * CC] = buf[i * CC]; 00076 m_y[m_ypos * CC] = buffer[i * CC] = filter(); 00077 00078 m_xpos = (m_xpos + 1) % m_xlen; 00079 m_ypos = (m_ypos + 1) % m_ylen; 00080 } 00081 } 00082 }