Examples for Sound Use.
#include "SoundDemo.h"
SoundDemo::SoundDemo() {
Matrix world = Matrix(SCALE, 10, 10, 10);
speaker->SetWorld(world);
sound->SetPos(speaker->getWorld().get(ROW_3));
cathedral->SetScale(100);
cave->SetScale(100);
}
SoundDemo::~SoundDemo() {
delete speaker;
}
void SoundDemo::Update() {
float speed = .5f;
float minZ = 50.0f;
float maxZ = 1500.0f;
float midZ = (minZ + maxZ) / 2.0f;
float ampZ = (maxZ - minZ) / 2.0f;
z = midZ + ampZ * sinf(t * 3.14159f * speed);
float minX = -200.0f;
float maxX = 200.0f;
float midX = (minX + maxX) / 2.0f;
float ampX = (maxX - minX) / 2.0f;
x = midX + ampX * sinf(t * 3.14159f * speed * .25f);
if (atWorld == false) {
SetPositions(200);
}
else {
SetPositions(20);
}
}
void SoundDemo::SetPositions(float f) {
switch (myState) {
case MoveState::STILL:
break;
case MoveState::FORWARD:
break;
case MoveState::SIDE:
break;
}
sound->SetPos(speaker->getWorld().get(ROW_3));
if (registerRev) {
switch (currPos) {
case RevPos::NONE:
switch (currType) {
case RevType::ROOM:
room->SetPos(0, f, 300);
cathedral->SetPos(0, f, -1000);
cave->SetPos(0, f, -1000);
break;
case RevType::CATHEDRAL:
cathedral->SetPos(0, f, 300);
room->SetPos(0, f, -1000);
cave->SetPos(0, f, -1000);
break;
case RevType::CAVE:
cave->SetPos(0, f, 300);
cathedral->SetPos(0, f, -1000);
room->SetPos(0, f, -1000);
break;
}
break;
case RevPos::EDGE:
switch (currType) {
case RevType::ROOM:
room->SetPos(0, f, 95);
cathedral->SetPos(0, f, -1000);
cave->SetPos(0, f, -1000);
break;
case RevType::CATHEDRAL:
cathedral->SetPos(0, f, 95);
room->SetPos(0, f, -1000);
cave->SetPos(0, f, -1000);
break;
case RevType::CAVE:
cave->SetPos(0, f, 95);
cathedral->SetPos(0, f, -1000);
room->SetPos(0, f, -1000);
break;
}
break;
case RevPos::FULL:
switch (currType) {
case RevType::ROOM:
room->SetPos(0, f, 0);
cathedral->SetPos(0, f, -1000);
cave->SetPos(0, f, -1000);
break;
case RevType::CATHEDRAL:
cathedral->SetPos(0, f, 0);
room->SetPos(0, f, -1000);
cave->SetPos(0, f, -1000);
break;
case RevType::CAVE:
cave->SetPos(0, f, 0);
cathedral->SetPos(0, f, -1000);
room->SetPos(0, f, -1000);
break;
}
break;
}
}
else {
room->SetPos(0, f, -1000);
cathedral->SetPos(0, f, -1000);
cave->SetPos(0, f, -1000);
}
}
void SoundDemo::Controls() {
pan->Add("");
pan->Add("");
pan->Add("ENABLING OCCLUSION");
pan->Add("9 : Enable Occlusion");
pan->Add("0 : Disable Occlusion");
pan->Add("");
pan->Add("CHANGING OCCLUDABLE MATERIAL");
pan->Add("5 : Terrain Dirt");
pan->Add("6 : Brick");
pan->Add("7 : Wool");
pan->Add("8 : Wood");
}
void SoundDemo::Draw() {
Controls();
room->Visualize();
cathedral->Visualize();
cave->Visualize();
}
void SoundDemo::KeyPress(AZUL_KEY k) {
switch (k) {
case AZUL_KEY::KEY_SPACE:
sound->Play();
break;
case AZUL_KEY::KEY_1:
break;
case AZUL_KEY::KEY_2:
break;
case AZUL_KEY::KEY_3:
break;
case AZUL_KEY::KEY_R:
if (registerRev == false) {
sound->Reverbable::SubmitRegistration();
registerRev = true;
}
break;
case AZUL_KEY::KEY_T:
if (registerRev == true) {
sound->Reverbable::SubmitDeregistration();
registerRev = false;
}
break;
case AZUL_KEY::KEY_Q:
currType = RevType::ROOM;
break;
case AZUL_KEY::KEY_W:
currType = RevType::CATHEDRAL;
break;
case AZUL_KEY::KEY_E:
currType = RevType::CAVE;
break;
case AZUL_KEY::KEY_A:
currPos = RevPos::NONE;
break;
case AZUL_KEY::KEY_S:
currPos = RevPos::EDGE;
break;
case AZUL_KEY::KEY_D:
currPos = RevPos::FULL;
break;
case AZUL_KEY::KEY_P:
sound->Pause();
break;
case AZUL_KEY::KEY_O:
sound->Stop();
break;
case AZUL_KEY::KEY_M:
sound->SetGain(volume);
break;
case AZUL_KEY::KEY_N:
sound->SetGain(volume);
break;
case AZUL_KEY::KEY_L:
sound->SetLooping(true);
break;
case AZUL_KEY::KEY_K:
sound->SetLooping(false);
break;
case AZUL_KEY::KEY_Z:
myState = MoveState::STILL;
break;
case AZUL_KEY::KEY_X:
myState = MoveState::FORWARD;
break;
case AZUL_KEY::KEY_C:
myState = MoveState::SIDE;
break;
case AZUL_KEY::KEY_9:
atWorld = false;
registerOcc = true;
sound->OccludableSnd::SubmitRegistration();
SceneManager::GetCurrScene()->
MoveCam(Vect(0, 1, 0), Vect(0, 200, 1, 0), Vect(0, 200, 0, 0));
break;
case AZUL_KEY::KEY_0:
atWorld = false;
registerOcc = false;
sound->OccludableSnd::SubmitDeregistration();
SceneManager::GetCurrScene()->
MoveCam(Vect(0, 1, 0), Vect(0, 200, 1, 0), Vect(0, 200, 0, 0));
break;
case AZUL_KEY::KEY_5:
if (registerOcc == true) {
atWorld = true;
SceneManager::GetCurrScene()->
MoveCam(Vect(0, 1, 0), Vect(0, 20, 1, 0), Vect(0, 20, 0, 0));
}
break;
case AZUL_KEY::KEY_6:
atWorld = false;
SceneManager::GetCurrScene()->
MoveCam(Vect(0, 1, 0), Vect(0, 200, 1, 0), Vect(0, 200, 0, 0));
break;
case AZUL_KEY::KEY_7:
atWorld = false;
SceneManager::GetCurrScene()->
MoveCam(Vect(0, 1, 0), Vect(0, 200, 1, 0), Vect(0, 200, 0, 0));
break;
case AZUL_KEY::KEY_8:
atWorld = false;
SceneManager::GetCurrScene()->
MoveCam(Vect(0, 1, 0), Vect(0, 200, 1, 0), Vect(0, 200, 0, 0));
break;
}
}
@ KEY_PRESS
Definition KeyStateCommon.h:6
void SubmitRegistration()
Called when wanting to show graphics objects on screen.
Definition Drawable.cpp:37
static int GetHeight()
Returns window's height in pixels.
Definition Game.h:174
static Model * GetModel(const MapKey &key)
Load Shader with KEY and AZUL's PREMADEMODELS.
Definition ModelManager.h:98
@ UNITBOX
Definition ModelManager.h:21
static const ALuint & GetReverb(DefaultReverbs key)
Returns Reverb from DEFAULT REVERBS.
Definition ReverbManager.h:85
@ CAVE
Definition ReverbManager.h:21
@ SMALLROOM
Definition ReverbManager.h:21
@ CATHEDRAL
Definition ReverbManager.h:21
void SetScale(float s)
Sets scale of Reverb Space. If generated with dynamic reverb, then recalculates.
Definition ReverbSpace.cpp:101
void SetListenerOrientation(Vect lookAt, Vect up)
Gets Listener Position. For more information go to Listener.
Definition Scene.cpp:153
void MoveCam(Vect up, Vect lookAt, Vect pos)
Moves Current Camera. For more information go to CameraManager.
Definition Scene.cpp:129
void ReturnReverbSpace(ReverbSpace *s)
Used to return a ReverbSpace to a scene.
Definition Scene.cpp:193
ReverbSpace * CreateReverbSpace(const ALuint &reverb)
Used to create a ReverbSpace with a reverb from ReverbManager.
Definition Scene.cpp:185
void UpdateCam()
Updates Current Camera. For more information go to CameraManager.
Definition Scene.cpp:133
void SetListenerPos(Vect p)
Sets Listener Position. For more information go to Listener.
Definition Scene.cpp:141
SoundSourceWorld * CreateSourceWorld()
Used to create a SoundSourceWorld.
Definition Scene.cpp:165
void ReturnSoundSource(SoundSourceWorld *w)
Used to return a sound to a scene.
Definition Scene.cpp:173
static Scene * GetCurrScene()
Returns pointer to current scene.
Definition SceneManager.h:51
static Panel * CreatePanel(int x, int y, Vect bkgColor=Vect(0, 0, 0, 0), Vect borderColor=Vect(0, 0, 0, 0))
Creates a panel for extra screen logging tools.
Definition ScreenLog.h:102
static void Add(char *A,...)
Adds a new line to the top left Screen Logger.
Definition ScreenLog.cpp:49
static ShaderObject * GetShader(const MapKey &key)
Returns shader object pointer with given KEY.
Definition ShaderManager.h:71
@ TEXTUREFLAT
Definition ShaderManager.h:20
static Sound GetSoundMono(const MapKey &key)
Returns Mono Sound with given KEY.
Definition SoundManager.h:93
virtual void SetSound(SoundManager::Sound s) override
Sets sound to be played.
Definition SoundSourceWorld.cpp:19
static Texture * GetTexture(const MapKey &key)
Returns texture pointer with given KEY.
Definition TextureManager.h:134
@ BLACK
Definition TextureManager.h:52
static float GetTime()
Returns Current Time.
Definition TimeManager.h:60
void SubmitRegistration()
Called when wanting to make changes every frame.
Definition Updatable.cpp:37
static void SetPos(Matrix &world, float x, float y, float z)
Sets world position to exact XYZ coordinates.
Definition MathTools.cpp:299
#include "OccludableDemo.h"
#include "SceneSwapTest.h"
OccludableDemo::OccludableDemo(Mat type) {
myType = type;
Vect LightColor(1.50f, 1.50f, 1.50f, 1.0f);
Vect LightPos(1.0f, 1.0f, 1.0f, 1.0f);
switch (myType)
{
case OccludableDemo::Mat::BRICK:
, LightColor, LightPos);
break;
case OccludableDemo::Mat::WOOL:
, LightColor, LightPos);
break;
case OccludableDemo::Mat::WOOD:
, LightColor, LightPos);
break;
}
Matrix world = Matrix(SCALE, 15, 15, 15);
pGObj_OccludableTest->SetWorld(world);
}
OccludableDemo::~OccludableDemo() {
delete pGObj_OccludableTest;
}
void OccludableDemo::SetPos(float x, float y, float z) {
}
void OccludableDemo::KeyPress(AZUL_KEY k) {
switch (k)
{
case AZUL_KEY::KEY_5:
SetPos(0, 200, -100);
break;
case AZUL_KEY::KEY_6:
if (myType == Mat::BRICK) {
SetPos(0, 200, 100);
}
else {
SetPos(0, 200, -100);
}
break;
case AZUL_KEY::KEY_7:
if (myType == Mat::WOOL) {
SetPos(0, 200, 100);
}
else {
SetPos(0, 200, -100);
}
break;
case AZUL_KEY::KEY_8:
if (myType == Mat::WOOD) {
SetPos(0, 200, 100);
}
else {
SetPos(0, 200, -100);
}
break;
case AZUL_KEY::KEY_9:
enabled = true;
if (myType == Mat::BRICK) {
SetPos(0, 200, 100);
}
else {
SetPos(0, 200, -100);
}
break;
case AZUL_KEY::KEY_0:
enabled = false;
break;
}
if (enabled == false) {
SetPos(0, 200, -100);
}
}
void OccludableDemo::Draw() {
}
void SetOcclusionModel(Model *mod)
Stores an Objects Occlusion Model for calculating collisions.
Definition OccludableObj.cpp:69
virtual void SubmitRegistration(float mat)
Called when wanting to make an object block sounds.
Definition OccludableObj.cpp:49
void UpdateOcclusionData(const Matrix &mat)
Updates Objects Occlusion Model for proper scaling and positioning.
Definition OccludableObj.cpp:73
@ TEXTURELIGHT
Definition ShaderManager.h:20
static const float Curtains
Definition MaterialsCommon.h:20
static const float Wood
Definition MaterialsCommon.h:18
static const float Brick
Definition MaterialsCommon.h:15