Skip to content

Commit

Permalink
Strum: Quantizer select via CV
Browse files Browse the repository at this point in the history
AuxButton on spacing to toggle CV2 between Spacing and Quantizer
  • Loading branch information
djphazer committed May 22, 2024
1 parent fd09fa7 commit f0d74d9
Showing 1 changed file with 32 additions and 12 deletions.
44 changes: 32 additions & 12 deletions software/src/applets/Strum.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,20 @@ class Strum : public HemisphereApplet {
}

spacing_mod = spacing;
Modulate(spacing_mod, 1, HEM_BURST_SPACING_MIN, HEM_BURST_SPACING_MAX);
qselect_mod = qselect;
if (qmod) {
// select Quantizer over a 1Volt range
int cv = DetentedIn(1);
qselect_mod = constrain(qselect_mod + Proportion(cv, 12 << 7, 4), 0, 3);
}
else
Modulate(spacing_mod, 1, HEM_BURST_SPACING_MIN, HEM_BURST_SPACING_MAX);

if (countdown <= 0 && !index_out_of_bounds && inc != 0) {
int raw_pitch = In(0);
HS::Quantize(qselect, raw_pitch);
int note_num = HS::GetLatestNoteNumber(qselect);
int pitch = HS::QuantizerLookup(qselect, note_num + intervals[index]);
HS::Quantize(qselect_mod, raw_pitch);
int note_num = HS::GetLatestNoteNumber(qselect_mod);
int pitch = HS::QuantizerLookup(qselect_mod, note_num + intervals[index]);
disp = note_num;
Out(0, pitch);
ClockOut(1);
Expand All @@ -80,10 +87,11 @@ class Strum : public HemisphereApplet {
}

void View() {
gfxPrint(8, 15, OC::scale_names_short[HS::GetScale(qselect)]);
gfxPrint(42, 15, OC::Strings::note_names_unpadded[HS::GetRootNote(qselect)]);
gfxPrint(1, 15, "Q"); gfxPrint(qselect_mod + 1);
gfxPrint(15, 15, OC::scale_names_short[HS::GetScale(qselect_mod)]);
gfxPrint(45, 15, OC::Strings::note_names_unpadded[HS::GetRootNote(qselect_mod)]);
if (cursor == QUANT)
gfxCursor(7, 23, 48);
gfxCursor(1, 23, 13);

if (show_encoder) {
gfxPrint(8 + pad(100, spacing), 25, spacing);
Expand All @@ -96,7 +104,9 @@ class Strum : public HemisphereApplet {
if (cursor == SPACING)
gfxCursor(1, 33, 27);

int num_notes = OC::Scales::GetScale(HS::GetScale(qselect)).num_notes;
gfxIcon(56, qmod? 15 : 25, LEFT_ICON);

int num_notes = OC::Scales::GetScale(HS::GetScale(qselect_mod)).num_notes;
const int cursor_width = 9;
const int col_width = cursor_width + 2;
const int top = 35;
Expand All @@ -122,8 +132,8 @@ class Strum : public HemisphereApplet {
}

int quant_note = disp + (intervals[i] % num_notes);
int32_t pitch = HS::QuantizerLookup(qselect, quant_note);
int semitone = (MIDIQuantizer::NoteNumber(pitch) + HS::GetRootNote(qselect)) % 12;
int32_t pitch = HS::QuantizerLookup(qselect_mod, quant_note);
int semitone = (MIDIQuantizer::NoteNumber(pitch) + HS::GetRootNote(qselect_mod)) % 12;
gfxBitmap(col_width * i, 55, 8, NOTE_NAMES + semitone * 8);

// TODO: Flip indicator on reverse strums, though tbh it looks fine as is
Expand All @@ -144,10 +154,15 @@ class Strum : public HemisphereApplet {
}

void OnButtonPress() {
isEditing = !isEditing;
}
void AuxButton() {
if (cursor == QUANT)
HS::QuantizerEdit(qselect);
else
isEditing = !isEditing;
if (cursor == SPACING) {
qmod = !qmod;
}
isEditing = false;
}

void OnEncoderMove(int direction) {
Expand All @@ -165,6 +180,9 @@ class Strum : public HemisphereApplet {
break;
// TODO: modify qselect instead
*/
case QUANT:
qselect = constrain(qselect + direction, 0, 3);
break;
case SPACING:
spacing = constrain(spacing + direction, HEM_BURST_SPACING_MIN,
HEM_BURST_SPACING_MAX);
Expand Down Expand Up @@ -232,6 +250,8 @@ class Strum : public HemisphereApplet {
int show_encoder = 0;

int8_t qselect = 0;
int8_t qselect_mod = 0;
bool qmod = 0; // switch CV between spacing and qselect

int cursor = 0;

Expand Down

0 comments on commit f0d74d9

Please sign in to comment.