15 AuxiliaryEffectSlotImpl
*mSlot
{nullptr};
16 ALuint mFilter
{AL_FILTER_NULL
};
18 SendProps(ALuint send
, AuxiliaryEffectSlotImpl
*slot
) : mSendIdx(send
), mSlot(slot
)
20 SendProps(ALuint send
, ALuint filter
) : mSendIdx(send
), mFilter(filter
)
22 SendProps(ALuint send
, AuxiliaryEffectSlotImpl
*slot
, ALuint filter
)
23 : mSendIdx(send
), mSlot(slot
), mFilter(filter
)
27 struct SourceBufferUpdateEntry
{
31 struct SourceStreamUpdateEntry
{
35 struct SourceFadeUpdateEntry
{
38 std::chrono::nanoseconds mFadeTimeStart
;
39 std::chrono::nanoseconds mFadeTimeTarget
;
41 ALfloat mFadeGainMult
;
46 ContextImpl
&mContext
;
50 UniquePtr
<ALBufferStream
> mStream
;
52 SourceGroupImpl
*mGroup
;
58 mutable std::mutex mMutex
;
59 std::atomic
<bool> mIsAsync
;
61 std::atomic
<bool> mPaused
;
65 ALfloat mMinGain
, mMaxGain
;
66 ALfloat mRefDist
, mMaxDist
;
70 Vector3 mOrientation
[2];
71 ALfloat mConeInnerAngle
, mConeOuterAngle
;
72 ALfloat mConeOuterGain
, mConeOuterGainHF
;
73 ALfloat mRolloffFactor
, mRoomRolloffFactor
;
74 ALfloat mDopplerFactor
;
75 ALfloat mAirAbsorptionFactor
;
77 ALfloat mStereoAngles
[2];
78 Spatialize mSpatialize
;
82 bool mDryGainHFAuto
: 1;
83 bool mWetGainAuto
: 1;
84 bool mWetGainHFAuto
: 1;
87 Vector
<SendProps
> mEffectSlots
;
91 void resetProperties();
92 void applyProperties(bool looping
) const;
94 ALint
refillBufferStream();
96 void setFilterParams(ALuint
&filterid
, const FilterParams
¶ms
);
99 SourceImpl(ContextImpl
&context
);
102 ALuint
getId() const { return mId
; }
104 bool checkPending(SharedFuture
<Buffer
> &future
);
105 bool fadeUpdate(std::chrono::nanoseconds cur_fade_time
, SourceFadeUpdateEntry
&fade
);
106 bool playUpdate(ALuint id
);
111 void groupPropUpdate(ALfloat gain
, ALfloat pitch
);
114 void unsetPaused() { mPaused
= false; }
116 void play(Buffer buffer
);
117 void play(SharedPtr
<Decoder
>&& decoder
, ALsizei chunk_len
, ALsizei queue_size
);
118 void play(SharedFuture
<Buffer
>&& future_buffer
);
120 void makeStopped(bool dolock
=true);
121 void fadeOutToStop(ALfloat gain
, std::chrono::milliseconds duration
);
125 bool isPending() const;
126 bool isPlaying() const;
127 bool isPaused() const;
128 bool isPlayingOrPending() const;
130 void setGroup(SourceGroup group
);
131 SourceGroup
getGroup() const { return SourceGroup(mGroup
); }
133 void setPriority(ALuint priority
);
134 ALuint
getPriority() const { return mPriority
; }
136 void setOffset(uint64_t offset
);
137 std::pair
<uint64_t,std::chrono::nanoseconds
> getSampleOffsetLatency() const;
138 std::pair
<Seconds
,Seconds
> getSecOffsetLatency() const;
140 void setLooping(bool looping
);
141 bool getLooping() const { return mLooping
; }
143 void setPitch(ALfloat pitch
);
144 ALfloat
getPitch() const { return mPitch
; }
146 void setGain(ALfloat gain
);
147 ALfloat
getGain() const { return mGain
; }
149 void setGainRange(ALfloat mingain
, ALfloat maxgain
);
150 std::pair
<ALfloat
,ALfloat
> getGainRange() const
151 { return {mMinGain
, mMaxGain
}; }
153 void setDistanceRange(ALfloat refdist
, ALfloat maxdist
);
154 std::pair
<ALfloat
,ALfloat
> getDistanceRange() const
155 { return {mRefDist
, mMaxDist
}; }
157 void set3DParameters(const Vector3
&position
, const Vector3
&velocity
, const Vector3
&direction
);
158 void set3DParameters(const Vector3
&position
, const Vector3
&velocity
, const std::pair
<Vector3
,Vector3
> &orientation
);
160 void setPosition(const Vector3
&position
);
161 void setPosition(const ALfloat
*pos
);
162 Vector3
getPosition() const { return mPosition
; }
164 void setVelocity(const Vector3
&velocity
);
165 void setVelocity(const ALfloat
*vel
);
166 Vector3
getVelocity() const { return mVelocity
; }
168 void setDirection(const Vector3
&direction
);
169 void setDirection(const ALfloat
*dir
);
170 Vector3
getDirection() const { return mDirection
; }
172 void setOrientation(const std::pair
<Vector3
,Vector3
> &orientation
);
173 void setOrientation(const ALfloat
*at
, const ALfloat
*up
);
174 void setOrientation(const ALfloat
*ori
);
175 std::pair
<Vector3
,Vector3
> getOrientation() const
176 { return {mOrientation
[0], mOrientation
[1]}; }
178 void setConeAngles(ALfloat inner
, ALfloat outer
);
179 std::pair
<ALfloat
,ALfloat
> getConeAngles() const
180 { return {mConeInnerAngle
, mConeOuterAngle
}; }
182 void setOuterConeGains(ALfloat gain
, ALfloat gainhf
=1.0f
);
183 std::pair
<ALfloat
,ALfloat
> getOuterConeGains() const
184 { return {mConeOuterGain
, mConeOuterGainHF
}; }
186 void setRolloffFactors(ALfloat factor
, ALfloat roomfactor
=0.0f
);
187 std::pair
<ALfloat
,ALfloat
> getRolloffFactors() const
188 { return {mRolloffFactor
, mRoomRolloffFactor
}; }
190 void setDopplerFactor(ALfloat factor
);
191 ALfloat
getDopplerFactor() const { return mDopplerFactor
; }
193 void setRelative(bool relative
);
194 bool getRelative() const { return mRelative
; }
196 void setRadius(ALfloat radius
);
197 ALfloat
getRadius() const { return mRadius
; }
199 void setStereoAngles(ALfloat leftAngle
, ALfloat rightAngle
);
200 std::pair
<ALfloat
,ALfloat
> getStereoAngles() const
201 { return std::make_pair(mStereoAngles
[0], mStereoAngles
[1]); }
203 void set3DSpatialize(Spatialize spatialize
);
204 Spatialize
get3DSpatialize() const { return mSpatialize
; }
206 void setResamplerIndex(ALsizei index
);
207 ALsizei
getResamplerIndex() const { return mResampler
; }
209 void setAirAbsorptionFactor(ALfloat factor
);
210 ALfloat
getAirAbsorptionFactor() const { return mAirAbsorptionFactor
; }
212 void setGainAuto(bool directhf
, bool send
, bool sendhf
);
213 std::tuple
<bool,bool,bool> getGainAuto() const
214 { return std::make_tuple(mDryGainHFAuto
, mWetGainAuto
, mWetGainHFAuto
); }
216 void setDirectFilter(const FilterParams
&filter
);
217 void setSendFilter(ALuint send
, const FilterParams
&filter
);
218 void setAuxiliarySend(AuxiliaryEffectSlot slot
, ALuint send
);
219 void setAuxiliarySendFilter(AuxiliaryEffectSlot slot
, ALuint send
, const FilterParams
&filter
);
226 #endif /* SOURCE_H */