Tabula Sonora 0.1.0
A native C++20 implementation of the Roland Sound Canvas VA synth voice
Loading...
Searching...
No Matches
table_manifest.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <optional>
5#include <string>
6#include <string_view>
7#include <unordered_map>
8#include <vector>
9
10namespace ts {
11
20 std::string file_name;
22 std::string product;
24 std::string version;
26 std::int64_t size = 0;
28 std::string sha256;
30 std::string sha1;
32 std::string md5;
34 std::uint32_t pe_timestamp = 0;
35};
36
38struct TableEntry {
40 std::string name;
42 std::string symbol;
44 std::string subsystem;
46 std::string dtype;
51 std::string shape;
53 std::int32_t size = 0;
55 std::int64_t file_offset = 0;
57 std::optional<std::int64_t> va;
59 std::optional<std::int64_t> section_adjust;
61 std::string match = "full";
63 std::string purpose;
64};
65
72struct LiveRegion {
74 std::string name;
76 std::string symbol;
78 std::string subsystem;
80 std::string dtype;
82 std::int64_t file_offset = 0;
84 std::optional<std::int64_t> size;
86 std::string purpose;
87};
88
94class TableManifest {
95public:
97 [[nodiscard]] static const TableManifest& defaults();
98
102 [[nodiscard]] static TableManifest parse(std::string_view json);
103
105 [[nodiscard]] const DllIdentity& dll() const noexcept { return dll_; }
106
108 [[nodiscard]] std::int64_t image_base() const noexcept { return image_base_; }
109
111 [[nodiscard]] const std::vector<TableEntry>& cached_tables() const noexcept { return tables_; }
112
114 [[nodiscard]] const std::vector<LiveRegion>& live_regions() const noexcept { return regions_; }
115
119 [[nodiscard]] const TableEntry& table(std::string_view name) const;
120
124 [[nodiscard]] const LiveRegion& region(std::string_view name) const;
125
126private:
127 TableManifest() = default;
128
129 void index();
130
135 struct StringHash {
136 using is_transparent = void;
137
138 [[nodiscard]] std::size_t operator()(std::string_view text) const noexcept
139 {
140 return std::hash<std::string_view>{}(text);
141 }
142 };
143
144 using Index = std::unordered_map<std::string, std::size_t, StringHash, std::equal_to<>>;
145
146 DllIdentity dll_;
147 std::int64_t image_base_ = 0;
148 std::vector<TableEntry> tables_;
149 std::vector<LiveRegion> regions_;
150 Index by_name_;
151 Index regions_by_name_;
152};
153
154} // namespace ts
const TableEntry & table(std::string_view name) const
Looks up a cached table by its .bin file name, e.g.
static const TableManifest & defaults()
The manifest embedded in this library. Parsed once, on first use.
static TableManifest parse(std::string_view json)
Parses a manifest from a JSON document.
const DllIdentity & dll() const noexcept
The DLL build these offsets are valid for.
Definition table_manifest.hpp:105
const std::vector< LiveRegion > & live_regions() const noexcept
The regions read directly from the DLL rather than cached.
Definition table_manifest.hpp:114
std::int64_t image_base() const noexcept
The DLL's preferred image base, 0x180000000.
Definition table_manifest.hpp:108
const std::vector< TableEntry > & cached_tables() const noexcept
The static tables cached as .bin slices.
Definition table_manifest.hpp:111
const LiveRegion & region(std::string_view name) const
Looks up a live region by name, e.g.
Definition control_decode.hpp:7
Identity of the SCCore.dll build every offset in the manifest is pinned to.
Definition table_manifest.hpp:18
std::string md5
Lower-case hex MD5 of the whole file.
Definition table_manifest.hpp:32
std::string version
The SOUND Canvas VA release this build ships in — 1.1.6.
Definition table_manifest.hpp:24
std::int64_t size
Exact file size in bytes.
Definition table_manifest.hpp:26
std::string sha1
Lower-case hex SHA-1 of the whole file.
Definition table_manifest.hpp:30
std::string sha256
Lower-case hex SHA-256 of the whole file.
Definition table_manifest.hpp:28
std::string product
Human-readable product description.
Definition table_manifest.hpp:22
std::uint32_t pe_timestamp
COFF TimeDateStamp from the PE header.
Definition table_manifest.hpp:34
std::string file_name
Expected file name, for diagnostics only.
Definition table_manifest.hpp:20
A region read straight from the DLL at render time rather than cached to a .bin file — the two wave-R...
Definition table_manifest.hpp:72
std::optional< std::int64_t > size
Length in bytes, when the manifest records one.
Definition table_manifest.hpp:84
std::int64_t file_offset
Offset of the first byte within the DLL file.
Definition table_manifest.hpp:82
std::string subsystem
Owning subsystem, ROM or DIR.
Definition table_manifest.hpp:78
std::string name
Region name, e.g. wave_rom_bank_A.
Definition table_manifest.hpp:74
std::string purpose
What the region is for.
Definition table_manifest.hpp:86
std::string dtype
Element description.
Definition table_manifest.hpp:80
std::string symbol
Project label for the symbol.
Definition table_manifest.hpp:76
One static table sliced byte-for-byte out of the DLL.
Definition table_manifest.hpp:38
std::string shape
Human-readable shape, e.g.
Definition table_manifest.hpp:51
std::optional< std::int64_t > va
Virtual address in the loaded image, when known.
Definition table_manifest.hpp:57
std::string subsystem
Owning subsystem: TVA, TVF, PITCH, ENV, LFO, DIR, SAMPLER, MIX or CTRL.
Definition table_manifest.hpp:44
std::string symbol
Project label for the symbol, e.g. g_amp_curve_hi. Not Roland's name.
Definition table_manifest.hpp:42
std::string dtype
Element type as recorded by the manifest generator.
Definition table_manifest.hpp:46
std::int32_t size
Length in bytes.
Definition table_manifest.hpp:53
std::optional< std::int64_t > section_adjust
Section skew used to derive file_offset from va.
Definition table_manifest.hpp:59
std::string purpose
What the table is for.
Definition table_manifest.hpp:63
std::string match
full when the cached bytes match the DLL exactly, or prefix n/m for an over-read cache.
Definition table_manifest.hpp:61
std::int64_t file_offset
Offset of the first byte within the DLL file.
Definition table_manifest.hpp:55
std::string name
Cache file name, e.g. curve_amp_hi_2ba0.bin.
Definition table_manifest.hpp:40