6 #include <unordered_map>
18 AuxiliaryEffectSlotImpl
*mSlot
;
21 SendProps(AuxiliaryEffectSlotImpl
*slot
) : mSlot(slot
), mFilter(AL_FILTER_NULL
)
23 SendProps(ALuint filter
) : mSlot(0), mFilter(filter
)
25 SendProps(AuxiliaryEffectSlotImpl
*slot
, ALuint filter
) : mSlot(slot
), mFilter(filter
)
28 typedef std::unordered_map
<ALuint
,SendProps
> SendPropMap
;
31 ContextImpl
*const mContext
;
35 UniquePtr
<ALBufferStream
> mStream
;
37 SourceGroupImpl
*mGroup
;
41 std::chrono::steady_clock::time_point mLastFadeTime
;
42 std::chrono::steady_clock::time_point mFadeTimeTarget
;
43 ALfloat mFadeGainTarget
;
46 mutable std::mutex mMutex
;
47 std::atomic
<bool> mIsAsync
;
49 std::atomic
<bool> mPaused
;
53 ALfloat mMinGain
, mMaxGain
;
54 ALfloat mRefDist
, mMaxDist
;
58 Vector3 mOrientation
[2];
59 ALfloat mConeInnerAngle
, mConeOuterAngle
;
60 ALfloat mConeOuterGain
, mConeOuterGainHF
;
61 ALfloat mRolloffFactor
, mRoomRolloffFactor
;
62 ALfloat mDopplerFactor
;
63 ALfloat mAirAbsorptionFactor
;
65 ALfloat mStereoAngles
[2];
66 Spatialize mSpatialize
;
70 bool mDryGainHFAuto
: 1;
71 bool mWetGainAuto
: 1;
72 bool mWetGainHFAuto
: 1;
75 SendPropMap mEffectSlots
;
79 void resetProperties();
80 void applyProperties(bool looping
, ALuint offset
) const;
82 ALint
refillBufferStream();
84 void setFilterParams(ALuint
&filterid
, const FilterParams
¶ms
);
87 SourceImpl(ContextImpl
*context
);
90 ALuint
getId() const { return mId
; }
92 bool fadeUpdate(std::chrono::steady_clock::time_point cur_fade_time
);
93 bool playUpdate(ALuint id
);
97 void setGroup(SourceGroupImpl
*group
);
99 void groupPropUpdate(ALfloat gain
, ALfloat pitch
);
102 void unsetPaused() { mPaused
= false; }
103 void makeStopped(bool dolock
=true);
105 void play(Buffer buffer
);
106 void play(SharedPtr
<Decoder
> decoder
, ALuint updatelen
, ALuint queuesize
);
108 void fadeOutToStop(ALfloat gain
, std::chrono::milliseconds duration
);
112 bool isPlaying() const;
113 bool isPaused() const;
115 void setPriority(ALuint priority
);
116 ALuint
getPriority() const { return mPriority
; }
118 void setOffset(uint64_t offset
);
119 std::pair
<uint64_t,std::chrono::nanoseconds
> getSampleOffsetLatency() const;
120 std::pair
<Seconds
,Seconds
> getSecOffsetLatency() const;
122 void setLooping(bool looping
);
123 bool getLooping() const { return mLooping
; }
125 void setPitch(ALfloat pitch
);
126 ALfloat
getPitch() const { return mPitch
; }
128 void setGain(ALfloat gain
);
129 ALfloat
getGain() const { return mGain
; }
131 void setGainRange(ALfloat mingain
, ALfloat maxgain
);
132 std::pair
<ALfloat
,ALfloat
> getGainRange() const
133 { return {mMinGain
, mMaxGain
}; }
135 void setDistanceRange(ALfloat refdist
, ALfloat maxdist
);
136 std::pair
<ALfloat
,ALfloat
> getDistanceRange() const
137 { return {mRefDist
, mMaxDist
}; }
139 void set3DParameters(const Vector3
&position
, const Vector3
&velocity
, const Vector3
&direction
);
140 void set3DParameters(const Vector3
&position
, const Vector3
&velocity
, std::pair
<Vector3
,Vector3
> orientation
);
142 void setPosition(ALfloat x
, ALfloat y
, ALfloat z
);
143 void setPosition(const ALfloat
*pos
);
144 Vector3
getPosition() const { return mPosition
; }
146 void setVelocity(ALfloat x
, ALfloat y
, ALfloat z
);
147 void setVelocity(const ALfloat
*vel
);
148 Vector3
getVelocity() const { return mVelocity
; }
150 void setDirection(ALfloat x
, ALfloat y
, ALfloat z
);
151 void setDirection(const ALfloat
*dir
);
152 Vector3
getDirection() const { return mDirection
; }
154 void setOrientation(ALfloat x1
, ALfloat y1
, ALfloat z1
, ALfloat x2
, ALfloat y2
, ALfloat z2
);
155 void setOrientation(const ALfloat
*at
, const ALfloat
*up
);
156 void setOrientation(const ALfloat
*ori
);
157 std::pair
<Vector3
,Vector3
> getOrientation() const
158 { return {mOrientation
[0], mOrientation
[1]}; }
160 void setConeAngles(ALfloat inner
, ALfloat outer
);
161 std::pair
<ALfloat
,ALfloat
> getConeAngles() const
162 { return {mConeInnerAngle
, mConeOuterAngle
}; }
164 void setOuterConeGains(ALfloat gain
, ALfloat gainhf
=1.0f
);
165 std::pair
<ALfloat
,ALfloat
> getOuterConeGains() const
166 { return {mConeOuterGain
, mConeOuterGainHF
}; }
168 void setRolloffFactors(ALfloat factor
, ALfloat roomfactor
=0.0f
);
169 std::pair
<ALfloat
,ALfloat
> getRolloffFactors() const
170 { return {mRolloffFactor
, mRoomRolloffFactor
}; }
172 void setDopplerFactor(ALfloat factor
);
173 ALfloat
getDopplerFactor() const { return mDopplerFactor
; }
175 void setRelative(bool relative
);
176 bool getRelative() const { return mRelative
; }
178 void setRadius(ALfloat radius
);
179 ALfloat
getRadius() const { return mRadius
; }
181 void setStereoAngles(ALfloat leftAngle
, ALfloat rightAngle
);
182 std::pair
<ALfloat
,ALfloat
> getStereoAngles() const
183 { return std::make_pair(mStereoAngles
[0], mStereoAngles
[1]); }
185 void set3DSpatialize(Spatialize spatialize
);
186 Spatialize
get3DSpatialize() const { return mSpatialize
; }
188 void setResamplerIndex(ALsizei index
);
189 ALsizei
getResamplerIndex() const { return mResampler
; }
191 void setAirAbsorptionFactor(ALfloat factor
);
192 ALfloat
getAirAbsorptionFactor() const { return mAirAbsorptionFactor
; }
194 void setGainAuto(bool directhf
, bool send
, bool sendhf
);
195 std::tuple
<bool,bool,bool> getGainAuto() const
196 { return std::make_tuple(mDryGainHFAuto
, mWetGainAuto
, mWetGainHFAuto
); }
198 void setDirectFilter(const FilterParams
&filter
);
199 void setSendFilter(ALuint send
, const FilterParams
&filter
);
200 void setAuxiliarySend(AuxiliaryEffectSlot slot
, ALuint send
);
201 void setAuxiliarySendFilter(AuxiliaryEffectSlot slot
, ALuint send
, const FilterParams
&filter
);
207 struct SourceBufferUpdateEntry
{
211 struct SourceStreamUpdateEntry
{
217 #endif /* SOURCE_H */