23 |
#ifndef __LS_AUDIOCHANNEL_H__ |
#ifndef __LS_AUDIOCHANNEL_H__ |
24 |
#define __LS_AUDIOCHANNEL_H__ |
#define __LS_AUDIOCHANNEL_H__ |
25 |
|
|
26 |
|
#include <map> |
27 |
|
#include <vector> |
28 |
#include <string.h> |
#include <string.h> |
29 |
#include "../common/global.h" |
#include "../common/global.h" |
30 |
|
#include "../drivers/DeviceParameter.h" |
31 |
|
|
32 |
namespace LinuxSampler { |
namespace LinuxSampler { |
33 |
|
|
53 |
*/ |
*/ |
54 |
class AudioChannel { |
class AudioChannel { |
55 |
public: |
public: |
56 |
|
|
57 |
|
class ParameterName : public DeviceRuntimeParameterString { |
58 |
|
public: |
59 |
|
ParameterName(String s) : DeviceRuntimeParameterString(s) {} |
60 |
|
virtual String Description() { return "Arbitrary name"; } |
61 |
|
virtual bool Fix() { return false; } |
62 |
|
virtual std::vector<String> PossibilitiesAsString() { return std::vector<String>(); } |
63 |
|
virtual void OnSetValue(String s) { /* nothing to do */ } |
64 |
|
}; |
65 |
|
|
66 |
|
class ParameterIsMixChannel : public DeviceRuntimeParameterBool { |
67 |
|
public: |
68 |
|
ParameterIsMixChannel(bool b) : DeviceRuntimeParameterBool(b) {} |
69 |
|
virtual String Description() { return "Wether real channel or mixed to another channel"; } |
70 |
|
virtual bool Fix() { return true; } |
71 |
|
virtual void OnSetValue(bool b) throw (LinuxSamplerException) { /* cannot happen, as parameter is fix */ } |
72 |
|
}; |
73 |
|
|
74 |
|
class ParameterMixChannelDestination : public DeviceRuntimeParameterInt { |
75 |
|
public: |
76 |
|
ParameterMixChannelDestination(int i) : DeviceRuntimeParameterInt(i) {} |
77 |
|
virtual String Description() { return "Destination channel of this mix channel"; } |
78 |
|
virtual bool Fix() { return true; } |
79 |
|
virtual optional<int> RangeMinAsInt() { return optional<int>::nothing; /*TODO: needs to be implemented */ } |
80 |
|
virtual optional<int> RangeMaxAsInt() { return optional<int>::nothing; /*TODO: needs to be implemented */ } |
81 |
|
virtual std::vector<int> PossibilitiesAsInt() { return std::vector<int>(); /*TODO: needs to be implemented */ } |
82 |
|
virtual void OnSetValue(int i) throw (LinuxSamplerException) { /*TODO: needs to be implemented */ } |
83 |
|
}; |
84 |
|
|
85 |
// attributes |
// attributes |
86 |
String Name; ///< Arbitrary name of this audio channel |
//String Name; ///< Arbitrary name of this audio channel |
87 |
|
|
88 |
// constructors / destructor |
// constructors / destructor |
89 |
AudioChannel(uint BufferSize, String Name = "unnamed"); |
#ifdef __GNUC__ |
90 |
AudioChannel(float* pBuffer, uint BufferSize, String Name = "unnamed"); |
typedef std::map<String,DeviceRuntimeParameter*> DeviceRuntimeParameterMap; // nasty workaround for a GCC bug (see GCC bug #15980, #57) |
91 |
AudioChannel(AudioChannel* pMixChannel, String Name = "unnamed"); |
AudioChannel(uint BufferSize, String Name = "unnamed", std::map<String,DeviceRuntimeParameter*> ChannelParameters = DeviceRuntimeParameterMap()); |
92 |
~AudioChannel(); |
AudioChannel(float* pBuffer, uint BufferSize, String Name = "unnamed", std::map<String,DeviceRuntimeParameter*> ChannelParameters = DeviceRuntimeParameterMap()); |
93 |
|
AudioChannel(AudioChannel* pMixChannel, String Name = "unnamed", std::map<String,DeviceRuntimeParameter*> ChannelParameters = DeviceRuntimeParameterMap()); |
94 |
|
#else |
95 |
|
AudioChannel(uint BufferSize, String Name = "unnamed", std::map<String,DeviceRuntimeParameter*> ChannelParameters = std::map<String,DeviceRuntimeParameter*>()); |
96 |
|
AudioChannel(float* pBuffer, uint BufferSize, String Name = "unnamed", std::map<String,DeviceRuntimeParameter*> ChannelParameters = std::map<String,DeviceRuntimeParameter*>()); |
97 |
|
AudioChannel(AudioChannel* pMixChannel, String Name = "unnamed", std::map<String,DeviceRuntimeParameter*> ChannelParameters = std::map<String,DeviceRuntimeParameter*>()); |
98 |
|
#endif // __GNUC__ |
99 |
|
virtual ~AudioChannel(); |
100 |
|
|
101 |
// methods |
// methods |
102 |
inline float* Buffer() { return pBuffer; } ///< Audio signal buffer |
inline float* Buffer() { return pBuffer; } ///< Audio signal buffer |
103 |
inline AudioChannel* MixChannel() { return pMixChannel; } ///< In case this channel is a mix channel, then it will return a pointer to the real channel this channel refers to, NULL otherwise. |
inline AudioChannel* MixChannel() { return pMixChannel; } ///< In case this channel is a mix channel, then it will return a pointer to the real channel this channel refers to, NULL otherwise. |
104 |
inline void Clear() { memset(pBuffer, 0, uiBufferSize * sizeof(float)); } ///< Reset audio buffer with silence |
inline void Clear() { memset(pBuffer, 0, uiBufferSize * sizeof(float)); } ///< Reset audio buffer with silence |
105 |
|
std::map<String,DeviceRuntimeParameter*> ChannelParameters(); |
106 |
private: |
private: |
107 |
float* pBuffer; |
float* pBuffer; |
108 |
uint uiBufferSize; |
uint uiBufferSize; |
109 |
AudioChannel* pMixChannel; |
AudioChannel* pMixChannel; |
110 |
bool UsesExternalBuffer; |
bool UsesExternalBuffer; |
111 |
|
std::map<String,DeviceRuntimeParameter*> mParameters; |
112 |
}; |
}; |
113 |
} |
} |
114 |
|
|