CSL  6.0
DistanceSimulator.h
Go to the documentation of this file.
1 //
2 // DistanceSimulator.h -- Specification of the DistanceSimulators
3 // See the copyright notice and acknowledgment of authors in the file COPYRIGHT
4 // Created by Jorge Castellanos on 6/23/06. Hacked 8/09 by STP.
5 //
6 
7 #ifndef DISTANCE_SIMULATOR_H
8 #define DISTANCE_SIMULATOR_H
9 #include "SpatialSource.h"
10 
11 #include "CSL_Core.h"
12 #include "CPoint.h"
13 
14 namespace csl {
15 
16 class IntensityAttenuationCue;
17 class AirAbsorptionCue;
18 
19 /// Only handles single sound sources because objects have different positions.
20 /// Two objects can't ocuppy the same position, and usually distance cues go before the
21 /// panning, so handling multiple sources by one Distance simulator, would producde a multi-channel
22 /// object, where the positions aren't dynamic anymore.
23 
25 public:
26  DistanceSimulator(UnitGenerator &source); // A UGen without position information. In this case, the distance simulator is the spatial source.
29 
30  virtual void nextBuffer(Buffer & outputBuffer, unsigned outBufNum) throw (CException);
31  /// Returns wether the sound source position changed since last block call.
32  virtual bool positionChanged();
33 
34 protected:
35  // SoundSource ... it refers to its input UGen, but with the knowledge of its position within a space.
36 // SpatialSource *mSource; // list of spatial inputs
39 
40 };
41 
42 /// Pure Abstract Base Class for all distance cues.
43 /// A DistanceCue subclass is just an algorithm that modifies a signal based on the distance from the listener.
44 /// Distance Cues should hold their state, so when "process" is called they can modify the signal buffer given.
45 /// When "compute" is called is usually due to a change in distance, so if anything has to be re-calculated, it's done.
46 
47 class DistanceCue {
48 public:
49  DistanceCue() { };
50  virtual ~DistanceCue() { };
51 
52  virtual void compute(float distance) = 0;
53  virtual void process(Buffer &inputBuffer) = 0;
54 
55 };
56 
57 /// Sound attenuation due to increasing distance. This "Base" Class uses the inverse square law.
58 /// Subclass for other methods.
59 
61 public:
63  virtual ~IntensityAttenuationCue() { };
64 
65  virtual void compute(float distance);
66  virtual void process(Buffer &aBuffer);
67 
68 protected:
69  float mGain;
70 
71 };
72 
73 /// Simulates the frequency dependent air absorption using a one pole/zero lowpass filter.
74 
75 class AirAbsorptionCue : public DistanceCue {
76 public:
78  virtual ~AirAbsorptionCue();
79 
80  virtual void compute(float distance); ///< Calculate the filter coefficients.
81  virtual void process(Buffer &aBuffer); ///< Process each sample in the buffer, applying the filter.
82 
83 protected:
84  float mBCoeff;
85  float mACoeff[2];
86  float mPrevOutput;
87  float mPrevInput;
88 
89 };
90 
91 //class AirAbsorptionCue : public DistanceCue {
92 //public:
93 // AirAbsorptionCue();
94 // virtual ~AirAbsorptionCue();
95 //
96 // virtual void compute(float distance);
97 // virtual void process(Buffer &aBuffer);
98 //
99 //protected:
100 // float mBCoeff[3];
101 // float mACoeff[3];
102 // float mPrevOutputs[3];
103 // float mPrevInputs[3];
104 //
105 //};
106 
107 }
108 
109 #endif
AirAbsorptionCue * mAirAbsorptionCue
virtual void compute(float distance)
virtual bool positionChanged()
Returns wether the sound source position changed since last block call.
virtual void process(Buffer &aBuffer)
Process each sample in the buffer, applying the filter.
AdditiveInstrument.h – Sum-of-sines synthesis instrument class.
Definition: Accessor.h:17
virtual void compute(float distance)
Calculate the filter coefficients.
IntensityAttenuationCue * mIntensityCue
Only handles single sound sources because objects have different positions. Two objects can't ocuppy ...
Sound attenuation due to increasing distance. This "Base" Class uses the inverse square law...
Simulates the frequency dependent air absorption using a one pole/zero lowpass filter.
virtual void compute(float distance)=0
virtual void nextBuffer(Buffer &outputBuffer, unsigned outBufNum)
really compute the next buffer given an offset base channel; this is called by nextBuffer, possibly multiple times
Pure Abstract Base Class for all distance cues. A DistanceCue subclass is just an algorithm that modi...
virtual void process(Buffer &inputBuffer)=0
Temp Spatial Sound Source.
Definition: SpatialSource.h:29
virtual void process(Buffer &aBuffer)
DistanceSimulator(UnitGenerator &source)
Buffer – the multi-channel sample buffer class (passed around between generators and IO guys)...
Definition: CSL_Core.h:106
forward declaration
Definition: CSL_Core.h:241
Base class of CSL exceptions (written upper-case). Has a string message.