Skip to content

Commit

Permalink
Merge pull request #4 from Quixotic7/Bugfix/CVGateOutputs
Browse files Browse the repository at this point in the history
Bugfix for CV gates being turned off when playing legato
  • Loading branch information
Quixotic7 committed Mar 3, 2024
2 parents 6e574d6 + 6863e49 commit e409725
Show file tree
Hide file tree
Showing 15 changed files with 383 additions and 142 deletions.
14 changes: 10 additions & 4 deletions OMX-27-firmware/OMX-27-firmware.ino
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// OMX-27 MIDI KEYBOARD / SEQUENCER

// v1.13.1
// v1.13.3
// Last update: Feb 2024
//
// Original concept and initial code by Steven Noreyko
Expand Down Expand Up @@ -28,6 +28,7 @@
#include "src/midi/sysex.h"
#include "src/hardware/omx_keypad.h"
#include "src/utils/omx_util.h"
#include "src/utils/cvNote_util.h"
#include "src/hardware/omx_disp.h"
#include "src/modes/omx_mode_midi_keyboard.h"
#include "src/modes/omx_mode_drum.h"
Expand Down Expand Up @@ -271,7 +272,7 @@ void handleNoteOn(byte channel, byte note, byte velocity)
}
if (midiSettings.midiInToCV)
{
omxUtil.cvNoteOn(note);
cvNoteUtil.cvNoteOn(note);
}

omxScreensaver.resetCounter();
Expand All @@ -288,7 +289,7 @@ void handleNoteOff(byte channel, byte note, byte velocity)

if (midiSettings.midiInToCV)
{
omxUtil.cvNoteOff();
cvNoteUtil.cvNoteOff(note);
}

activeOmxMode->inMidiNoteOff(channel, note, velocity);
Expand Down Expand Up @@ -370,7 +371,9 @@ void saveHeader()

storage->write(EEPROM_HEADER_ADDRESS + 36, clockConfig.globalQuantizeStepIndex);

// 37 bytes
storage->write(EEPROM_HEADER_ADDRESS + 37, cvNoteUtil.triggerMode);

// 38 bytes
}

// returns true if the header contained initialized data
Expand Down Expand Up @@ -440,6 +443,8 @@ bool loadHeader(void)

clockConfig.globalQuantizeStepIndex = constrain(storage->read(EEPROM_HEADER_ADDRESS + 36), 0, kNumArpRates - 1);

cvNoteUtil.triggerMode = constrain(storage->read(EEPROM_HEADER_ADDRESS + 37), 0, 1);

return true;
}

Expand Down Expand Up @@ -688,6 +693,7 @@ void loop()
seqConfig.currentFrameMicros = micros();
// Micros timeStart = micros();
activeOmxMode->loopUpdate(passed);
cvNoteUtil.loopUpdate(passed);

