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_SDLMixer.h"
27 #include "AUD_SDLMixerFactory.h"
31 AUD_SDLMixer::AUD_SDLMixer()
36 AUD_SDLMixer::~AUD_SDLMixer()
40 delete m_factory; AUD_DELETE("factory")
44 AUD_IReader* AUD_SDLMixer::prepare(AUD_IReader* reader)
46 m_factory->setReader(reader);
47 return m_factory->createReader();
50 void AUD_SDLMixer::setSpecs(AUD_Specs specs)
52 m_samplesize = AUD_SAMPLE_SIZE(specs);
55 delete m_factory; AUD_DELETE("factory")
57 m_factory = new AUD_SDLMixerFactory(specs); AUD_NEW("factory")
60 void AUD_SDLMixer::add(sample_t* buffer, AUD_Specs specs, int length,
63 AUD_SDLMixerBuffer buf;
67 m_buffers.push_back(buf);
70 void AUD_SDLMixer::superpose(sample_t* buffer, int length, float volume)
72 AUD_SDLMixerBuffer buf;
74 while(!m_buffers.empty())
76 buf = m_buffers.front();
77 m_buffers.pop_front();
78 SDL_MixAudio((Uint8*)buffer,
80 buf.length * m_samplesize,
81 (int)(SDL_MIX_MAXVOLUME * volume * buf.volume));