2
* $Id: AUD_Mixer.h 26712 2010-02-08 15:37:38Z nexyon $
4
* ***** BEGIN LGPL LICENSE BLOCK *****
6
* Copyright 2009 Jörg Hermann Müller
2
* ***** BEGIN GPL LICENSE BLOCK *****
4
* Copyright 2009-2011 Jörg Hermann Müller
8
6
* 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
8
* Audaspace is free software; you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License as published by
10
* the Free Software Foundation; either version 2 of the License, or
13
11
* (at your option) any later version.
15
13
* AudaSpace is distributed in the hope that it will be useful,
16
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
15
* 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 *****
29
#define AUD_MIXER_RESAMPLER AUD_SRCResampleFactory
16
* GNU General Public License for more details.
18
* You should have received a copy of the GNU General Public License
19
* along with Audaspace; if not, write to the Free Software Foundation,
20
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22
* ***** END GPL LICENSE BLOCK *****
25
/** \file audaspace/intern/AUD_Mixer.h
26
* \ingroup audaspaceintern
30
#ifndef __AUD_MIXER_H__
31
#define __AUD_MIXER_H__
31
33
#include "AUD_ConverterFunctions.h"
32
class AUD_ConverterFactory;
33
class AUD_MIXER_RESAMPLER;
34
class AUD_ChannelMapperFactory;
34
#include "AUD_Buffer.h"
35
#include "AUD_Reference.h"
39
struct AUD_MixerBuffer
48
* This class is able to mix audiosignals of different channel count and sample
49
* rate and convert it to a specific output format.
50
* It uses a default ChannelMapperFactory and a SRCResampleFactory for
39
* This abstract class is able to mix audiosignals with same channel count
40
* and sample rate and convert it to a specific output format.
57
* The resampling factory that resamples all readers for superposition.
59
AUD_MIXER_RESAMPLER* m_resampler;
62
* The channel mapper factory that maps all readers for superposition.
64
AUD_ChannelMapperFactory* m_mapper;
67
* The list of buffers to superpose.
69
std::list<AUD_MixerBuffer> m_buffers;
72
46
* The output specification.
74
48
AUD_DeviceSpecs m_specs;
77
* The temporary mixing buffer.
51
* The length of the mixing buffer.
82
61
* Converter function.
88
67
* Creates the mixer.
69
AUD_Mixer(AUD_DeviceSpecs specs);
93
72
* Destroys the mixer.
98
* This funuction prepares a reader for playback.
99
* \param reader The reader to prepare.
100
* \return The reader that should be used for playback.
102
AUD_IReader* prepare(AUD_IReader* reader);
74
virtual ~AUD_Mixer() {}
105
77
* Returns the target specification for superposing.
106
78
* \return The target specification.
108
AUD_DeviceSpecs getSpecs();
80
AUD_DeviceSpecs getSpecs() const;
111
83
* Sets the target specification for superposing.
112
84
* \param specs The target specification.
114
void setSpecs(AUD_DeviceSpecs specs);
86
void setSpecs(AUD_Specs specs);
117
* Adds a buffer for superposition.
118
90
* \param buffer The buffer to superpose.
119
91
* \param start The start sample of the buffer.
120
92
* \param length The length of the buffer in samples.
121
93
* \param volume The mixing volume. Must be a value between 0.0 and 1.0.
123
void add(sample_t* buffer, int start, int length, float volume);
95
void mix(sample_t* buffer, int start, int length, float volume);
126
* Superposes all added buffers into an output buffer.
98
* Writes the mixing buffer into an output buffer.
127
99
* \param buffer The target buffer for superposing.
100
* \param volume The mixing volume. Must be a value between 0.0 and 1.0.
102
void read(data_t* buffer, float volume);
105
* Clears the mixing buffer.
128
106
* \param length The length of the buffer in samples.
129
* \param volume The mixing volume. Must be a value between 0.0 and 1.0.
131
void superpose(data_t* buffer, int length, float volume);
108
void clear(int length);
111
#endif //__AUD_MIXER_H__