1 / 15

GAM532 DPS932 – Week 10

GAM532 DPS932 – Week 10. 3 D Audio. 3D Sound and The Scene. Mono Sound Effects. Stereo Music. Mono vs Stereo. Left - Right 100% 100% Ch 1 Ch 1. Mono Sound File. One Channel. Left - Right 100% 100% Ch 1 Ch 2. Stereo Sound File. Two Channels.

eljah
Download Presentation

GAM532 DPS932 – Week 10

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. GAM532DPS932 – Week 10 3D Audio

  2. 3D Sound and The Scene Mono Sound Effects Stereo Music

  3. Mono vs Stereo Left - Right100% 100% Ch 1Ch 1 Mono Sound File One Channel Left - Right100% 100% Ch 1Ch 2 Stereo Sound File Two Channels

  4. 3D Sound and The Scene Mono Sound Effects Stereo Music

  5. Deriving Spatial Info From Matrix Up Direction [ 23, 32, -17 ] Forward Direction Orientation Position [ 0, 1, 0, 0 ] * AbsTransform = Up Direction Forward Direction = [ 0, 0, -1, 0 ] * AbsTransform Position Vector = [ 0, 0, 0, 1 ] * AbsTransform

  6. Initializing 3D Audio #include <X3DAudio.h> #pragma comment (lib, "X3DAudio.lib") //After XAudio2 is initialized… XAUDIO2_DEVICE_DETAILS vd; engine->GetDeviceDetails(0, &vd); //initialize the 3D audio system X3DAudioInitialize(vd.OutputFormat.dwChannelMask, X3DAUDIO_SPEED_OF_SOUND, x3h); X3DAUDIO_DSP_SETTINGS set; //used later set.SrcChannelCount = 1; set.DstChannelCount = vd.OutputFormat.Format.nChannels; set.pMatrixCoefficients = new float[set.DstChannelCount]; //No additional initialization must be done with OpenAL

  7. Emitter Spatial Information Directionality Distance, Direction, & Velocity Up Direction Attenuation Doppler Effect Forward Direction Position Vector

  8. Initializing a 3D Emitter X3DAUDIO_EMITTER emt; ZeroMemory(&emit, sizeof(emit)); emt.ChannelCount = 1; //sets # output channels emt.CurveDistanceScaler = 14; emit.DopplerScaler= 1; emit.InnerRadius= 2; emit.ChannelRadius= 1; //Note: This simply prepares the struct, the //listener info isn’t updated yet //No additional code required for OpenAL

  9. Updating Emitter //Sets the spatial information of the emitter emt.OrientFront = frontVec;//3 float array emt.OrientTop = upVec; emt.Position = posVec; //Note: This simply prepares the struct, the //emitter info isn’t updated yet //Sets the spatial information of the emitter alSourcefv(src, AL_POSITION, posVec);//3 float array alSourcefv(src, AL_ORIENTATION, forwardVec); //3 float //Unlike DX, this sets the emitter information //immediately

  10. Listener Spatial Information Left - Right70% 70% Left - Right80%20% Left - Right20% 80% Up Direction Right Channel Left Channel Forward Direction Position Vector Listener facing screen

  11. Updating Listener X3DAUDIO_LISTENER lst; //Sets the spatial information of the listener lst.OrientFront = frontVec;//3 float array lst.OrientTop = upVec; Lst.Position = posVec; //Note: This simply prepares the struct, the //listener info isn’t updated yet //Sets the spatial information of the listener alListenerfv(AL_POSITION, posVec);//3 float array //6 float array, first 3 up vector, last 3 forward vector alListenerfv(AL_ORIENTATION, ori); //Unlike DX, this sets the listeners information //immediately

  12. Applying 3D Audio in XAudio2 X3DAudioCalculate(x3h, &lst, //The listener struct &emt, //The emitter struct X3DAUDIO_CALCULATE_MATRIX, //instruct the calculation of the sound matrix &set); //DPS struct to be used below engine->SetOutputMatrix(master, //The master voice 1, //number of source channels vd.OutputFormat.Format.nChannels, //number of output channels set.pMatrixCoefficients); //Sound matrix

  13. Doppler Effect

  14. Updating Emitter Velocity //Sets the spatial information of the emitter emt.Velocity = velocity; //when updating the emitter X3DAudioCalculate(x3h, &lst, &emt, X3DAUDIO_CALCULATE_MATRIX | X3DAUDIO_CALCULATE_DOPPLER, &set); //Sets the spatial information of the emitter alSourcefv(src, AL_VELOCITY, velocity);//3 float array

  15. To Do • Continue work on your enhancement • Work on OpenGL labs

More Related