@@ -189,7 +189,9 @@ enum LiveCutControls{ |
189 | 189 | LVC_FILTERDRIVE = 145, // filter input saturation, 0 = clean |
190 | 190 | LVC_CRUSHMIX = 146, // crusher dry / wet (1 = fully crushed) |
191 | 191 | LVC_CRUSHLP = 147, // crusher post lowpass, Hz (20000 = bypassed) |
192 | | - LVC_CONTROL_NR = 148 |
| 192 | + // Appended so existing sessions keep their parameter ids. Bit i = the note i semitones above LVC_CHKEY. |
| 193 | + LVC_CHCUSTOM = 148, // custom pitch classes of the pitchmap scale (used when LVC_CHSCALE = Custom) |
| 194 | + LVC_CONTROL_NR = 149 |
193 | 195 | }; |
194 | 196 |
|
195 | 197 | static const std::array<std::pair<float, float>, LVC_CONTROL_NR> controlLimits = |
@@ -261,7 +263,7 @@ static const std::array<std::pair<float, float>, LVC_CONTROL_NR> controlLimits = |
261 | 263 | {0.0f, 1.0f}, // LVC_CHROMA |
262 | 264 | {0.0f, 5.0f}, // LVC_CHPOS |
263 | 265 | {0.0f, 11.0f}, // LVC_CHKEY |
264 | | - {0.0f, 23.0f}, // LVC_CHSCALE (LVC_NUM_SCALES - 1) |
| 266 | + {0.0f, 30.0f}, // LVC_CHSCALE (LVC_NUM_SCALES - 1) |
265 | 267 | {0.0f, 2.0f}, // LVC_CHCOLOR |
266 | 268 | {-24.0f, 24.0f}, // LVC_CHPITCH (semitones) |
267 | 269 | {-50.0f, 50.0f}, // LVC_CHTUNE (cents) |
@@ -341,7 +343,8 @@ static const std::array<std::pair<float, float>, LVC_CONTROL_NR> controlLimits = |
341 | 343 | {0.0f, 1.0f}, // LVC_DLYROUTE |
342 | 344 | {0.0f, 1.0f}, // LVC_FILTERDRIVE |
343 | 345 | {0.0f, 1.0f}, // LVC_CRUSHMIX |
344 | | - {20.0f, 20000.0f} // LVC_CRUSHLP |
| 346 | + {20.0f, 20000.0f}, // LVC_CRUSHLP |
| 347 | + {0.0f, 4095.0f} // LVC_CHCUSTOM (12 pitch classes) |
345 | 348 | }}; |
346 | 349 |
|
347 | 350 | static const float LVC_DEFAULTS[LVC_CONTROL_NR] = { |
@@ -493,6 +496,7 @@ static const float LVC_DEFAULTS[LVC_CONTROL_NR] = { |
493 | 496 | 0.0f, // LVC_FILTERDRIVE (clean: old sessions sound the same) |
494 | 497 | 1.0f, // LVC_CRUSHMIX (fully wet: old sessions sound the same) |
495 | 498 | 20000.0f, // LVC_CRUSHLP (open: old sessions sound the same) |
| 499 | + 2741.0f, // LVC_CHCUSTOM (C major: 0x0AB5, used when Custom is selected) |
496 | 500 | }; |
497 | 501 |
|
498 | 502 | // Parameter symbols (stable identifiers used by hosts, sessions and preset files). Never reorder or rename. |
@@ -645,6 +649,7 @@ static const char* const LVC_SYMBOLS[LVC_CONTROL_NR] = { |
645 | 649 | "livecut_filterdrive", |
646 | 650 | "livecut_crushmix", |
647 | 651 | "livecut_crushlp", |
| 652 | + "livecut_chcustom", |
648 | 653 | }; |
649 | 654 |
|
650 | 655 | // Chroma scales: bit i set = the note i semitones above the root belongs to the scale. |
@@ -681,18 +686,101 @@ static const LvcScale LVC_SCALES[] = { |
681 | 686 | { "Fifths", lvcMask({0, 7}), -1, 0 }, |
682 | 687 | { "Root Only", lvcMask({0}), -1, 0 }, |
683 | 688 | { "Chromatic", 0x0FFF, -1, 0 }, |
| 689 | + // Modes of melodic minor (appended: old sessions keep their indices) |
| 690 | + { "Dorian #2", lvcMask({0, 1, 3, 5, 7, 9, 10}), -1, 0 }, // 24 |
| 691 | + { "Lydian Augmented", lvcMask({0, 2, 4, 6, 8, 9, 11}), -1, 0 }, // 25 |
| 692 | + { "Lydian Dominant", lvcMask({0, 2, 4, 6, 7, 9, 10}), -1, 0 }, // 26 |
| 693 | + { "Mixo b6", lvcMask({0, 2, 4, 5, 7, 8, 10}), -1, 0 }, // 27 |
| 694 | + { "Locrian #2", lvcMask({0, 2, 3, 5, 6, 8, 10}), -1, 0 }, // 28 |
| 695 | + { "Altered", lvcMask({0, 1, 3, 4, 6, 8, 10}), -1, 0 }, // 29 |
| 696 | + { "Custom", 0, -1, 0 }, // 30: mask comes from LVC_CHCUSTOM |
684 | 697 | }; |
685 | 698 | static constexpr int LVC_NUM_SCALES = static_cast<int>(sizeof(LVC_SCALES) / sizeof(LVC_SCALES[0])); |
686 | | -static_assert(LVC_NUM_SCALES == 24, "LVC_CHSCALE range must match the scale table"); |
| 699 | +static constexpr int kLvcCustomScale = 30; |
| 700 | +static_assert(LVC_NUM_SCALES == 31, "LVC_CHSCALE range must match the scale table"); |
| 701 | +static_assert(kLvcCustomScale == LVC_NUM_SCALES - 1, "Custom must be the last scale"); |
687 | 702 |
|
688 | 703 | static const char* const LVC_KEY_NAMES[12] = { "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" }; |
689 | 704 |
|
| 705 | +// The pitchmap's three preset dropdowns. LVC_CHSCALE stays the single source of truth, so sessions saved before |
| 706 | +// the dropdowns existed keep selecting exactly the same scale. The mode groups below map the new UI onto those |
| 707 | +// indices; scales from older sessions that are not part of a group are shown as Custom (their sound is unchanged). |
| 708 | +enum LvcScaleFamily { kLvcMajor = 0, kLvcMelodicMinor, kLvcPentatonic, kLvcCustomFamily, kLvcFamilyCount }; |
| 709 | + |
| 710 | +static const char* const LVC_FAMILY_NAMES[kLvcFamilyCount] = { "Major", "Melodic Minor", "Pentatonic", "Custom" }; |
| 711 | + |
| 712 | +static const char* const LVC_MAJOR_MODES[] = { "Ionian", "Dorian", "Phrygian", "Lydian", "Mixolydian", "Aeolian", "Locrian" }; |
| 713 | +static const int LVC_MAJOR_MODE_SCALES[] = { 0, 4, 5, 6, 7, 1, 8 }; |
| 714 | + |
| 715 | +static const char* const LVC_MM_MODES[] = { "Melodic Minor", "Dorian #2", "Lydian Augmented", "Lydian Dominant", |
| 716 | + "Mixo b6", "Locrian #2", "Altered", "Phrygian Dominant" }; |
| 717 | +static const int LVC_MM_MODE_SCALES[] = { 3, 24, 25, 26, 27, 28, 29, 12 }; |
| 718 | + |
| 719 | +static const char* const LVC_PENTA_MODES[] = { "Pentatonic", "Minor Pentatonic" }; |
| 720 | +static const int LVC_PENTA_MODE_SCALES[] = { 9, 10 }; |
| 721 | + |
| 722 | +static const char* const LVC_CUSTOM_MODES[] = { "Custom" }; |
| 723 | +static const int LVC_CUSTOM_MODE_SCALES[] = { kLvcCustomScale }; |
| 724 | + |
| 725 | +struct LvcModeGroup { const char* name; const char* const* modes; const int* scales; int count; }; |
| 726 | +static const LvcModeGroup LVC_MODE_GROUPS[kLvcFamilyCount] = { |
| 727 | + { LVC_FAMILY_NAMES[0], LVC_MAJOR_MODES, LVC_MAJOR_MODE_SCALES, |
| 728 | + static_cast<int>(sizeof(LVC_MAJOR_MODE_SCALES) / sizeof(LVC_MAJOR_MODE_SCALES[0])) }, |
| 729 | + { LVC_FAMILY_NAMES[1], LVC_MM_MODES, LVC_MM_MODE_SCALES, |
| 730 | + static_cast<int>(sizeof(LVC_MM_MODE_SCALES) / sizeof(LVC_MM_MODE_SCALES[0])) }, |
| 731 | + { LVC_FAMILY_NAMES[2], LVC_PENTA_MODES, LVC_PENTA_MODE_SCALES, |
| 732 | + static_cast<int>(sizeof(LVC_PENTA_MODE_SCALES) / sizeof(LVC_PENTA_MODE_SCALES[0])) }, |
| 733 | + { LVC_FAMILY_NAMES[3], LVC_CUSTOM_MODES, LVC_CUSTOM_MODE_SCALES, |
| 734 | + static_cast<int>(sizeof(LVC_CUSTOM_MODE_SCALES) / sizeof(LVC_CUSTOM_MODE_SCALES[0])) }, |
| 735 | +}; |
| 736 | + |
| 737 | +static inline int lvcClampScale(int scale) |
| 738 | +{ |
| 739 | + return scale < 0 ? 0 : (scale >= LVC_NUM_SCALES ? LVC_NUM_SCALES - 1 : scale); |
| 740 | +} |
| 741 | + |
| 742 | +static inline int lvcFamilyOfScale(int scale) |
| 743 | +{ |
| 744 | + scale = lvcClampScale(scale); |
| 745 | + if (scale == kLvcCustomScale) return kLvcCustomFamily; |
| 746 | + for (int f = 0; f < kLvcFamilyCount - 1; ++f) |
| 747 | + for (int m = 0; m < LVC_MODE_GROUPS[f].count; ++m) |
| 748 | + if (LVC_MODE_GROUPS[f].scales[m] == scale) return f; |
| 749 | + return kLvcCustomFamily; // legacy scale outside the preset groups |
| 750 | +} |
| 751 | + |
| 752 | +static inline int lvcModeOfScale(int scale) |
| 753 | +{ |
| 754 | + const int f = lvcFamilyOfScale(scale); |
| 755 | + if (f == kLvcCustomFamily) return -1; |
| 756 | + scale = lvcClampScale(scale); |
| 757 | + for (int m = 0; m < LVC_MODE_GROUPS[f].count; ++m) |
| 758 | + if (LVC_MODE_GROUPS[f].scales[m] == scale) return m; |
| 759 | + return -1; |
| 760 | +} |
| 761 | + |
| 762 | +static inline int lvcScaleForMode(int family, int mode) |
| 763 | +{ |
| 764 | + family = family < 0 ? 0 : (family >= kLvcFamilyCount ? kLvcFamilyCount - 1 : family); |
| 765 | + const LvcModeGroup& g = LVC_MODE_GROUPS[family]; |
| 766 | + mode = mode < 0 ? 0 : (mode >= g.count ? g.count - 1 : mode); |
| 767 | + return g.scales[mode]; |
| 768 | +} |
| 769 | + |
| 770 | +// Name shown in the MODE field and the pitchmap chip, including legacy custom scales. |
| 771 | +static inline const char* lvcModeLabel(int scale) |
| 772 | +{ |
| 773 | + const int m = lvcModeOfScale(scale); |
| 774 | + if (m >= 0) return LVC_MODE_GROUPS[lvcFamilyOfScale(scale)].modes[m]; |
| 775 | + return LVC_SCALES[lvcClampScale(scale)].name; |
| 776 | +} |
| 777 | + |
690 | 778 | // absolute pitch classes (bit 0 = C) of a scale on a root |
691 | | -static inline uint16_t lvcScalePitchClasses(int scale, int root) |
| 779 | +static inline uint16_t lvcScalePitchClasses(int scale, int root, uint16_t customMask = 0) |
692 | 780 | { |
693 | | - scale = scale < 0 ? 0 : (scale >= LVC_NUM_SCALES ? LVC_NUM_SCALES - 1 : scale); |
| 781 | + scale = lvcClampScale(scale); |
694 | 782 | root = ((root % 12) + 12) % 12; |
695 | | - const uint32_t m = LVC_SCALES[scale].mask; |
| 783 | + const uint32_t m = scale == kLvcCustomScale ? (customMask & 0x0FFF) : LVC_SCALES[scale].mask; |
696 | 784 | return static_cast<uint16_t>(((m << root) | (m >> (12 - root))) & 0x0FFF); |
697 | 785 | } |
698 | 786 |
|
|