/[svn]/linuxsampler/trunk/src/drivers/audio/AudioChannel.h
ViewVC logotype

Annotation of /linuxsampler/trunk/src/drivers/audio/AudioChannel.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 724 - (hide annotations) (download) (as text)
Mon Jul 25 09:28:00 2005 UTC (18 years, 9 months ago) by iliev
File MIME type: text/x-c++hdr
File size: 6530 byte(s)
- Fixed some typos

1 schoenebeck 200 /***************************************************************************
2     * *
3     * LinuxSampler - modular, streaming capable sampler *
4     * *
5     * Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck *
6     * *
7     * This program is free software; you can redistribute it and/or modify *
8     * it under the terms of the GNU General Public License as published by *
9     * the Free Software Foundation; either version 2 of the License, or *
10     * (at your option) any later version. *
11     * *
12     * This program is distributed in the hope that it will be useful, *
13     * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15     * GNU General Public License for more details. *
16     * *
17     * You should have received a copy of the GNU General Public License *
18     * along with this program; if not, write to the Free Software *
19     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
20     * MA 02111-1307 USA *
21     ***************************************************************************/
22    
23     #ifndef __LS_AUDIOCHANNEL_H__
24     #define __LS_AUDIOCHANNEL_H__
25    
26     #include <map>
27     #include <vector>
28     #include <string.h>
29     #include "../../common/global.h"
30     #include "../DeviceParameter.h"
31    
32     namespace LinuxSampler {
33    
34     /** Audio Channel (always mono)
35     *
36     * This class is used for routing audio signals between arbitrary sources
37     * and destinations. You can either create a normal channel like:
38     *
39     * AudioChannel c1(512); // create unnamed channel
40     * AudioChannel c2(512, "Effect send mono channel"); // create named channel
41     *
42     * Or you can create a mix channel, e.g. the following would create a
43     * normal channel first, and the second channel is just a copy of the
44     * first channel:
45     *
46     * AudioChannel mono_chan(512, "Effect send channel"); // real channel
47     * AudioChannel mix_chan(&mono_chan, "Effect send mono channel"); // mix channel
48     *
49     * So in the last example, when writing to 'mix_chan' the signal will
50     * actually be mixed to the 'mono_chan' channel, so this is an easy way
51     * to downmix a signal source which has more audio channels than the
52     * signal destination can offer.
53     */
54     class AudioChannel {
55     public:
56     class ParameterName : public DeviceRuntimeParameterString {
57     public:
58     ParameterName(String s) : DeviceRuntimeParameterString(s) {}
59     virtual String Description() { return "Arbitrary name"; }
60     virtual bool Fix() { return false; }
61     virtual std::vector<String> PossibilitiesAsString() { return std::vector<String>(); }
62     virtual void OnSetValue(String s) { /* nothing to do */ }
63     };
64    
65     class ParameterIsMixChannel : public DeviceRuntimeParameterBool {
66     public:
67     ParameterIsMixChannel(bool b) : DeviceRuntimeParameterBool(b) {}
68 iliev 724 virtual String Description() { return "Whether real channel or mixed to another channel"; }
69 schoenebeck 200 virtual bool Fix() { return true; }
70     virtual void OnSetValue(bool b) throw (LinuxSamplerException) { /* cannot happen, as parameter is fix */ }
71     };
72    
73     class ParameterMixChannelDestination : public DeviceRuntimeParameterInt {
74     public:
75     ParameterMixChannelDestination(int i) : DeviceRuntimeParameterInt(i) {}
76     virtual String Description() { return "Destination channel of this mix channel"; }
77     virtual bool Fix() { return true; }
78     virtual optional<int> RangeMinAsInt() { return optional<int>::nothing; /*TODO: needs to be implemented */ }
79     virtual optional<int> RangeMaxAsInt() { return optional<int>::nothing; /*TODO: needs to be implemented */ }
80     virtual std::vector<int> PossibilitiesAsInt() { return std::vector<int>(); /*TODO: needs to be implemented */ }
81     virtual void OnSetValue(int i) throw (LinuxSamplerException) { /*TODO: needs to be implemented */ }
82     };
83    
84     // attributes
85     //String Name; ///< Arbitrary name of this audio channel
86    
87     // methods
88     inline float* Buffer() { return pBuffer; } ///< Audio signal buffer
89     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.
90     inline void Clear() { memset(pBuffer, 0, uiBufferSize * sizeof(float)); } ///< Reset audio buffer with silence
91     std::map<String,DeviceRuntimeParameter*> ChannelParameters();
92 schoenebeck 226
93     // constructors / destructor
94     AudioChannel(uint ChannelNr, uint BufferSize);
95     AudioChannel(uint ChannelNr, float* pBuffer, uint BufferSize);
96     AudioChannel(uint ChannelNr, AudioChannel* pMixChannelDestination);
97     virtual ~AudioChannel();
98     protected:
99     uint ChannelNr;
100     std::map<String,DeviceRuntimeParameter*> Parameters;
101 schoenebeck 200 private:
102     float* pBuffer;
103     uint uiBufferSize;
104     AudioChannel* pMixChannel;
105     bool UsesExternalBuffer;
106     };
107     }
108    
109     #endif // __LS_AUDIOCHANNEL_H__

  ViewVC Help
Powered by ViewVC