mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-09 13:30:06 -05:00
audioconvert: Always apply noise when asked
Rename empty.noise -> dither.noise and always add this amount of noise when > 0. This also adds the noise to silent sounds, not only when nothing is connected because that would also be a problem when an amp needs to be kept alive with an non-0 signal. Rename noise -> dither because we can use this also for dithering later. See #705
This commit is contained in:
parent
abcf7cb8d8
commit
9f55708e9d
9 changed files with 107 additions and 68 deletions
42
spa/plugins/audioconvert/dither-ops-c.c
Normal file
42
spa/plugins/audioconvert/dither-ops-c.c
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
/* Spa
|
||||
*
|
||||
* Copyright © 2022 Wim Taymans
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "dither-ops.h"
|
||||
|
||||
void dither_f32_c(struct dither *dt, void * SPA_RESTRICT dst[],
|
||||
const void * SPA_RESTRICT src[], uint32_t n_samples)
|
||||
{
|
||||
uint32_t i, n;
|
||||
const float **s = (const float**)src;
|
||||
float **d = (float**)dst;
|
||||
const float *t = dt->tab;
|
||||
int tab_idx = dt->tab_idx;
|
||||
|
||||
for (i = 0; i < dt->n_channels; i++) {
|
||||
for (n = 0; n < n_samples; n++)
|
||||
d[i][n] = s[i][n] + t[tab_idx++ & DITHER_MOD];
|
||||
tab_idx += 61;
|
||||
}
|
||||
dt->tab_idx = tab_idx & DITHER_MOD;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue