brickworks/include/bw_osc_sin.h

95 lines
2.4 KiB
C
Raw Normal View History

2022-11-15 23:49:51 +00:00
/*
* Brickworks
*
* Copyright (C) 2022 Orastron Srl unipersonale
*
* Brickworks is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License.
*
* Brickworks is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
2022-12-06 08:01:34 +00:00
* along with Brickworks. If not, see <http://www.gnu.org/licenses/>.
2022-11-15 23:49:51 +00:00
*
* File author: Stefano D'Angelo
*/
/*!
* module_type {{{ dsp }}}
* version {{{ 0.2.0 }}}
2023-05-29 11:51:57 +00:00
* requires {{{ bw_common bw_config bw_math }}}
2022-11-15 23:49:51 +00:00
* description {{{
* Sinusoidal oscillator waveshaper.
*
* It turns a normalized phase signal, such as that geneated by
* [bw\_phase\_gen](bw_phase_gen), into a sinusoidal wave.
2022-11-15 23:49:51 +00:00
* }}}
* changelog {{{
* <ul>
* <li>Version <strong>0.2.0</strong>:
* <ul>
* <li>Refactored API.</li>
* </ul>
* </li>
2022-11-15 23:49:51 +00:00
* <li>Version <strong>0.1.0</strong>:
* <ul>
* <li>First release.</li>
* </ul>
* </li>
* </ul>
* }}}
*/
#ifndef _BW_OSC_SIN_H
#define _BW_OSC_SIN_H
#ifdef __cplusplus
extern "C" {
#endif
#include <bw_common.h>
2022-11-15 23:49:51 +00:00
/*! api {{{
* #### bw_osc_sin_process1()
* ```>>> */
static inline float bw_osc_sin_process1(float x);
/*! <<<```
* Processes one input sample `x`, indicating the normalized phase, and
* returns the corresponding output
* sample.
*
2022-11-15 23:49:51 +00:00
* #### bw_osc_sin_process()
* ```>>> */
static inline void bw_osc_sin_process(const float *x, float* y, int n_samples);
2022-11-15 23:49:51 +00:00
/*! <<<```
* Processes the first `n_samples` of the input buffer `x`, containing the
* normalized phase signal, and fills the first `n_samples` of the output
* buffer `y`.
2022-11-15 23:49:51 +00:00
* }}} */
/*** Implementation ***/
/* WARNING: This part of the file is not part of the public API. Its content may
* change at any time in future versions. Please, do not use it directly. */
#include <bw_math.h>
static inline float bw_osc_sin_process1(float x) {
return bw_sin2pif_3(x);
}
static inline void bw_osc_sin_process(const float *x, float* y, int n_samples) {
for (int i = 0; i < n_samples; i++)
y[i] = bw_osc_sin_process1(x[i]);
}
2022-11-15 23:49:51 +00:00
#ifdef __cplusplus
}
#endif
#endif