4#include <Tempest/MemWriter>
11using namespace Tempest;
15 throw std::runtime_error(
"not a riff");
22void DlsCollection::Region::implRead(
Riff &input) {
24 input.
read(&head,
sizeof(head));
26 else if(input.
is(
"LIST") && input.
isListId(
"lart")){
29 else if(input.
is(
"wlnk")){
30 input.
read(&wlink,
sizeof(wlink));
32 else if(input.
is(
"wsmp")){
33 input.
read(&waveSample,
sizeof(waveSample));
34 loop.resize(waveSample.cSampleLoops);
36 input.
read(&i,
sizeof(i));
37 input.
skip(i.cbSize-
sizeof(i));
45 throw std::runtime_error(
"not a riff");
50 input.
read(&cbSize,
sizeof(cbSize));
51 input.
read(&size,
sizeof(size));
52 connectionBlocks.resize(size);
54 for(
auto& i:connectionBlocks) {
55 input.
read(&i,
sizeof(i));
61 throw std::runtime_error(
"not a list");
68void DlsCollection::Instrument::implRead(
Riff &input) {
72 regions.emplace_back(c);
77 articulators.emplace_back(c);
84 else if(input.
is(
"insh")){
85 input.
read(&header,
sizeof(header));
91 throw std::runtime_error(
"not a riff");
101void DlsCollection::implRead(
Riff &input) {
104 else if(input.
is(
"dlid"))
106 else if(input.
is(
"LIST")){
110 wave.emplace_back(std::move(wx));
129 for(
auto& r:i.regions) {
130 if(r.wlink.ulTableIndex<wave.size()) {
131 Log::i(
" ",r.head.RangeKey.usLow,
"-",r.head.RangeKey.usHigh,
" ",r.wlink.ulTableIndex);
133 Log::i(
" ",r.wlink.ulTableIndex);
141 for(
auto& r:i.regions) {
142 if(r.head.RangeKey.usLow<=note && note<=r.head.RangeKey.usHigh) {
143 if(r.wlink.ulTableIndex<wave.size())
144 return &wave[r.wlink.ulTableIndex];
std::vector< Instrument > instrument
DlsCollection(Riff &input)
const Wave * findWave(uint8_t note) const
SoundFont toSoundfont(uint32_t dwPatch) const
bool is(const char *idx) const
void read(std::u16string &str)
bool isListId(const char *id)
static std::shared_ptr< Data > shared(const DlsCollection &dls, const std::vector< Wave > &wave)