linuxsampler 2.3.1
AudioChannel.h
Go to the documentation of this file.
1/***************************************************************************
2 * *
3 * LinuxSampler - modular, streaming capable sampler *
4 * *
5 * Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck *
6 * Copyright (C) 2005 - 2013 Christian Schoenebeck *
7 * *
8 * This program 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 *
11 * (at your option) any later version. *
12 * *
13 * This program is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU General Public License *
19 * along with this program; if not, write to the Free Software *
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
21 * MA 02111-1307 USA *
22 ***************************************************************************/
23
24#ifndef __LS_AUDIOCHANNEL_H__
25#define __LS_AUDIOCHANNEL_H__
26
27#include <map>
28#include <vector>
29#include <string.h>
30#include "../../common/global.h"
31#include "../../common/Exception.h"
32#include "../DeviceParameter.h"
33
34namespace LinuxSampler {
35
57 public:
59 public:
61 virtual String Description() OVERRIDE { return "Arbitrary name"; }
62 virtual bool Fix() OVERRIDE { return false; }
63 virtual std::vector<String> PossibilitiesAsString() OVERRIDE { return std::vector<String>(); }
64 virtual void OnSetValue(String s) OVERRIDE { /* nothing to do */ }
65 };
66
68 public:
70 virtual String Description() OVERRIDE { return "Whether real channel or mixed to another channel"; }
71 virtual bool Fix() OVERRIDE { return true; }
72 virtual void OnSetValue(bool b) throw (Exception) OVERRIDE { /* cannot happen, as parameter is fix */ }
73 };
74
76 public:
78 virtual String Description() OVERRIDE { return "Destination channel of this mix channel"; }
79 virtual bool Fix() OVERRIDE { return true; }
80 virtual optional<int> RangeMinAsInt() OVERRIDE { return optional<int>::nothing; /*TODO: needs to be implemented */ }
81 virtual optional<int> RangeMaxAsInt() OVERRIDE { return optional<int>::nothing; /*TODO: needs to be implemented */ }
82 virtual std::vector<int> PossibilitiesAsInt() OVERRIDE { return std::vector<int>(); /*TODO: needs to be implemented */ }
83 virtual void OnSetValue(int i) throw (Exception) OVERRIDE { /*TODO: needs to be implemented */ }
84 };
85
86 // attributes
87 //String Name; ///< Arbitrary name of this audio channel
88
89 // methods
90 inline float* Buffer() { return pBuffer; }
91 void SetBuffer(float* pBuffer) { this->pBuffer = pBuffer; }
92 inline AudioChannel* MixChannel() { return pMixChannel; }
93 inline void Clear() { memset(pBuffer, 0, uiBufferSize * sizeof(float)); }
94 inline void Clear(uint Samples) { memset(pBuffer, 0, Samples * sizeof(float)); }
95 void CopyTo(AudioChannel* pDst, const uint Samples);
96 void CopyTo(AudioChannel* pDst, const uint Samples, const float fLevel);
97 void MixTo(AudioChannel* pDst, const uint Samples);
98 void MixTo(AudioChannel* pDst, const uint Samples, const float fLevel);
99 std::map<String,DeviceRuntimeParameter*> ChannelParameters();
100
101 // constructors / destructor
103 AudioChannel(uint ChannelNr, float* pBuffer, uint BufferSize);
105 virtual ~AudioChannel();
106 protected:
108 std::map<String,DeviceRuntimeParameter*> Parameters;
109 private:
110 float* pBuffer;
111 uint uiBufferSize;
112 AudioChannel* pMixChannel;
113 bool UsesExternalBuffer;
114 };
115}
116
117#endif // __LS_AUDIOCHANNEL_H__
virtual bool Fix() OVERRIDE
Whether the parameter is read only.
virtual void OnSetValue(bool b) OVERRIDE
Must be implemented be a driver's parameter class to react on the parameter value being set / altered...
virtual String Description() OVERRIDE
A human readable description, explaining the exact purpose of the driver parameter.
virtual optional< int > RangeMinAsInt() OVERRIDE
Must be implemented by descendant, returning a minimum int value for the parameter.
virtual bool Fix() OVERRIDE
Whether the parameter is read only.
virtual void OnSetValue(int i) OVERRIDE
Must be implemented be a driver's parameter class to react on the parameter value being set / altered...
virtual optional< int > RangeMaxAsInt() OVERRIDE
Must be implemented by descendant, returning a maximum int value for the parameter.
virtual String Description() OVERRIDE
A human readable description, explaining the exact purpose of the driver parameter.
virtual std::vector< int > PossibilitiesAsInt() OVERRIDE
Must be implemented by descendant, returning a list of possible int values for the parameter.
virtual std::vector< String > PossibilitiesAsString() OVERRIDE
Must be implemented by descendant, returning a list of possible String values for the parameter.
virtual bool Fix() OVERRIDE
Whether the parameter is read only.
virtual void OnSetValue(String s) OVERRIDE
Must be implemented be a driver's parameter class to react on the parameter value being set / altered...
virtual String Description() OVERRIDE
A human readable description, explaining the exact purpose of the driver parameter.
Audio Channel (always mono)
virtual ~AudioChannel()
Destructor.
void SetBuffer(float *pBuffer)
void Clear(uint Samples)
Reset audio buffer with silence.
float * Buffer()
Audio signal buffer.
std::map< String, DeviceRuntimeParameter * > Parameters
void CopyTo(AudioChannel *pDst, const uint Samples)
Copies audio data (unmodified) from this AudioChannel to the given destination AudioChannel.
std::map< String, DeviceRuntimeParameter * > ChannelParameters()
void Clear()
Reset audio buffer with silence.
void MixTo(AudioChannel *pDst, const uint Samples)
Copies audio data (unmodified) from this AudioChannel and mixes it to the given destination AudioChan...
AudioChannel * MixChannel()
In case this channel is a mix channel, then it will return a pointer to the real channel this channel...
Abstract base class for driver parameters of type bool.
Abstract base class for driver parameters of type int.
Abstract base class for driver parameters of type String.
Exception that will be thrown in NON REAL TIME PARTS of the LinuxSampler application.
Definition Exception.h:37
Wraps as a kind of pointer class some data object shared with other threads, to protect / synchronize...
#define OVERRIDE
Definition global.h:84
std::string String
Definition global.h:44