summaryrefslogtreecommitdiff
path: root/Source/Core/AudioCommon
diff options
context:
space:
mode:
authorsmelenchuk <smelenchuk@gmail.com>2011-02-11 18:59:42 +0000
committersmelenchuk <smelenchuk@gmail.com>2011-02-11 18:59:42 +0000
commitb0fa0a83f8a370e3661de3c06fce85e53973f189 (patch)
tree2cff242878bfeb667ade8d7f65f513811b8337a6 /Source/Core/AudioCommon
parentca78d3639ba621a99e325c919f6cbb2a46596990 (diff)
* Dump AVI output on every VI (fixes issue #4064).
* Add audio dumping (fixes issue #1638). git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7131 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/AudioCommon')
-rw-r--r--Source/Core/AudioCommon/Src/AudioCommon.cpp20
-rw-r--r--Source/Core/AudioCommon/Src/AudioCommonConfig.cpp2
-rw-r--r--Source/Core/AudioCommon/Src/AudioCommonConfig.h1
-rw-r--r--Source/Core/AudioCommon/Src/Mixer.cpp28
-rw-r--r--Source/Core/AudioCommon/Src/Mixer.h29
5 files changed, 64 insertions, 16 deletions
diff --git a/Source/Core/AudioCommon/Src/AudioCommon.cpp b/Source/Core/AudioCommon/Src/AudioCommon.cpp
index 547c0a8fe6..043d07d151 100644
--- a/Source/Core/AudioCommon/Src/AudioCommon.cpp
+++ b/Source/Core/AudioCommon/Src/AudioCommon.cpp
@@ -16,6 +16,7 @@
// http://code.google.com/p/dolphin-emu/
#include "AudioCommon.h"
+#include "FileUtil.h"
#include "Mixer.h"
#include "NullSoundStream.h"
#include "DSoundStream.h"
@@ -53,11 +54,13 @@ namespace AudioCommon
ac_Config.Update();
if (soundStream->Start())
{
-#if 0
- // Start the sound recording
- if (ac_Config.record)
- soundStream->StartLogAudio(FULL_DUMP_DIR g_Config.recordFile);
-#endif
+ if (ac_Config.m_DumpAudio) {
+ char audio_file_name[255];
+ snprintf(audio_file_name, 255, "%saudiodump.wav", File::GetUserPath(D_DUMPAUDIO_IDX));
+ mixer->StartLogAudio(audio_file_name);
+ //soundStream->StartLogAudio(audio_file_name);
+ }
+
return soundStream;
}
PanicAlertT("Could not initialize backend %s.", backend.c_str());
@@ -76,10 +79,9 @@ namespace AudioCommon
if (soundStream)
{
soundStream->Stop();
-#if 0
- if (ac_Config.record)
- soundStream->StopLogAudio();
-#endif
+ if (ac_Config.m_DumpAudio)
+ soundStream->GetMixer()->StopLogAudio();
+ //soundStream->StopLogAudio();
delete soundStream;
soundStream = NULL;
}
diff --git a/Source/Core/AudioCommon/Src/AudioCommonConfig.cpp b/Source/Core/AudioCommon/Src/AudioCommonConfig.cpp
index 6a8a22f5e5..6e22512c06 100644
--- a/Source/Core/AudioCommon/Src/AudioCommonConfig.cpp
+++ b/Source/Core/AudioCommon/Src/AudioCommonConfig.cpp
@@ -33,6 +33,7 @@ void AudioCommonConfig::Load()
file.Get("Config", "EnableDTKMusic", &m_EnableDTKMusic, true);
file.Get("Config", "EnableThrottle", &m_EnableThrottle, true);
file.Get("Config", "EnableJIT", &m_EnableJIT, true);
+ file.Get("Config", "DumpAudio", &m_DumpAudio, false);
#if defined __linux__ && HAVE_ALSA
file.Get("Config", "Backend", &sBackend, BACKEND_ALSA);
#elif defined __APPLE__
@@ -55,6 +56,7 @@ void AudioCommonConfig::SaveSettings()
file.Set("Config", "EnableDTKMusic", m_EnableDTKMusic);
file.Set("Config", "EnableThrottle", m_EnableThrottle);
file.Set("Config", "EnableJIT", m_EnableJIT);
+ file.Set("Config", "DumpAudio", m_DumpAudio);
file.Set("Config", "Backend", sBackend);
file.Set("Config", "Frequency", sFrequency);
file.Set("Config", "Volume", m_Volume);
diff --git a/Source/Core/AudioCommon/Src/AudioCommonConfig.h b/Source/Core/AudioCommon/Src/AudioCommonConfig.h
index c5f2efe645..98cbf60500 100644
--- a/Source/Core/AudioCommon/Src/AudioCommonConfig.h
+++ b/Source/Core/AudioCommon/Src/AudioCommonConfig.h
@@ -36,6 +36,7 @@ struct AudioCommonConfig
bool m_EnableDTKMusic;
bool m_EnableThrottle;
bool m_EnableJIT;
+ bool m_DumpAudio;
int m_Volume;
std::string sBackend;
int sFrequency;
diff --git a/Source/Core/AudioCommon/Src/Mixer.cpp b/Source/Core/AudioCommon/Src/Mixer.cpp
index c8eece73c7..8dcc972535 100644
--- a/Source/Core/AudioCommon/Src/Mixer.cpp
+++ b/Source/Core/AudioCommon/Src/Mixer.cpp
@@ -125,16 +125,30 @@ unsigned int CMixer::Mix(short* samples, unsigned int numSamples)
if (numSamples > numLeft)
memset(&samples[numLeft * 2], 0, (numSamples - numLeft) * 4);
- // Add the DSPHLE sound, re-sampling is done inside
- Premix(samples, numSamples);
+ //when logging, also throttle HLE audio
+ if (m_logAudio) {
+ if (m_AIplaying) {
+ Premix(samples, numLeft);
- // Add the DTK Music
- if (m_EnableDTKMusic)
- {
- // Re-sampling is done inside
- AudioInterface::Callback_GetStreaming(samples, numSamples, m_sampleRate);
+ if (m_EnableDTKMusic)
+ AudioInterface::Callback_GetStreaming(samples, numLeft, m_sampleRate);
+
+ g_wave_writer.AddStereoSamples(samples, numLeft);
+ }
+ }
+ else { //or mix as usual
+ // Add the DSPHLE sound, re-sampling is done inside
+ Premix(samples, numSamples);
+
+ // Add the DTK Music
+ if (m_EnableDTKMusic)
+ {
+ // Re-sampling is done inside
+ AudioInterface::Callback_GetStreaming(samples, numSamples, m_sampleRate);
+ }
}
+
Common::AtomicAdd(m_numSamples, -(s32)numLeft);
return numSamples;
diff --git a/Source/Core/AudioCommon/Src/Mixer.h b/Source/Core/AudioCommon/Src/Mixer.h
index 0ce68ed259..9d7459921f 100644
--- a/Source/Core/AudioCommon/Src/Mixer.h
+++ b/Source/Core/AudioCommon/Src/Mixer.h
@@ -18,6 +18,8 @@
#ifndef _MIXER_H_
#define _MIXER_H_
+#include "WaveFile.h"
+
// 16 bit Stereo
#define MAX_SAMPLES (1024 * 8)
#define INDEX_MASK (MAX_SAMPLES * 2 - 1)
@@ -36,6 +38,7 @@ public:
, m_indexW(0)
, m_indexR(0)
, m_AIplaying(true)
+ , m_logAudio(0)
{
// AyuanX: The internal (Core & DSP) sample rate is fixed at 32KHz
// So when AI/DAC sample rate differs than 32KHz, we have to do re-sampling
@@ -63,14 +66,40 @@ public:
void SetHLEReady(bool ready) { m_HLEready = ready;}
// ---------------------
+
+ virtual void StartLogAudio(const char *filename) {
+ if (! m_logAudio) {
+ m_logAudio = true;
+ g_wave_writer.Start(filename);
+ g_wave_writer.SetSkipSilence(false);
+ NOTICE_LOG(DSPHLE, "Starting Audio logging");
+ } else {
+ WARN_LOG(DSPHLE, "Audio logging already started");
+ }
+ }
+
+ virtual void StopLogAudio() {
+ if (m_logAudio) {
+ m_logAudio = false;
+ g_wave_writer.Stop();
+ NOTICE_LOG(DSPHLE, "Stopping Audio logging");
+ } else {
+ WARN_LOG(DSPHLE, "Audio logging already stopped");
+ }
+ }
+
+
protected:
unsigned int m_sampleRate;
unsigned int m_aiSampleRate;
unsigned int m_dacSampleRate;
int m_bits;
int m_channels;
+
+ WaveFileWriter g_wave_writer;
bool m_HLEready;
+ bool m_logAudio;
bool m_EnableDTKMusic;
bool m_throttle;