1//************************************ bs::framework - Copyright 2018 Marko Pintera **************************************//
2//*********** Licensed under the MIT license. See LICENSE.md for full terms. This notice is not to be removed. ***********//
3#include "Audio/BsAudioSource.h"
4#include "Audio/BsAudio.h"
5#include "Math/BsMath.h"
6#include "Private/RTTI/BsAudioSourceRTTI.h"
7
8namespace bs
9{
10 void AudioSource::setClip(const HAudioClip& clip)
11 {
12 mAudioClip = clip;
13
14 markListenerResourcesDirty();
15 }
16
17 void AudioSource::setVelocity(const Vector3& velocity)
18 {
19 mVelocity = velocity;
20 }
21
22 void AudioSource::setVolume(float volume)
23 {
24 mVolume = Math::clamp01(volume);
25 }
26
27 void AudioSource::setPitch(float pitch)
28 {
29 mPitch = pitch;
30 }
31
32 void AudioSource::setIsLooping(bool loop)
33 {
34 mLoop = loop;
35 }
36
37 void AudioSource::setPriority(INT32 priority)
38 {
39 mPriority = priority;
40 }
41
42 void AudioSource::setMinDistance(float distance)
43 {
44 mMinDistance = distance;
45 }
46
47 void AudioSource::setAttenuation(float attenuation)
48 {
49 mAttenuation = attenuation;
50 }
51
52 SPtr<AudioSource> AudioSource::create()
53 {
54 return gAudio().createSource();
55 }
56
57 void AudioSource::getListenerResources(Vector<HResource>& resources)
58 {
59 if (mAudioClip != nullptr)
60 resources.push_back(mAudioClip);
61 }
62
63 void AudioSource::notifyResourceChanged(const HResource& resource)
64 {
65 onClipChanged();
66 }
67
68 RTTITypeBase* AudioSource::getRTTIStatic()
69 {
70 return AudioSourceRTTI::instance();
71 }
72
73 RTTITypeBase* AudioSource::getRTTI() const
74 {
75 return AudioSource::getRTTIStatic();
76 }
77}
78