if (passed > 0) // This should always be true
{
Expand Down
1 change: 1 addition & 0 deletions OMX-27-firmware/src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ const char *mfxArpEditMsg = "Arp Edit";
const char *mfxPassthroughEditMsg = "MFX Quickedit";
const char *exitMsg = "Exit";
const char *paramOffMsg = "OFF";
const char *paramOnMsg = "ON";

const char *modes[] = {"MI", "DRUM", "CH", "S1", "S2", "GR", "EL", "OM"};
const char *macromodes[] = {"Off", "M8", "NRN", "DEL"};
Expand Down
13 changes: 10 additions & 3 deletions OMX-27-firmware/src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@
// #include <cstdarg>

/* * firmware metadata */
// OMX_VERSION = 1.13.1
// OMX_VERSION = 1.13.3
const int MAJOR_VERSION = 1;
const int MINOR_VERSION = 13;
const int POINT_VERSION = 1;
const int POINT_VERSION = 3;

// 1.13.2 - Adds CV Trigger modes for legato and regtrig
// 1.13.3 - Bugfix for CV Trigger modes


const int DEVICE_ID = 2;

Expand Down Expand Up @@ -72,6 +76,8 @@ extern const uint8_t EEPROM_VERSION;
#define EEPROM_HEADER_SIZE 36
#define EEPROM_PATTERN_ADDRESS 64

#define TRACKED_CV_SIZE 16 //

// next address 1104 (was 1096 before clock)

extern const byte DAC_ADDR;
Expand Down Expand Up @@ -138,6 +144,7 @@ extern PotSettings potSettings;
extern int potMinVal;
extern int potMaxVal;


struct MidiConfig
{
uint8_t defaultVelocity = 100;
Expand All @@ -163,7 +170,6 @@ struct MidiConfig
int currbank = 0;
bool midiInToCV = true;
bool midiSoftThru = false;
int pitchCV;
bool midiAUX = false;
};

Expand Down Expand Up @@ -378,6 +384,7 @@ extern const char *mfxArpEditMsg;
extern const char *mfxPassthroughEditMsg;
extern const char *exitMsg;
extern const char *paramOffMsg;
extern const char *paramOnMsg;

extern const char *modes[];
extern const char *macromodes[];
Expand Down
6 changes: 3 additions & 3 deletions OMX-27-firmware/src/consts/consts.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ const float stepsPerVolt = fullRangeDAC / fullRangeV;
const float stepsPerOctave = stepsPerVolt;
const float stepsPerSemitone = stepsPerOctave / 12;

const int midiMiddleC = 60;
const int midiLowestNote = midiMiddleC - 3 * 12; // 3 is how many octaves under middle c
const int midiHightestNote = midiLowestNote + int(fullRangeV * 12) - 1;
const uint8_t midiMiddleC = 60;
const uint8_t cvLowestNote = midiMiddleC - 3 * 12; // 3 is how many octaves under middle c
const uint8_t cvHightestNote = cvLowestNote + int(fullRangeV * 12) - 1;

// FONTS
#define FONT_LABELS u8g2_font_5x8_tf
Expand Down
4 changes: 4 additions & 0 deletions OMX-27-firmware/src/hardware/omx_disp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,10 @@ void OmxDisp::setLegend(uint8_t index, const char *label, bool isOff, String tex
setLegend(index, label, text);
}
}
void OmxDisp::setLegend(uint8_t index, const char* label, bool value)
{
setLegend(index, label, value ? paramOnMsg : paramOffMsg);
}

