• R/O
  • HTTP
  • SSH
  • HTTPS

timidity41: Commit


Commit MetaInfo

Révision83f7f1746dd03c738d6f37724ab376accf46968d (tree)
l'heure2020-10-10 04:26:29
AuteurStarg <starg@user...>
CommiterStarg

Message de Log

Merge branch 'dev41' into unicode

Change Summary

Modification

--- a/timidity/dls.cpp
+++ b/timidity/dls.cpp
@@ -134,18 +134,22 @@ struct DLSConnectionBlock
134134 {
135135 enum class SourceKind : std::uint16_t
136136 {
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,
144144
145145 CC1 = 0x81,
146146 CC7 = 0x87,
147147 CC10 = 0x8A,
148- CC11 = 0x8B
148+ CC11 = 0x8B,
149+
150+ RPN0 = 0x100,
151+ RPN1 = 0x101,
152+ RPN2 = 0x102
149153 };
150154
151155 SourceKind Source;
@@ -153,31 +157,31 @@ struct DLSConnectionBlock
153157
154158 enum class DestinationKind : std::uint16_t
155159 {
156- None,
157- Attenuation,
160+ None = 0,
161+ Attenuation = 1,
158162 Pitch = 3,
159- Pan,
163+ Pan = 4,
160164
161165 LFOFrequency = 0x104,
162- LFOStartDelay,
166+ LFOStartDelay = 0x105,
163167
164168 EG1AttackTime = 0x206,
165- EG1DecayTime,
169+ EG1DecayTime = 0x297,
166170 EG1ReleaseTime = 0x209,
167- EG1SustainLevel,
171+ EG1SustainLevel = 0x20A,
168172
169173 EG2AttackTime = 0x30A,
170- EG2DecayTime,
174+ EG2DecayTime = 0x30B,
171175 EG2ReleaseTime = 0x30D,
172- EG2SustainLevel
176+ EG2SustainLevel = 0x30E
173177 };
174178
175179 DestinationKind Destination;
176180
177181 enum class TransformKind : std::uint16_t
178182 {
179- None,
180- Concave
183+ None = 0,
184+ Concave = 1
181185 };
182186
183187 TransformKind Transform;
@@ -613,7 +617,7 @@ public:
613617 case DLSConnectionBlock::DestinationKind::Pan:
614618 if (b.Source == DLSConnectionBlock::SourceKind::None && b.Control == DLSConnectionBlock::SourceKind::None && b.Transform == DLSConnectionBlock::TransformKind::None)
615619 {
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);
617621 continue;
618622 }
619623 break;
--- a/timidity/instrum.h
+++ b/timidity/instrum.h
@@ -90,7 +90,7 @@ typedef struct _Sample {
9090 int8 xfmode_key, xfin_lokey, xfin_hikey, xfout_lokey, xfout_hikey;
9191 int8 xfmode_vel, xfin_lovel, xfin_hivel, xfout_lovel, xfout_hivel;
9292
93- // keyswitches (requires MODES_KEYSWITCHES)
93+ // keyswitches (requires MODES_KEYSWITCH)
9494 int8 sw_lokey, sw_hikey, sw_default, sw_down, sw_up, sw_previous, sw_lolast, sw_hilast;
9595 } Sample;
9696
--- a/timidity/sfz.cpp
+++ b/timidity/sfz.cpp
@@ -826,6 +826,7 @@ enum class OpCodeKind
826826 AmpKeyCenter,
827827 AmpKeyTrack,
828828 AmpVelTrack,
829+ Cutoff,
829830 DefaultPath,
830831 End,
831832 HiKey,
@@ -841,6 +842,8 @@ enum class OpCodeKind
841842 Key,
842843 Pan,
843844 PitchKeyCenter,
845+ Position,
846+ Resonance,
844847 RtDecay,
845848 Sample,
846849 SequenceLength,
@@ -858,6 +861,7 @@ enum class OpCodeKind
858861 Trigger,
859862 Tune,
860863 Volume,
864+ Width,
861865 XfInHiKey,
862866 XfInHiVel,
863867 XfInLoKey,
@@ -1041,6 +1045,7 @@ public:
10411045 case OpCodeKind::AmpEG_Sustain:
10421046 case OpCodeKind::AmpKeyTrack:
10431047 case OpCodeKind::AmpVelTrack:
1048+ case OpCodeKind::Cutoff:
10441049 case OpCodeKind::End:
10451050 case OpCodeKind::HiRand:
10461051 case OpCodeKind::HiVelocity:
@@ -1050,12 +1055,15 @@ public:
10501055 case OpCodeKind::LoVelocity:
10511056 case OpCodeKind::Offset:
10521057 case OpCodeKind::Pan:
1058+ case OpCodeKind::Position:
1059+ case OpCodeKind::Resonance:
10531060 case OpCodeKind::RtDecay:
10541061 case OpCodeKind::SequenceLength:
10551062 case OpCodeKind::SequencePosition:
10561063 case OpCodeKind::Transpose:
10571064 case OpCodeKind::Tune:
10581065 case OpCodeKind::Volume:
1066+ case OpCodeKind::Width:
10591067 case OpCodeKind::XfInHiVel:
10601068 case OpCodeKind::XfInLoVel:
10611069 case OpCodeKind::XfOutHiVel:
@@ -1197,6 +1205,7 @@ private:
11971205 {"amp_keycenter"sv, OpCodeKind::AmpKeyCenter},
11981206 {"amp_keytrack"sv, OpCodeKind::AmpKeyTrack},
11991207 {"amp_veltrack"sv, OpCodeKind::AmpVelTrack},
1208+ {"cutoff"sv, OpCodeKind::Cutoff},
12001209 {"default_path"sv, OpCodeKind::DefaultPath},
12011210 {"end"sv, OpCodeKind::End},
12021211 {"hikey"sv, OpCodeKind::HiKey},
@@ -1212,6 +1221,8 @@ private:
12121221 {"offset"sv, OpCodeKind::Offset},
12131222 {"pan"sv, OpCodeKind::Pan},
12141223 {"pitch_keycenter"sv, OpCodeKind::PitchKeyCenter},
1224+ {"position"sv, OpCodeKind::Position},
1225+ {"resonance"sv, OpCodeKind::Resonance},
12151226 {"rt_decay"sv, OpCodeKind::RtDecay},
12161227 {"sample"sv, OpCodeKind::Sample},
12171228 {"seq_length"sv, OpCodeKind::SequenceLength},
@@ -1229,6 +1240,7 @@ private:
12291240 {"trigger"sv, OpCodeKind::Trigger},
12301241 {"tune"sv, OpCodeKind::Tune},
12311242 {"volume"sv, OpCodeKind::Volume},
1243+ {"width"sv, OpCodeKind::Width},
12321244 {"xf_keycurve"sv, OpCodeKind::XfKeyCurve},
12331245 {"xf_velcurve"sv, OpCodeKind::XfVelCurve},
12341246 {"xfin_hikey"sv, OpCodeKind::XfInHiKey},
@@ -1631,7 +1643,47 @@ private:
16311643 + std::clamp(flatSection.GetAs<double>(OpCodeKind::Tune).value_or(0.0), -100.0, 100.0) / 1200.0
16321644 );
16331645
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+ }
16351687
16361688 s.envelope_keyf_bpo = static_cast<int8>(std::clamp(flatSection.GetAs<std::int32_t>(OpCodeKind::AmpKeyCenter).value_or(60), -127, 127));
16371689 s.envelope_velf_bpo = 0;
@@ -1721,6 +1773,17 @@ private:
17211773 );
17221774 }
17231775
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+
17241787 if (auto seqLen = flatSection.GetAs<double>(OpCodeKind::SequenceLength))
17251788 {
17261789 s.seq_length = std::clamp(static_cast<int32>(std::round(seqLen.value())), 1, 100);
Afficher sur ancien navigateur de dépôt.