Revision | 83f7f1746dd03c738d6f37724ab376accf46968d (tree) |
---|---|
Time | 2020-10-10 04:26:29 |
Author | Starg <starg@user...> |
Commiter | Starg |
Merge branch 'dev41' into unicode
@@ -134,18 +134,22 @@ struct DLSConnectionBlock | ||
134 | 134 | { |
135 | 135 | enum class SourceKind : std::uint16_t |
136 | 136 | { |
137 | - None, | |
138 | - LFO, | |
139 | - KeyOnVelocity, | |
140 | - KeyNumber, | |
141 | - EG1, | |
142 | - EG2, | |
143 | - PitchWheel, | |
137 | + None = 0, | |
138 | + LFO = 1, | |
139 | + KeyOnVelocity = 2, | |
140 | + KeyNumber = 3, | |
141 | + EG1 = 4, | |
142 | + EG2 = 5, | |
143 | + PitchWheel = 6, | |
144 | 144 | |
145 | 145 | CC1 = 0x81, |
146 | 146 | CC7 = 0x87, |
147 | 147 | CC10 = 0x8A, |
148 | - CC11 = 0x8B | |
148 | + CC11 = 0x8B, | |
149 | + | |
150 | + RPN0 = 0x100, | |
151 | + RPN1 = 0x101, | |
152 | + RPN2 = 0x102 | |
149 | 153 | }; |
150 | 154 | |
151 | 155 | SourceKind Source; |
@@ -153,31 +157,31 @@ struct DLSConnectionBlock | ||
153 | 157 | |
154 | 158 | enum class DestinationKind : std::uint16_t |
155 | 159 | { |
156 | - None, | |
157 | - Attenuation, | |
160 | + None = 0, | |
161 | + Attenuation = 1, | |
158 | 162 | Pitch = 3, |
159 | - Pan, | |
163 | + Pan = 4, | |
160 | 164 | |
161 | 165 | LFOFrequency = 0x104, |
162 | - LFOStartDelay, | |
166 | + LFOStartDelay = 0x105, | |
163 | 167 | |
164 | 168 | EG1AttackTime = 0x206, |
165 | - EG1DecayTime, | |
169 | + EG1DecayTime = 0x297, | |
166 | 170 | EG1ReleaseTime = 0x209, |
167 | - EG1SustainLevel, | |
171 | + EG1SustainLevel = 0x20A, | |
168 | 172 | |
169 | 173 | EG2AttackTime = 0x30A, |
170 | - EG2DecayTime, | |
174 | + EG2DecayTime = 0x30B, | |
171 | 175 | EG2ReleaseTime = 0x30D, |
172 | - EG2SustainLevel | |
176 | + EG2SustainLevel = 0x30E | |
173 | 177 | }; |
174 | 178 | |
175 | 179 | DestinationKind Destination; |
176 | 180 | |
177 | 181 | enum class TransformKind : std::uint16_t |
178 | 182 | { |
179 | - None, | |
180 | - Concave | |
183 | + None = 0, | |
184 | + Concave = 1 | |
181 | 185 | }; |
182 | 186 | |
183 | 187 | TransformKind Transform; |
@@ -613,7 +617,7 @@ public: | ||
613 | 617 | case DLSConnectionBlock::DestinationKind::Pan: |
614 | 618 | if (b.Source == DLSConnectionBlock::SourceKind::None && b.Control == DLSConnectionBlock::SourceKind::None && b.Transform == DLSConnectionBlock::TransformKind::None) |
615 | 619 | { |
616 | - pSample->sample_pan = std::clamp(b.Scale / 65536.0 / 1000.0, -0.5, 0.5); | |
620 | + pSample->sample_pan = std::clamp(b.Scale / 1000.0, -0.5, 0.5); | |
617 | 621 | continue; |
618 | 622 | } |
619 | 623 | break; |
@@ -90,7 +90,7 @@ typedef struct _Sample { | ||
90 | 90 | int8 xfmode_key, xfin_lokey, xfin_hikey, xfout_lokey, xfout_hikey; |
91 | 91 | int8 xfmode_vel, xfin_lovel, xfin_hivel, xfout_lovel, xfout_hivel; |
92 | 92 | |
93 | - // keyswitches (requires MODES_KEYSWITCHES) | |
93 | + // keyswitches (requires MODES_KEYSWITCH) | |
94 | 94 | int8 sw_lokey, sw_hikey, sw_default, sw_down, sw_up, sw_previous, sw_lolast, sw_hilast; |
95 | 95 | } Sample; |
96 | 96 |
@@ -826,6 +826,7 @@ enum class OpCodeKind | ||
826 | 826 | AmpKeyCenter, |
827 | 827 | AmpKeyTrack, |
828 | 828 | AmpVelTrack, |
829 | + Cutoff, | |
829 | 830 | DefaultPath, |
830 | 831 | End, |
831 | 832 | HiKey, |
@@ -841,6 +842,8 @@ enum class OpCodeKind | ||
841 | 842 | Key, |
842 | 843 | Pan, |
843 | 844 | PitchKeyCenter, |
845 | + Position, | |
846 | + Resonance, | |
844 | 847 | RtDecay, |
845 | 848 | Sample, |
846 | 849 | SequenceLength, |
@@ -858,6 +861,7 @@ enum class OpCodeKind | ||
858 | 861 | Trigger, |
859 | 862 | Tune, |
860 | 863 | Volume, |
864 | + Width, | |
861 | 865 | XfInHiKey, |
862 | 866 | XfInHiVel, |
863 | 867 | XfInLoKey, |
@@ -1041,6 +1045,7 @@ public: | ||
1041 | 1045 | case OpCodeKind::AmpEG_Sustain: |
1042 | 1046 | case OpCodeKind::AmpKeyTrack: |
1043 | 1047 | case OpCodeKind::AmpVelTrack: |
1048 | + case OpCodeKind::Cutoff: | |
1044 | 1049 | case OpCodeKind::End: |
1045 | 1050 | case OpCodeKind::HiRand: |
1046 | 1051 | case OpCodeKind::HiVelocity: |
@@ -1050,12 +1055,15 @@ public: | ||
1050 | 1055 | case OpCodeKind::LoVelocity: |
1051 | 1056 | case OpCodeKind::Offset: |
1052 | 1057 | case OpCodeKind::Pan: |
1058 | + case OpCodeKind::Position: | |
1059 | + case OpCodeKind::Resonance: | |
1053 | 1060 | case OpCodeKind::RtDecay: |
1054 | 1061 | case OpCodeKind::SequenceLength: |
1055 | 1062 | case OpCodeKind::SequencePosition: |
1056 | 1063 | case OpCodeKind::Transpose: |
1057 | 1064 | case OpCodeKind::Tune: |
1058 | 1065 | case OpCodeKind::Volume: |
1066 | + case OpCodeKind::Width: | |
1059 | 1067 | case OpCodeKind::XfInHiVel: |
1060 | 1068 | case OpCodeKind::XfInLoVel: |
1061 | 1069 | case OpCodeKind::XfOutHiVel: |
@@ -1197,6 +1205,7 @@ private: | ||
1197 | 1205 | {"amp_keycenter"sv, OpCodeKind::AmpKeyCenter}, |
1198 | 1206 | {"amp_keytrack"sv, OpCodeKind::AmpKeyTrack}, |
1199 | 1207 | {"amp_veltrack"sv, OpCodeKind::AmpVelTrack}, |
1208 | + {"cutoff"sv, OpCodeKind::Cutoff}, | |
1200 | 1209 | {"default_path"sv, OpCodeKind::DefaultPath}, |
1201 | 1210 | {"end"sv, OpCodeKind::End}, |
1202 | 1211 | {"hikey"sv, OpCodeKind::HiKey}, |
@@ -1212,6 +1221,8 @@ private: | ||
1212 | 1221 | {"offset"sv, OpCodeKind::Offset}, |
1213 | 1222 | {"pan"sv, OpCodeKind::Pan}, |
1214 | 1223 | {"pitch_keycenter"sv, OpCodeKind::PitchKeyCenter}, |
1224 | + {"position"sv, OpCodeKind::Position}, | |
1225 | + {"resonance"sv, OpCodeKind::Resonance}, | |
1215 | 1226 | {"rt_decay"sv, OpCodeKind::RtDecay}, |
1216 | 1227 | {"sample"sv, OpCodeKind::Sample}, |
1217 | 1228 | {"seq_length"sv, OpCodeKind::SequenceLength}, |
@@ -1229,6 +1240,7 @@ private: | ||
1229 | 1240 | {"trigger"sv, OpCodeKind::Trigger}, |
1230 | 1241 | {"tune"sv, OpCodeKind::Tune}, |
1231 | 1242 | {"volume"sv, OpCodeKind::Volume}, |
1243 | + {"width"sv, OpCodeKind::Width}, | |
1232 | 1244 | {"xf_keycurve"sv, OpCodeKind::XfKeyCurve}, |
1233 | 1245 | {"xf_velcurve"sv, OpCodeKind::XfVelCurve}, |
1234 | 1246 | {"xfin_hikey"sv, OpCodeKind::XfInHiKey}, |
@@ -1631,7 +1643,47 @@ private: | ||
1631 | 1643 | + std::clamp(flatSection.GetAs<double>(OpCodeKind::Tune).value_or(0.0), -100.0, 100.0) / 1200.0 |
1632 | 1644 | ); |
1633 | 1645 | |
1634 | - s.sample_pan = std::clamp(flatSection.GetAs<double>(OpCodeKind::Pan).value_or(0.0), -100.0, 100.0) / 200.0; | |
1646 | + | |
1647 | + double panValue = std::clamp(flatSection.GetAs<double>(OpCodeKind::Pan).value_or(0.0) / 200.0, -0.5, 0.5); | |
1648 | + | |
1649 | + if (pSampleInstrument->samples == 2) // stereo | |
1650 | + { | |
1651 | + s.volume *= std::clamp((i == 0 ? 0.5 - panValue : panValue + 0.5) * 2.0, 0.0, 2.0); | |
1652 | + | |
1653 | + s.sample_pan = std::clamp( | |
1654 | + s.sample_pan * flatSection.GetAs<double>(OpCodeKind::Width).value_or(100.0) / 100.0, | |
1655 | + -0.5, | |
1656 | + 0.5 | |
1657 | + ); | |
1658 | + | |
1659 | + s.sample_pan = std::clamp( | |
1660 | + s.sample_pan + flatSection.GetAs<double>(OpCodeKind::Position).value_or(0.0) / 100.0, | |
1661 | + -0.5, | |
1662 | + 0.5 | |
1663 | + ); | |
1664 | + } | |
1665 | + else | |
1666 | + { | |
1667 | + s.sample_pan = panValue; | |
1668 | + | |
1669 | + if (i == 0) | |
1670 | + { | |
1671 | + for (auto op : {OpCodeKind::Width, OpCodeKind::Position}) | |
1672 | + { | |
1673 | + if (flatSection.GetAs<double>(op).has_value()) | |
1674 | + { | |
1675 | + auto loc = flatSection.GetLocationForOpCode(op); | |
1676 | + ctl->cmsg( | |
1677 | + CMSG_WARNING, | |
1678 | + VERB_VERBOSE, | |
1679 | + "%s(%u): 'width' and 'position' opcodes are only operational for stereo samples", | |
1680 | + std::string(m_Parser.GetPreprocessor().GetFileNameFromID(loc.FileID)).c_str(), | |
1681 | + static_cast<std::uint32_t>(loc.Line) | |
1682 | + ); | |
1683 | + } | |
1684 | + } | |
1685 | + } | |
1686 | + } | |
1635 | 1687 | |
1636 | 1688 | s.envelope_keyf_bpo = static_cast<int8>(std::clamp(flatSection.GetAs<std::int32_t>(OpCodeKind::AmpKeyCenter).value_or(60), -127, 127)); |
1637 | 1689 | s.envelope_velf_bpo = 0; |
@@ -1721,6 +1773,17 @@ private: | ||
1721 | 1773 | ); |
1722 | 1774 | } |
1723 | 1775 | |
1776 | + if (auto cutoff = flatSection.GetAs<double>(OpCodeKind::Cutoff)) | |
1777 | + { | |
1778 | + s.cutoff_freq = std::clamp(static_cast<int32>(std::round(cutoff.value())), 1, 20000); | |
1779 | + } | |
1780 | + | |
1781 | + if (auto resonance = flatSection.GetAs<double>(OpCodeKind::Resonance)) | |
1782 | + { | |
1783 | + int resoCB = static_cast<int>(std::round(std::clamp(resonance.value(), 0.0, 40.0) * 10.0)); | |
1784 | + s.resonance = static_cast<int16>(std::clamp(resoCB, 0, 960)); | |
1785 | + } | |
1786 | + | |
1724 | 1787 | if (auto seqLen = flatSection.GetAs<double>(OpCodeKind::SequenceLength)) |
1725 | 1788 | { |
1726 | 1789 | s.seq_length = std::clamp(static_cast<int32>(std::round(seqLen.value())), 1, 100); |