Skip to content

Commit

Permalink
ModSrc_Random*
Browse files Browse the repository at this point in the history
  • Loading branch information
chn-dev committed May 31, 2024
1 parent 89d984a commit db9fcea
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/SamplerEngine/ModMatrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,8 @@ std::set<ModMatrix::ModSrc> ModMatrix::allModSrc()
ModSrc_LFO2,
ModSrc_LFO3,
ModSrc_ModWheel,
ModSrc_RandomUnipolar,
ModSrc_RandomBipolar,
ModSrc_None
} ) );
}
Expand Down Expand Up @@ -499,6 +501,10 @@ std::string ModMatrix::toString( ModSrc v )
return( "AbsNote" );
case( ModSrc_RelNote ):
return( "RelNote" );
case( ModSrc_RandomUnipolar ):
return( "Random+" );
case( ModSrc_RandomBipolar ):
return( "Random+-" );
case( ModSrc_None ):
return( "None" );
default:
Expand Down Expand Up @@ -578,6 +584,11 @@ ModMatrix::ModSrc ModMatrix::modSrcFromString( const std::string &s )
else
if( util::trim( util::toLower( s ) ) == "relnote" )
return( ModSrc_RelNote );
else
if( util::trim( util::toLower( s ) ) == "random+" )
return( ModSrc_RandomUnipolar );
if( util::trim( util::toLower( s ) ) == "random+-" )
return( ModSrc_RandomBipolar );
else
return( ModSrc_None );
}
Expand Down
4 changes: 3 additions & 1 deletion src/SamplerEngine/ModMatrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ namespace SamplerEngine
ModSrc_LFO1,
ModSrc_LFO2,
ModSrc_LFO3,
ModSrc_ModWheel
ModSrc_ModWheel,
ModSrc_RandomUnipolar,
ModSrc_RandomBipolar
};

enum ModDest
Expand Down
8 changes: 8 additions & 0 deletions src/SamplerEngine/Voice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ Voice::Voice( const Part *pPart, const Sample *pSample, int note, int velocity )
}

m_pFilter = new Filter( *pSample->getFilter() );

m_RandomBipolar = util::randomValue( -1.0, 1.0 );
}


Expand Down Expand Up @@ -166,6 +168,12 @@ double Voice::getModValue( ModMatrix::ModSrc modSrc, double defaultValue ) const
else
if( modSrc == ModMatrix::ModSrc_RelNote )
return( 2.0 * (double)( m_Note - m_pSample->getMinNote() ) / (double)( m_pSample->getMaxNote() - m_pSample->getMinNote() ) );
else
if( modSrc == ModMatrix::ModSrc_RandomUnipolar )
return( ( m_RandomBipolar + 1.0 ) / 2.0 );
else
if( modSrc == ModMatrix::ModSrc_RandomBipolar )
return( m_RandomBipolar );
else
return( defaultValue );
}
Expand Down
1 change: 1 addition & 0 deletions src/SamplerEngine/Voice.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ namespace SamplerEngine
int m_Velocity;
double m_Ofs;
unsigned long m_nSample;
double m_RandomBipolar;
};
}

Expand Down

0 comments on commit db9fcea

Please sign in to comment.