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];
65 bool mDryGainHFAuto
: 1;
66 bool mWetGainAuto
: 1;
67 bool mWetGainHFAuto
: 1;
70 SendPropMap mEffectSlots
;
74 void resetProperties();
75 void applyProperties(bool looping
, ALuint offset
) const;
77 ALint
refillBufferStream();
79 void setFilterParams(ALuint
&filterid
, const FilterParams
¶ms
);
82 ALSource(ALContext
*context
);
85 ALuint
getId() const { return mId
; }
87 void updateNoCtxCheck();
90 void setGroup(ALSourceGroup
*group
);
94 void groupPropUpdate(ALfloat gain
, ALfloat pitch
);
97 void unsetPaused() { mPaused
= false; }
100 void play(Buffer buffer
);
101 void play(SharedPtr
<Decoder
> decoder
, ALuint updatelen
, ALuint queuesize
);
106 bool isPlaying() const;
107 bool isPaused() const;
109 void setPriority(ALuint priority
);
110 ALuint
getPriority() const { return mPriority
; }
112 void setOffset(uint64_t offset
);
113 uint64_t getOffset(uint64_t *latency
=0) const;
115 void setLooping(bool looping
);
116 bool getLooping() const { return mLooping
; }
118 void setPitch(ALfloat pitch
);
119 ALfloat
getPitch() const { return mPitch
; }
121 void setGain(ALfloat gain
);
122 ALfloat
getGain() const { return mGain
; }
124 void setGainRange(ALfloat mingain
, ALfloat maxgain
);
125 std::pair
<ALfloat
,ALfloat
> getGainRange() const
126 { return {mMinGain
, mMaxGain
}; }
128 void setDistanceRange(ALfloat refdist
, ALfloat maxdist
);
129 std::pair
<ALfloat
,ALfloat
> getDistanceRange() const
130 { return {mRefDist
, mMaxDist
}; }
132 void setPosition(ALfloat x
, ALfloat y
, ALfloat z
);
133 void setPosition(const ALfloat
*pos
);
134 Vector3
getPosition() const { return mPosition
; }
136 void setVelocity(ALfloat x
, ALfloat y
, ALfloat z
);
137 void setVelocity(const ALfloat
*vel
);
138 Vector3
getVelocity() const { return mVelocity
; }
140 void setDirection(ALfloat x
, ALfloat y
, ALfloat z
);
141 void setDirection(const ALfloat
*dir
);
142 Vector3
getDirection() const { return mDirection
; }
144 void setOrientation(ALfloat x1
, ALfloat y1
, ALfloat z1
, ALfloat x2
, ALfloat y2
, ALfloat z2
);
145 void setOrientation(const ALfloat
*at
, const ALfloat
*up
);
146 void setOrientation(const ALfloat
*ori
);
147 std::pair
<Vector3
,Vector3
> getOrientation() const
148 { return {mOrientation
[0], mOrientation
[1]}; }
150 void setConeAngles(ALfloat inner
, ALfloat outer
);
151 std::pair
<ALfloat
,ALfloat
> getConeAngles() const
152 { return {mConeInnerAngle
, mConeOuterAngle
}; }
154 void setOuterConeGains(ALfloat gain
, ALfloat gainhf
=1.0f
);
155 std::pair
<ALfloat
,ALfloat
> getOuterConeGains() const
156 { return {mConeOuterGain
, mConeOuterGainHF
}; }
158 void setRolloffFactors(ALfloat factor
, ALfloat roomfactor
=0.0f
);
159 std::pair
<ALfloat
,ALfloat
> getRolloffFactors() const
160 { return {mRolloffFactor
, mRoomRolloffFactor
}; }
162 void setDopplerFactor(ALfloat factor
);
163 ALfloat
getDopplerFactor() const { return mDopplerFactor
; }
165 void setRelative(bool relative
);
166 bool getRelative() const { return mRelative
; }
168 void setRadius(ALfloat radius
);
169 ALfloat
getRadius() const { return mRadius
; }
171 void setStereoAngles(ALfloat leftAngle
, ALfloat rightAngle
);
172 std::pair
<ALfloat
,ALfloat
> getStereoAngles() const
173 { return std::make_pair(mStereoAngles
[0], mStereoAngles
[1]); }
175 void setAirAbsorptionFactor(ALfloat factor
);
176 ALfloat
getAirAbsorptionFactor() const { return mAirAbsorptionFactor
; }
178 void setGainAuto(bool directhf
, bool send
, bool sendhf
);
179 std::tuple
<bool,bool,bool> getGainAuto() const
180 { return std::make_tuple(mDryGainHFAuto
, mWetGainAuto
, mWetGainHFAuto
); }
182 void setDirectFilter(const FilterParams
&filter
);
183 void setSendFilter(ALuint send
, const FilterParams
&filter
);
184 void setAuxiliarySend(AuxiliaryEffectSlot slot
, ALuint send
);
185 void setAuxiliarySendFilter(AuxiliaryEffectSlot slot
, ALuint send
, const FilterParams
&filter
);
194 #endif /* SOURCE_H */