void OmxDisp::dispGenericMode(int selected)
{
Expand Down
2 changes: 2 additions & 0 deletions OMX-27-firmware/src/hardware/omx_disp.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ class OmxDisp
void setLegend(uint8_t index, const char* label, bool isOff, const char* text);
void setLegend(uint8_t index, const char* label, String text);
void setLegend(uint8_t index, const char* label, bool isOff, String text);
void setLegend(uint8_t index, const char* label, bool value);


void setSubmode(int submode);

Expand Down
25 changes: 8 additions & 17 deletions OMX-27-firmware/src/midi/noteoffs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "../consts/consts.h"
#include "../config.h"
#include "../midi/midi.h"
#include "../utils/cvNote_util.h"

PendingNoteHistory::PendingNoteHistory()
{
Expand Down Expand Up @@ -88,7 +89,7 @@ void PendingNoteOffs::play(uint32_t now)
// analogWrite(CVPITCH_PIN, 0);
if (queue[i].sendCV)
{
digitalWrite(CVGATE_PIN, LOW);
cvNoteUtil.cvNoteOff(queue[i].note);
}
queue[i].inUse = false;

Expand Down Expand Up @@ -134,7 +135,7 @@ bool PendingNoteOffs::sendOffIfPresent(int note, int channel, bool sendCV)
// analogWrite(CVPITCH_PIN, 0);
if (queue[i].sendCV)
{
digitalWrite(CVGATE_PIN, LOW);
cvNoteUtil.cvNoteOff(queue[i].note);
}
noteOffSent = true;
onNoteOff(queue[i].note, queue[i].channel);
Expand All @@ -156,7 +157,7 @@ void PendingNoteOffs::sendOffNow(int note, int channel, bool sendCV)
MM::sendNoteOff(note, 0, channel);
if (sendCV)
{
digitalWrite(CVGATE_PIN, LOW);
cvNoteUtil.cvNoteOff(note);
}
onNoteOff(note, channel);
}
Expand Down Expand Up @@ -235,7 +236,7 @@ bool PendingNoteOns::remove(int note, int channel)

void PendingNoteOns::play(uint32_t now)
{
int pCV;
// int pCV;
for (int i = 0; i < queueSize; ++i)
{
if (queue[i].inUse && queue[i].time <= now)
Expand All @@ -247,17 +248,7 @@ void PendingNoteOns::play(uint32_t now)

if (queue[i].sendCV)
{
if (queue[i].note >= midiLowestNote && queue[i].note < midiHightestNote)
{
pCV = static_cast<int>(roundf((queue[i].note - midiLowestNote) * stepsPerSemitone));
// map (adjnote, 36, 91, 0, 4080);
digitalWrite(CVGATE_PIN, HIGH);
#if T4
dac.setVoltage(pCV, false);
#else
analogWrite(CVPITCH_PIN, pCV);
#endif
}
cvNoteUtil.cvNoteOn(queue[i].note);
}
queue[i].inUse = false;

Expand All @@ -268,9 +259,9 @@ void PendingNoteOns::play(uint32_t now)

// if (queue[i].sendCV)
// {
// if (queue[i].note >= midiLowestNote && queue[i].note < midiHightestNote)
// if (queue[i].note >= cvLowestNote && queue[i].note < cvHightestNote)
// {
// pCV = static_cast<int>(roundf((queue[i].note - midiLowestNote) * stepsPerSemitone));
// pCV = static_cast<int>(roundf((queue[i].note - cvLowestNote) * stepsPerSemitone));
// digitalWrite(CVGATE_PIN, HIGH);
// analogWrite(CVPITCH_PIN, pCV);
// }
Expand Down
6 changes: 4 additions & 2 deletions OMX-27-firmware/src/modes/omx_mode_chords.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
#include "../config.h"
#include "../consts/colors.h"
#include "../utils/omx_util.h"
#include "../utils/cvNote_util.h"
#include "../hardware/omx_disp.h"
#include "../hardware/omx_leds.h"
// #include "../sequencer.h"
#include "../midi/midi.h"
#include "../midi/noteoffs.h"


enum ChordsModePage
{
CHRDPAGE_NOTES,
Expand Down Expand Up @@ -2092,7 +2094,7 @@ void OmxModeChords::onNotePostFX(MidiNoteGroup note)
}
if (note.sendCV)
{
omxUtil.cvNoteOff();
cvNoteUtil.cvNoteOff(note.noteNumber);
}
}
else
Expand Down Expand Up @@ -2120,7 +2122,7 @@ void OmxModeChords::onNotePostFX(MidiNoteGroup note)
}
if (note.sendCV)
{
omxUtil.cvNoteOn(note.noteNumber);
cvNoteUtil.cvNoteOn(note.noteNumber);
}
}
}
Expand Down
20 changes: 11 additions & 9 deletions OMX-27-firmware/src/modes/omx_mode_drum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "../config.h"
#include "../consts/colors.h"
#include "../utils/omx_util.h"
#include "../utils/cvNote_util.h"
#include "../hardware/omx_disp.h"
#include "../hardware/omx_leds.h"
#include "../midi/midi.h"
Expand Down Expand Up @@ -371,6 +372,10 @@ void OmxModeDrum::onEncoderChanged(Encoder::Update enc)
{
clockConfig.globalQuantizeStepIndex = constrain(clockConfig.globalQuantizeStepIndex + amt, 0, kNumArpRates - 1);
}
else if (selParam == 4)
{
cvNoteUtil.triggerMode = constrain(cvNoteUtil.triggerMode + amt, 0, 1);
}
}

omxDisp.setDirty();
Expand Down Expand Up @@ -1058,13 +1063,10 @@ void OmxModeDrum::onDisplayUpdate()
else if (params.getSelPage() == DRUMPAGE_CFG) // CONFIG
{
omxDisp.clearLegends();
omxDisp.legends[0] = "CC";
omxDisp.legendText[0] = "CFG";


omxDisp.legends[2] = "QUANT";
omxDisp.useLegendString[2] = true;
omxDisp.legendString[2] = "1/" + String(kArpRates[clockConfig.globalQuantizeStepIndex]);
omxDisp.setLegend(0,"P CC", "CFG");
omxDisp.setLegend(1,"CLR", "STOR");
omxDisp.setLegend(2,"QUANT", "1/" + String(kArpRates[clockConfig.globalQuantizeStepIndex]));
omxDisp.setLegend(3,"CV M", cvNoteUtil.getTriggerModeDispName());
}

omxDisp.dispGenericMode2(params.getNumPages(), params.getSelPage(), params.getSelParam(), getEncoderSelect());
Expand Down Expand Up @@ -1326,7 +1328,7 @@ void OmxModeDrum::onNotePostFX(MidiNoteGroup note)
}
if (note.sendCV)
{
omxUtil.cvNoteOff();
cvNoteUtil.cvNoteOff(note.noteNumber);
}
}
else
Expand Down Expand Up @@ -1356,7 +1358,7 @@ void OmxModeDrum::onNotePostFX(MidiNoteGroup note)
}
if (note.sendCV)
{
omxUtil.cvNoteOn(note.noteNumber);
cvNoteUtil.cvNoteOn(note.noteNumber);
}
}
}
Expand Down
Loading

0 comments on commit e409725

Please sign in to comment.