00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef __LS_AUDIOCHANNEL_H__
00025 #define __LS_AUDIOCHANNEL_H__
00026
00027 #include <map>
00028 #include <vector>
00029 #include <string.h>
00030 #include "../../common/global.h"
00031 #include "../../common/Exception.h"
00032 #include "../DeviceParameter.h"
00033
00034 namespace LinuxSampler {
00035
00056 class AudioChannel {
00057 public:
00058 class ParameterName : public DeviceRuntimeParameterString {
00059 public:
00060 ParameterName(String s) : DeviceRuntimeParameterString(s) {}
00061 virtual String Description() { return "Arbitrary name"; }
00062 virtual bool Fix() { return false; }
00063 virtual std::vector<String> PossibilitiesAsString() { return std::vector<String>(); }
00064 virtual void OnSetValue(String s) { }
00065 };
00066
00067 class ParameterIsMixChannel : public DeviceRuntimeParameterBool {
00068 public:
00069 ParameterIsMixChannel(bool b) : DeviceRuntimeParameterBool(b) {}
00070 virtual String Description() { return "Whether real channel or mixed to another channel"; }
00071 virtual bool Fix() { return true; }
00072 virtual void OnSetValue(bool b) throw (Exception) { }
00073 };
00074
00075 class ParameterMixChannelDestination : public DeviceRuntimeParameterInt {
00076 public:
00077 ParameterMixChannelDestination(int i) : DeviceRuntimeParameterInt(i) {}
00078 virtual String Description() { return "Destination channel of this mix channel"; }
00079 virtual bool Fix() { return true; }
00080 virtual optional<int> RangeMinAsInt() { return optional<int>::nothing; }
00081 virtual optional<int> RangeMaxAsInt() { return optional<int>::nothing; }
00082 virtual std::vector<int> PossibilitiesAsInt() { return std::vector<int>(); }
00083 virtual void OnSetValue(int i) throw (Exception) { }
00084 };
00085
00086
00087
00088
00089
00090 inline float* Buffer() { return pBuffer; }
00091 void SetBuffer(float* pBuffer) { this->pBuffer = pBuffer; }
00092 inline AudioChannel* MixChannel() { return pMixChannel; }
00093 inline void Clear() { memset(pBuffer, 0, uiBufferSize * sizeof(float)); }
00094 inline void Clear(uint Samples) { memset(pBuffer, 0, Samples * sizeof(float)); }
00095 void CopyTo(AudioChannel* pDst, const uint Samples);
00096 void CopyTo(AudioChannel* pDst, const uint Samples, const float fLevel);
00097 void MixTo(AudioChannel* pDst, const uint Samples);
00098 void MixTo(AudioChannel* pDst, const uint Samples, const float fLevel);
00099 std::map<String,DeviceRuntimeParameter*> ChannelParameters();
00100
00101
00102 AudioChannel(uint ChannelNr, uint BufferSize);
00103 AudioChannel(uint ChannelNr, float* pBuffer, uint BufferSize);
00104 AudioChannel(uint ChannelNr, AudioChannel* pMixChannelDestination);
00105 virtual ~AudioChannel();
00106 protected:
00107 uint ChannelNr;
00108 std::map<String,DeviceRuntimeParameter*> Parameters;
00109 private:
00110 float* pBuffer;
00111 uint uiBufferSize;
00112 AudioChannel* pMixChannel;
00113 bool UsesExternalBuffer;
00114 };
00115 }
00116
00117 #endif // __LS_AUDIOCHANNEL_H__