@ -30,6 +30,8 @@
# include <math.h>
# include <math.h>
extern float _loudness ;
extern float _loudness ;
extern uint8_t master_volume ;
extern config_t configuration ;
mdaEPiano : : mdaEPiano ( ) // mdaEPiano::mdaEPiano(audioMasterCallback audioMaster) : AudioEffectX(audioMaster, NPROGS, NPARAMS)
mdaEPiano : : mdaEPiano ( ) // mdaEPiano::mdaEPiano(audioMasterCallback audioMaster) : AudioEffectX(audioMaster, NPROGS, NPARAMS)
{
{
@ -115,23 +117,39 @@ mdaEPiano::mdaEPiano() // mdaEPiano::mdaEPiano(audioMasterCallback audioMaster)
void mdaEPiano : : reset_voices ( void ) // reset all voices
void mdaEPiano : : reset_voices ( void ) // reset all voices
{
{
//initialise...
for ( int32_t v = 0 ; v < NVOICES ; v + + )
for ( int32_t v = 0 ; v < NVOICES ; v + + )
{
{
voice [ v ] . env = 0.0f ;
voice [ v ] . env = 0.0f ;
voice [ v ] . dec = 0.99f ; //all notes off
voice [ v ] . dec = 0.99f ; //all notes off
}
}
volume = 0.2f ;
//volume = // 0.00002f * 127; // Fixing this level and using CC#7 as master_volume
muff = 160.0f ;
muff = 160.0f ;
sustain = activevoices = 0 ;
sustain = activevoices = 0 ;
tl = tr = lfo0 = dlfo = 0.0f ;
tl = tr = lfo0 = dlfo = 0.0f ;
lfo1 = 1.0f ;
lfo1 = 1.0f ;
vol = VOLUME ;
update ( ) ;
update ( ) ;
// suspend();
}
}
void mdaEPiano : : reset_controllers ( void ) // reset controllers
{
tl = tr = lfo0 = dlfo = 0.0f ;
lfo1 = 1.0f ;
update ( ) ;
}
void mdaEPiano : : stop_voices ( void ) // all keys off, but no reset for sustain
{
for ( int32_t v = 0 ; v < NVOICES ; v + + )
{
voice [ v ] . env = 0.0f ;
}
muff = 160.0f ;
activevoices = 0 ;
update ( ) ;
}
void mdaEPiano : : update ( ) //parameter change
void mdaEPiano : : update ( ) //parameter change
{
{
@ -401,7 +419,7 @@ bool mdaEPiano::processMidiController(uint8_t data1, uint8_t data2)
break ;
break ;
case 0x07 : //volume
case 0x07 : //volume
volume = 0.00002f * ( float ) ( data2 * data2 ) ;
master_ volume = map ( data2 , 0 , 127 , ENC_MASTER_VOLUME_MIN , ENC_MASTER_VOLUME_MAX ) ;
break ;
break ;
case 0x40 : //sustain pedal
case 0x40 : //sustain pedal
@ -413,13 +431,20 @@ bool mdaEPiano::processMidiController(uint8_t data1, uint8_t data2)
}
}
break ;
break ;
default : //all notes off
case 0x78 : // All Sound Off: mutes all sounding notes. It does so regardless of release time or sustain. (See MIDI CC 123)
if ( data1 > 0x7A )
reset_voices ( ) ;
{
break ;
for ( int32_t v = 0 ; v < max_polyphony ; v + + ) voice [ v ] . dec = 0.99f ;
case 0x79 : // Reset All Controllers: it will reset all controllers to their default.
sustain = 0 ;
reset_controllers ( ) ;
muff = 160.0f ;
break ;
}
case 0x7b : // All Notes Off: mutes all sounding notes. Release time will still be maintained, and notes held by sustain will not turn off until sustain pedal is depressed.
stop_voices ( ) ;
break ;
case 0x7e : // Mono Mode: sets device mode to Monophonic.
setMaxPolyphony ( 1 ) ;
break ;
case 0x7f : // Poly Mode: sets device mode to Polyphonic.
setMaxPolyphony ( configuration . max_poly ) ;
break ;
break ;
}
}
return ( true ) ;
return ( true ) ;