Skip to content

Commit

Permalink
fix: roll and shuffle based on new uClock v2
Browse files Browse the repository at this point in the history
  • Loading branch information
midilab committed Jan 6, 2024
1 parent 7113bda commit bd98e75
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 35 deletions.
13 changes: 8 additions & 5 deletions v2/AciduinoV2/6_shared_gui_comp.ino
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,15 @@ struct Transpose : PageComponent {
} transposeComponent;

struct RollType : PageComponent {


uint8_t current_roll = 0;
ROLL_TYPE rollTypes[7] = {FLAM_1, FLAM_2, FLAM_3, FLAM_4, FLAM_5, SUB_STEP_1, SUB_STEP_2};

String options;
void view() {
uint8_t roll_type = AcidSequencer.getRollType(_selected_track);
uint8_t roll_type = rollTypes[current_roll]; //AcidSequencer.getRollType(_selected_track);
if (roll_type <= FLAM_5) {
options = "f" + String(roll_type+1);
options = "f" + String(roll_type);
} else {
options = "s" + String(roll_type - FLAM_5);
}
Expand All @@ -156,8 +159,8 @@ struct RollType : PageComponent {

void change(int16_t data) {
//clearStackNote(_selected_track);
data = parseData(data, 0, 6, AcidSequencer.getRollType(_selected_track));
AcidSequencer.setRollType(_selected_track, data);
current_roll = parseData(data, 0, 6, current_roll); //AcidSequencer.getRollType(_selected_track));
AcidSequencer.setRollType(_selected_track, rollTypes[current_roll]);
}

} rollTypeComponent;
Expand Down
32 changes: 22 additions & 10 deletions v2/AciduinoV2/src/ports/esp32/wroom.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,14 @@
// enable ble-midi? needs USE_MIDI2
//#define USE_BT_MIDI_ESP32

#define USE_MIDI1
//#define USE_MIDI2
//#define USE_MIDI3
// enable Serial to be able to use on serial-to-midi bridges on PCs
// like hairless midi or ttymidi
// does it needs USE_MIDI1
#define USE_SERIAL_MIDI_115200

#define USE_MIDI1 // USB MIDI, needs a serial-to-midi bridge on the other side: hariless midi or ttymidi
//#define USE_MIDI2 // BLE MIDI: bluetooth is not a good option to run realtime application like midi, so be aware of shit timming and issues(good for a midi controller only)
#define USE_MIDI3 // real MIDI serial port: connect to your hardware synths via MIDI cable(check midi out schematics for 3.3v)

// wich modules you need acidman?
// PUSH and LED modules require booth PUSH_SPI and LED_SPI to point into some spi device
Expand Down Expand Up @@ -97,19 +102,26 @@ U8G2_SH1106_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, U8X8_PIN_NONE);

// Midi device
// initing midi devices
//MIDI_CREATE_INSTANCE(HardwareSerial, Serial, MIDI1);
MIDI_CREATE_INSTANCE(HardwareSerial, Serial2, MIDI1);
#if defined(USE_MIDI1) // USB
MIDI_CREATE_INSTANCE(HardwareSerial, Serial, MIDI1);
#endif

#if defined(USE_BT_MIDI_ESP32) && defined(CONFIG_BT_ENABLED)
#if defined(USE_MIDI2) // Bluetooth
#if defined(USE_BT_MIDI_ESP32) && defined(CONFIG_BT_ENABLED)
BLEMIDI_CREATE_INSTANCE("Aciduino", MIDI2);
#endif
#endif

// in case we got USB native mode support builtin, use it!
#if defined(CONFIG_TINYUSB_ENABLED)
ESPNATIVEUSBMIDI espNativeUsbMidi;
MIDI_CREATE_INSTANCE(ESPNATIVEUSBMIDI, espNativeUsbMidi, MIDI3);
#if defined(USE_MIDI3) // Hardware midi
MIDI_CREATE_INSTANCE(HardwareSerial, Serial2, MIDI3);
#endif

// in case we got USB native mode support builtin, use it! note the case of wroom, keep this setup for later other boards
//#if defined(CONFIG_TINYUSB_ENABLED)
//ESPNATIVEUSBMIDI espNativeUsbMidi;
//MIDI_CREATE_INSTANCE(ESPNATIVEUSBMIDI, espNativeUsbMidi, MIDI1);
//#endif

// SPI devices
//#define PUSH_SPI SPI
//#define LED_SPI SPI
4 changes: 2 additions & 2 deletions v2/AciduinoV2/src/sequencer/acid_sequencer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ void AcidSequencerClass::on96PPQN(uint32_t tick)
{
_tick = tick;
// 303 clock call
_engine303.onClockCall(tick);
_engine303.on96PPQNCall(tick);
// 808 clock call
_engine808.onClockCall(tick);
_engine808.on96PPQNCall(tick);
}

uint16_t AcidSequencerClass::get303PatternMemorySize()
Expand Down
2 changes: 1 addition & 1 deletion v2/AciduinoV2/src/sequencer/engine_303.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ void Engine303::onStepCall(uint32_t tick, int8_t shuffle_length_ctrl)
}

