Skip to content

Commit

Permalink
Yarns voice allocation bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Emilie Gillet committed Nov 16, 2020
1 parent 17f793a commit a8089ae
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
17 changes: 11 additions & 6 deletions yarns/part.cc
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@ bool Part::PitchBend(uint8_t channel, uint16_t pitch_bend) {
bool Part::Aftertouch(uint8_t channel, uint8_t note, uint8_t velocity) {
if (voicing_.allocation_mode != VOICE_ALLOCATION_MODE_MONO) {
uint8_t voice_index = \
voicing_.allocation_mode == VOICE_ALLOCATION_MODE_POLY ? \
(voicing_.allocation_mode == VOICE_ALLOCATION_MODE_POLY || \
voicing_.allocation_mode == VOICE_ALLOCATION_MODE_POLY_STEAL_MOST_RECENT) ? \
poly_allocator_.Find(note) : \
FindVoiceForNote(note);
if (voice_index < poly_allocator_.size()) {
Expand Down Expand Up @@ -479,18 +480,21 @@ void Part::DispatchSortedNotes(bool unison) {
uint8_t n = mono_allocator_.size();
for (uint8_t i = 0; i < num_voices_; ++i) {
uint8_t index = 0xff;
if (unison) {
if (unison && n < num_voices_) {
index = n ? (i * n / num_voices_) : 0xff;
} else {
index = i < mono_allocator_.size() ? i : 0xff;
}
if (index != 0xff) {
const NoteEntry& note_entry = mono_allocator_.note_by_priority(
static_cast<NoteStackFlags>(voicing_.allocation_priority),
index);
voice_[i]->NoteOn(
Tune(mono_allocator_.sorted_note(index).note),
mono_allocator_.sorted_note(index).velocity,
Tune(note_entry.note),
note_entry.velocity,
voicing_.portamento,
!voice_[i]->gate_on());
active_note_[i] = mono_allocator_.sorted_note(index).note;
active_note_[i] = note_entry.note;
} else {
voice_[i]->NoteOff();
active_note_[i] = VOICE_ALLOCATION_NOT_FOUND;
Expand Down Expand Up @@ -627,7 +631,8 @@ void Part::InternalNoteOff(uint8_t note) {
}
} else {
uint8_t voice_index = \
voicing_.allocation_mode == VOICE_ALLOCATION_MODE_POLY ? \
(voicing_.allocation_mode == VOICE_ALLOCATION_MODE_POLY ||
voicing_.allocation_mode == VOICE_ALLOCATION_MODE_POLY_STEAL_MOST_RECENT) ? \
poly_allocator_.NoteOff(note) : \
FindVoiceForNote(note);
if (voice_index < num_voices_) {
Expand Down
6 changes: 4 additions & 2 deletions yarns/settings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const char* const voicing_oscillator_values[] = {
};

const char* const voicing_allocation_priority_values[] = {
"LAST", "LOW", "HIGH"
"LAST", "LOW", "HIGH", "FIRST"
};

const char* const trigger_shape_values[] = {
Expand Down Expand Up @@ -256,7 +256,7 @@ const Setting Settings::settings_[] = {
{
"NP", "NOTE PRIORITY",
SETTING_DOMAIN_PART, { PART_VOICING_ALLOCATION_PRIORITY, 0 },
SETTING_UNIT_ENUMERATION, 0, 2, voicing_allocation_priority_values,
SETTING_UNIT_ENUMERATION, 0, 3, voicing_allocation_priority_values,
19, 9,
},
{
Expand Down Expand Up @@ -564,6 +564,7 @@ const SettingIndex dual_poly_menu[] = {
SETTING_MIDI_CHANNEL,
SETTING_MIDI_OUT_MODE,
SETTING_VOICING_ALLOCATION_MODE,
SETTING_VOICING_ALLOCATION_PRIORITY,
SETTING_VOICING_PORTAMENTO,
SETTING_VOICING_PITCH_BEND_RANGE,
SETTING_VOICING_VIBRATO_RANGE,
Expand Down Expand Up @@ -601,6 +602,7 @@ const SettingIndex quad_poly_menu[] = {
SETTING_MIDI_CHANNEL,
SETTING_MIDI_OUT_MODE,
SETTING_VOICING_ALLOCATION_MODE,
SETTING_VOICING_ALLOCATION_PRIORITY,
SETTING_VOICING_PORTAMENTO,
SETTING_VOICING_PITCH_BEND_RANGE,
SETTING_VOICING_VIBRATO_RANGE,
Expand Down

0 comments on commit a8089ae

Please sign in to comment.