• R/O
  • HTTP
  • SSH
  • HTTPS

timidity41: Commit


Commit MetaInfo

Revisiondd7cf0a144cf1e7817af6ccb4802926cc3ce8534 (tree)
Time2020-10-10 04:23:53
AuthorStarg <starg@user...>
CommiterStarg

Log Message

[sfz] Add support for cutoff and resonance

Change Summary

Incremental Difference

--- 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,
@@ -842,6 +843,7 @@ enum class OpCodeKind
842843 Pan,
843844 PitchKeyCenter,
844845 Position,
846+ Resonance,
845847 RtDecay,
846848 Sample,
847849 SequenceLength,
@@ -1043,6 +1045,7 @@ public:
10431045 case OpCodeKind::AmpEG_Sustain:
10441046 case OpCodeKind::AmpKeyTrack:
10451047 case OpCodeKind::AmpVelTrack:
1048+ case OpCodeKind::Cutoff:
10461049 case OpCodeKind::End:
10471050 case OpCodeKind::HiRand:
10481051 case OpCodeKind::HiVelocity:
@@ -1053,6 +1056,7 @@ public:
10531056 case OpCodeKind::Offset:
10541057 case OpCodeKind::Pan:
10551058 case OpCodeKind::Position:
1059+ case OpCodeKind::Resonance:
10561060 case OpCodeKind::RtDecay:
10571061 case OpCodeKind::SequenceLength:
10581062 case OpCodeKind::SequencePosition:
@@ -1201,6 +1205,7 @@ private:
12011205 {"amp_keycenter"sv, OpCodeKind::AmpKeyCenter},
12021206 {"amp_keytrack"sv, OpCodeKind::AmpKeyTrack},
12031207 {"amp_veltrack"sv, OpCodeKind::AmpVelTrack},
1208+ {"cutoff"sv, OpCodeKind::Cutoff},
12041209 {"default_path"sv, OpCodeKind::DefaultPath},
12051210 {"end"sv, OpCodeKind::End},
12061211 {"hikey"sv, OpCodeKind::HiKey},
@@ -1217,6 +1222,7 @@ private:
12171222 {"pan"sv, OpCodeKind::Pan},
12181223 {"pitch_keycenter"sv, OpCodeKind::PitchKeyCenter},
12191224 {"position"sv, OpCodeKind::Position},
1225+ {"resonance"sv, OpCodeKind::Resonance},
12201226 {"rt_decay"sv, OpCodeKind::RtDecay},
12211227 {"sample"sv, OpCodeKind::Sample},
12221228 {"seq_length"sv, OpCodeKind::SequenceLength},
@@ -1767,6 +1773,17 @@ private:
17671773 );
17681774 }
17691775
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+
17701787 if (auto seqLen = flatSection.GetAs<double>(OpCodeKind::SequenceLength))
17711788 {
17721789 s.seq_length = std::clamp(static_cast<int32>(std::round(seqLen.value())), 1, 100);
Show on old repository browser