@@ -251,9 +251,15 @@ void AudioPlayback::SetLaserEffect(EffectType type)
251
251
m_laserEffect = m_beatmap->GetFilter (type);
252
252
}
253
253
}
254
+ bool AudioPlayback::m_SkipEffectIfInputIsZero ()
255
+ {
256
+ return m_laserEffect.type == EffectType::PeakingFilter || m_laserEffect.type == EffectType::HighPassFilter
257
+ || m_laserEffect.type == EffectType::LowPassFilter || m_laserEffect.type == EffectType::PitchShift
258
+ || m_laserEffect.type == EffectType::Bitcrush;
259
+ }
254
260
void AudioPlayback::SetLaserFilterInput (float input, bool active)
255
261
{
256
- if (m_laserEffect.type != EffectType::None && (active || (input != 0 .0f )))
262
+ if (m_laserEffect.type != EffectType::None && (active && (input != 0 .0f || ! m_SkipEffectIfInputIsZero () )))
257
263
{
258
264
if (m_laserEffect.type == EffectType::SwitchAudio)
259
265
{
@@ -292,6 +298,7 @@ void AudioPlayback::SetLaserFilterInput(float input, bool active)
292
298
293
299
// Set params
294
300
m_SetLaserEffectParameter (input);
301
+ m_laserDSP->mix = Math::Clamp (m_laserDSP->mix , 0 .f , 1 .f );
295
302
m_laserInput = input;
296
303
}
297
304
else
@@ -436,9 +443,6 @@ void AudioPlayback::m_CleanupDSP(DSP *&ptr)
436
443
}
437
444
void AudioPlayback::m_SetLaserEffectParameter (float input)
438
445
{
439
- if (!m_laserDSP)
440
- return ;
441
-
442
446
assert (input >= 0 .0f && input <= 1 .0f );
443
447
444
448
// Mix float biquad filters, these are applied manualy by changing the filter parameters (gain,q,freq,etc.)
@@ -454,14 +458,14 @@ void AudioPlayback::m_SetLaserEffectParameter(float input)
454
458
case EffectType::Bitcrush:
455
459
{
456
460
m_laserDSP->mix = m_laserEffect.mix .Sample (input);
457
- BitCrusherDSP *bcDSP = (BitCrusherDSP *)m_laserDSP;
461
+ auto *bcDSP = (BitCrusherDSP *)m_laserDSP;
458
462
bcDSP->SetPeriod ((float )m_laserEffect.bitcrusher .reduction .Sample (input));
459
463
break ;
460
464
}
461
465
case EffectType::Echo:
462
466
{
463
467
m_laserDSP->mix = m_laserEffect.mix .Sample (input);
464
- EchoDSP *echoDSP = (EchoDSP *)m_laserDSP;
468
+ auto *echoDSP = (EchoDSP *)m_laserDSP;
465
469
echoDSP->feedback = m_laserEffect.echo .feedback .Sample (input);
466
470
break ;
467
471
}
@@ -471,42 +475,40 @@ void AudioPlayback::m_SetLaserEffectParameter(float input)
471
475
if (input > 0 .8f )
472
476
mix *= 1 .0f - (input - 0 .8f ) / 0 .2f ;
473
477
474
- BQFDSP *bqfDSP = (BQFDSP *)m_laserDSP;
478
+ auto *bqfDSP = (BQFDSP *)m_laserDSP;
475
479
bqfDSP->SetPeaking (m_laserEffect.peaking .q .Sample (input), m_laserEffect.peaking .freq .Sample (input), m_laserEffect.peaking .gain .Sample (input) * mix);
476
480
break ;
477
481
}
478
482
case EffectType::LowPassFilter:
479
483
{
480
484
m_laserDSP->mix = m_laserEffectMix;
481
- BQFDSP *bqfDSP = (BQFDSP *)m_laserDSP;
485
+ auto *bqfDSP = (BQFDSP *)m_laserDSP;
482
486
bqfDSP->SetLowPass (m_laserEffect.lpf .q .Sample (input) * mix + 0 .1f , m_laserEffect.lpf .freq .Sample (input));
483
487
break ;
484
488
}
485
489
case EffectType::HighPassFilter:
486
490
{
487
491
m_laserDSP->mix = m_laserEffectMix;
488
- BQFDSP *bqfDSP = (BQFDSP *)m_laserDSP;
492
+ auto *bqfDSP = (BQFDSP *)m_laserDSP;
489
493
bqfDSP->SetHighPass (m_laserEffect.hpf .q .Sample (input) * mix + 0 .1f , m_laserEffect.hpf .freq .Sample (input));
490
494
break ;
491
495
}
492
496
case EffectType::PitchShift:
493
497
{
494
498
m_laserDSP->mix = m_laserEffect.mix .Sample (input);
495
- PitchShiftDSP *ps = (PitchShiftDSP *)m_laserDSP;
499
+ auto *ps = (PitchShiftDSP *)m_laserDSP;
496
500
ps->amount = m_laserEffect.pitchshift .amount .Sample (input);
497
501
break ;
498
502
}
499
503
case EffectType::Gate:
500
504
{
501
505
m_laserDSP->mix = m_laserEffect.mix .Sample (input);
502
- GateDSP *gd = (GateDSP *)m_laserDSP;
503
- // gd->SetLength(actualLength);
504
506
break ;
505
507
}
506
508
case EffectType::Retrigger:
507
509
{
508
510
m_laserDSP->mix = m_laserEffect.mix .Sample (input);
509
- RetriggerDSP *rt = (RetriggerDSP *)m_laserDSP;
511
+ auto *rt = (RetriggerDSP *)m_laserDSP;
510
512
rt->SetLength (actualLength);
511
513
break ;
512
514
}
0 commit comments