4 * ***** BEGIN LGPL LICENSE BLOCK *****
6 * Copyright 2009 Jörg Hermann Müller
8 * This file is part of AudaSpace.
10 * AudaSpace is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
15 * AudaSpace is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with AudaSpace. If not, see <http://www.gnu.org/licenses/>.
23 * ***** END LGPL LICENSE BLOCK *****
26 #include "AUD_DefaultMixer.h"
27 #include "AUD_SRCResampleReader.h"
28 #include "AUD_ChannelMapperReader.h"
29 #include "AUD_ChannelMapperFactory.h"
33 AUD_DefaultMixer::AUD_DefaultMixer(AUD_DeviceSpecs specs) :
38 AUD_IReader* AUD_DefaultMixer::prepare(AUD_IReader* reader)
40 // hacky for now, until a better channel mapper reader is available
41 AUD_ChannelMapperFactory cmf(NULL, m_specs);
43 AUD_Specs specs = reader->getSpecs();
45 // if channel count is lower in output, rechannel before resampling
46 if(specs.channels < m_specs.channels)
48 reader = new AUD_ChannelMapperReader(reader,
49 cmf.getMapping(specs.channels));
50 specs.channels = m_specs.channels;
54 if(specs.rate != m_specs.rate)
55 reader = new AUD_SRCResampleReader(reader, m_specs.specs);
58 if(specs.channels != m_specs.channels)
59 reader = new AUD_ChannelMapperReader(reader,
60 cmf.getMapping(specs.channels));