Arpeggiator - Note repeats (#5784)

Co-authored-by: Kevin Zander <veratil@gmail.com>
Co-authored-by: IanCaio <iancaio_dev@hotmail.com>
This commit is contained in:
Oskar Wallgren
2021-01-01 14:43:46 +01:00
committed by GitHub
parent aa02a21541
commit d769459764
4 changed files with 22 additions and 7 deletions

View File

@@ -78,6 +78,7 @@ private:
GroupBox * m_arpGroupBox;
ComboBox * m_arpComboBox;
Knob * m_arpRangeKnob;
Knob * m_arpRepeatsKnob;
Knob * m_arpCycleKnob;
Knob * m_arpSkipKnob;
Knob * m_arpMissKnob;

View File

@@ -196,6 +196,7 @@ private:
BoolModel m_arpEnabledModel;
ComboBoxModel m_arpModel;
FloatModel m_arpRangeModel;
FloatModel m_arpRepeatsModel;
FloatModel m_arpCycleModel;
FloatModel m_arpSkipModel;
FloatModel m_arpMissModel;

View File

@@ -301,6 +301,7 @@ InstrumentFunctionArpeggio::InstrumentFunctionArpeggio( Model * _parent ) :
m_arpEnabledModel( false ),
m_arpModel( this, tr( "Arpeggio type" ) ),
m_arpRangeModel( 1.0f, 1.0f, 9.0f, 1.0f, this, tr( "Arpeggio range" ) ),
m_arpRepeatsModel( 1.0f, 1.0f, 8.0f, 1.0f, this, tr( "Note repeats" ) ),
m_arpCycleModel( 0.0f, 0.0f, 6.0f, 1.0f, this, tr( "Cycle steps" ) ),
m_arpSkipModel( 0.0f, 0.0f, 100.0f, 1.0f, this, tr( "Skip rate" ) ),
m_arpMissModel( 0.0f, 0.0f, 100.0f, 1.0f, this, tr( "Miss rate" ) ),
@@ -369,7 +370,7 @@ void InstrumentFunctionArpeggio::processNote( NotePlayHandle * _n )
const InstrumentFunctionNoteStacking::ChordTable & chord_table = InstrumentFunctionNoteStacking::ChordTable::getInstance();
const int cur_chord_size = chord_table[selected_arp].size();
const int range = (int)( cur_chord_size * m_arpRangeModel.value() );
const int range = static_cast<int>(cur_chord_size * m_arpRangeModel.value() * m_arpRepeatsModel.value());
const int total_range = range * cnphv.size();
// number of frames that every note should be played
@@ -479,11 +480,14 @@ void InstrumentFunctionArpeggio::processNote( NotePlayHandle * _n )
cur_arp_idx = (int)( range * ( (float) rand() / (float) RAND_MAX ) );
}
// Divide cur_arp_idx with wanted repeats. The repeat feature will not affect random notes.
cur_arp_idx = static_cast<int>(cur_arp_idx / m_arpRepeatsModel.value());
// Cycle notes
if( m_arpCycleModel.value() && dir != ArpDirRandom )
{
cur_arp_idx *= m_arpCycleModel.value() + 1;
cur_arp_idx %= range;
cur_arp_idx %= static_cast<int>( range / m_arpRepeatsModel.value() );
}
// now calculate final key for our arp-note
@@ -525,6 +529,7 @@ void InstrumentFunctionArpeggio::saveSettings( QDomDocument & _doc, QDomElement
m_arpEnabledModel.saveSettings( _doc, _this, "arp-enabled" );
m_arpModel.saveSettings( _doc, _this, "arp" );
m_arpRangeModel.saveSettings( _doc, _this, "arprange" );
m_arpRepeatsModel.saveSettings( _doc, _this, "arprepeats" );
m_arpCycleModel.saveSettings( _doc, _this, "arpcycle" );
m_arpSkipModel.saveSettings( _doc, _this, "arpskip" );
m_arpMissModel.saveSettings( _doc, _this, "arpmiss" );
@@ -542,6 +547,7 @@ void InstrumentFunctionArpeggio::loadSettings( const QDomElement & _this )
m_arpEnabledModel.loadSettings( _this, "arp-enabled" );
m_arpModel.loadSettings( _this, "arp" );
m_arpRangeModel.loadSettings( _this, "arprange" );
m_arpRepeatsModel.loadSettings( _this, "arprepeats" );
m_arpCycleModel.loadSettings( _this, "arpcycle" );
m_arpSkipModel.loadSettings( _this, "arpskip" );
m_arpMissModel.loadSettings( _this, "arpmiss" );

View File

@@ -95,6 +95,7 @@ InstrumentFunctionArpeggioView::InstrumentFunctionArpeggioView( InstrumentFuncti
m_arpGroupBox( new GroupBox( tr( "ARPEGGIO" ) ) ),
m_arpComboBox( new ComboBox() ),
m_arpRangeKnob( new Knob( knobBright_26 ) ),
m_arpRepeatsKnob( new Knob( knobBright_26 ) ),
m_arpCycleKnob( new Knob( knobBright_26 ) ),
m_arpSkipKnob( new Knob( knobBright_26 ) ),
m_arpMissKnob( new Knob( knobBright_26 ) ),
@@ -117,6 +118,10 @@ InstrumentFunctionArpeggioView::InstrumentFunctionArpeggioView( InstrumentFuncti
m_arpRangeKnob->setHintText( tr( "Arpeggio range:" ), " " + tr( "octave(s)" ) );
m_arpRepeatsKnob->setLabel( tr( "REP" ) );
m_arpRepeatsKnob->setHintText( tr( "Note repeats:" ) + " ", " " + tr( "time(s)" ) );
m_arpCycleKnob->setLabel( tr( "CYCLE" ) );
m_arpCycleKnob->setHintText( tr( "Cycle notes:" ) + " ", " " + tr( "note(s)" ) );
@@ -154,11 +159,12 @@ InstrumentFunctionArpeggioView::InstrumentFunctionArpeggioView( InstrumentFuncti
mainLayout->addWidget( m_arpModeComboBox, 7, 0 );
mainLayout->addWidget( m_arpRangeKnob, 0, 1, 2, 1, Qt::AlignHCenter );
mainLayout->addWidget( m_arpCycleKnob, 0, 2, 2, 1, Qt::AlignHCenter );
mainLayout->addWidget( m_arpSkipKnob, 3, 1, 2, 1, Qt::AlignHCenter );
mainLayout->addWidget( m_arpMissKnob, 3, 2, 2, 1, Qt::AlignHCenter );
mainLayout->addWidget( m_arpGateKnob, 6, 1, 2, 1, Qt::AlignHCenter );
mainLayout->addWidget( m_arpTimeKnob, 6, 2, 2, 1, Qt::AlignHCenter );
mainLayout->addWidget( m_arpRepeatsKnob, 0, 2, 2, 1, Qt::AlignHCenter );
mainLayout->addWidget( m_arpCycleKnob, 0, 3, 2, 1, Qt::AlignHCenter );
mainLayout->addWidget( m_arpSkipKnob, 3, 2, 2, 1, Qt::AlignHCenter );
mainLayout->addWidget( m_arpMissKnob, 3, 3, 2, 1, Qt::AlignHCenter );
mainLayout->addWidget( m_arpGateKnob, 6, 2, 2, 1, Qt::AlignHCenter );
mainLayout->addWidget( m_arpTimeKnob, 6, 3, 2, 1, Qt::AlignHCenter );
mainLayout->setRowMinimumHeight( 2, 10 );
mainLayout->setRowMinimumHeight( 5, 10 );
@@ -181,6 +187,7 @@ void InstrumentFunctionArpeggioView::modelChanged()
m_arpGroupBox->setModel( &m_a->m_arpEnabledModel );
m_arpComboBox->setModel( &m_a->m_arpModel );
m_arpRangeKnob->setModel( &m_a->m_arpRangeModel );
m_arpRepeatsKnob->setModel( &m_a->m_arpRepeatsModel );
m_arpCycleKnob->setModel( &m_a->m_arpCycleModel );
m_arpSkipKnob->setModel( &m_a->m_arpSkipModel );
m_arpMissKnob->setModel( &m_a->m_arpMissModel );