32class Repeat final :
public Selection,
public FormattedTitle {
34 Repeat(l10n::String name, l10n::String title_format_str) :
Selection(name), FormattedTitle(title_format_str) {}
36 [[nodiscard]] std::string_view
getTitle()
const override {
return FormattedTitle::title(); }
39 return isSampleModeSample(modControllable, whichThing);
43 void readCurrentValue()
override { this->setValue(soundEditor.currentSource->repeatMode); }
44 void writeCurrentValue()
override {
45 auto current_value = this->getValue<SampleRepeatMode>();
47 Kit* kit = getCurrentKit();
50 if (kit !=
nullptr && currentUIMode == UI_MODE_HOLDING_AFFECT_ENTIRE_IN_SOUND_EDITOR) {
52 for (
Drum* thisDrum = kit->firstDrum; thisDrum !=
nullptr; thisDrum = thisDrum->next) {
53 if (thisDrum->type == DrumType::SOUND) {
54 auto* soundDrum =
static_cast<SoundDrum*
>(thisDrum);
55 Source* source = &soundDrum->sources[soundEditor.currentSourceIndex];
58 if (current_value == SampleRepeatMode::STRETCH) {
59 soundDrum->killAllVoices();
60 source->sampleControls.pitchAndSpeedAreIndependent =
true;
62 else if (source->repeatMode == SampleRepeatMode::STRETCH) {
63 soundDrum->killAllVoices();
64 soundEditor.currentSource->sampleControls.pitchAndSpeedAreIndependent =
false;
67 if (current_value == SampleRepeatMode::ONCE) {
69 sendNoteOffForKitArpeggiator(kit);
72 source->repeatMode = current_value;
79 if (
static_cast<SampleRepeatMode
>(current_value) == SampleRepeatMode::STRETCH) {
81 soundEditor.currentSource->sampleControls.pitchAndSpeedAreIndependent =
true;
83 else if (soundEditor.currentSource->repeatMode == SampleRepeatMode::STRETCH) {
85 soundEditor.currentSource->sampleControls.pitchAndSpeedAreIndependent =
false;
88 if (kit !=
nullptr && current_value == SampleRepeatMode::ONCE) {
90 sendNoteOffForKitArpeggiator(kit);
93 soundEditor.currentSource->repeatMode = current_value;
98 uiNeedsRendering(&instrumentClipView, 0xFFFFFFFF, 0);
100 deluge::vector<std::string_view> getOptions(OptType optType)
override {
103 l10n::getView(l10n::String::STRING_FOR_CUT),
104 l10n::getView(l10n::String::STRING_FOR_ONCE),
105 l10n::getView(l10n::String::STRING_FOR_LOOP),
106 l10n::getView(l10n::String::STRING_FOR_STRETCH),
111 void sendNoteOffForKitArpeggiator(Kit* kit) {
112 int32_t noteRowIndex;
113 NoteRow* noteRow = getCurrentInstrumentClip()->getNoteRowForDrum(kit->selectedDrum, ¬eRowIndex);
114 char modelStackMemory[MODEL_STACK_MAX_SIZE];
115 ModelStack* modelStack = (ModelStack*)modelStackMemory;
116 ModelStackWithThreeMainThings* modelStackWithThreeMainThings =
117 modelStack->addTimelineCounter(getCurrentClip())
118 ->addNoteRow(noteRowIndex, noteRow)
119 ->
addOtherTwoThings(soundEditor.currentModControllable, soundEditor.currentParamManager);
120 kit->noteOffPreKitArp(modelStackWithThreeMainThings, kit->selectedDrum);