Audaspace  1.4.0
A high level audio library.
ChannelMapperReader.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 "fx/EffectReader.h"
26 #include "util/Buffer.h"
27 
29 
35 {
36 private:
40  Buffer m_buffer;
41 
45  Channels m_target_channels;
46 
50  Channels m_source_channels;
51 
55  float* m_mapping;
56 
60  int m_map_size;
61 
65  float m_mono_angle;
66 
67  static const Channel MONO_MAP[];
68  static const Channel STEREO_MAP[];
69  static const Channel STEREO_LFE_MAP[];
70  static const Channel SURROUND4_MAP[];
71  static const Channel SURROUND5_MAP[];
72  static const Channel SURROUND51_MAP[];
73  static const Channel SURROUND61_MAP[];
74  static const Channel SURROUND71_MAP[];
75  static const Channel* CHANNEL_MAPS[];
76 
77  static const float MONO_ANGLES[];
78  static const float STEREO_ANGLES[];
79  static const float STEREO_LFE_ANGLES[];
80  static const float SURROUND4_ANGLES[];
81  static const float SURROUND5_ANGLES[];
82  static const float SURROUND51_ANGLES[];
83  static const float SURROUND61_ANGLES[];
84  static const float SURROUND71_ANGLES[];
85  static const float* CHANNEL_ANGLES[];
86 
87  // delete copy constructor and operator=
89  ChannelMapperReader& operator=(const ChannelMapperReader&) = delete;
90 
94  void AUD_LOCAL calculateMapping();
95 
99  float AUD_LOCAL angleDistance(float alpha, float beta);
100 
101 public:
107  ChannelMapperReader(std::shared_ptr<IReader> reader, Channels channels);
108 
113 
118  Channels getSourceChannels() const;
119 
125  Channels getChannels() const;
126 
131  void setChannels(Channels channels);
132 
139  float getMapping(int source, int target);
140 
145  void setMonoAngle(float angle);
146 
147  virtual Specs getSpecs() const;
148  virtual void read(int& length, bool& eos, sample_t* buffer);
149 };
150 
#define AUD_NAMESPACE_BEGIN
Opens the audaspace namespace aud.
Definition: Audaspace.h:116
virtual Specs getSpecs() const
Returns the specification of the reader.
Channels
The channel count.
Definition: Specification.h:58
#define AUD_API
Used for exporting symbols in the shared library.
Definition: Audaspace.h:93
Channel
The channel names.
Definition: Specification.h:72
This class maps a sound source&#39;s channels to a specific output channel count.
Definition: ChannelMapperReader.h:34
Specification of a sound source.
Definition: Specification.h:109
This reader is a base class for all effect readers that take one other reader as input.
Definition: EffectReader.h:35
The EffectReader class.
This class is a simple buffer in RAM which is 32 Byte aligned and provides resize functionality...
Definition: Buffer.h:33
float sample_t
Sample type.(float samples)
Definition: Audaspace.h:126
#define AUD_NAMESPACE_END
Closes the audaspace namespace aud.
Definition: Audaspace.h:119
#define AUD_LOCAL
Used for hiding symbols from export in the shared library.
Definition: Audaspace.h:80
virtual void read(int &length, bool &eos, sample_t *buffer)
Request to read the next length samples out of the source.
The Buffer class.