Implemented setting parameters to disable audio, reverb, and/or hrtf processing.

This commit is contained in:
2013-04-29 14:10:03 -07:00
parent 6c9c6c5881
commit f13d93de29
7 changed files with 115 additions and 26 deletions

View File

@@ -44,6 +44,10 @@ ALvoid alcMacOSXRenderingQualityProc(const ALint value);
KRAudioManager::KRAudioManager(KRContext &context) : KRContextObject(context) KRAudioManager::KRAudioManager(KRContext &context) : KRContextObject(context)
{ {
m_enable_audio = true;
m_enable_hrtf = true;
m_enable_reverb = true;
m_anticlick_block = true; m_anticlick_block = true;
mach_timebase_info(&m_timebase_info); mach_timebase_info(&m_timebase_info);
@@ -100,6 +104,34 @@ void KRAudioManager::initAudio()
} }
} }
bool KRAudioManager::getEnableAudio()
{
return m_enable_audio;
}
void KRAudioManager::setEnableAudio(bool enable)
{
m_enable_audio = enable;
}
bool KRAudioManager::getEnableHRTF()
{
return m_enable_hrtf;
}
void KRAudioManager::setEnableHRTF(bool enable)
{
m_enable_hrtf = enable;
}
bool KRAudioManager::getEnableReverb()
{
return m_enable_reverb;
}
void KRAudioManager::setEnableReverb(bool enable)
{
m_enable_reverb = enable;
}
KRScene *KRAudioManager::getListenerScene() KRScene *KRAudioManager::getListenerScene()
{ {
return m_listener_scene; return m_listener_scene;
@@ -327,8 +359,6 @@ void KRAudioManager::renderBlock()
{ {
m_mutex.lock(); m_mutex.lock();
bool headphone_mode = true;
// ----====---- Advance to next block in accumulation buffer ----====---- // ----====---- Advance to next block in accumulation buffer ----====----
// Zero out block that was last used, so it will be ready for the next pass through the circular buffer // Zero out block that was last used, so it will be ready for the next pass through the circular buffer
@@ -338,18 +368,22 @@ void KRAudioManager::renderBlock()
// Advance to the next block, and wrap around // Advance to the next block, and wrap around
m_output_accumulation_block_start = (m_output_accumulation_block_start + KRENGINE_AUDIO_BLOCK_LENGTH * KRENGINE_MAX_OUTPUT_CHANNELS) % (KRENGINE_REVERB_MAX_SAMPLES * KRENGINE_MAX_OUTPUT_CHANNELS); m_output_accumulation_block_start = (m_output_accumulation_block_start + KRENGINE_AUDIO_BLOCK_LENGTH * KRENGINE_MAX_OUTPUT_CHANNELS) % (KRENGINE_REVERB_MAX_SAMPLES * KRENGINE_MAX_OUTPUT_CHANNELS);
if(m_enable_audio) {
// ----====---- Render Direct / HRTF audio ----====---- // ----====---- Render Direct / HRTF audio ----====----
if(headphone_mode) { if(m_enable_hrtf) {
renderHRTF(); renderHRTF();
} else { } else {
renderITD(); renderITD();
} }
// ----====---- Render Indirect / Reverb channel ----====---- // ----====---- Render Indirect / Reverb channel ----====----
if(m_enable_reverb) {
renderReverb(); renderReverb();
}
// ----====---- Render Ambient Sound ----====---- // ----====---- Render Ambient Sound ----====----
renderAmbient(); renderAmbient();
}
// ----====---- Advance audio sources ----====---- // ----====---- Advance audio sources ----====----
m_audio_frame += KRENGINE_AUDIO_BLOCK_LENGTH; m_audio_frame += KRENGINE_AUDIO_BLOCK_LENGTH;
@@ -1719,6 +1753,8 @@ void KRAudioManager::renderHRTF()
void KRAudioManager::renderITD() void KRAudioManager::renderITD()
{ {
// FINDME, TODO - Need Inter-Temperal based phase shifting to support 3-d spatialized audio without headphones
/* /*

View File

@@ -127,7 +127,20 @@ public:
void startFrame(float deltaTime); void startFrame(float deltaTime);
bool getEnableAudio();
void setEnableAudio(bool enable);
bool getEnableHRTF();
void setEnableHRTF(bool enable);
bool getEnableReverb();
void setEnableReverb(bool enable);
private: private:
bool m_enable_audio;
bool m_enable_hrtf;
bool m_enable_reverb;
KRScene *m_listener_scene; // For now, only one scene is allowed to have active audio at once KRScene *m_listener_scene; // For now, only one scene is allowed to have active audio at once

View File

@@ -193,7 +193,10 @@ void kraken::set_parameter(const std::string &parameter_name, float parameter_va
@"dust_intensity" : @46, @"dust_intensity" : @46,
@"lod_bias" : @47, @"lod_bias" : @47,
@"enable_realtime_occlusion" : @48, @"enable_realtime_occlusion" : @48,
@"debug_display" : @49 @"debug_display" : @49,
@"siren_enable" : @50,
@"siren_enable_reverb" : @51,
@"siren_enable_hrtf" : @52
} copy]; } copy];
[self loadShaders]; [self loadShaders];
@@ -266,7 +269,7 @@ void kraken::set_parameter(const std::string &parameter_name, float parameter_va
-(int)getParameterCount -(int)getParameterCount
{ {
return 50; return 53;
} }
@@ -282,7 +285,7 @@ void kraken::set_parameter(const std::string &parameter_name, float parameter_va
-(NSString *)getParameterLabelWithIndex: (int)i -(NSString *)getParameterLabelWithIndex: (int)i
{ {
NSString *parameter_labels[50] = { NSString *parameter_labels[53] = {
@"Camera FOV", @"Camera FOV",
@"Shadow Quality (0 - 2)", @"Shadow Quality (0 - 2)",
@"Enable per-pixel lighting", @"Enable per-pixel lighting",
@@ -332,13 +335,16 @@ void kraken::set_parameter(const std::string &parameter_name, float parameter_va
@"Dust - Intensity", @"Dust - Intensity",
@"LOD Bias", @"LOD Bias",
@"Realtime Occlusion Tests", @"Realtime Occlusion Tests",
@"Debug - Display" @"Debug - Display",
@"Siren - Enable Audio",
@"Siren - Enable Reverb",
@"Siren - Enable HRTF"
}; };
return parameter_labels[i]; return parameter_labels[i];
} }
-(KREngineParameterType)getParameterTypeWithIndex: (int)i -(KREngineParameterType)getParameterTypeWithIndex: (int)i
{ {
KREngineParameterType types[50] = { KREngineParameterType types[53] = {
KRENGINE_PARAMETER_FLOAT, KRENGINE_PARAMETER_FLOAT,
KRENGINE_PARAMETER_INT, KRENGINE_PARAMETER_INT,
@@ -389,13 +395,16 @@ void kraken::set_parameter(const std::string &parameter_name, float parameter_va
KRENGINE_PARAMETER_FLOAT, KRENGINE_PARAMETER_FLOAT,
KRENGINE_PARAMETER_FLOAT, KRENGINE_PARAMETER_FLOAT,
KRENGINE_PARAMETER_BOOL, KRENGINE_PARAMETER_BOOL,
KRENGINE_PARAMETER_INT KRENGINE_PARAMETER_INT,
KRENGINE_PARAMETER_BOOL,
KRENGINE_PARAMETER_BOOL,
KRENGINE_PARAMETER_BOOL
}; };
return types[i]; return types[i];
} }
-(float)getParameterValueWithIndex: (int)i -(float)getParameterValueWithIndex: (int)i
{ {
float values[50] = { float values[53] = {
_settings.perspective_fov, _settings.perspective_fov,
(float)_settings.m_cShadowBuffers, (float)_settings.m_cShadowBuffers,
_settings.bEnablePerPixel ? 1.0f : 0.0f, _settings.bEnablePerPixel ? 1.0f : 0.0f,
@@ -445,7 +454,10 @@ void kraken::set_parameter(const std::string &parameter_name, float parameter_va
_settings.dust_particle_intensity, _settings.dust_particle_intensity,
_settings.getLODBias(), _settings.getLODBias(),
_settings.getEnableRealtimeOcclusion(), _settings.getEnableRealtimeOcclusion(),
_settings.debug_display _settings.debug_display,
_settings.siren_enable,
_settings.siren_enable_reverb,
_settings.siren_enable_hrtf
}; };
return values[i]; return values[i];
} }
@@ -642,17 +654,27 @@ void kraken::set_parameter(const std::string &parameter_name, float parameter_va
case 49: case 49:
_settings.debug_display = (KRRenderSettings::debug_display_type)v; _settings.debug_display = (KRRenderSettings::debug_display_type)v;
break; break;
case 50:
_settings.siren_enable = bNewBoolVal;
break;
case 51:
_settings.siren_enable_reverb = bNewBoolVal;
break;
case 52:
_settings.siren_enable_hrtf = bNewBoolVal;
break;
} }
} }
-(float)getParameterMinWithIndex: (int)i -(float)getParameterMinWithIndex: (int)i
{ {
float minValues[50] = { float minValues[53] = {
0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
0.0f, 0.0f, 0.01f, 50.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.01f, 50.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, -10.0f, 0.0f, 0.0f 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, -10.0f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f
}; };
return minValues[i]; return minValues[i];
@@ -660,12 +682,13 @@ void kraken::set_parameter(const std::string &parameter_name, float parameter_va
-(float)getParameterMaxWithIndex: (int)i -(float)getParameterMaxWithIndex: (int)i
{ {
float maxValues[50] = { float maxValues[53] = {
PI, 3.0f, 1.0f, 1.0, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 10.0f, PI, 3.0f, 1.0f, 1.0, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 10.0f,
1.0f, 10.0f, 2.0f, 1.0f, 1.0f, 1.0f, 5.0f, 1.0f, 0.5f, 1.0f, 1.0f, 10.0f, 2.0f, 1.0f, 1.0f, 1.0f, 5.0f, 1.0f, 0.5f, 1.0f,
2.0f, 2.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 2.0f, 2.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 10.0f, 1000.0f, 1.0f, 5.0f, 1000.0f, 1.0f, 5.0f, 3.0f, 1.0f, 1.0f, 10.0f, 1000.0f, 1.0f, 5.0f, 1000.0f, 1.0f, 5.0f, 3.0f,
1000.0f, 1000.0f, 0.01f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 10.0f, 1.0f, (float)(KRRenderSettings::KRENGINE_DEBUG_DISPLAY_NUMBER - 1) 1000.0f, 1000.0f, 0.01f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 10.0f, 1.0f, (float)(KRRenderSettings::KRENGINE_DEBUG_DISPLAY_NUMBER - 1),
1.0f, 1.0f, 1.0f
}; };
return maxValues[i]; return maxValues[i];

View File

@@ -10,6 +10,9 @@
KRRenderSettings::KRRenderSettings() KRRenderSettings::KRRenderSettings()
{ {
siren_enable = true;
siren_enable_reverb = true;
siren_enable_hrtf = true;
m_enable_realtime_occlusion = true; m_enable_realtime_occlusion = true;
bShowShadowBuffer = false; bShowShadowBuffer = false;
@@ -85,6 +88,10 @@ KRRenderSettings::~KRRenderSettings()
KRRenderSettings& KRRenderSettings::operator=(const KRRenderSettings &s) KRRenderSettings& KRRenderSettings::operator=(const KRRenderSettings &s)
{ {
siren_enable = s.siren_enable;
siren_enable_reverb = s.siren_enable_reverb;
siren_enable_hrtf = s.siren_enable_hrtf;
bEnablePerPixel = s.bEnablePerPixel; bEnablePerPixel = s.bEnablePerPixel;
bEnableDiffuseMap = s.bEnableDiffuseMap; bEnableDiffuseMap = s.bEnableDiffuseMap;
bEnableNormalMap = s.bEnableNormalMap; bEnableNormalMap = s.bEnableNormalMap;

View File

@@ -99,6 +99,10 @@ public:
bool getEnableRealtimeOcclusion(); bool getEnableRealtimeOcclusion();
void setEnableRealtimeOcclusion(bool enable); void setEnableRealtimeOcclusion(bool enable);
bool siren_enable;
bool siren_enable_reverb;
bool siren_enable_hrtf;
private: private:
float m_lodBias; float m_lodBias;
bool m_enable_realtime_occlusion; bool m_enable_realtime_occlusion;

View File

@@ -68,6 +68,12 @@ void KRScene::renderFrame(float deltaTime, int width, int height) {
camera = new KRCamera(*this, "default_camera"); camera = new KRCamera(*this, "default_camera");
m_pRootNode->addChild(camera); m_pRootNode->addChild(camera);
} }
// FINDME - This should be moved to de-couple Siren from the Rendering pipeline
getContext().getAudioManager()->setEnableAudio(camera->settings.siren_enable);
getContext().getAudioManager()->setEnableHRTF(camera->settings.siren_enable_hrtf);
getContext().getAudioManager()->setEnableReverb(camera->settings.siren_enable_reverb);
camera->renderFrame(deltaTime, width, height); camera->renderFrame(deltaTime, width, height);
getContext().endFrame(deltaTime); getContext().endFrame(deltaTime);
physicsUpdate(deltaTime); physicsUpdate(deltaTime);