Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic 3D audio added #114

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open

Basic 3D audio added #114

wants to merge 29 commits into from

Conversation

cappah
Copy link

@cappah cappah commented May 11, 2016

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
Copy link
Author

cappah commented May 17, 2016

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

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

@cappah
Copy link
Author

cappah commented Jun 3, 2016

@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