2018-12-20 22:35:49 +00:00
|
|
|
|
#include "stdafx.h"
|
2014-03-08 02:15:39 +03:00
|
|
|
|
#include "AudioDumper.h"
|
2017-01-25 02:22:19 +03:00
|
|
|
|
|
2020-06-01 16:58:14 +11:00
|
|
|
|
#include "Utilities/date_time.h"
|
|
|
|
|
|
#include "Emu/System.h"
|
2014-03-08 02:15:39 +03:00
|
|
|
|
|
2016-02-02 00:51:35 +03:00
|
|
|
|
AudioDumper::AudioDumper(u16 ch)
|
|
|
|
|
|
: m_header(ch)
|
2014-03-08 02:15:39 +03:00
|
|
|
|
{
|
2016-02-02 00:51:35 +03:00
|
|
|
|
if (GetCh())
|
2015-01-16 17:36:53 +03:00
|
|
|
|
{
|
2020-06-01 16:58:14 +11:00
|
|
|
|
std::string path = fs::get_cache_dir() + "audio_";
|
|
|
|
|
|
if (const std::string id = Emu.GetTitleID(); !id.empty())
|
|
|
|
|
|
{
|
|
|
|
|
|
path += id + "_";
|
|
|
|
|
|
};
|
|
|
|
|
|
path += date_time::current_time_narrow<'_'>() + ".wav";
|
|
|
|
|
|
m_output.open(path, fs::rewrite);
|
2016-02-02 00:51:35 +03:00
|
|
|
|
m_output.write(m_header); // write initial file header
|
2015-01-16 17:36:53 +03:00
|
|
|
|
}
|
2014-03-08 02:15:39 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
2016-02-02 00:51:35 +03:00
|
|
|
|
AudioDumper::~AudioDumper()
|
2014-03-08 02:15:39 +03:00
|
|
|
|
{
|
2016-02-02 00:51:35 +03:00
|
|
|
|
if (GetCh())
|
2015-01-16 17:36:53 +03:00
|
|
|
|
{
|
2016-02-02 00:51:35 +03:00
|
|
|
|
m_output.seek(0);
|
|
|
|
|
|
m_output.write(m_header); // rewrite file header
|
2015-01-16 17:36:53 +03:00
|
|
|
|
}
|
2014-03-08 02:15:39 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
2016-02-02 00:51:35 +03:00
|
|
|
|
void AudioDumper::WriteData(const void* buffer, u32 size)
|
2014-03-08 02:15:39 +03:00
|
|
|
|
{
|
2016-02-02 00:51:35 +03:00
|
|
|
|
if (GetCh())
|
2014-03-19 04:32:23 +04:00
|
|
|
|
{
|
2016-08-15 03:11:49 +03:00
|
|
|
|
verify(HERE), size, m_output.write(buffer, size) == size;
|
2016-02-02 00:51:35 +03:00
|
|
|
|
m_header.Size += size;
|
|
|
|
|
|
m_header.RIFF.Size += size;
|
2014-03-19 04:32:23 +04:00
|
|
|
|
}
|
2014-03-08 02:15:39 +03:00
|
|
|
|
}
|