OpenGothic
Open source reimplementation of Gothic I and II
Loading...
Searching...
No Matches
patternlist.h
Go to the documentation of this file.
1#pragma once
2
3#include <Tempest/Sound>
4#include <unordered_map>
5#include <atomic>
6
7#include "segment.h"
8#include "soundfont.h"
9#include "style.h"
10
11namespace Dx8 {
12
13class DirectMusic;
14class DlsCollection;
15class SoundFont;
16class Music;
17
18class PatternList final {
19 public:
20 struct Pattern {
21 std::string name;
22 };
23
24 PatternList()=default;
26
28
29 auto operator[](size_t i) const -> const Pattern& { return intern->pptn[i]; }
30 size_t size() const;
31
32 void dbgDumpPatternList() const;
33 void dbgDump(const size_t patternId) const;
34
35 private:
36 PatternList(const Segment& s,DirectMusic& owner);
37
38 struct Instrument final {
39 const DlsCollection* dls=nullptr;
40 float volume=0.f;
41 float pan=0.f;
42 uint32_t dwPatch=0;
43 };
44
45 struct InsInternal final {
46 uint32_t key;
47 Dx8::SoundFont font;
48 float volume =0.f;
49 float pan =0.f;
50
51 uint32_t dwVariationChoices[32]={};
52 uint8_t dwVarCount=0;
53 };
54
55 struct Note final {
56 uint64_t at =0;
57 uint64_t duration =0;
58 uint8_t note =0;
59 uint8_t velosity =127;
60 uint32_t dwVariation=0;
61 InsInternal* inst =nullptr;
62 };
63
64 struct Curve final {
65 uint64_t at =0;
66 uint64_t duration =0;
68 float startV =0.f;
69 float endV =0.f;
70 Control ctrl =BankSelect;
71 uint32_t dwVariation=0;
72 InsInternal* inst =nullptr;
73 };
74
75 struct Groove final {
76 uint64_t at = 0;
77 uint8_t bGrooveLevel = 0;
78 uint8_t bGrooveRange = 0;
79 };
80
81 struct PatternInternal final : Pattern {
82 DMUS_IO_PATTERN ptnh;
83 DMUS_IO_STYLE styh;
84
85 uint64_t timeTotal=0;
86
87 std::vector<InsInternal> instruments;
88 std::vector<Note> waves;
89 std::vector<Curve> volume;
90 };
91
92 struct Internal final {
93 std::vector<PatternInternal> pptn;
94 std::vector<Groove> groove;
95 };
96
97 void index();
98 void index(const Style &stl, PatternInternal& inst, const Dx8::Pattern &pattern);
99 void index(PatternInternal &idx, InsInternal *inst, const Style &stl, const Style::Part &part);
100
101 void dbgDump(const Style &stl, const Dx8::Pattern::PartRef &pref, const Style::Part &part) const;
102
103 DirectMusic* owner=nullptr;
104
105 uint32_t cordHeader=0;
106 std::vector<DMUS_IO_SUBCHORD> subchord;
107 const Style* style=nullptr;
108 std::vector<DMUS_IO_COMMAND> commands;
109
110 std::unordered_map<uint32_t,Instrument> instruments;
111 std::shared_ptr<Internal> intern;
112
113
114 friend class DirectMusic;
115 friend class Mixer;
116 friend class Music;
117 };
118
119}
PatternList & operator=(PatternList &&)=default
auto operator[](size_t i) const -> const Pattern &
Definition patternlist.h:29
PatternList()=default
size_t size() const
PatternList(PatternList &&)=default
void dbgDumpPatternList() const
friend class DirectMusic
void dbgDump(const size_t patternId) const
Definition band.h:10
Shape
Definition structs.h:219
@ DMUS_CURVES_LINEAR
Definition structs.h:220
Control
Definition structs.h:200
@ BankSelect
Definition structs.h:201