foobar2000 SDK  2015-08-03
writer_wav.h
Go to the documentation of this file.
1 #ifndef _foobar2000_wav_writer_h_
2 #define _foobar2000_wav_writer_h_
3 
4 #ifdef _WIN32
5 #include <mmreg.h>
6 #endif
7 
9 {
12 
13 
14  void initialize(const audio_chunk & p_chunk,unsigned p_bps,bool p_float,bool p_dither, bool p_wave64 = false);
15  void initialize2(const audio_chunk & p_chunk,unsigned p_bps, unsigned p_bpsValid,bool p_float,bool p_dither, bool p_wave64 = false);
16  void initialize3(const audio_chunk::spec_t & spec, unsigned bps, unsigned bpsValid, bool bFloat, bool bDither, bool bWave64 = false);
17 
18 #ifdef _WAVEFORMATEX_
19  void setup_wfx(WAVEFORMATEX & p_wfx);
20 #endif
21 #ifdef _WAVEFORMATEXTENSIBLE_
22  void setup_wfxe(WAVEFORMATEXTENSIBLE & p_wfx);
23 #endif
24  bool needWFXE() const;
25 };
26 
28 {
29 public:
30  void open(const char * p_path, const wavWriterSetup_t & p_setup, abort_callback & p_abort);
31  void open(service_ptr_t<file> p_file, const wavWriterSetup_t & p_setup, abort_callback & p_abort);
32  void write(const audio_chunk & p_chunk,abort_callback & p_abort);
33  void finalize(abort_callback & p_abort);
34  void close();
35  bool is_open() const { return m_file.is_valid(); }
36  audio_chunk::spec_t get_spec() const;
37 private:
38  size_t align(abort_callback & abort);
39  void writeSize(t_uint64 size, abort_callback & abort);
40  bool is64() const {return m_setup.m_wave64;}
41  t_uint32 chunkOverhead() const {return is64() ? 24 : 8;}
42  t_uint32 idOverhead() const {return is64() ? 16 : 4;}
43  void writeID(const GUID & id, abort_callback & abort);
47  bool m_wfxe;
48  t_uint64 m_offset_fix1,m_offset_fix2,m_offset_fix1_delta,m_bytes_written;
50 };
51 
52 #endif //_foobar2000_wav_writer_h_
void setup_wfx(WAVEFORMATEX &p_wfx)
Definition: writer_wav.cpp:70
service_ptr_t< audio_postprocessor > m_postprocessor
Definition: writer_wav.h:45
Definition: pfc.h:71
uint64_t t_uint64
Definition: int_types.h:3
bool is64() const
Definition: writer_wav.h:40
void setup_wfxe(WAVEFORMATEXTENSIBLE &p_wfx)
Definition: writer_wav.cpp:81
Interface to container of a chunk of audio data. See audio_chunk_impl for an implementation.
Definition: audio_chunk.h:5
unsigned m_bpsValid
Definition: writer_wav.h:10
unsigned m_samplerate
Definition: writer_wav.h:10
void initialize(const audio_chunk &p_chunk, unsigned p_bps, bool p_float, bool p_dither, bool p_wave64=false)
Definition: writer_wav.cpp:63
bool m_wfxe
Definition: writer_wav.h:47
t_uint32 idOverhead() const
Definition: writer_wav.h:42
t_uint64 m_offset_fix2
Definition: writer_wav.h:48
bool is_open() const
Definition: writer_wav.h:35
wavWriterSetup_t m_setup
Definition: writer_wav.h:46
unsigned m_bps
Definition: writer_wav.h:10
unsigned m_channel_mask
Definition: writer_wav.h:10
mem_block_container_aligned_incremental_impl< 16 > m_postprocessor_output
Definition: writer_wav.h:49
void write(const service_ptr_t< file > &p_file, abort_callback &p_abort, const char *p_string, bool is_utf8)
void initialize2(const audio_chunk &p_chunk, unsigned p_bps, unsigned p_bpsValid, bool p_float, bool p_dither, bool p_wave64=false)
Definition: writer_wav.cpp:52
service_ptr_t< file > m_file
Definition: writer_wav.h:44
unsigned m_channels
Definition: writer_wav.h:10
void initialize3(const audio_chunk::spec_t &spec, unsigned bps, unsigned bpsValid, bool bFloat, bool bDither, bool bWave64=false)
Definition: writer_wav.cpp:41
bool needWFXE() const
Definition: writer_wav.cpp:21
t_uint32 chunkOverhead() const
Definition: writer_wav.h:41
uint32_t t_uint32
Definition: int_types.h:5