Skip to content

Basic 3D audio added#114

Open
cappah wants to merge 29 commits into
TheCherno:masterfrom
cappah:master
Open

Basic 3D audio added#114
cappah wants to merge 29 commits into
TheCherno:masterfrom
cappah:master

Conversation

@cappah

@cappah cappah commented May 11, 2016

Copy link
Copy Markdown

Audio scales based on the distance of the object emitting sound within a given radius.

Audio is panned left, center or right based on the angle of the object emitting sound
in conjunction with the direction the camera is facing. Objects emitting sound that are
left of the camera in accordance to the camera's facing direction will pan the audio
to the left speaker for example.

@cappah

cappah commented May 17, 2016

Copy link
Copy Markdown
Author

UPDATE: 5/18/2016 SetPanByAngle broken

UPDATE: 5/19/2016 Fixed and improved SetPanByAngle
SetPanByAngle requires the following in the base Camera class:

protected:
float m_Yaw;
public:
inline float GetYaw() const { return m_Yaw; }

Example Usage
Within Test3D::OnInit():

audio::SoundManager::Add(new audio::Sound("name", "resource audio dir/name.*"));
audio::SoundManager::Get("name")->Loop();

Within Test3D::OnUpdate() (specifically in this order):

audio::SoundManager::Get("name")->SetGainByDistance(m_Scene->GetCamera()->GetPosition(), g_CubeTransform, 50.0f, 0.7f);
audio::SoundManager::Get("name")->SetPanByAngle(m_Scene->GetCamera()->GetPosition(), g_CubeTransform, m_Scene->GetCamera()->GetYaw(), 25.0f);

@Jacob-Mango

Copy link
Copy Markdown

I would recommend using SP_INFO instead of std::cout.

@cappah

cappah commented Jun 3, 2016

Copy link
Copy Markdown
Author

@Jacob-Mango That's part of the original Sound.cpp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants