#include "ckernel_tts.h"
#include "checked_float_buffer.h"
#include <math.h>
#include <stdint.h>
Go to the source code of this file.
◆ audio_noise_counter_gaussian_f32()
| int audio_noise_counter_gaussian_f32 |
( |
float * |
output, |
|
|
size_t |
output_capacity, |
|
|
size_t |
count, |
|
|
uint64_t |
seed, |
|
|
uint64_t |
stream |
|
) |
| |
Definition at line 18 of file audio_noise_counter.c.
19 {
21 if (
count > (1u << 24) || output_capacity <
count)
24 const uint64_t domain =
mix64(seed ^
mix64(stream));
25 for (
size_t index = 0; index <
count; ++index) {
26 const uint64_t counter = (uint64_t)index * UINT64_C(2);
27 const uint64_t first =
mix64(domain + counter);
28 const uint64_t second =
mix64(domain + counter + UINT64_C(1));
29 const double uniform_positive =
30 ((double)(first >> 11) + 0.5) * 0x1.0p-53;
31 const double uniform_angle = (double)(second >> 11) * 0x1.0p-53;
32 const double radius = sqrt(-2.0 * log(uniform_positive));
33 output[index] = (float)(radius * cos(
34 6.283185307179586476925286766559 * uniform_angle));
35 }
37}
static uint64_t mix64(uint64_t value)
static int ck_checked_region(const float *ptr, size_t n)
@ CK_AUDIO_EXTENT_INVALID
const uint8_t size_t count
References CK_AUDIO_EXTENT_INVALID, CK_AUDIO_EXTENT_LIMIT, CK_AUDIO_EXTENT_OK, ck_checked_region(), count, and mix64().
◆ mix64()
| static uint64_t mix64 |
( |
uint64_t |
value | ) |
|
|
static |
Definition at line 11 of file audio_noise_counter.c.
11 {
12 value += UINT64_C(0x9e3779b97f4a7c15);
13 value = (value ^ (value >> 30)) * UINT64_C(0xbf58476d1ce4e5b9);
14 value = (value ^ (value >> 27)) * UINT64_C(0x94d049bb133111eb);
15 return value ^ (value >> 31);
16}
Referenced by audio_noise_counter_gaussian_f32().