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

mB_prJune23_2020 #5544

Closed
wants to merge 11 commits into from
4 changes: 4 additions & 0 deletions include/PianoRoll.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,10 @@ protected slots:
void quantizeChanged();
void noteLengthChanged();
void quantizeNotes();
void humanizeNotesVel();
void humanizeNotesLen();
void strumNotesUp();
void strumNotesDn();

void updateSemiToneMarkerMenu();

Expand Down
70 changes: 37 additions & 33 deletions src/core/EnvelopeAndLfoParameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@
extern const float SECS_PER_ENV_SEGMENT = 5.0f;
// how long should be one LFO-oscillation maximal?
extern const float SECS_PER_LFO_OSCILLATION = 20.0f;
// minimum number of frames for ENV/LFO stages that mustn't be '0'
const f_cnt_t minimumFrames = 1;


EnvelopeAndLfoParameters::LfoInstances * EnvelopeAndLfoParameters::s_lfoInstances = NULL;
Expand All @@ -59,8 +57,7 @@ void EnvelopeAndLfoParameters::LfoInstances::trigger()
void EnvelopeAndLfoParameters::LfoInstances::reset()
{
QMutexLocker m( &m_lfoListMutex );
for( LfoList::Iterator it = m_lfos.begin();
it != m_lfos.end(); ++it )
for( LfoList::Iterator it = m_lfos.begin(); it != m_lfos.end(); ++it )
{
( *it )->m_lfoFrame = 0;
( *it )->m_bad_lfoShapeData = true;
Expand Down Expand Up @@ -89,33 +86,36 @@ void EnvelopeAndLfoParameters::LfoInstances::remove( EnvelopeAndLfoParameters *


EnvelopeAndLfoParameters::EnvelopeAndLfoParameters(
float _value_for_zero_amount,
Model * _parent ) :
Model( _parent ),
float _value_for_zero_amount,
Model * _parent ) :
Model( _parent ),
m_used( false ),


// m_predelayModel( val, min, max, incr, this, tr( ">info<" ) )
m_predelayModel( 0.0, 0.0, 2.0, 0.001, this, tr( "Env pre-delay" ) ),
m_attackModel( 0.0, 0.0, 2.0, 0.001, this, tr( "Env attack" ) ),
m_holdModel( 0.5, 0.0, 2.0, 0.001, this, tr( "Env hold" ) ),
m_decayModel( 0.5, 0.0, 2.0, 0.001, this, tr( "Env decay" ) ),
m_sustainModel( 0.5, 0.0, 1.0, 0.001, this, tr( "Env sustain" ) ),
m_releaseModel( 0.1, 0.0, 2.0, 0.001, this, tr( "Env release" ) ),
m_amountModel( 0.0, -1.0, 1.0, 0.005, this, tr( "Env mod amount" ) ),
m_attackModel( 0.025, 0.0, 2.0, 0.001, this, tr( "Env attack" ) ),
m_holdModel( 0.0, 0.0, 2.0, 0.001, this, tr( "Env hold" ) ),
m_decayModel( 0.6, 0.0, 2.0, 0.001, this, tr( "Env decay" ) ),
m_sustainModel( 0.0, 0.0, 1.0, 0.001, this, tr( "Env sustain" ) ),
m_releaseModel( 0.2, 0.0, 2.0, 0.001, this, tr( "Env release" ) ),
m_amountModel( 1.0, -1.0, 1.0, 0.005, this, tr( "Env mod amount" ) ), //AMP
m_valueForZeroAmount( _value_for_zero_amount ),
m_pahdFrames( 0 ),
m_rFrames( 0 ),
m_pahdEnv( NULL ),
m_rEnv( NULL ),
m_pahdBufSize( 0 ),
m_rBufSize( 0 ),
m_lfoPredelayModel( 0.0, 0.0, 1.0, 0.001, this, tr( "LFO pre-delay" ) ),
m_lfoAttackModel( 0.0, 0.0, 1.0, 0.001, this, tr( "LFO attack" ) ),
m_lfoPredelayModel( 0.0, 0.0, 1.0, 0.001, this, tr( "LFO Predelay" ) ),
m_lfoAttackModel( 0.0, 0.0, 1.0, 0.001, this, tr( "LFO Attack" ) ),
m_lfoSpeedModel( 0.1, 0.001, 1.0, 0.0001,
SECS_PER_LFO_OSCILLATION * 1000.0, this,
tr( "LFO frequency" ) ),
m_lfoAmountModel( 0.0, -1.0, 1.0, 0.005, this, tr( "LFO mod amount" ) ),
m_lfoWaveModel( SineWave, 0, NumLfoShapes, this, tr( "LFO wave shape" ) ),
m_x100Model( false, this, tr( "LFO frequency x 100" ) ),
m_controlEnvAmountModel( false, this, tr( "Modulate env amount" ) ),
SECS_PER_LFO_OSCILLATION * 1000.0, this,
tr( "LFO speed" ) ),
m_lfoAmountModel( 0.0, -1.0, 1.0, 0.005, this, tr( "LFO Modulation" ) ),
m_lfoWaveModel( SineWave, 0, NumLfoShapes, this, tr( "LFO Wave Shape" ) ),
m_x100Model( false, this, tr( "Freq x 100" ) ),
m_controlEnvAmountModel( false, this, tr( "Modulate Env-Amount" ) ),
Comment on lines -113 to +118
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will updating these break translations?

I'm also not sure about the changes here - I like frequency -> speed, but I'm not as sure about env amount -> Env-Amount. This makes the capitalization inconsistent, as it hasn't been changed above (above is first word has first letter capitalized: 'Env attack', 'Env release', etc, while this is all words have first letter capitalized: 'LFO Modulation', 'LFO Wave Shape', etc).

Also, Env mod amount has not been changed, so I think changing LFO mod amount to LFO Modulation could be confusing to a new user - they both do the same thing for their respective modulators, i.e. control mod amount, so naming them in a similar way makes the most sense to me.

I would personally suggest leaving the names unchanged for this PR and submitting a separate PR for name changes that also maintains consistency across LMMS, and also that deals with any translation issues, if that's something you're interested in.

m_lfoFrame( 0 ),
m_lfoAmountIsZero( false ),
m_lfoShapeData( NULL )
Expand Down Expand Up @@ -144,7 +144,6 @@ EnvelopeAndLfoParameters::EnvelopeAndLfoParameters(
this, SLOT( updateSampleVars() ), Qt::DirectConnection );
connect( &m_amountModel, SIGNAL( dataChanged() ),
this, SLOT( updateSampleVars() ), Qt::DirectConnection );

connect( &m_lfoPredelayModel, SIGNAL( dataChanged() ),
this, SLOT( updateSampleVars() ), Qt::DirectConnection );
connect( &m_lfoAttackModel, SIGNAL( dataChanged() ),
Expand All @@ -157,7 +156,6 @@ EnvelopeAndLfoParameters::EnvelopeAndLfoParameters(
this, SLOT( updateSampleVars() ), Qt::DirectConnection );
connect( &m_x100Model, SIGNAL( dataChanged() ),
this, SLOT( updateSampleVars() ), Qt::DirectConnection );

connect( Engine::mixer(), SIGNAL( sampleRateChanged() ),
this, SLOT( updateSampleVars() ) );

Expand Down Expand Up @@ -274,7 +272,7 @@ inline void EnvelopeAndLfoParameters::fillLfoLevel( float * _buf,
}

fpp_t offset = 0;
const float lafI = 1.0f / qMax( minimumFrames, m_lfoAttackFrames );
const float lafI = 1.0f / m_lfoAttackFrames;
Comment on lines -277 to +275
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious for your rationale behind removing the minimum here. Can you guarantee that m_lfoAttackFrames will never be 0?

Copy link
Member

@zonkmachine zonkmachine Jun 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you guarantee that m_lfoAttackFrames will never be 0?

He can't. I believe I added that statement early after stable-1.2 was branched off master. One of the things that most likely will break by this change is the fpe debug option (WANT_DEBUG_FPE). @musikBear What was the reason behind this change?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was the reason behind this change?

I have N O T made these changes!
I do not have the faintest idea, why they are in this commit!
Could that happen if i updated one file through GIT?
Bottom-line : The only code i have added in EnvelopeAndLfoParameters.cpp is for the Envelopes, nothing else has been touched by me
My code:

//  m_predelayModel( val, min, max, incr,  this, tr( ">info<" ) )   
	m_predelayModel( 0.0, 0.0, 2.0, 0.001, this, tr( "Env pre-delay" ) ),
	m_attackModel( 0.025, 0.0, 2.0, 0.001, this, tr( "Env attack" ) ),
	m_holdModel( 0.0, 0.0, 2.0, 0.001,     this, tr( "Env hold" ) ),
	m_decayModel( 0.6, 0.0, 2.0, 0.001,    this, tr( "Env decay" ) ),
	m_sustainModel( 0.0, 0.0, 1.0, 0.001,  this, tr( "Env sustain" ) ),
	m_releaseModel( 0.2, 0.0, 2.0, 0.001,  this, tr( "Env release" ) ),
        m_amountModel( 1.0, -1.0, 1.0, 0.005,  this, tr( "Env mod amount" ) ), //AMP 

And ONLY those lines are mine.
This is my fault, no question, but HOW i have gotten an unknown file 'merged'(?) into my commit, i do not know. I used the 'add-file-through-upload'.
I definitively expected that my 'added' file would replace the current!
I does NOT?!?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This must be something with your git workflow then... I would expect this to show up as a merge conflict under a typical fork -> commit -> PR scenario.

My guess here is that there are changes in LMMS/lmms/master that you don't have yet. You may have to manually update your code with the changes in master.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I definitively expected that my 'added' file would replace the current!

You shouldn't add files. You should push commits. Your master branch is borked and needs to be reset to the lmms master branch.

I used the 'add-file-through-upload'.

What's that? Are you uploading files via the GitHub interface? Have you followed any tutorial to learn how to work with git/GitHub?

for( ; offset < _frames && _frame < m_lfoAttackFrames; ++offset,
++_frame )
{
Expand Down Expand Up @@ -380,12 +378,22 @@ void EnvelopeAndLfoParameters::loadSettings( const QDomElement & _this )
/* ### TODO:
Old reversed sustain kept for backward compatibility
with 4.15 file format*/

if( _this.hasAttribute( "sus" ) )
{
m_sustainModel.loadSettings( _this, "sus" );
m_sustainModel.setValue( 1.0 - m_sustainModel.value() );
}

// ### TODO:
/* // Keep compatibility with version 2.1 file format
if( _this.hasAttribute( "lfosyncmode" ) )
{
m_lfoSpeedKnob->setSyncMode(
( TempoSyncKnob::TtempoSyncMode ) _this.attribute(
"lfosyncmode" ).toInt() );
}*/

Comment on lines +388 to +396
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean to leave this commented? Also curious if you meant to put 1.2 and not 2.1.

m_userWave.setAudioFile( _this.attribute( "userwavefile" ) );

updateSampleVars();
Expand All @@ -400,23 +408,20 @@ void EnvelopeAndLfoParameters::updateSampleVars()

const float frames_per_env_seg = SECS_PER_ENV_SEGMENT *
Engine::mixer()->processingSampleRate();

// TODO: Remove the expKnobVals, time should be linear
const f_cnt_t predelay_frames = static_cast<f_cnt_t>(
frames_per_env_seg *
expKnobVal( m_predelayModel.value() ) );

const f_cnt_t attack_frames = qMax( minimumFrames,
static_cast<f_cnt_t>( frames_per_env_seg *
expKnobVal( m_attackModel.value() ) ) );
const f_cnt_t attack_frames = static_cast<f_cnt_t>( frames_per_env_seg *
expKnobVal( m_attackModel.value() ) );

const f_cnt_t hold_frames = static_cast<f_cnt_t>( frames_per_env_seg *
expKnobVal( m_holdModel.value() ) );

const f_cnt_t decay_frames = qMax( minimumFrames,
static_cast<f_cnt_t>( frames_per_env_seg *
const f_cnt_t decay_frames = static_cast<f_cnt_t>( frames_per_env_seg *
expKnobVal( m_decayModel.value() *
( 1 - m_sustainModel.value() ) ) ) );
( 1 - m_sustainModel.value() ) ) );

m_sustainLevel = m_sustainModel.value();
m_amount = m_amountModel.value();
Expand All @@ -433,11 +438,10 @@ void EnvelopeAndLfoParameters::updateSampleVars()
decay_frames;
m_rFrames = static_cast<f_cnt_t>( frames_per_env_seg *
expKnobVal( m_releaseModel.value() ) );
m_rFrames = qMax( minimumFrames, m_rFrames );

if( static_cast<int>( floorf( m_amount * 1000.0f ) ) == 0 )
{
m_rFrames = minimumFrames;
m_rFrames = 0;
}

// if the buffers are too small, make bigger ones - so we only alloc new memory when necessary
Expand Down