| 36 | END_EVENT_TABLE() |
| 37 | |
| 38 | CompressionMeterPanel::CompressionMeterPanel( |
| 39 | wxWindow* parent, int id, CompressorInstance& instance, float dbRange, |
| 40 | std::function<void()> onClipped) |
| 41 | : wxPanelWrapper { parent, id } |
| 42 | , mMeterValuesQueue { std::make_unique< |
| 43 | DynamicRangeProcessorMeterValuesQueue>(audioFramesPerTick) } |
| 44 | , mPlaybackStartStopSubscription { static_cast< |
| 45 | InitializeProcessingSettingsPublisher&>( |
| 46 | instance) |
| 47 | .Subscribe( |
| 48 | [&](const std::optional< |
| 49 | InitializeProcessingSettings>& |
| 50 | evt) { |
| 51 | if (evt) |
| 52 | Reset(); |
| 53 | else |
| 54 | mStopWhenZero = true; |
| 55 | }) } |
| 56 | , mPlaybackPausedSubscription { AudioIO::Get()->Subscribe( |
| 57 | [this](const AudioIOEvent& evt) { |
| 58 | if (evt.type != AudioIOEvent::PAUSE) |
| 59 | return; |
| 60 | if (evt.on) |
| 61 | mTimer.Stop(); |
| 62 | else |
| 63 | mTimer.Start(compressorMeterUpdatePeriodMs); |
| 64 | }) } |
| 65 | , mOnClipped { onClipped } |
| 66 | , mDbBottomEdgeValue { -dbRange } |
| 67 | , mCompressionMeter { MeterValueProvider::Create( |
| 68 | MeterValueProvider::Direction::Downwards) } |
| 69 | , mOutputMeter { MeterValueProvider::Create( |
| 70 | MeterValueProvider::Direction::Upwards) } |
| 71 | { |
| 72 | if (instance.GetSampleRate().has_value()) |
| 73 | // Playback is ongoing, and so the `InitializeProcessingSettings` event |
| 74 | // was already fired. |
| 75 | Reset(); |
| 76 | instance.SetMeterValuesQueue(mMeterValuesQueue); |
| 77 | mTimer.SetOwner(this, timerId); |
| 78 | SetDoubleBuffered(true); |
| 79 | } |
| 80 | |
| 81 | void CompressionMeterPanel::SetDbRange(float dbRange) |
| 82 | { |
nothing calls this directly
no test coverage detected