libnedit
Lightweight C++ library for Nintendo DS(i) formats
Loading...
Searching...
No Matches
fmt_SWAR.hpp
1
2#pragma once
3#include <ntr/fmt/fmt_Common.hpp>
4
5namespace ntr::fmt {
6
7 struct SWAR : public fs::FileFormat {
8
9 struct Header : public CommonHeader<0x52415753 /* "SWAR" */ > {
10 };
11
12 struct SampleInfo {
13 WaveType wave_type;
14 bool has_loop;
15 u16 sample_rate;
16 u16 time;
17 u16 loop_offset;
18 u32 non_loop_len;
19 };
20
21 struct Sample {
22 u32 info_offset;
23 SampleInfo info;
24 u32 data_size;
25 };
26
27 struct DataSection : public CommonBlock<0x41544144 /* "DATA" */ > {
28 u8 unk_pad[32];
29 u32 sample_count;
30 };
31
32 Header header;
33 DataSection data;
34 std::vector<Sample> samples;
35
36 SWAR() {}
37 SWAR(const SWAR&) = delete;
38
39 Result ReadSampleData(const Sample sample, u8 *out_sample_data);
40 Result WriteSampleData(const Sample sample, const u8 *sample_data, size_t sample_data_size, const std::string &path, std::shared_ptr<fs::FileHandle> file_handle);
41
42 inline Result WriteSampleData(const Sample sample, const u8 *sample_data, size_t sample_data_size, std::shared_ptr<fs::FileHandle> file_handle) {
43 return this->WriteSampleData(sample, sample_data, sample_data_size, this->read_path, file_handle);
44 }
45
46 Result ValidateImpl(const std::string &path, std::shared_ptr<fs::FileHandle> file_handle, const fs::FileCompression comp) override;
47 Result ReadImpl(const std::string &path, std::shared_ptr<fs::FileHandle> file_handle, const fs::FileCompression comp) override;
48
49 Result WriteImpl(const std::string &path, std::shared_ptr<fs::FileHandle> file_handle, const fs::FileCompression comp) override {
50 NTR_R_FAIL(ResultSWARWriteNotSupported);
51 }
52 };
53
54}
Definition ntr_Include.hpp:75
Definition fmt_Common.hpp:53
Definition fmt_Common.hpp:35
Definition fmt_SWAR.hpp:27
Definition fmt_SWAR.hpp:9
Definition fmt_SWAR.hpp:12
Definition fmt_SWAR.hpp:21
Definition fmt_SWAR.hpp:7
Definition fs_Base.hpp:45