From 4dfc021599bc781e5720ac993e797a9c6beb3ed2 Mon Sep 17 00:00:00 2001 From: turanszkij Date: Mon, 7 Oct 2019 19:25:24 +0100 Subject: [PATCH] audio fixes, added reverb settings --- Documentation/ScriptingAPI-Documentation.md | 37 ++++++ Editor/SoundWindow.cpp | 44 +++++- Editor/SoundWindow.h | 3 +- WickedEngine/wiAudio.cpp | 140 ++++++++++++++++---- WickedEngine/wiAudio.h | 35 +++++ WickedEngine/wiAudio_BindLua.cpp | 49 +++++++ WickedEngine/wiAudio_BindLua.h | 1 + WickedEngine/wiECS.h | 2 +- WickedEngine/wiSceneSystem_Serializers.cpp | 13 +- WickedEngine/wiVersion.cpp | 2 +- 10 files changed, 293 insertions(+), 33 deletions(-) diff --git a/Documentation/ScriptingAPI-Documentation.md b/Documentation/ScriptingAPI-Documentation.md index ffe136bad..476130976 100644 --- a/Documentation/ScriptingAPI-Documentation.md +++ b/Documentation/ScriptingAPI-Documentation.md @@ -17,6 +17,9 @@ The documentation completion is still pending.... 4. DrawRecAnim 3. Texture 4. Audio + 1. Sound + 2. SoundInstance + 3. SoundInstance3D 5. Vector 6. Matrix 7. Scene System (using entity-component system) @@ -294,6 +297,7 @@ Loads and plays an audio files. - GetSubmixVolume(int submixtype) : float -- returns the volume of the submix group - SetSubmixVolume(int submixtype, float volume) -- sets the volume for a submix group - Update3D(SoundInstance soundinstance, SoundInstance3D instance3D) -- adds 3D effect to the sound instance +- SetReverb(int reverbtype) -- sets an environment effect for reverb globally. Refer to Reverb Types section for acceptable input values #### Sound An audio file. Can be instanced several times via SoundInstance. @@ -324,6 +328,39 @@ The submix types group sound instances together to be controlled together - [outer]SUBMIX_TYPE_USER0 : int -- user submix group - [outer]SUBMIX_TYPE_USER1 : int -- user submix group +#### Reverb Types +The reverb types are built in presets that can mimic a specific kind of environment +- [outer]REVERB_PRESET_DEFAULT : int +- [outer]REVERB_PRESET_GENERIC : int +- [outer]REVERB_PRESET_FOREST : int +- [outer]REVERB_PRESET_PADDEDCELL : int +- [outer]REVERB_PRESET_ROOM : int +- [outer]REVERB_PRESET_BATHROOM : int +- [outer]REVERB_PRESET_LIVINGROOM : int +- [outer]REVERB_PRESET_STONEROOM : int +- [outer]REVERB_PRESET_AUDITORIUM : int +- [outer]REVERB_PRESET_CONCERTHALL : int +- [outer]REVERB_PRESET_CAVE : int +- [outer]REVERB_PRESET_ARENA : int +- [outer]REVERB_PRESET_HANGAR : int +- [outer]REVERB_PRESET_CARPETEDHALLWAY : int +- [outer]REVERB_PRESET_HALLWAY : int +- [outer]REVERB_PRESET_STONECORRIDOR : int +- [outer]REVERB_PRESET_ALLEY : int +- [outer]REVERB_PRESET_CITY : int +- [outer]REVERB_PRESET_MOUNTAINS : int +- [outer]REVERB_PRESET_QUARRY : int +- [outer]REVERB_PRESET_PLAIN : int +- [outer]REVERB_PRESET_PARKINGLOT : int +- [outer]REVERB_PRESET_SEWERPIPE : int +- [outer]REVERB_PRESET_UNDERWATER : int +- [outer]REVERB_PRESET_SMALLROOM : int +- [outer]REVERB_PRESET_MEDIUMROOM : int +- [outer]REVERB_PRESET_LARGEROOM : int +- [outer]REVERB_PRESET_MEDIUMHALL : int +- [outer]REVERB_PRESET_LARGEHALL : int +- [outer]REVERB_PRESET_PLATE : int + ### Vector A four component floating point vector. Provides efficient calculations with SIMD support. - [outer]vector diff --git a/Editor/SoundWindow.cpp b/Editor/SoundWindow.cpp index c6b308188..55bdfaa89 100644 --- a/Editor/SoundWindow.cpp +++ b/Editor/SoundWindow.cpp @@ -1,5 +1,6 @@ #include "stdafx.h" #include "SoundWindow.h" +#include "wiAudio.h" #include @@ -19,7 +20,7 @@ SoundWindow::SoundWindow(wiGUI* gui) : GUI(gui) float screenH = (float)wiRenderer::GetDevice()->GetScreenHeight(); soundWindow = new wiWindow(GUI, "Sound Window"); - soundWindow->SetSize(XMFLOAT2(440, 240)); + soundWindow->SetSize(XMFLOAT2(440, 340)); soundWindow->SetEnabled(false); GUI->AddWidget(soundWindow); @@ -27,6 +28,47 @@ SoundWindow::SoundWindow(wiGUI* gui) : GUI(gui) float y = 0; float step = 35; + reverbComboBox = new wiComboBox("Reverb: "); + reverbComboBox->SetPos(XMFLOAT2(x + 80, y += step)); + reverbComboBox->SetSize(XMFLOAT2(180, 25)); + reverbComboBox->OnSelect([&](wiEventArgs args) { + wiAudio::SetReverb((wiAudio::REVERB_PRESET)args.iValue); + }); + reverbComboBox->AddItem("DEFAULT"); + reverbComboBox->AddItem("GENERIC"); + reverbComboBox->AddItem("FOREST"); + reverbComboBox->AddItem("PADDEDCELL"); + reverbComboBox->AddItem("ROOM"); + reverbComboBox->AddItem("BATHROOM"); + reverbComboBox->AddItem("LIVINGROOM"); + reverbComboBox->AddItem("STONEROOM"); + reverbComboBox->AddItem("AUDITORIUM"); + reverbComboBox->AddItem("CONCERTHALL"); + reverbComboBox->AddItem("CAVE"); + reverbComboBox->AddItem("ARENA"); + reverbComboBox->AddItem("HANGAR"); + reverbComboBox->AddItem("CARPETEDHALLWAY"); + reverbComboBox->AddItem("HALLWAY"); + reverbComboBox->AddItem("STONECORRIDOR"); + reverbComboBox->AddItem("ALLEY"); + reverbComboBox->AddItem("CITY"); + reverbComboBox->AddItem("MOUNTAINS"); + reverbComboBox->AddItem("QUARRY"); + reverbComboBox->AddItem("PLAIN"); + reverbComboBox->AddItem("PARKINGLOT"); + reverbComboBox->AddItem("SEWERPIPE"); + reverbComboBox->AddItem("UNDERWATER"); + reverbComboBox->AddItem("SMALLROOM"); + reverbComboBox->AddItem("MEDIUMROOM"); + reverbComboBox->AddItem("LARGEROOM"); + reverbComboBox->AddItem("MEDIUMHALL"); + reverbComboBox->AddItem("LARGEHALL"); + reverbComboBox->AddItem("PLATE"); + reverbComboBox->SetTooltip("Set the global reverb setting."); + soundWindow->AddWidget(reverbComboBox); + + y += step; + addButton = new wiButton("Add Sound"); addButton->SetTooltip("Add a sound file to the scene."); addButton->SetPos(XMFLOAT2(x, y += step)); diff --git a/Editor/SoundWindow.h b/Editor/SoundWindow.h index 3963fd9af..44dc0168b 100644 --- a/Editor/SoundWindow.h +++ b/Editor/SoundWindow.h @@ -22,9 +22,10 @@ public: wiGUI* GUI; wiWindow* soundWindow; + wiComboBox* reverbComboBox; + wiButton* addButton; wiLabel* filenameLabel; wiTextInputField* nameField; - wiButton* addButton; wiButton* playstopButton; wiCheckBox* loopedCheckbox; wiSlider* volumeSlider; diff --git a/WickedEngine/wiAudio.cpp b/WickedEngine/wiAudio.cpp index 4168b9985..bc9f7b500 100644 --- a/WickedEngine/wiAudio.cpp +++ b/WickedEngine/wiAudio.cpp @@ -5,6 +5,7 @@ #include #include +#include #include #pragma comment(lib,"xaudio2.lib") @@ -31,8 +32,10 @@ namespace wiAudio IXAudio2* audioEngine = nullptr; IXAudio2MasteringVoice* masteringVoice = nullptr; XAUDIO2_VOICE_DETAILS masteringVoiceDetails = {}; - X3DAUDIO_HANDLE audio3D = {}; IXAudio2SubmixVoice* submixVoices[SUBMIX_TYPE_COUNT] = {}; + X3DAUDIO_HANDLE audio3D = {}; + IUnknown* reverbEffect = nullptr; + IXAudio2SubmixVoice* reverbSubmix = nullptr; Sound::~Sound() { @@ -52,6 +55,7 @@ namespace wiAudio IXAudio2SourceVoice* sourceVoice = nullptr; XAUDIO2_VOICE_DETAILS voiceDetails = {}; std::vector outputMatrix; + std::vector channelAzimuths; XAUDIO2_BUFFER buffer = {}; const SoundInternal* soundinternal = nullptr; }; @@ -77,18 +81,36 @@ namespace wiAudio masteringVoice->GetVoiceDetails(&masteringVoiceDetails); + for (int i = 0; i < SUBMIX_TYPE_COUNT; ++i) + { + hr = audioEngine->CreateSubmixVoice( + &submixVoices[i], + masteringVoiceDetails.InputChannels, + masteringVoiceDetails.InputSampleRate, + 0, 0, 0, 0); + assert(SUCCEEDED(hr)); + } + DWORD channelMask; masteringVoice->GetChannelMask(&channelMask); hr = X3DAudioInitialize(channelMask, X3DAUDIO_SPEED_OF_SOUND, audio3D); assert(SUCCEEDED(hr)); - for (int i = 0; i < SUBMIX_TYPE_COUNT; ++i) + // Reverb setup: { - audioEngine->CreateSubmixVoice( - &submixVoices[i], - masteringVoiceDetails.InputChannels, + hr = XAudio2CreateReverb(&reverbEffect); + assert(SUCCEEDED(hr)); + + XAUDIO2_EFFECT_DESCRIPTOR effects[] = { { reverbEffect, TRUE, 1 } }; + XAUDIO2_EFFECT_CHAIN effectChain = { ARRAYSIZE(effects), effects }; + hr = audioEngine->CreateSubmixVoice( + &reverbSubmix, + 1, // reverb is mono masteringVoiceDetails.InputSampleRate, - 0, 0, 0, 0); + 0, 0, nullptr, &effectChain); + assert(SUCCEEDED(hr)); + + SetReverb(REVERB_PRESET_DEFAULT); } if (SUCCEEDED(hr)) @@ -98,12 +120,24 @@ namespace wiAudio } void CleanUp() { + SAFE_RELEASE(reverbEffect); + + if (reverbSubmix != nullptr) + reverbSubmix->DestroyVoice(); + for (int i = 0; i < SUBMIX_TYPE_COUNT; ++i) { - if (submixVoices[i] != nullptr) submixVoices[i]->DestroyVoice(); + if (submixVoices[i] != nullptr) + submixVoices[i]->DestroyVoice(); } - if (masteringVoice != nullptr) masteringVoice->DestroyVoice(); + + if (masteringVoice != nullptr) + masteringVoice->DestroyVoice(); + + audioEngine->StopEngine(); SAFE_RELEASE(audioEngine); + + CoUninitialize(); } HRESULT FindChunk(HANDLE hFile, DWORD fourcc, DWORD& dwChunkSize, DWORD& dwChunkDataPosition) @@ -241,11 +275,14 @@ namespace wiAudio SoundInstanceInternal* instanceinternal = new SoundInstanceInternal; instanceinternal->soundinternal = soundinternal; - XAUDIO2_SEND_DESCRIPTOR SFXSend = { 0, submixVoices[instance->type] }; - XAUDIO2_VOICE_SENDS SFXSendList = { 1, &SFXSend }; + XAUDIO2_SEND_DESCRIPTOR SFXSend[] = { + { XAUDIO2_SEND_USEFILTER, submixVoices[instance->type] }, + { XAUDIO2_SEND_USEFILTER, reverbSubmix }, + }; + XAUDIO2_VOICE_SENDS SFXSendList = { ARRAYSIZE(SFXSend), SFXSend }; hr = audioEngine->CreateSourceVoice(&instanceinternal->sourceVoice, &soundinternal->wfx, - XAUDIO2_VOICE_USEFILTER, XAUDIO2_DEFAULT_FREQ_RATIO, NULL, &SFXSendList, NULL); + 0, XAUDIO2_DEFAULT_FREQ_RATIO, NULL, &SFXSendList, NULL); if (FAILED(hr)) { assert(0); @@ -254,7 +291,12 @@ namespace wiAudio instanceinternal->sourceVoice->GetVoiceDetails(&instanceinternal->voiceDetails); - instanceinternal->outputMatrix.resize(masteringVoiceDetails.InputChannels); + instanceinternal->outputMatrix.resize(size_t(instanceinternal->voiceDetails.InputChannels) * size_t(masteringVoiceDetails.InputChannels)); + instanceinternal->channelAzimuths.resize(instanceinternal->voiceDetails.InputChannels); + for (size_t i = 0; i < instanceinternal->channelAzimuths.size(); ++i) + { + instanceinternal->channelAzimuths[i] = X3DAUDIO_2PI * float(i) / float(instanceinternal->channelAzimuths.size()); + } instanceinternal->buffer.AudioBytes = (UINT32)soundinternal->audioData.size(); instanceinternal->buffer.pAudioData = soundinternal->audioData.data(); @@ -363,7 +405,8 @@ namespace wiAudio void SetSubmixVolume(SUBMIX_TYPE type, float volume) { - submixVoices[type]->SetVolume(volume); + HRESULT hr = submixVoices[type]->SetVolume(volume); + assert(SUCCEEDED(hr)); } float GetSubmixVolume(SUBMIX_TYPE type) { @@ -389,17 +432,21 @@ namespace wiAudio emitter.OrientFront = instance3D.emitterFront; emitter.OrientTop = instance3D.emitterUp; emitter.Velocity = instance3D.emitterVelocity; - emitter.CurveDistanceScaler = 1; - emitter.ChannelCount = 1; emitter.InnerRadius = instance3D.emitterRadius; + emitter.InnerRadiusAngle = X3DAUDIO_PI / 4.0f; + emitter.ChannelCount = instanceinternal->voiceDetails.InputChannels; + emitter.pChannelAzimuths = instanceinternal->channelAzimuths.data(); + emitter.ChannelRadius = 0.1f; + emitter.CurveDistanceScaler = 1; + emitter.DopplerScaler = 1; UINT32 flags = 0; flags |= X3DAUDIO_CALCULATE_MATRIX; flags |= X3DAUDIO_CALCULATE_LPF_DIRECT; flags |= X3DAUDIO_CALCULATE_REVERB; + flags |= X3DAUDIO_CALCULATE_LPF_REVERB; flags |= X3DAUDIO_CALCULATE_DOPPLER; //flags |= X3DAUDIO_CALCULATE_DELAY; - //flags |= X3DAUDIO_CALCULATE_LPF_REVERB; //flags |= X3DAUDIO_CALCULATE_EMITTER_ANGLE; //flags |= X3DAUDIO_CALCULATE_ZEROCENTER; //flags |= X3DAUDIO_CALCULATE_REDIRECT_TO_LFE; @@ -412,6 +459,10 @@ namespace wiAudio X3DAudioCalculate(audio3D, &listener, &emitter, flags, &settings); HRESULT hr; + + hr = instanceinternal->sourceVoice->SetFrequencyRatio(settings.DopplerFactor); + assert(SUCCEEDED(hr)); + hr = instanceinternal->sourceVoice->SetOutputMatrix( submixVoices[instance->type], settings.SrcChannelCount, @@ -420,17 +471,56 @@ namespace wiAudio ); assert(SUCCEEDED(hr)); - hr = instanceinternal->sourceVoice->SetFrequencyRatio(settings.DopplerFactor); + hr = instanceinternal->sourceVoice->SetOutputMatrix(reverbSubmix, settings.SrcChannelCount, 1, &settings.ReverbLevel); assert(SUCCEEDED(hr)); - - XAUDIO2_FILTER_PARAMETERS filterParams = - { - LowPassFilter, - 2.0f * sinf(X3DAUDIO_PI / 6.0f * settings.LPFDirectCoefficient), - 1.0f - }; - hr = instanceinternal->sourceVoice->SetFilterParameters(&filterParams); + + XAUDIO2_FILTER_PARAMETERS FilterParametersDirect = { LowPassFilter, 2.0f * sinf(X3DAUDIO_PI / 6.0f * settings.LPFDirectCoefficient), 1.0f }; + hr = instanceinternal->sourceVoice->SetOutputFilterParameters(submixVoices[instance->type], &FilterParametersDirect); + assert(SUCCEEDED(hr)); + XAUDIO2_FILTER_PARAMETERS FilterParametersReverb = { LowPassFilter, 2.0f * sinf(X3DAUDIO_PI / 6.0f * settings.LPFReverbCoefficient), 1.0f }; + hr = instanceinternal->sourceVoice->SetOutputFilterParameters(reverbSubmix, &FilterParametersReverb); assert(SUCCEEDED(hr)); } } + + static const XAUDIO2FX_REVERB_I3DL2_PARAMETERS reverbPresets[] = + { + XAUDIO2FX_I3DL2_PRESET_DEFAULT, + XAUDIO2FX_I3DL2_PRESET_GENERIC, + XAUDIO2FX_I3DL2_PRESET_FOREST, + XAUDIO2FX_I3DL2_PRESET_PADDEDCELL, + XAUDIO2FX_I3DL2_PRESET_ROOM, + XAUDIO2FX_I3DL2_PRESET_BATHROOM, + XAUDIO2FX_I3DL2_PRESET_LIVINGROOM, + XAUDIO2FX_I3DL2_PRESET_STONEROOM, + XAUDIO2FX_I3DL2_PRESET_AUDITORIUM, + XAUDIO2FX_I3DL2_PRESET_CONCERTHALL, + XAUDIO2FX_I3DL2_PRESET_CAVE, + XAUDIO2FX_I3DL2_PRESET_ARENA, + XAUDIO2FX_I3DL2_PRESET_HANGAR, + XAUDIO2FX_I3DL2_PRESET_CARPETEDHALLWAY, + XAUDIO2FX_I3DL2_PRESET_HALLWAY, + XAUDIO2FX_I3DL2_PRESET_STONECORRIDOR, + XAUDIO2FX_I3DL2_PRESET_ALLEY, + XAUDIO2FX_I3DL2_PRESET_CITY, + XAUDIO2FX_I3DL2_PRESET_MOUNTAINS, + XAUDIO2FX_I3DL2_PRESET_QUARRY, + XAUDIO2FX_I3DL2_PRESET_PLAIN, + XAUDIO2FX_I3DL2_PRESET_PARKINGLOT, + XAUDIO2FX_I3DL2_PRESET_SEWERPIPE, + XAUDIO2FX_I3DL2_PRESET_UNDERWATER, + XAUDIO2FX_I3DL2_PRESET_SMALLROOM, + XAUDIO2FX_I3DL2_PRESET_MEDIUMROOM, + XAUDIO2FX_I3DL2_PRESET_LARGEROOM, + XAUDIO2FX_I3DL2_PRESET_MEDIUMHALL, + XAUDIO2FX_I3DL2_PRESET_LARGEHALL, + XAUDIO2FX_I3DL2_PRESET_PLATE, + }; + void SetReverb(REVERB_PRESET preset) + { + XAUDIO2FX_REVERB_PARAMETERS native; + ReverbConvertI3DL2ToNative(&reverbPresets[preset], &native); + HRESULT hr = reverbSubmix->SetEffectParameters(0, &native, sizeof(native)); + assert(SUCCEEDED(hr)); + } } diff --git a/WickedEngine/wiAudio.h b/WickedEngine/wiAudio.h index 9a1e0b457..07a052c62 100644 --- a/WickedEngine/wiAudio.h +++ b/WickedEngine/wiAudio.h @@ -89,4 +89,39 @@ namespace wiAudio float emitterRadius = 0; }; void Update3D(SoundInstance* instance, const SoundInstance3D& instance3D); + + enum REVERB_PRESET + { + REVERB_PRESET_DEFAULT, + REVERB_PRESET_GENERIC, + REVERB_PRESET_FOREST, + REVERB_PRESET_PADDEDCELL, + REVERB_PRESET_ROOM, + REVERB_PRESET_BATHROOM, + REVERB_PRESET_LIVINGROOM, + REVERB_PRESET_STONEROOM, + REVERB_PRESET_AUDITORIUM, + REVERB_PRESET_CONCERTHALL, + REVERB_PRESET_CAVE, + REVERB_PRESET_ARENA, + REVERB_PRESET_HANGAR, + REVERB_PRESET_CARPETEDHALLWAY, + REVERB_PRESET_HALLWAY, + REVERB_PRESET_STONECORRIDOR, + REVERB_PRESET_ALLEY, + REVERB_PRESET_CITY, + REVERB_PRESET_MOUNTAINS, + REVERB_PRESET_QUARRY, + REVERB_PRESET_PLAIN, + REVERB_PRESET_PARKINGLOT, + REVERB_PRESET_SEWERPIPE, + REVERB_PRESET_UNDERWATER, + REVERB_PRESET_SMALLROOM, + REVERB_PRESET_MEDIUMROOM, + REVERB_PRESET_LARGEROOM, + REVERB_PRESET_MEDIUMHALL, + REVERB_PRESET_LARGEHALL, + REVERB_PRESET_PLATE, + }; + void SetReverb(REVERB_PRESET preset); } diff --git a/WickedEngine/wiAudio_BindLua.cpp b/WickedEngine/wiAudio_BindLua.cpp index 4f35902c7..91a0103b8 100644 --- a/WickedEngine/wiAudio_BindLua.cpp +++ b/WickedEngine/wiAudio_BindLua.cpp @@ -17,6 +17,7 @@ Luna::FunctionType wiAudio_BindLua::methods[] = { lunamethod(wiAudio_BindLua, GetSubmixVolume), lunamethod(wiAudio_BindLua, SetSubmixVolume), lunamethod(wiAudio_BindLua, Update3D), + lunamethod(wiAudio_BindLua, SetReverb), { NULL, NULL } }; Luna::PropertyType wiAudio_BindLua::properties[] = { @@ -244,6 +245,17 @@ int wiAudio_BindLua::Update3D(lua_State* L) wiLua::SError(L, "Update3D(SoundInstance soundinstance, SoundInstance3D instance3D) not enough arguments!"); return 0; } +int wiAudio_BindLua::SetReverb(lua_State* L) +{ + int argc = wiLua::SGetArgCount(L); + if (argc > 0) + { + wiAudio::SetReverb((wiAudio::REVERB_PRESET)wiLua::SGetInt(L, 1)); + } + else + wiLua::SError(L, "SetReverb(int reverbtype) not enough arguments!"); + return 0; +} void wiAudio_BindLua::Bind() { @@ -252,8 +264,45 @@ void wiAudio_BindLua::Bind() { initialized = true; Luna::Register(wiLua::GetGlobal()->GetLuaState()); + wiLua::GetGlobal()->RunText("audio = Audio()"); + wiLua::GetGlobal()->RunText("SUBMIX_TYPE_SOUNDEFFECT = 0"); + wiLua::GetGlobal()->RunText("SUBMIX_TYPE_MUSIC = 1"); + wiLua::GetGlobal()->RunText("SUBMIX_TYPE_USER0 = 2"); + wiLua::GetGlobal()->RunText("SUBMIX_TYPE_USER1 = 3"); + + wiLua::GetGlobal()->RunText("REVERB_PRESET_DEFAULT = 0"); + wiLua::GetGlobal()->RunText("REVERB_PRESET_GENERIC = 1"); + wiLua::GetGlobal()->RunText("REVERB_PRESET_FOREST = 2"); + wiLua::GetGlobal()->RunText("REVERB_PRESET_PADDEDCELL = 3"); + wiLua::GetGlobal()->RunText("REVERB_PRESET_ROOM = 4"); + wiLua::GetGlobal()->RunText("REVERB_PRESET_BATHROOM = 5"); + wiLua::GetGlobal()->RunText("REVERB_PRESET_LIVINGROOM = 6"); + wiLua::GetGlobal()->RunText("REVERB_PRESET_STONEROOM = 7"); + wiLua::GetGlobal()->RunText("REVERB_PRESET_AUDITORIUM = 8"); + wiLua::GetGlobal()->RunText("REVERB_PRESET_CONCERTHALL = 9"); + wiLua::GetGlobal()->RunText("REVERB_PRESET_CAVE = 10"); + wiLua::GetGlobal()->RunText("REVERB_PRESET_ARENA = 11"); + wiLua::GetGlobal()->RunText("REVERB_PRESET_HANGAR = 12"); + wiLua::GetGlobal()->RunText("REVERB_PRESET_CARPETEDHALLWAY = 13"); + wiLua::GetGlobal()->RunText("REVERB_PRESET_HALLWAY = 14"); + wiLua::GetGlobal()->RunText("REVERB_PRESET_STONECORRIDOR = 15"); + wiLua::GetGlobal()->RunText("REVERB_PRESET_ALLEY = 16"); + wiLua::GetGlobal()->RunText("REVERB_PRESET_CITY = 17"); + wiLua::GetGlobal()->RunText("REVERB_PRESET_MOUNTAINS = 18"); + wiLua::GetGlobal()->RunText("REVERB_PRESET_QUARRY = 19"); + wiLua::GetGlobal()->RunText("REVERB_PRESET_PLAIN = 20"); + wiLua::GetGlobal()->RunText("REVERB_PRESET_PARKINGLOT = 21"); + wiLua::GetGlobal()->RunText("REVERB_PRESET_SEWERPIPE = 22"); + wiLua::GetGlobal()->RunText("REVERB_PRESET_UNDERWATER = 23"); + wiLua::GetGlobal()->RunText("REVERB_PRESET_SMALLROOM = 24"); + wiLua::GetGlobal()->RunText("REVERB_PRESET_MEDIUMROOM = 25"); + wiLua::GetGlobal()->RunText("REVERB_PRESET_LARGEROOM = 26"); + wiLua::GetGlobal()->RunText("REVERB_PRESET_MEDIUMHALL = 27"); + wiLua::GetGlobal()->RunText("REVERB_PRESET_LARGEHALL = 28"); + wiLua::GetGlobal()->RunText("REVERB_PRESET_PLATE = 29"); + wiSound_BindLua::Bind(); wiSoundInstance_BindLua::Bind(); wiSoundInstance3D_BindLua::Bind(); diff --git a/WickedEngine/wiAudio_BindLua.h b/WickedEngine/wiAudio_BindLua.h index bb5b05c9d..4566a8b9b 100644 --- a/WickedEngine/wiAudio_BindLua.h +++ b/WickedEngine/wiAudio_BindLua.h @@ -27,6 +27,7 @@ public: int SetSubmixVolume(lua_State* L); int Update3D(lua_State* L); + int SetReverb(lua_State* L); static void Bind(); }; diff --git a/WickedEngine/wiECS.h b/WickedEngine/wiECS.h index 617bf0790..1762a6a23 100644 --- a/WickedEngine/wiECS.h +++ b/WickedEngine/wiECS.h @@ -145,7 +145,7 @@ namespace wiECS lookup[entity] = components.size(); // New components are always pushed to the end: - components.push_back(Component()); + components.emplace_back(); // Also push corresponding entity: entities.push_back(entity); diff --git a/WickedEngine/wiSceneSystem_Serializers.cpp b/WickedEngine/wiSceneSystem_Serializers.cpp index 71c34fd01..18aeb8a9a 100644 --- a/WickedEngine/wiSceneSystem_Serializers.cpp +++ b/WickedEngine/wiSceneSystem_Serializers.cpp @@ -184,6 +184,7 @@ namespace wiSceneSystem archive << texAnimElapsedTime; // If detecting an absolute path in textures, remove it and convert to relative: + if(!dir.empty()) { size_t found = baseColorMapName.rfind(dir); if (found != std::string::npos) @@ -498,12 +499,15 @@ namespace wiSceneSystem archive << height; // If detecting an absolute path in textures, remove it and convert to relative: - for (size_t i = 0; i < lensFlareNames.size(); ++i) + if (!dir.empty()) { - size_t found = lensFlareNames[i].rfind(dir); - if (found != std::string::npos) + for (size_t i = 0; i < lensFlareNames.size(); ++i) { - lensFlareNames[i] = lensFlareNames[i].substr(found + dir.length()); + size_t found = lensFlareNames[i].rfind(dir); + if (found != std::string::npos) + { + lensFlareNames[i] = lensFlareNames[i].substr(found + dir.length()); + } } } archive << lensFlareNames; @@ -717,6 +721,7 @@ namespace wiSceneSystem else { // If detecting an absolute path in textures, remove it and convert to relative: + if(!dir.empty()) { size_t found = filename.rfind(dir); if (found != std::string::npos) diff --git a/WickedEngine/wiVersion.cpp b/WickedEngine/wiVersion.cpp index 1e6643986..50fab5aac 100644 --- a/WickedEngine/wiVersion.cpp +++ b/WickedEngine/wiVersion.cpp @@ -9,7 +9,7 @@ namespace wiVersion // minor features, major updates const int minor = 29; // minor bug fixes, alterations, refactors, updates - const int revision = 1; + const int revision = 2; long GetVersion()