PoiZoneBank.cpp 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. // LYNX's own PoiZone bank (round 168n). Designed for LYNX — never converted from FL's preset files. PoiZone's engine
  2. // is self-contained (two naive saw / pulse oscillators, noise, a 4-pole filter, two envelopes, an LFO, delay, chorus,
  3. // gate and arpeggiator; REA_rodada44), so these presets play without FL Studio. Values follow the laws of §1.3.
  4. #include <algorithm>
  5. #include <cmath>
  6. #include <cstring>
  7. #include "core/LynxBanks.h"
  8. #include "core/PoiZone.h"
  9. namespace lynx::banks
  10. {
  11. namespace
  12. {
  13. struct Poi
  14. {
  15. std::vector<std::uint8_t> s = poizoneDefaultState();
  16. void p (int index, float x)
  17. {
  18. const auto at = poizoneParamOffset (s, index);
  19. if (at >= 0)
  20. std::memcpy (s.data() + at, &x, 4);
  21. }
  22. // −24 − trunc(x·(−48)) = n
  23. static float semis (int n) { return ((float) n + 24.0f + 0.25f) / 48.0f; }
  24. // clamp(x⁴·(hi − lo) + lo) milliseconds
  25. static float ms (float milliseconds, float lo, float hi) { return std::pow (std::clamp ((milliseconds - lo) / (hi - lo), 0.0f, 1.0f), 0.25f); }
  26. static float sel (int i, int count) { return (float) i / (float) (count - 1); }
  27. void oscA (bool pulse, float width = 1.0f) { p (0, pulse ? 1.0f : 0.0f), p (1, width); }
  28. void oscB (bool pulse, int semitones, float detune = 0.0f, float width = 1.0f)
  29. {
  30. p (4, pulse ? 1.0f : 0.0f), p (5, width), p (6, semis (semitones)), p (7, detune);
  31. }
  32. void balance (float x) { p (8, x); } // 0 = osc A … 1 = osc B
  33. void noise (float x) { p (9, x); }
  34. void sync (bool on) { p (2, on ? 1.0f : 0.0f); }
  35. void ring (bool on) { p (3, on ? 1.0f : 0.0f); }
  36. // filter: 0 LP, 1 BP, 2 HP
  37. void filter (int mode, float cutoff, float resonance, float keyTrack = 0.5f, float velTrack = 0.0f)
  38. {
  39. p (66, sel (mode, 3)), p (18, cutoff), p (19, resonance), p (20, keyTrack), p (21, velTrack);
  40. }
  41. // modulation envelope: destination 0 cutoff, 1 Frq A, 2 Frq AB, 3 PW A, 4 PW AB; amount −1…1; times in ms
  42. void modEnv (int destination, float amount, float attack, float decay, float sustain, float release)
  43. {
  44. p (65, sel (destination, 5)), p (10, (amount + 1.0f) * 0.5f);
  45. p (11, ms (attack, 5, 50000)), p (12, ms (decay, 5, 50000)), p (13, sustain), p (14, ms (release, 5, 50000));
  46. }
  47. void amp (float attack, float decay, float sustain, float release)
  48. {
  49. p (22, ms (attack, 1, 5000)), p (23, ms (decay, 5, 20000)), p (24, std::sqrt (sustain)), p (25, ms (release, 15, 10000));
  50. }
  51. // LFO: destination 0 cutoff, 1 Frq A, 2 Frq AB, 3 PW A, 4 PW AB, 5 pan; shape 0 saw, 1 pulse, 2 tri, 3 sine, 4 random
  52. void lfo (int destination, int shape, float amount, float hz, int sync = 0, bool retrigger = false)
  53. {
  54. p (67, sel (destination, 6)), p (68, sel (shape, 5)), p (26, (amount + 1.0f) * 0.5f);
  55. p (28, std::pow (std::clamp (hz / 30.0f, 0.0f, 1.0f), 0.2f)), p (80, (float) sync), p (27, retrigger ? 1.0f : 0.0f);
  56. }
  57. void unison (int index, float detune, float pan) { p (75, (float) index), p (29, detune), p (30, pan); } // index 0…6 → 1, 2, 3, 4, 8, 12, 16
  58. void mono (float glideSeconds, bool held = false)
  59. {
  60. p (44, 1.0f), p (46, std::cbrt (std::clamp (glideSeconds / 2.0f, 0.0f, 1.0f))), p (72, held ? 1.0f : 0.0f);
  61. }
  62. void octaver() { p (45, 1.0f); }
  63. void gain (float x) { p (15, x); }
  64. void transpose (int semitones) { p (17, semis (semitones)); }
  65. void delay (float timeL, float timeR, float feedback, float wet, float hiCut = 0.6f)
  66. {
  67. p (31, 1.0f), p (32, timeL), p (33, timeR), p (34, feedback), p (38, wet), p (37, hiCut);
  68. }
  69. void chorus (float rate, float depth, float wet) { p (39, 1.0f), p (40, rate), p (41, depth), p (42, wet); }
  70. // arpeggiator: mode 1 up, 2 down, 3 up-down, 4 random; range 1…4 octaves; speed index 0…6 → 0.5, 1, 2, 3, 4, 8, 16
  71. void arp (int mode, int range, int speed) { p (69, sel (mode, 5)), p (70, sel (range - 1, 4)), p (77, (float) speed); }
  72. // gate: 16 steps (1 = open), speed index, mix, smooth
  73. void gate (const char* steps, int speed, float mix, float smooth)
  74. {
  75. for (int i = 0; i < 16; ++i)
  76. p (49 + i, steps[i] == 'x' ? 1.0f : 0.0f);
  77. p (79, (float) speed), p (47, mix), p (48, smooth);
  78. }
  79. };
  80. using Recipe = void (*) (Poi&);
  81. Preset make (const char* name, const char* category, std::vector<std::string> tags, Recipe recipe)
  82. {
  83. return { name, category, std::move (tags), [recipe] (ChannelDef& c) {
  84. Poi t;
  85. recipe (t);
  86. c.pluginState = t.s;
  87. } };
  88. }
  89. } // namespace
  90. std::vector<Preset> poizoneBank()
  91. {
  92. return {
  93. make ("Init", "Init", { "init", "saw" }, [] (Poi&) {}),
  94. // --- bass
  95. make ("Acid Line", "Bass", { "acid", "303", "resonant" }, [] (Poi& t) {
  96. t.mono (0.06f), t.oscA (false);
  97. t.filter (0, 0.25f, 0.75f, 0.3f);
  98. t.modEnv (0, 0.55f, 5, 220, 0.0f, 120);
  99. t.amp (1, 400, 0.7f, 40);
  100. t.gain (0.62f);
  101. }),
  102. make ("Fat Saw Bass", "Bass", { "unison", "saw" }, [] (Poi& t) {
  103. t.mono (0.03f), t.oscA (false), t.oscB (false, -12, 0.08f), t.balance (0.45f);
  104. t.unison (1, 0.12f, 0.3f);
  105. t.filter (0, 0.45f, 0.2f);
  106. t.modEnv (0, 0.3f, 5, 300, 0.2f, 100);
  107. t.amp (1, 500, 1.0f, 50);
  108. t.gain (0.58f);
  109. }),
  110. make ("Square Sub", "Bass", { "sub", "square" }, [] (Poi& t) {
  111. t.mono (0.02f), t.oscA (true, 0.5f), t.oscB (false, -12), t.balance (0.3f);
  112. t.filter (0, 0.3f, 0.05f, 0.4f);
  113. t.amp (2, 400, 1.0f, 60);
  114. t.gain (0.6f);
  115. }),
  116. make ("Sync Bass", "Bass", { "sync", "aggressive" }, [] (Poi& t) {
  117. t.mono (0.04f), t.oscA (false), t.oscB (false, 7), t.sync (true), t.balance (0.6f);
  118. t.modEnv (2, 0.45f, 5, 250, 0.1f, 80);
  119. t.filter (0, 0.6f, 0.25f);
  120. t.amp (1, 600, 0.9f, 50);
  121. t.gain (0.55f);
  122. }),
  123. make ("Pluck Bass", "Bass", { "pluck", "short" }, [] (Poi& t) {
  124. t.oscA (true, 0.7f), t.oscB (false, 0, 0.1f), t.balance (0.5f);
  125. t.filter (0, 0.2f, 0.4f, 0.4f);
  126. t.modEnv (0, 0.5f, 5, 160, 0.0f, 80);
  127. t.amp (1, 300, 0.0f, 80);
  128. t.gain (0.887f);
  129. }),
  130. // --- lead
  131. make ("Poison Lead", "Lead", { "saw", "classic" }, [] (Poi& t) {
  132. t.mono (0.08f), t.oscA (false), t.oscB (false, 0, 0.12f), t.balance (0.5f);
  133. t.filter (0, 0.65f, 0.3f);
  134. t.modEnv (0, 0.25f, 10, 400, 0.4f, 200);
  135. t.lfo (1, 3, 0.04f, 5.5f);
  136. t.amp (3, 800, 1.0f, 150);
  137. t.delay (0.43f, 0.43f, 0.35f, 0.22f);
  138. t.gain (0.55f);
  139. }),
  140. make ("Square Lead", "Lead", { "square", "pwm" }, [] (Poi& t) {
  141. t.mono (0.05f), t.oscA (true, 0.5f), t.oscB (true, 12, 0.05f, 0.35f), t.balance (0.35f);
  142. t.lfo (4, 2, 0.35f, 2.0f);
  143. t.filter (0, 0.7f, 0.15f);
  144. t.amp (3, 600, 1.0f, 120);
  145. t.chorus (0.3f, 0.4f, 0.25f);
  146. t.gain (0.55f);
  147. }),
  148. make ("Supersaw", "Lead", { "unison", "trance" }, [] (Poi& t) {
  149. t.oscA (false), t.oscB (false, 0, 0.1f), t.balance (0.5f);
  150. t.unison (4, 0.35f, 0.9f);
  151. t.filter (0, 0.8f, 0.1f);
  152. t.amp (5, 800, 1.0f, 300);
  153. t.delay (0.43f, 0.43f, 0.3f, 0.2f);
  154. t.chorus (0.25f, 0.4f, 0.3f);
  155. t.gain (0.307f);
  156. }),
  157. make ("Sync Scream", "Lead", { "sync", "sweep" }, [] (Poi& t) {
  158. t.mono (0.06f), t.oscA (false), t.oscB (false, 12), t.sync (true), t.balance (0.7f);
  159. t.lfo (2, 2, 0.3f, 0.8f);
  160. t.filter (0, 0.75f, 0.2f);
  161. t.amp (3, 600, 1.0f, 150);
  162. t.gain (0.5f);
  163. }),
  164. make ("Octave Lead", "Lead", { "octaver", "unison" }, [] (Poi& t) {
  165. t.mono (0.07f), t.oscA (true, 0.6f), t.balance (0.0f);
  166. t.unison (1, 0.06f, 0.5f), t.octaver();
  167. t.filter (0, 0.6f, 0.2f);
  168. t.amp (3, 600, 1.0f, 150);
  169. t.delay (0.29f, 0.43f, 0.3f, 0.2f);
  170. t.gain (0.55f);
  171. }),
  172. // --- pad
  173. make ("Soft Pad", "Pad", { "warm", "slow" }, [] (Poi& t) {
  174. t.oscA (false), t.oscB (false, 0, 0.15f), t.balance (0.5f);
  175. t.unison (2, 0.2f, 0.8f);
  176. t.filter (0, 0.4f, 0.1f);
  177. t.modEnv (0, 0.2f, 1200, 2000, 0.5f, 1500);
  178. t.amp (900, 2000, 1.0f, 1800);
  179. t.chorus (0.2f, 0.5f, 0.4f);
  180. t.gain (0.327f);
  181. }),
  182. make ("PWM Strings", "Pad", { "pwm", "strings" }, [] (Poi& t) {
  183. t.oscA (true, 0.55f), t.oscB (true, 0, 0.1f, 0.45f), t.balance (0.5f);
  184. t.lfo (4, 2, 0.3f, 0.7f);
  185. t.filter (0, 0.55f, 0.05f);
  186. t.amp (500, 1000, 1.0f, 900);
  187. t.chorus (0.25f, 0.5f, 0.4f);
  188. t.gain (0.387f);
  189. }),
  190. make ("Sweep Pad", "Pad", { "sweep", "lfo" }, [] (Poi& t) {
  191. t.oscA (false), t.oscB (false, 7, 0.1f), t.balance (0.45f);
  192. t.unison (1, 0.15f, 0.7f);
  193. t.filter (0, 0.35f, 0.45f);
  194. t.lfo (0, 2, 0.4f, 0.15f);
  195. t.amp (1200, 2000, 1.0f, 2000);
  196. t.delay (0.57f, 0.71f, 0.4f, 0.25f);
  197. t.gain (0.5f);
  198. }),
  199. make ("Noise Wind", "Pad", { "noise", "atmosphere" }, [] (Poi& t) {
  200. t.noise (0.9f), t.balance (0.5f);
  201. t.filter (1, 0.45f, 0.6f, 0.0f);
  202. t.lfo (0, 4, 0.35f, 0.4f);
  203. t.amp (1500, 2000, 1.0f, 2500);
  204. t.chorus (0.2f, 0.6f, 0.4f);
  205. t.gain (0.55f);
  206. }),
  207. // --- pluck
  208. make ("Poly Pluck", "Pluck", { "short", "bright" }, [] (Poi& t) {
  209. t.oscA (false), t.oscB (false, 12, 0.08f), t.balance (0.4f);
  210. t.filter (0, 0.3f, 0.3f);
  211. t.modEnv (0, 0.5f, 5, 200, 0.0f, 150);
  212. t.amp (1, 450, 0.0f, 200);
  213. t.delay (0.43f, 0.57f, 0.35f, 0.22f);
  214. t.gain (0.58f);
  215. }),
  216. make ("Arp Pluck", "Pluck", { "arpeggio", "trance" }, [] (Poi& t) {
  217. t.oscA (false), t.oscB (true, 0, 0.08f, 0.5f), t.balance (0.5f);
  218. t.filter (0, 0.35f, 0.35f);
  219. t.modEnv (0, 0.4f, 5, 150, 0.0f, 100);
  220. t.amp (1, 250, 0.0f, 120);
  221. t.arp (3, 2, 3);
  222. t.delay (0.43f, 0.43f, 0.4f, 0.25f);
  223. t.gain (0.58f);
  224. }),
  225. make ("Gated Chords", "Pluck", { "gate", "trance" }, [] (Poi& t) {
  226. t.oscA (false), t.oscB (false, 0, 0.12f), t.balance (0.5f);
  227. t.unison (2, 0.2f, 0.8f);
  228. t.filter (0, 0.55f, 0.15f);
  229. t.amp (5, 800, 1.0f, 200);
  230. t.gate ("x.xx.x.xx.xx.x.x", 3, 1.0f, 0.15f);
  231. t.gain (0.52f);
  232. }),
  233. // --- keys
  234. make ("Funk Key", "Keys", { "clav", "funk" }, [] (Poi& t) {
  235. t.oscA (true, 0.3f), t.oscB (true, 12, 0.03f, 0.6f), t.balance (0.4f);
  236. t.filter (0, 0.35f, 0.25f, 0.5f, 0.5f);
  237. t.modEnv (0, 0.45f, 5, 180, 0.1f, 60);
  238. t.amp (1, 400, 0.3f, 60);
  239. t.gain (0.6f);
  240. }),
  241. make ("Ring Bell", "Keys", { "ring", "bell" }, [] (Poi& t) {
  242. t.oscA (false), t.oscB (false, 19, 0.0f), t.ring (true), t.balance (0.5f);
  243. t.filter (0, 0.75f, 0.1f);
  244. t.amp (1, 1500, 0.0f, 900);
  245. t.delay (0.43f, 0.57f, 0.3f, 0.2f);
  246. t.gain (0.6f);
  247. }),
  248. make ("Soft Keys", "Keys", { "mellow" }, [] (Poi& t) {
  249. t.oscA (true, 0.5f), t.balance (0.0f);
  250. t.filter (0, 0.3f, 0.05f, 0.6f, 0.6f);
  251. t.modEnv (0, 0.25f, 5, 600, 0.2f, 300);
  252. t.amp (2, 1200, 0.4f, 400);
  253. t.chorus (0.25f, 0.4f, 0.3f);
  254. t.gain (0.457f);
  255. }),
  256. // --- fx
  257. make ("Sci-Fi Siren", "FX", { "siren", "lfo" }, [] (Poi& t) {
  258. t.mono (0.0f), t.oscA (true, 0.5f);
  259. t.lfo (2, 2, 0.6f, 1.5f);
  260. t.filter (0, 0.7f, 0.2f);
  261. t.amp (50, 1000, 1.0f, 600);
  262. t.delay (0.43f, 0.57f, 0.5f, 0.3f);
  263. t.gain (0.5f);
  264. }),
  265. make ("Noise Riser", "FX", { "riser", "noise", "sweep" }, [] (Poi& t) {
  266. t.noise (1.0f);
  267. t.filter (0, 0.1f, 0.5f, 0.0f);
  268. t.modEnv (0, 0.85f, 4000, 1000, 1.0f, 500);
  269. t.amp (3000, 1000, 1.0f, 600);
  270. t.gain (0.55f);
  271. }),
  272. make ("Zap", "FX", { "zap", "laser" }, [] (Poi& t) {
  273. t.oscA (true, 0.5f);
  274. t.modEnv (1, -0.9f, 5, 120, 0.0f, 60);
  275. t.amp (1, 200, 0.0f, 80);
  276. t.delay (0.29f, 0.43f, 0.45f, 0.3f);
  277. t.gain (0.55f);
  278. }),
  279. };
  280. }
  281. } // namespace lynx::banks