Common: Add WAVWriter class
This commit is contained in:
31
src/common/wav_writer.h
Normal file
31
src/common/wav_writer.h
Normal file
@@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
#include "types.h"
|
||||
#include <cstdio>
|
||||
|
||||
namespace Common {
|
||||
|
||||
class WAVWriter
|
||||
{
|
||||
public:
|
||||
WAVWriter();
|
||||
~WAVWriter();
|
||||
|
||||
ALWAYS_INLINE bool IsOpen() const { return (m_file != nullptr); }
|
||||
|
||||
bool Open(const char* filename, u32 sample_rate, u32 num_channels);
|
||||
void Close();
|
||||
|
||||
void WriteFrames(const s16* samples, u32 num_frames);
|
||||
|
||||
private:
|
||||
using SampleType = s16;
|
||||
|
||||
bool WriteHeader();
|
||||
|
||||
std::FILE* m_file = nullptr;
|
||||
u32 m_sample_rate = 0;
|
||||
u32 m_num_channels = 0;
|
||||
u32 m_num_frames = 0;
|
||||
};
|
||||
|
||||
} // namespace Common
|
||||
Reference in New Issue
Block a user