libnedit
Lightweight C++ library for Nintendo DS(i) formats
Loading...
Searching...
No Matches
fmt_STRM.hpp
1
2#pragma once
3#include <ntr/fmt/fmt_Common.hpp>
4
5namespace ntr::fmt {
6
7 struct STRM : public fs::FileFormat {
8
9 struct Header : public CommonHeader<0x4D525453 /* "STRM" */ > {
10 };
11
12 struct HeadSection : public CommonBlock<0x44414548 /* "HEAD" */ > {
13 WaveType type;
14 bool has_loop;
15 u8 channel_count;
16 u8 unk_pad;
17 u16 sample_rate;
18 u16 time;
19 u32 loop_offset;
20 u32 sample_count;
21 u32 data_offset;
22 u32 block_count;
23 u32 block_size;
24 u32 samples_per_block;
25 u32 last_block_size;
26 u32 samples_per_last_block;
27 u8 reserved[32];
28 };
29
30 struct DataSection : public CommonBlock<0x41544144 /* "DATA" */ > {
31 };
32
33 Header header;
34 HeadSection head;
35 DataSection data;
36
37 STRM() {}
38 STRM(const STRM&) = delete;
39
40 inline constexpr size_t GetBlockSize(const u32 block_idx) {
41 if(block_idx < this->head.block_count) {
42 if(block_idx == this->head.block_count - 1) {
43 return this->head.last_block_size;
44 }
45 else {
46 return this->head.block_size;
47 }
48 }
49 else {
50 return 0;
51 }
52 }
53
54 /* TODO: read/write stream data blocks */
55
56 Result ValidateImpl(const std::string &path, std::shared_ptr<fs::FileHandle> file_handle, const fs::FileCompression comp) override;
57 Result ReadImpl(const std::string &path, std::shared_ptr<fs::FileHandle> file_handle, const fs::FileCompression comp) override;
58
59 Result WriteImpl(const std::string &path, std::shared_ptr<fs::FileHandle> file_handle, const fs::FileCompression comp) override {
60 NTR_R_FAIL(ResultSTRMWriteNotSupported);
61 }
62 };
63
64}
Definition fmt_Common.hpp:53
Definition fmt_Common.hpp:35
Definition fmt_STRM.hpp:30
Definition fmt_STRM.hpp:12
Definition fmt_STRM.hpp:9
Definition fmt_STRM.hpp:7
Definition fs_Base.hpp:45