30
30
#include < stdio.h>
31
31
#include < assert.h>
32
32
#include " arm_float_to_q23.h"
33
+ #include " arm_scale_zip_f32.h"
33
34
34
35
const char WLANFirmwarePath[] = " SD:firmware/" ;
35
36
const char WLANConfigFile[] = " SD:wpa_supplicant.conf" ;
@@ -1354,33 +1355,20 @@ void CMiniDexed::ProcessSound (void)
1354
1355
float32_t tmp_float[nFrames*Channels];
1355
1356
int32_t tmp_int[nFrames*Channels];
1356
1357
1357
- if (nMasterVolume > 0.0 )
1358
+ // Convert dual float array (8 chan) to single int16 array (8 chan)
1359
+ for (uint16_t i=0 ; i<nFrames;i++)
1358
1360
{
1359
- // Convert dual float array (8 chan) to single int16 array (8 chan)
1360
- for (uint16_t i=0 ; i<nFrames;i++)
1361
+ // TGs will alternate on L/R channels for each output
1362
+ // reading directly from the TG OutputLevel buffer with
1363
+ // no additional processing.
1364
+ for (uint8_t tg = 0 ; tg < Channels; tg++)
1361
1365
{
1362
- // TGs will alternate on L/R channels for each output
1363
- // reading directly from the TG OutputLevel buffer with
1364
- // no additional processing.
1365
- for (uint8_t tg = 0 ; tg < Channels; tg++)
1366
- {
1367
- if (nMasterVolume >0.0 && nMasterVolume <1.0 )
1368
- {
1369
- tmp_float[(i*Channels)+tg]=m_OutputLevel[tg][i] * nMasterVolume;
1370
- }
1371
- else if (nMasterVolume == 1.0 )
1372
- {
1373
- tmp_float[(i*Channels)+tg]=m_OutputLevel[tg][i];
1374
- }
1375
- }
1366
+ tmp_float[(i*Channels)+tg]=m_OutputLevel[tg][i] * nMasterVolume;
1376
1367
}
1377
- arm_float_to_q23 (tmp_float,tmp_int,nFrames*Channels);
1378
- }
1379
- else
1380
- {
1381
- arm_fill_q31 (0 , tmp_int, nFrames*Channels);
1382
1368
}
1383
1369
1370
+ arm_float_to_q23 (tmp_float,tmp_int,nFrames*Channels);
1371
+
1384
1372
// Prevent PCM510x analog mute from kicking in
1385
1373
for (uint8_t tg = 0 ; tg < Channels; tg++)
1386
1374
{
@@ -1404,77 +1392,60 @@ void CMiniDexed::ProcessSound (void)
1404
1392
float32_t tmp_float[nFrames*2 ];
1405
1393
int32_t tmp_int[nFrames*2 ];
1406
1394
1407
- if (nMasterVolume > 0.0 )
1408
- {
1409
- for (uint8_t i = 0 ; i < m_nToneGenerators; i++)
1410
- {
1411
- tg_mixer->doAddMix (i,m_OutputLevel[i]);
1412
- reverb_send_mixer->doAddMix (i,m_OutputLevel[i]);
1413
- }
1414
- // END TG mixing
1395
+ // get the mix buffer of all TGs
1396
+ float32_t *SampleBuffer[2 ];
1397
+ tg_mixer->getBuffers (SampleBuffer);
1415
1398
1416
- // BEGIN create SampleBuffer for holding audio data
1417
- float32_t SampleBuffer[2 ][nFrames];
1418
- // END create SampleBuffer for holding audio data
1399
+ tg_mixer->zeroFill ();
1419
1400
1420
- // get the mix of all TGs
1421
- tg_mixer->getMix (SampleBuffer[indexL], SampleBuffer[indexR]);
1401
+ for (uint8_t i = 0 ; i < m_nToneGenerators; i++)
1402
+ {
1403
+ tg_mixer->doAddMix (i,m_OutputLevel[i]);
1404
+ }
1405
+ // END TG mixing
1422
1406
1423
- // BEGIN adding reverb
1424
- if (m_nParameter[ParameterReverbEnable])
1425
- {
1426
- float32_t ReverbBuffer[2 ][nFrames];
1427
- float32_t ReverbSendBuffer[2 ][nFrames];
1407
+ // BEGIN adding reverb
1408
+ if (m_nParameter[ParameterReverbEnable])
1409
+ {
1410
+ float32_t ReverbBuffer[2 ][nFrames];
1428
1411
1429
- arm_fill_f32 (0 .0f , ReverbBuffer[indexL], nFrames);
1430
- arm_fill_f32 (0 .0f , ReverbBuffer[indexR], nFrames);
1431
- arm_fill_f32 (0 .0f , ReverbSendBuffer[indexR], nFrames);
1432
- arm_fill_f32 (0 .0f , ReverbSendBuffer[indexL], nFrames);
1412
+ float32_t *ReverbSendBuffer[2 ];
1413
+ reverb_send_mixer->getBuffers (ReverbSendBuffer);
1433
1414
1434
- m_ReverbSpinLock. Acquire ();
1415
+ reverb_send_mixer-> zeroFill ();
1435
1416
1436
- reverb_send_mixer->getMix (ReverbSendBuffer[indexL], ReverbSendBuffer[indexR]);
1437
- reverb->doReverb (ReverbSendBuffer[indexL],ReverbSendBuffer[indexR],ReverbBuffer[indexL], ReverbBuffer[indexR],nFrames);
1417
+ for (uint8_t i = 0 ; i < m_nToneGenerators; i++)
1418
+ {
1419
+ reverb_send_mixer->doAddMix (i,m_OutputLevel[i]);
1420
+ }
1438
1421
1439
- // scale down and add left reverb buffer by reverb level
1440
- arm_scale_f32 (ReverbBuffer[indexL], reverb->get_level (), ReverbBuffer[indexL], nFrames);
1441
- arm_add_f32 (SampleBuffer[indexL], ReverbBuffer[indexL], SampleBuffer[indexL], nFrames);
1442
- // scale down and add right reverb buffer by reverb level
1443
- arm_scale_f32 (ReverbBuffer[indexR], reverb->get_level (), ReverbBuffer[indexR], nFrames);
1444
- arm_add_f32 (SampleBuffer[indexR], ReverbBuffer[indexR], SampleBuffer[indexR], nFrames);
1422
+ m_ReverbSpinLock.Acquire ();
1445
1423
1446
- m_ReverbSpinLock.Release ();
1447
- }
1448
- // END adding reverb
1424
+ reverb->doReverb (ReverbSendBuffer[indexL],ReverbSendBuffer[indexR],ReverbBuffer[indexL], ReverbBuffer[indexR],nFrames);
1449
1425
1450
- // swap stereo channels if needed prior to writing back out
1451
- if (m_bChannelsSwapped)
1452
- {
1453
- indexL= 1 ;
1454
- indexR= 0 ;
1455
- }
1426
+ // scale down and add left reverb buffer by reverb level
1427
+ arm_scale_f32 (ReverbBuffer[indexL], reverb-> get_level (), ReverbBuffer[indexL], nFrames);
1428
+ arm_add_f32 (SampleBuffer[indexL], ReverbBuffer[indexL], SampleBuffer[indexL], nFrames);
1429
+ // scale down and add right reverb buffer by reverb level
1430
+ arm_scale_f32 (ReverbBuffer[ indexR], reverb-> get_level (), ReverbBuffer[indexR], nFrames) ;
1431
+ arm_add_f32 (SampleBuffer[indexR], ReverbBuffer[indexR], SampleBuffer[indexR], nFrames);
1456
1432
1457
- // Convert dual float array (left, right) to single int16 array (left/right)
1458
- for (uint16_t i=0 ; i<nFrames;i++)
1459
- {
1460
- if (nMasterVolume >0.0 && nMasterVolume <1.0 )
1461
- {
1462
- tmp_float[i*2 ]=SampleBuffer[indexL][i] * nMasterVolume;
1463
- tmp_float[(i*2 )+1 ]=SampleBuffer[indexR][i] * nMasterVolume;
1464
- }
1465
- else if (nMasterVolume == 1.0 )
1466
- {
1467
- tmp_float[i*2 ]=SampleBuffer[indexL][i];
1468
- tmp_float[(i*2 )+1 ]=SampleBuffer[indexR][i];
1469
- }
1470
- }
1471
- arm_float_to_q23 (tmp_float,tmp_int,nFrames*2 );
1433
+ m_ReverbSpinLock.Release ();
1472
1434
}
1473
- else
1435
+ // END adding reverb
1436
+
1437
+ // swap stereo channels if needed prior to writing back out
1438
+ if (m_bChannelsSwapped)
1474
1439
{
1475
- arm_fill_q31 (0 , tmp_int, nFrames * 2 );
1440
+ indexL=1 ;
1441
+ indexR=0 ;
1476
1442
}
1477
1443
1444
+ // Convert dual float array (left, right) to single int16 array (left/right)
1445
+ arm_scale_zip_f32 (SampleBuffer[indexL], SampleBuffer[indexR], nMasterVolume, tmp_float, nFrames);
1446
+
1447
+ arm_float_to_q23 (tmp_float,tmp_int,nFrames*2 );
1448
+
1478
1449
// Prevent PCM510x analog mute from kicking in
1479
1450
if (tmp_int[nFrames * 2 - 1 ] == 0 )
1480
1451
{
0 commit comments