6 #include <unordered_map>
18 class ALAuxiliaryEffectSlot
;
22 ALAuxiliaryEffectSlot
*mSlot
;
25 SendProps(ALAuxiliaryEffectSlot
*slot
) : mSlot(slot
), mFilter(AL_FILTER_NULL
)
27 SendProps(ALuint filter
) : mSlot(0), mFilter(filter
)
29 SendProps(ALAuxiliaryEffectSlot
*slot
, ALuint filter
) : mSlot(slot
), mFilter(filter
)
32 typedef std::unordered_map
<ALuint
,SendProps
> SendPropMap
;
35 ALContext
*const mContext
;
39 UniquePtr
<ALBufferStream
> mStream
;
41 ALSourceGroup
*mGroup
;
43 mutable std::mutex mMutex
;
44 std::atomic
<bool> mIsAsync
;
46 std::atomic
<bool> mPaused
;
50 ALfloat mMinGain
, mMaxGain
;
51 ALfloat mRefDist
, mMaxDist
;
55 Vector3 mOrientation
[2];
56 ALfloat mConeInnerAngle
, mConeOuterAngle
;
57 ALfloat mConeOuterGain
, mConeOuterGainHF
;
58 ALfloat mRolloffFactor
, mRoomRolloffFactor
;
59 ALfloat mDopplerFactor
;
60 ALfloat mAirAbsorptionFactor
;
62 ALfloat mStereoAngles
[2];
63 Spatialize mSpatialize
;
67 bool mDryGainHFAuto
: 1;
68 bool mWetGainAuto
: 1;
69 bool mWetGainHFAuto
: 1;
72 SendPropMap mEffectSlots
;
76 void resetProperties();
77 void applyProperties(bool looping
, ALuint offset
) const;
79 ALint
refillBufferStream();
81 void setFilterParams(ALuint
&filterid
, const FilterParams
¶ms
);
84 ALSource(ALContext
*context
);
87 ALuint
getId() const { return mId
; }
89 void updateNoCtxCheck();
92 void setGroup(ALSourceGroup
*group
);
96 void groupPropUpdate(ALfloat gain
, ALfloat pitch
);
99 void unsetPaused() { mPaused
= false; }
102 void play(Buffer buffer
);
103 void play(SharedPtr
<Decoder
> decoder
, ALuint updatelen
, ALuint queuesize
);
108 bool isPlaying() const;
109 bool isPaused() const;
111 void setPriority(ALuint priority
);
112 ALuint
getPriority() const { return mPriority
; }
114 void setOffset(uint64_t offset
);
115 std::pair
<uint64_t,std::chrono::nanoseconds
> getSampleOffsetLatency() const;
116 std::pair
<Seconds
,Seconds
> getSecOffsetLatency() const;
118 void setLooping(bool looping
);
119 bool getLooping() const { return mLooping
; }
121 void setPitch(ALfloat pitch
);
122 ALfloat
getPitch() const { return mPitch
; }
124 void setGain(ALfloat gain
);
125 ALfloat
getGain() const { return mGain
; }
127 void setGainRange(ALfloat mingain
, ALfloat maxgain
);
128 std::pair
<ALfloat
,ALfloat
> getGainRange() const
129 { return {mMinGain
, mMaxGain
}; }
131 void setDistanceRange(ALfloat refdist
, ALfloat maxdist
);
132 std::pair
<ALfloat
,ALfloat
> getDistanceRange() const
133 { return {mRefDist
, mMaxDist
}; }
135 void set3DParameters(const Vector3
&position
, const Vector3
&velocity
, const Vector3
&direction
);
136 void set3DParameters(const Vector3
&position
, const Vector3
&velocity
, std::pair
<Vector3
,Vector3
> orientation
);
138 void setPosition(ALfloat x
, ALfloat y
, ALfloat z
);
139 void setPosition(const ALfloat
*pos
);
140 Vector3
getPosition() const { return mPosition
; }
142 void setVelocity(ALfloat x
, ALfloat y
, ALfloat z
);
143 void setVelocity(const ALfloat
*vel
);
144 Vector3
getVelocity() const { return mVelocity
; }
146 void setDirection(ALfloat x
, ALfloat y
, ALfloat z
);
147 void setDirection(const ALfloat
*dir
);
148 Vector3
getDirection() const { return mDirection
; }
150 void setOrientation(ALfloat x1
, ALfloat y1
, ALfloat z1
, ALfloat x2
, ALfloat y2
, ALfloat z2
);
151 void setOrientation(const ALfloat
*at
, const ALfloat
*up
);
152 void setOrientation(const ALfloat
*ori
);
153 std::pair
<Vector3
,Vector3
> getOrientation() const
154 { return {mOrientation
[0], mOrientation
[1]}; }
156 void setConeAngles(ALfloat inner
, ALfloat outer
);
157 std::pair
<ALfloat
,ALfloat
> getConeAngles() const
158 { return {mConeInnerAngle
, mConeOuterAngle
}; }
160 void setOuterConeGains(ALfloat gain
, ALfloat gainhf
=1.0f
);
161 std::pair
<ALfloat
,ALfloat
> getOuterConeGains() const
162 { return {mConeOuterGain
, mConeOuterGainHF
}; }
164 void setRolloffFactors(ALfloat factor
, ALfloat roomfactor
=0.0f
);
165 std::pair
<ALfloat
,ALfloat
> getRolloffFactors() const
166 { return {mRolloffFactor
, mRoomRolloffFactor
}; }
168 void setDopplerFactor(ALfloat factor
);
169 ALfloat
getDopplerFactor() const { return mDopplerFactor
; }
171 void setRelative(bool relative
);
172 bool getRelative() const { return mRelative
; }
174 void setRadius(ALfloat radius
);
175 ALfloat
getRadius() const { return mRadius
; }
177 void setStereoAngles(ALfloat leftAngle
, ALfloat rightAngle
);
178 std::pair
<ALfloat
,ALfloat
> getStereoAngles() const
179 { return std::make_pair(mStereoAngles
[0], mStereoAngles
[1]); }
181 void set3DSpatialize(Spatialize spatialize
);
182 Spatialize
get3DSpatialize() const { return mSpatialize
; }
184 void setResamplerIndex(ALsizei index
);
185 ALsizei
getResamplerIndex() const { return mResampler
; }
187 void setAirAbsorptionFactor(ALfloat factor
);
188 ALfloat
getAirAbsorptionFactor() const { return mAirAbsorptionFactor
; }
190 void setGainAuto(bool directhf
, bool send
, bool sendhf
);
191 std::tuple
<bool,bool,bool> getGainAuto() const
192 { return std::make_tuple(mDryGainHFAuto
, mWetGainAuto
, mWetGainHFAuto
); }
194 void setDirectFilter(const FilterParams
&filter
);
195 void setSendFilter(ALuint send
, const FilterParams
&filter
);
196 void setAuxiliarySend(AuxiliaryEffectSlot slot
, ALuint send
);
197 void setAuxiliarySendFilter(AuxiliaryEffectSlot slot
, ALuint send
, const FilterParams
&filter
);
204 #endif /* SOURCE_H */