Tabula Sonora 0.1.0
A native C++20 implementation of the Roland Sound Canvas VA synth voice
Loading...
Searching...
No Matches
tone.hpp
Go to the documentation of this file.
1#pragma once
2
5
6#include <cstdint>
7#include <span>
8#include <string>
9#include <vector>
10
11namespace ts {
12
14class Tone {
15public:
17 static constexpr int stride = 0x100;
18
20 static constexpr int header_size = 0x24;
21
23 static constexpr int partial_slots = 2;
24
26 static constexpr int name_length = 12;
27
31 [[nodiscard]] static Tone read(std::span<const std::uint8_t> tone_table, int number);
32
34 [[nodiscard]] int number() const noexcept { return number_; }
35
37 [[nodiscard]] const std::string& name() const noexcept { return name_; }
38
43 [[nodiscard]] int level() const noexcept { return level_; }
44
49 [[nodiscard]] const std::vector<PartialParameters>& partials() const noexcept
50 {
51 return partials_;
52 }
53
58 [[nodiscard]] bool is_defined() const noexcept { return name_.size() >= 2; }
59
60private:
61 int number_ = 0;
62 std::string name_;
63 int level_ = 0;
64 std::vector<PartialParameters> partials_;
65};
66
76
80 std::string name;
82 std::vector<ResolvedPartial> partials;
83};
84
85} // namespace ts
One melodic tone record: an ASCII name, a master level, and up to two partial parameter blocks.
Definition tone.hpp:14
const std::string & name() const noexcept
The tone's ASCII name, trailing padding removed.
Definition tone.hpp:37
int level() const noexcept
Per-tone master level, header +0x0c.
Definition tone.hpp:43
bool is_defined() const noexcept
Whether this record holds a real tone.
Definition tone.hpp:58
static Tone read(std::span< const std::uint8_t > tone_table, int number)
Reads a tone record out of the tone table.
int number() const noexcept
The tone number this record was read from.
Definition tone.hpp:34
static constexpr int partial_slots
Partial slots in a melodic tone record. The drum tone table has four.
Definition tone.hpp:23
static constexpr int name_length
Length of the ASCII name field.
Definition tone.hpp:26
static constexpr int header_size
Bytes of header before the first partial block.
Definition tone.hpp:20
static constexpr int stride
Bytes per tone record.
Definition tone.hpp:17
const std::vector< PartialParameters > & partials() const noexcept
The partials that are actually present, in slot order.
Definition tone.hpp:49
Definition control_decode.hpp:7
One partial that sounds for a given note and velocity.
Definition tone.hpp:68
WaveDescriptor descriptor
The wave's ROM coordinates.
Definition tone.hpp:74
int wave
Selected wave number.
Definition tone.hpp:72
int partial_index
Index within the tone's present partials.
Definition tone.hpp:70
The waves that sound for one tone at a given note and velocity.
Definition tone.hpp:78
std::string name
The tone's name, or a placeholder when it is unassigned.
Definition tone.hpp:80
std::vector< ResolvedPartial > partials
The sounding partials.
Definition tone.hpp:82
One entry of the wave-descriptor table: where a sample lives in the wave ROM, how it is tuned,...
Definition wave_descriptor.hpp:14