From 4af088c251468caf922387e7d87788048745c2a6 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 11 Jul 2014 18:05:59 +0200 Subject: [PATCH] DummyBackend: add Uniform White Noise Generator. --- libs/backends/dummy/dummy_audiobackend.cc | 19 ++++++++++++++----- libs/backends/dummy/dummy_audiobackend.h | 3 ++- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/libs/backends/dummy/dummy_audiobackend.cc b/libs/backends/dummy/dummy_audiobackend.cc index 8cd7dac12c..b7b7f955ff 100644 --- a/libs/backends/dummy/dummy_audiobackend.cc +++ b/libs/backends/dummy/dummy_audiobackend.cc @@ -82,7 +82,8 @@ DummyAudioBackend::enumerate_devices () const if (_device_status.empty()) { _device_status.push_back (DeviceStatus (_("Silence"), true)); _device_status.push_back (DeviceStatus (_("Sine Wave"), true)); - _device_status.push_back (DeviceStatus (_("White Noise"), true)); + _device_status.push_back (DeviceStatus (_("Uniform White Noise"), true)); + _device_status.push_back (DeviceStatus (_("Gaussian White Noise"), true)); _device_status.push_back (DeviceStatus (_("Pink Noise"), true)); _device_status.push_back (DeviceStatus (_("Pink Noise (low CPU)"), true)); } @@ -646,8 +647,10 @@ DummyAudioBackend::register_system_ports() { LatencyRange lr; enum DummyAudioPort::GeneratorType gt; - if (_device == _("White Noise")) { - gt = DummyAudioPort::WhiteNoise; + if (_device == _("Uniform White Noise")) { + gt = DummyAudioPort::UniformWhiteNoise; + } else if (_device == _("Gaussian White Noise")) { + gt = DummyAudioPort::GaussianWhiteNoise; } else if (_device == _("Pink Noise")) { gt = DummyAudioPort::PinkNoise; } else if (_device == _("Pink Noise (low CPU)")) { @@ -1317,7 +1320,8 @@ void DummyAudioPort::setup_generator (GeneratorType const g, float const sampler switch (_gen_type) { case PinkNoise: case PonyNoise: - case WhiteNoise: + case UniformWhiteNoise: + case GaussianWhiteNoise: case Silence: break; case SineWave: @@ -1407,7 +1411,12 @@ void DummyAudioPort::generate (const pframes_t n_samples) } } break; - case WhiteNoise: + case UniformWhiteNoise: + for (pframes_t i = 0 ; i < n_samples; ++i) { + _buffer[i] = .158489f * randf(); + } + break; + case GaussianWhiteNoise: for (pframes_t i = 0 ; i < n_samples; ++i) { _buffer[i] = .089125f * grandf(); } diff --git a/libs/backends/dummy/dummy_audiobackend.h b/libs/backends/dummy/dummy_audiobackend.h index f1e9deae0a..149fba871d 100644 --- a/libs/backends/dummy/dummy_audiobackend.h +++ b/libs/backends/dummy/dummy_audiobackend.h @@ -127,7 +127,8 @@ class DummyAudioPort : public DummyPort { enum GeneratorType { Silence, - WhiteNoise, + UniformWhiteNoise, + GaussianWhiteNoise, PinkNoise, PonyNoise, SineWave,