Skip to content

Commit

Permalink
Merge commit 'b14f8ab8fd1f675cd0c69793219e5a70c0248a91' into arpeggia…
Browse files Browse the repository at this point in the history
…tor_multiple_note_bug
  • Loading branch information
zonkmachine committed Apr 7, 2024
2 parents ccb230f + b14f8ab commit 73eaf08
Showing 1 changed file with 10 additions and 22 deletions.
32 changes: 10 additions & 22 deletions src/core/InstrumentFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,41 +470,23 @@ void InstrumentFunctionArpeggio::processNote( NotePlayHandle * _n )

int cur_arp_idx = 0;
// process according to arpeggio-direction...
if( dir == ArpDirection::Up )
if (dir == ArpDirection::Up || dir == ArpDirection::Down)
{
cur_arp_idx = (cur_frame / arp_frames) % (range + sortOffset);
}
else if( dir == ArpDirection::Down )
{
cur_arp_idx = range + sortOffset - (cur_frame / arp_frames) %
(range + sortOffset) - 1;
}
else if (dir == ArpDirection::UpAndDown && (range + sortOffset) > 1)
else if ((dir == ArpDirection::UpAndDown || dir == ArpDirection::DownAndUp) && (range + sortOffset) > 1)
{
// imagine, we had to play the arp once up and then
// once down -> makes 2 * range possible notes...
// because we don't play the lower and upper notes
// twice, we have to subtract 2
cur_arp_idx = (cur_frame / arp_frames) % ((range + sortOffset) * 2 - 2);
// if greater than range, we have to play down...
// looks like the code for arp_dir==DOWN... :)
if (cur_arp_idx >= range + sortOffset)
{
cur_arp_idx = range + sortOffset - cur_arp_idx % (range + sortOffset - 1) - 1;
}
}
else if (dir == ArpDirection::DownAndUp && (range + sortOffset) > 1)
{
// copied from ArpDirection::UpAndDown above
cur_arp_idx = (cur_frame / arp_frames) % ((range + sortOffset) * 2 - 2);
cur_arp_idx = (cur_frame / arp_frames) % ((range + sortOffset) * 2 - (2 * static_cast<int>(m_arpRepeatsModel.value())));
// if greater than range, we have to play down...
// looks like the code for arp_dir==DOWN... :)
if (cur_arp_idx >= range + sortOffset)
{
cur_arp_idx = range + sortOffset - cur_arp_idx % (range + sortOffset - 1) - 1;
cur_arp_idx = range + sortOffset - cur_arp_idx % (range + sortOffset - 1) - static_cast<int>(m_arpRepeatsModel.value());
}
// inverts direction
cur_arp_idx = range + sortOffset - cur_arp_idx - 1;
}
else if( dir == ArpDirection::Random )
{
Expand All @@ -522,6 +504,12 @@ void InstrumentFunctionArpeggio::processNote( NotePlayHandle * _n )
cur_arp_idx %= static_cast<int>((range + sortOffset) / m_arpRepeatsModel.value());
}

// If ArpDirection::Down or ArpDirection::DownAndUp, invert the final range.
if (dir == ArpDirection::Down || dir == ArpDirection::DownAndUp)
{
cur_arp_idx = static_cast<int>((range + sortOffset) / m_arpRepeatsModel.value()) - cur_arp_idx - 1;
}

// now calculate final key for our arp-note
int sub_note_key = 0;
if (static_cast<ArpMode>(m_arpModeModel.value()) != ArpMode::Sort)
Expand Down

0 comments on commit 73eaf08

Please sign in to comment.