Skip to content

Commit

Permalink
Merge pull request #61 from mxmxmx/1.3.3b
Browse files Browse the repository at this point in the history
1.3.3b
  • Loading branch information
mxmxmx authored Aug 26, 2017
2 parents 2ff774e + 134c892 commit c404ac1
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 67 deletions.
14 changes: 11 additions & 3 deletions software/o_c_REV/APP_A_SEQ.ino
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,17 @@ const uint64_t multipliers_[] = {
const uint64_t pw_scale_[] = {

0xFFFFFFFF, // /64
0xFBFFFFFF, // /63
0xF7FFFFFF, // /62
0xC3FFFFFF, // /49
0xC0000000, // /48
0xBBFFFFFF, // /47
0x83FFFFFF, // /33
0x80000000, // /32
0x7BFFFFFF, // /31
0x43FFFFFF, // /17
0x40000000, // /16
0x3BFFFFFF, // /15
0x20000000, // /8
0x1C000000, // /7
0x18000000, // /6
Expand All @@ -89,12 +97,12 @@ const uint64_t pw_scale_[] = {
0x8000000, // /2
0x4000000, // x1

}; // = 2^32 * divisor / 64
}; // = 0xFFFFFFFF * divisor / 64

const uint8_t divisors_[] = {
65,
64,
63,
62,
49,
48,
47,
Expand Down Expand Up @@ -1919,7 +1927,7 @@ const char* const reset_trigger_sources[] = {
};

const char* const display_multipliers[] = {
"/65", "/64", "/63", "/49", "/48", "/47", "/33", "/32", "/31", "/17", "/16", "/15", "/8", "/7", "/6", "/5", "/4", "/3", "/2", "-", "x2", "x3", "x4", "x5", "x6", "x7", "x8"
"/64", "/63", "/62", "/49", "/48", "/47", "/33", "/32", "/31", "/17", "/16", "/15", "/8", "/7", "/6", "/5", "/4", "/3", "/2", "-", "x2", "x3", "x4", "x5", "x6", "x7", "x8"
};

const char* const modes[] = {
Expand Down
38 changes: 16 additions & 22 deletions software/o_c_REV/APP_CHORDS.ino
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,9 @@ enum CHORDS_SETTINGS {

enum CHORDS_CV_SOURCES {
CHORDS_CV_SOURCE_CV1,
CHORDS_CV_SOURCE_NONE,
// todo
CHORDS_CV_SOURCE_CV2,
CHORDS_CV_SOURCE_CV3,
CHORDS_CV_SOURCE_CV4,
CHORDS_CV_SOURCE_LAST
};

Expand Down Expand Up @@ -378,7 +379,6 @@ public:
last_scale_= -1;
last_mask_ = 0;
last_sample_ = 0;
schedule_mask_rotate_ = false;
chord_advance_last_ = true;
progression_advance_last_ = true;
active_chord_ = 0;
Expand All @@ -402,7 +402,7 @@ public:
}

void force_update() {
force_update_ = true;
//force_update_ = true;
}

int8_t _clock(uint8_t sequence_length, uint8_t sequence_count, uint8_t sequence_max, bool _reset) {
Expand Down Expand Up @@ -552,16 +552,13 @@ public:
if (triggered)
trigger_delay_.Push(OC::trigger_delay_ticks[get_trigger_delay()]);
triggered = trigger_delay_.triggered();

if (triggered)
update_scale(force_update_, schedule_mask_rotate_);


int32_t sample_a = last_sample_;
int32_t temp_sample = 0;

if (triggered) {

int32_t pitch, cv_source, transpose, octave, root;
int32_t pitch, cv_source, transpose, octave, root, mask_rotate;
int8_t num_progression, num_progression_cv, num_chords, num_chords_cv, progression_max, progression_cnt, playmode, reset;

cv_source = get_cv_source();
Expand All @@ -575,8 +572,16 @@ public:
num_chords = 0;
num_chords_cv = 0;
reset = 0;
mask_rotate = 0;
playmode = get_playmode();

// update mask?
if (get_mask_cv()) {
mask_rotate = (OC::ADC::value(static_cast<ADC_CHANNEL>(get_mask_cv() - 0x1)) + 127) >> 8;
}

update_scale(force_update_, mask_rotate);

if (num_progression != progression_last_ || playmode != playmode_last_) {
// reset progression:
progression_cnt_ = 0x0;
Expand Down Expand Up @@ -792,12 +797,6 @@ public:
_voicing += (OC::ADC::value(static_cast<ADC_CHANNEL>(get_voicing_cv() - 1)) + 255) >> 9;
CONSTRAIN(_voicing, 0, OC::Chords::CHORDS_VOICING_LAST - 1);
}

if (get_mask_cv()) {
// to do
}

update_scale(true, schedule_mask_rotate_);

int32_t quantized = quantizer_.Process(pitch, root << 7, transpose);
// main sample, S/H:
Expand Down Expand Up @@ -894,7 +893,7 @@ public:
break;
case MENU_CV_MAPPING: {

*settings++ = CHORDS_SETTING_MASK;
*settings++ = CHORDS_SETTING_MASK_CV;
// destinations:
// hide root CV?
if (get_scale(DUMMY) != OC::Scales::SCALE_NONE)
Expand Down Expand Up @@ -930,7 +929,6 @@ private:
bool _octave_toggle;
int last_scale_;
uint16_t last_mask_;
int32_t schedule_mask_rotate_;
int32_t last_sample_;
uint8_t display_num_chords_;
bool chord_advance_last_;
Expand Down Expand Up @@ -979,10 +977,6 @@ const char* const chords_advance_trigger_sources[] = {
"TR1", "TR2"
};

const char* const chords_cv_main_source[] = {
"CV1", "-"
};

const char* const chords_slots[] = {
"#1", "#2", "#3", "#4", "#5", "#6", "#7", "#8"
};
Expand All @@ -996,7 +990,7 @@ SETTINGS_DECLARE(Chords, CHORDS_SETTING_LAST) {
{ 0, 0, 11, "root", OC::Strings::note_names_unpadded, settings::STORAGE_TYPE_U8 },
{ 0, 0, OC::Chords::NUM_CHORD_PROGRESSIONS - 1, "progression", chords_slots, settings::STORAGE_TYPE_U8 },
{ 65535, 1, 65535, "scale -->", NULL, settings::STORAGE_TYPE_U16 }, // mask
{ 0, 0, CHORDS_CV_SOURCE_LAST - 1, "CV source", chords_cv_main_source, settings::STORAGE_TYPE_U8 }, /// to do ..
{ 0, 0, CHORDS_CV_SOURCE_LAST - 1, "CV source", OC::Strings::cv_input_names, settings::STORAGE_TYPE_U8 }, /// to do ..
{ CHORDS_ADVANCE_TRIGGER_SOURCE_TR2, 0, CHORDS_ADVANCE_TRIGGER_SOURCE_LAST - 1, "chords trg src", chords_advance_trigger_sources, settings::STORAGE_TYPE_U8 },
{ 0, 0, CHORDS_PLAYMODES_LAST - 1, "playmode", chord_playmodes, settings::STORAGE_TYPE_U8 },
{ 0, 0, CHORDS_DIRECTIONS_LAST - 1, "direction", OC::Strings::seq_directions, settings::STORAGE_TYPE_U8 },
Expand Down
2 changes: 1 addition & 1 deletion software/o_c_REV/OC_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ static constexpr uint32_t OC_UI_TIMER_RATE = 1000UL;
// From kinetis.h
// Cortex-M4: 0,16,32,48,64,80,96,112,128,144,160,176,192,208,224,240
static constexpr int OC_CORE_TIMER_PRIO = 80; // yet higher
static constexpr int OC_GPIO_ISR_PRIO = 112; // higher
static constexpr int OC_GPIO_ISR_PRIO = 112; // higher
static constexpr int OC_UI_TIMER_PRIO = 128; // default

static constexpr unsigned long REDRAW_TIMEOUT_MS = 1;
Expand Down
2 changes: 1 addition & 1 deletion software/o_c_REV/OC_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
//
// GENERATED FILE, DO NOT EDIT
//
#define OC_VERSION "v1.3.3"
#define OC_VERSION "v1.3.3b"
#endif
39 changes: 0 additions & 39 deletions software/o_c_REV/braids_quantizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,45 +50,6 @@ void Quantizer::Init() {
}
}

void Quantizer::Configure(
const int16_t* notes,
int16_t span,
size_t num_notes,
uint16_t mask) {
enabled_ = notes != NULL && num_notes != 0 && span != 0 && (mask & ~(0xffff<<num_notes));
if (enabled_) {

// Build up array that contains only the enabled notes, and use that to
// generate the codebook. This avoids a bunch of issues and checks in the
// main generating loop.
size_t num_enabled_notes = 0;
for (size_t i = 0; i < num_notes; ++i) {
if (mask & 1)
enabled_notes_[num_enabled_notes++] = notes[i];
mask >>= 1;
}
num_notes = num_enabled_notes;
notes = enabled_notes_;

int32_t octave = 0;
size_t note = 0;
int16_t root = 0;
for (int32_t i = 0; i < 64; ++i) {
int32_t up = root + notes[note] + span * octave;
int32_t down = root + notes[num_notes - 1 - note] + (-octave - 1) * span;
CLIP(up)
CLIP(down)
codebook_[64 + i] = up;
codebook_[64 - i - 1] = down;
++note;
if (note >= num_notes) {
note = 0;
++octave;
}
}
}
}

int32_t Quantizer::Process(int32_t pitch, int32_t root, int32_t transpose) {
if (!enabled_) {
return pitch;
Expand Down
39 changes: 38 additions & 1 deletion software/o_c_REV/braids_quantizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,52 @@ class Quantizer {
int32_t Lookup(int32_t index) const;

private:
void Configure(const int16_t* notes, int16_t span, size_t num_notes, uint16_t mask);
bool enabled_;
int16_t enabled_notes_[16];
int16_t codebook_[128];
int32_t codeword_;
int32_t transpose_;
int32_t previous_boundary_;
int32_t next_boundary_;
inline void Configure(const int16_t* notes, int16_t scale_span, size_t num_notes, uint16_t mask)
{
enabled_ = notes != NULL && num_notes != 0 && scale_span != 0 && (mask & ~(0xffff<<num_notes));
if (enabled_) {

// Build up array that contains only the enabled notes, and use that to
// generate the codebook. This avoids a bunch of issues and checks in the
// main generating loop.
size_t num_enabled_notes = 0;
for (size_t i = 0; i < num_notes; ++i) {
if (mask & 1)
enabled_notes_[num_enabled_notes++] = notes[i];
mask >>= 1;
}
notes = enabled_notes_;

int32_t octave = 0;
size_t note = 0;
int16_t span = scale_span;
int16_t *codebook;

codebook = &codebook_[0];

for (int32_t i = 0; i < 64; ++i) {
int32_t up = notes[note] + span * octave;
int32_t down = notes[num_enabled_notes - 1 - note] + (-octave - 1) * span;
CLIP(up)
CLIP(down)
*(codebook + 64 + i) = up;
*(codebook + 63 - i) = down;
++note;
if (note >= num_enabled_notes) {
note = 0;
++octave;
}
}
}
}

DISALLOW_COPY_AND_ASSIGN(Quantizer);
};

Expand Down

0 comments on commit c404ac1

Please sign in to comment.