@ -414,120 +414,120 @@ void loop()
//while (42 == 42)
//while (42 == 42)
//{
//{
# ifdef OLD
# ifdef OLD
// Main sound calculation
// Main sound calculation
if ( queue1 . available ( ) & & fill_audio_buffer > audio_block_time_us - 10 )
if ( queue1 . available ( ) & & fill_audio_buffer > audio_block_time_us - 10 )
{
{
fill_audio_buffer = 0 ;
fill_audio_buffer = 0 ;
audio_buffer = queue1 . getBuffer ( ) ;
audio_buffer = queue1 . getBuffer ( ) ;
elapsedMicros t1 ;
elapsedMicros t1 ;
for ( uint8_t i = 0 ; i < NUM_DEXED ; i + + )
for ( uint8_t i = 0 ; i < NUM_DEXED ; i + + )
{
{
MicroDexed [ i ] - > getSamples ( AUDIO_BLOCK_SAMPLES , audio_buffer ) ;
MicroDexed [ i ] - > getSamples ( AUDIO_BLOCK_SAMPLES , audio_buffer ) ;
}
if ( t1 > audio_block_time_us ) // everything greater 2.9ms is a buffer underrun!
xrun + + ;
if ( t1 > render_time_max )
render_time_max = t1 ;
if ( peak1 . available ( ) )
{
if ( peak1 . read ( ) > 0.99 )
peak + + ;
}
queue1 . playBuffer ( ) ;
}
}
# endif
if ( t1 > audio_block_time_us ) // everything greater 2.9ms is a buffer underrun!
xrun + + ;
// EEPROM update handling
if ( t1 > render_time_max )
if ( autostore > = AUTOSTORE_MS & & active_voices = = 0 & & eeprom_update_flag = = true )
render_time_max = t1 ;
if ( peak1 . available ( ) )
{
{
// only store configuration data to EEPROM when AUTOSTORE_MS is reached and no voices are activated anymore
if ( peak1 . read ( ) > 0.99 )
eeprom_update ( ) ;
peak + + ;
}
}
queue1 . playBuffer ( ) ;
}
# endif
// MIDI input handling
// EEPROM update handling
check_midi_devices ( ) ;
if ( autostore > = AUTOSTORE_MS & & active_voices = = 0 & & eeprom_update_flag = = true )
{
// only store configuration data to EEPROM when AUTOSTORE_MS is reached and no voices are activated anymore
eeprom_update ( ) ;
}
// CONTROL-RATE-EVENT-HANDLING
// MIDI input handling
if ( control_rate > CONTROL_RATE_MS )
check_midi_devices ( ) ;
{
// CONTROL-RATE-EVENT-HANDLING
if ( control_rate > CONTROL_RATE_MS )
{
# ifdef ENABLE_LCD_UI
# ifdef ENABLE_LCD_UI
// LCD Menu
// LCD Menu
LCDML . loop ( ) ;
LCDML . loop ( ) ;
// initial starts voice selection menu as default
// initial starts voice selection menu as default
if ( menu_state = = MENU_START )
if ( menu_state = = MENU_START )
{
{
menu_state = MENU_VOICE ;
menu_state = MENU_VOICE ;
UI_func_voice_selection ( 0 ) ;
UI_func_voice_selection ( 0 ) ;
}
}
# endif
# endif
control_rate = 0 ;
control_rate = 0 ;
// check for value changes and unused voices
// check for value changes and unused voices
soften_volume . tick ( ) ;
soften_volume . tick ( ) ;
for ( uint8_t i = 0 ; i < NUM_DEXED ; i + + )
for ( uint8_t i = 0 ; i < NUM_DEXED ; i + + )
{
{
active_voices = MicroDexed [ i ] - > getNumNotesPlaying ( ) ;
active_voices = MicroDexed [ i ] - > getNumNotesPlaying ( ) ;
soften_filter_res [ i ] . tick ( ) ;
soften_filter_res [ i ] . tick ( ) ;
soften_filter_cut [ i ] . tick ( ) ;
soften_filter_cut [ i ] . tick ( ) ;
if ( soften_filter_res [ i ] . running ( ) )
if ( soften_filter_res [ i ] . running ( ) )
{
{
// soften filter resonance value
// soften filter resonance value
MicroDexed [ i ] - > fx . Reso = soften_filter_res [ i ] . value ( ) ;
MicroDexed [ i ] - > fx . Reso = soften_filter_res [ i ] . value ( ) ;
# ifdef DEBUG
# ifdef DEBUG
Serial . print ( F ( " Filter-Resonance: " ) ) ;
Serial . print ( F ( " Filter-Resonance: " ) ) ;
Serial . print ( MicroDexed [ i ] - > fx . Reso , 5 ) ;
Serial . print ( MicroDexed [ i ] - > fx . Reso , 5 ) ;
Serial . print ( F ( " Filter-Resonance step: " ) ) ;
Serial . print ( F ( " Filter-Resonance step: " ) ) ;
Serial . print ( soften_filter_res [ i ] . steps ( ) ) ;
Serial . print ( soften_filter_res [ i ] . steps ( ) ) ;
Serial . print ( F ( " Filter-Resonance diff: " ) ) ;
Serial . print ( F ( " Filter-Resonance diff: " ) ) ;
Serial . println ( soften_filter_res [ i ] . diff ( ) , 5 ) ;
Serial . println ( soften_filter_res [ i ] . diff ( ) , 5 ) ;
# endif
# endif
}
// soften filter cutoff value
if ( soften_filter_cut [ i ] . running ( ) )
{
MicroDexed [ i ] - > fx . Cutoff = soften_filter_cut [ i ] . value ( ) ;
# ifdef DEBUG
Serial . print ( F ( " Filter-Cutoff: " ) ) ;
Serial . print ( MicroDexed [ i ] - > fx . Cutoff , 5 ) ;
Serial . print ( F ( " Filter-Cutoff step: " ) ) ;
Serial . print ( soften_filter_cut [ i ] . steps ( ) ) ;
Serial . print ( F ( " Filter-Cutoff diff: " ) ) ;
Serial . println ( soften_filter_cut [ i ] . diff ( ) , 5 ) ;
# endif
}
}
}
if ( soften_volume . running ( ) )
// soften filter cutoff value
if ( soften_filter_cut [ i ] . running ( ) )
{
{
set_volume ( soften_volume . value ( ) , configuration . pan , configuration . mono ) ;
MicroDexed [ i ] - > fx . Cutoff = soften_filter_cut [ i ] . value ( ) ;
# ifdef DEBUG
# ifdef DEBUG
Serial . print ( F ( " Volume : " ) ) ;
Serial . print ( F ( " Filter-Cutoff: " ) ) ;
Serial . print ( configuration . vol , DEC ) ;
Serial . print ( MicroDexed [ i ] - > fx . Cutoff , 5 ) ;
Serial . print ( F ( " step: " ) ) ;
Serial . print ( F ( " Filter-Cutoff step: " ) ) ;
Serial . print ( soften_volume . steps ( ) ) ;
Serial . print ( soften_filter_cut [ i ] . steps ( ) ) ;
Serial . print ( F ( " diff: " ) ) ;
Serial . print ( F ( " Filter-Cutoff diff: " ) ) ;
Serial . println ( soften_volume . diff ( ) , 5 ) ;
Serial . println ( soften_filter_cut [ i ] . diff ( ) , 5 ) ;
# endif
# endif
}
}
}
}
if ( soften_volume . running ( ) )
{
set_volume ( soften_volume . value ( ) , configuration . pan , configuration . mono ) ;
# ifdef DEBUG
Serial . print ( F ( " Volume: " ) ) ;
Serial . print ( configuration . vol , DEC ) ;
Serial . print ( F ( " step: " ) ) ;
Serial . print ( soften_volume . steps ( ) ) ;
Serial . print ( F ( " diff: " ) ) ;
Serial . println ( soften_volume . diff ( ) , 5 ) ;
# endif
}
}
# if defined (DEBUG) && defined (SHOW_CPU_LOAD_MSEC)
# if defined (DEBUG) && defined (SHOW_CPU_LOAD_MSEC)
if ( cpu_mem_millis > = SHOW_CPU_LOAD_MSEC )
if ( cpu_mem_millis > = SHOW_CPU_LOAD_MSEC )
{
if ( peak1 . available ( ) )
{
{
if ( peak1 . available ( ) )
if ( peak1 . read ( ) > 0.99 )
{
peak + + ;
if ( peak1 . read ( ) > 0.99 )
peak + + ;
}
cpu_mem_millis - = SHOW_CPU_LOAD_MSEC ;
show_cpu_and_mem_usage ( ) ;
}
}
cpu_mem_millis - = SHOW_CPU_LOAD_MSEC ;
show_cpu_and_mem_usage ( ) ;
}
# endif
# endif
//}
//}
}
}
@ -547,7 +547,7 @@ void handleNoteOff(byte inChannel, byte inNumber, byte inVelocity)
{
{
if ( checkMidiChannel ( inChannel ) )
if ( checkMidiChannel ( inChannel ) )
{
{
MicroDexed [ 0 ] - > keyup ( inNumber ) ;
MicroDexed [ 0 ] - > keyup ( inNumber ) ;
}
}
}
}
@ -1015,22 +1015,25 @@ void set_volume(uint8_t v, int8_t p, uint8_t m)
// http://files.csound-tutorial.net/floss_manual/Release03/Cs_FM_03_ScrapBook/b-panning-and-spatialization.html
// http://files.csound-tutorial.net/floss_manual/Release03/Cs_FM_03_ScrapBook/b-panning-and-spatialization.html
volume_r . gain ( tmp3 * sinf ( tmp2 * PI / 2 ) ) ;
volume_r . gain ( tmp3 * sinf ( tmp2 * PI / 2 ) ) ;
volume_l . gain ( tmp3 * cosf ( tmp2 * PI / 2 ) ) ;
volume_l . gain ( tmp3 * cosf ( tmp2 * PI / 2 ) ) ;
switch ( m )
switch ( m )
{
{
case 0 :
case 0 : // stereo
stereomono1 . stereo ( true ) ;
stereomono1 . stereo ( true ) ;
break ;
break ;
case 1 :
case 1 : // mono both
stereomono1 . stereo ( false ) ;
stereomono1 . stereo ( false ) ;
configuration . pan = 0.5 ;
break ;
break ;
case 2 :
case 2 : // mono right
volume_l . gain ( 0.0 ) ;
volume_l . gain ( 0.0 ) ;
stereomono1 . stereo ( false ) ;
stereomono1 . stereo ( false ) ;
configuration . pan = 0.5 ;
break ;
break ;
case 3 :
case 3 : // mono left
volume_r . gain ( 0.0 ) ;
volume_r . gain ( 0.0 ) ;
stereomono1 . stereo ( false ) ;
stereomono1 . stereo ( false ) ;
configuration . pan = 0.5 ;
break ;
break ;
}
}
}
}