libnedit
Lightweight C++ library for Nintendo DS(i) formats
Loading...
Searching...
No Matches
fmt_SBNK.hpp
1
2#pragma once
3#include <ntr/fmt/fmt_Common.hpp>
4
5namespace ntr::fmt {
6
7 struct SBNK : public fs::FileFormat {
8
9 struct Header : public CommonHeader<0x4B4E4253 /* "SBNK" */ > {
10 };
11
12 struct DataSection : public CommonBlock<0x41544144 /* "DATA" */ > {
13 u8 reserved[0x20];
14 u32 instrument_count;
15 };
16
17 enum class InstrumentType : u8 {
18 Invalid = 0,
19 Pcm = 1,
20 Psg = 2,
21 Noise = 3,
22 DirectPcm = 4,
23 Null = 5,
24 DrumSet = 16,
25 KeySplit = 17
26 };
27
28 static inline constexpr bool IsSimpleInstrument(const InstrumentType type) {
29 return (type == InstrumentType::Pcm) || (type == InstrumentType::Psg) || (type == InstrumentType::Noise) || (type == InstrumentType::DirectPcm) || (type == InstrumentType::Null);
30 }
31
33 InstrumentType type;
34 u16 offset;
35 u8 reserved;
36 };
37
39 u16 swav;
40 u16 swar;
41 u8 note;
42 u8 attack_rate;
43 u8 decay_rate;
44 u8 sustain_level;
45 u8 release_rate;
46 u8 pan;
47 };
48
50 u8 unk1;
51 u8 unk2;
52 InstrumentData data;
53 };
54
56 InstrumentData data;
57 };
58
60 u8 lower_note;
61 u8 upper_note;
62 };
63
65 u8 note_region_end_keys[8];
66 };
67
68 struct KeySplit {
69 KeySplitHeader header;
70 std::vector<HeadedInstrumentData> data;
71 };
72
73 struct DrumSet {
74 DrumSetHeader header;
75 std::vector<HeadedInstrumentData> data;
76 };
77
80 // ...
81 SimpleInstrument simple;
82 DrumSet drum_set;
83 KeySplit key_split;
84 };
85
86 Header header;
87 DataSection data;
88 std::vector<InstrumentRecord> instruments;
89
90 SBNK() {}
91 SBNK(const SBNK&) = delete;
92
93 Result ValidateImpl(const std::string &path, std::shared_ptr<fs::FileHandle> file_handle, const fs::FileCompression comp) override;
94 Result ReadImpl(const std::string &path, std::shared_ptr<fs::FileHandle> file_handle, const fs::FileCompression comp) override;
95
96 Result WriteImpl(const std::string &path, std::shared_ptr<fs::FileHandle> file_handle, const fs::FileCompression comp) override {
97 NTR_R_FAIL(ResultSBNKWriteNotSupported);
98 }
99 };
100
101}
Definition ntr_Include.hpp:75
Definition fmt_Common.hpp:53
Definition fmt_Common.hpp:35
Definition fmt_SBNK.hpp:12
Definition fmt_SBNK.hpp:59
Definition fmt_SBNK.hpp:73
Definition fmt_SBNK.hpp:49
Definition fmt_SBNK.hpp:9
Definition fmt_SBNK.hpp:38
Definition fmt_SBNK.hpp:32
Definition fmt_SBNK.hpp:78
Definition fmt_SBNK.hpp:64
Definition fmt_SBNK.hpp:68
Definition fmt_SBNK.hpp:55
Definition fmt_SBNK.hpp:7
Definition fs_Base.hpp:45