Audaspace  1.3.0
A high level audio library.
Mixer.h
Go to the documentation of this file.
1 /*******************************************************************************
2  * Copyright 2009-2016 Jörg Müller
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  ******************************************************************************/
16 
17 #pragma once
18 
25 #include "respec/Specification.h"
27 #include "util/Buffer.h"
28 
29 #include <memory>
30 
32 
33 class IReader;
34 
40 {
41 private:
42  // delete copy constructor and operator=
43  Mixer(const Mixer&) = delete;
44  Mixer& operator=(const Mixer&) = delete;
45 
46 protected:
51 
55  int m_length;
56 
61 
66 
67 public:
72 
76  virtual ~Mixer() {}
77 
83 
88  void setSpecs(Specs specs);
89 
97  void mix(sample_t* buffer, int start, int length, float volume);
98 
107  void mix(sample_t* buffer, int start, int length, float volume_to, float volume_from);
108 
114  void read(data_t* buffer, float volume);
115 
120  void clear(int length);
121 };
122 
convert_f
void(* convert_f)(data_t *target, data_t *source, int length)
The function template for functions converting from one sample format to another, having the same par...
Definition: ConverterFunctions.h:35
Specs
Specification of a sound source.
Definition: Specification.h:110
Mixer::mix
void mix(sample_t *buffer, int start, int length, float volume)
Mixes a buffer.
Mixer::m_convert
convert_f m_convert
Converter function.
Definition: Mixer.h:65
ConverterFunctions.h
Defines several conversion functions between different sample formats.
Mixer::read
void read(data_t *buffer, float volume)
Writes the mixing buffer into an output buffer.
Mixer
This abstract class is able to mix audiosignals with same channel count and sample rate and convert i...
Definition: Mixer.h:40
DeviceSpecs
Specification of a sound device.
Definition: Specification.h:120
Mixer::clear
void clear(int length)
Clears the mixing buffer.
Mixer::m_specs
DeviceSpecs m_specs
The output specification.
Definition: Mixer.h:50
IReader
This class represents a sound source as stream or as buffer which can be read for example by another ...
Definition: IReader.h:35
Mixer::m_buffer
Buffer m_buffer
The mixing buffer.
Definition: Mixer.h:60
Mixer::getSpecs
DeviceSpecs getSpecs() const
Returns the target specification for superposing.
Mixer::setSpecs
void setSpecs(Specs specs)
Sets the target specification for superposing.
Specification.h
Defines all important macros and basic data structures for stream format descriptions.
Buffer.h
The Buffer class.
Mixer::Mixer
Mixer(DeviceSpecs specs)
Creates the mixer.
Buffer
This class is a simple buffer in RAM which is 32 Byte aligned and provides resize functionality.
Definition: Buffer.h:34
data_t
unsigned char data_t
Sample data type (format samples)
Definition: Audaspace.h:129
Mixer::~Mixer
virtual ~Mixer()
Destroys the mixer.
Definition: Mixer.h:76
AUD_NAMESPACE_END
#define AUD_NAMESPACE_END
Closes the audaspace namespace aud.
Definition: Audaspace.h:119
Mixer::mix
void mix(sample_t *buffer, int start, int length, float volume_to, float volume_from)
Mixes a buffer with linear volume interpolation.
Mixer::m_length
int m_length
The length of the mixing buffer.
Definition: Mixer.h:55
sample_t
float sample_t
Sample type.(float samples)
Definition: Audaspace.h:126
AUD_NAMESPACE_BEGIN
#define AUD_NAMESPACE_BEGIN
Opens the audaspace namespace aud.
Definition: Audaspace.h:116
AUD_API
#define AUD_API
Used for exporting symbols in the shared library.
Definition: Audaspace.h:93