// The callback function wich will be called by uClock each Pulse of 96PPQN clock resolution.
void Engine303::onClockCall(uint32_t tick)
void Engine303::on96PPQNCall(uint32_t tick)
{
for ( uint8_t track = 0; track < TRACK_NUMBER_303; track++ ) {

Expand Down
2 changes: 1 addition & 1 deletion v2/AciduinoV2/src/sequencer/engine_303.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class Engine303 : public Engine
void onStepCall(uint32_t tick, int8_t shuffle_length_ctrl);

// The callback function wich will be called by uClock each Pulse of 96PPQN clock resolution.
void onClockCall(uint32_t tick);
void on96PPQNCall(uint32_t tick);

void clearStackNote(int8_t track);

Expand Down
19 changes: 10 additions & 9 deletions v2/AciduinoV2/src/sequencer/engine_808.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,23 +122,24 @@ void Engine808::onStepCall(uint32_t tick, int8_t shuffle_length_ctrl)
#endif
// it this a roll? prepare the data
if (roll) {
// a full one step in 96ppqn is 24 pulses. minus this shot one, we have 23 pulses left, put it 20
_sequencer[track].voice[voice].trigger_ctrl = -20;
// a full one step in 96ppqn is 24 pulses. minus this shot one, we have 23 pulses left
_sequencer[track].voice[voice].trigger_ctrl = -24;
if (_sequencer[track].roll_type >= SUB_STEP_1)
return; // handle on 96ppqn only
} else {
_sequencer[track].voice[voice].trigger_ctrl = NOTE_LENGTH_808;
}

// send the drum triger
_onEventCallback(NOTE_ON, _sequencer[track].voice[voice].note, accent ? ACCENT_VELOCITY_808 : NOTE_VELOCITY_808, track+TRACK_NUMBER_303);

}
}

}
}

// The callback function wich will be called by uClock each Pulse of 96PPQN clock resolution.
void Engine808::onClockCall(uint32_t tick)
// The callback function wich will be called by uClock each Pulse of 96PPQN
void Engine808::on96PPQNCall(uint32_t tick)
{
for ( uint8_t track = 0; track < TRACK_NUMBER_808; track++ ) {

Expand Down Expand Up @@ -168,17 +169,17 @@ void Engine808::onClockCall(uint32_t tick)
} else {
// SUB_STEP_1
if (_sequencer[track].roll_type == SUB_STEP_1) {
if (_sequencer[track].voice[i].trigger_ctrl == -3 || _sequencer[track].voice[i].trigger_ctrl == -1)
if (_sequencer[track].voice[i].trigger_ctrl%8 == 0)
shot_the_moon = true;
// SUB_STEP_2
} else if (_sequencer[track].roll_type == SUB_STEP_2) {
shot_the_moon = true;
if (_sequencer[track].voice[i].trigger_ctrl%4 == 0)
shot_the_moon = true;
}

}

if (shot_the_moon)
_onEventCallback(NOTE_ON, _sequencer[track].voice[i].note, NOTE_VELOCITY_808, track+TRACK_NUMBER_303);
_onEventCallback(NOTE_ON, _sequencer[track].voice[i].note, ACCENT_VELOCITY_808, track+TRACK_NUMBER_303);
}

}
Expand Down
13 changes: 7 additions & 6 deletions v2/AciduinoV2/src/sequencer/engine_808.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@
#include "setup.h"
#include "engine.h"

// based on 96PPQN place the pulse location of each FLAM option
typedef enum {
FLAM_1,
FLAM_2,
FLAM_3,
FLAM_4,
FLAM_5,
FLAM_1 = 1,
FLAM_2 = 3,
FLAM_3 = 6,
FLAM_4 = 9,
FLAM_5 = 13,
SUB_STEP_1,
SUB_STEP_2,
} ROLL_TYPE;
Expand Down Expand Up @@ -142,7 +143,7 @@ class Engine808 : public Engine
uint16_t getPatternTrackSize();

// The callback function wich will be called by uClock each Pulse of 96PPQN clock resolution.
void onClockCall(uint32_t tick);
void on96PPQNCall(uint32_t tick);
void clearStackNote(int8_t track);

private:
Expand Down
2 changes: 1 addition & 1 deletion v2/AciduinoV2/src/uClock
Submodule uClock updated 0 files

0 comments on commit bd98e75

Please sign in to comment.