Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arpeggiator - Note repeats #5784

Merged
merged 5 commits into from
Jan 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/InstrumentFunctionViews.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class InstrumentFunctionArpeggioView : public QWidget, public ModelView
GroupBox * m_arpGroupBox;
ComboBox * m_arpComboBox;
Knob * m_arpRangeKnob;
Knob * m_arpRepeatsKnob;
Knob * m_arpCycleKnob;
Knob * m_arpSkipKnob;
Knob * m_arpMissKnob;
Expand Down
1 change: 1 addition & 0 deletions include/InstrumentFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ class InstrumentFunctionArpeggio : public Model, public JournallingObject
BoolModel m_arpEnabledModel;
ComboBoxModel m_arpModel;
FloatModel m_arpRangeModel;
FloatModel m_arpRepeatsModel;
FloatModel m_arpCycleModel;
FloatModel m_arpSkipModel;
FloatModel m_arpMissModel;
Expand Down
10 changes: 8 additions & 2 deletions src/core/InstrumentFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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" ) ),
IanCaio marked this conversation as resolved.
Show resolved Hide resolved
zonkmachine marked this conversation as resolved.
Show resolved Hide resolved
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" ) ),
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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() );
IanCaio marked this conversation as resolved.
Show resolved Hide resolved
zonkmachine marked this conversation as resolved.
Show resolved Hide resolved
}

// now calculate final key for our arp-note
Expand Down Expand Up @@ -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" );
IanCaio marked this conversation as resolved.
Show resolved Hide resolved
zonkmachine marked this conversation as resolved.
Show resolved Hide resolved
m_arpCycleModel.saveSettings( _doc, _this, "arpcycle" );
m_arpSkipModel.saveSettings( _doc, _this, "arpskip" );
m_arpMissModel.saveSettings( _doc, _this, "arpmiss" );
Expand All @@ -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" );
IanCaio marked this conversation as resolved.
Show resolved Hide resolved
zonkmachine marked this conversation as resolved.
Show resolved Hide resolved
m_arpCycleModel.loadSettings( _this, "arpcycle" );
m_arpSkipModel.loadSettings( _this, "arpskip" );
m_arpMissModel.loadSettings( _this, "arpmiss" );
Expand Down
17 changes: 12 additions & 5 deletions src/gui/widgets/InstrumentFunctionViews.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) ),
IanCaio marked this conversation as resolved.
Show resolved Hide resolved
zonkmachine marked this conversation as resolved.
Show resolved Hide resolved
m_arpCycleKnob( new Knob( knobBright_26 ) ),
m_arpSkipKnob( new Knob( knobBright_26 ) ),
m_arpMissKnob( new Knob( knobBright_26 ) ),
Expand All @@ -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)" ) );
IanCaio marked this conversation as resolved.
Show resolved Hide resolved
zonkmachine marked this conversation as resolved.
Show resolved Hide resolved


m_arpCycleKnob->setLabel( tr( "CYCLE" ) );
m_arpCycleKnob->setHintText( tr( "Cycle notes:" ) + " ", " " + tr( "note(s)" ) );

Expand Down Expand Up @@ -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 );
IanCaio marked this conversation as resolved.
Show resolved Hide resolved
zonkmachine marked this conversation as resolved.
Show resolved Hide resolved

mainLayout->setRowMinimumHeight( 2, 10 );
mainLayout->setRowMinimumHeight( 5, 10 );
Expand All @@ -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 );
IanCaio marked this conversation as resolved.
Show resolved Hide resolved
zonkmachine marked this conversation as resolved.
Show resolved Hide resolved
m_arpCycleKnob->setModel( &m_a->m_arpCycleModel );
m_arpSkipKnob->setModel( &m_a->m_arpSkipModel );
m_arpMissKnob->setModel( &m_a->m_arpMissModel );
Expand Down