🍑 nectarine
Audio synthesis tools for C23
Loading...
Searching...
No Matches
waveforms.h
Go to the documentation of this file.
1// This Source Code Form is subject to the terms of the Mozilla Public
2// License, v. 2.0. If a copy of the MPL was not distributed with this
3// file, You can obtain one at https://mozilla.org/MPL/2.0/.
4
7#pragma once
8#include <stddef.h>
9#include <math.h>
10#include "vendor/prelude/hint.h"
11
26[[nodiscard, gnu::const]]
27inline long double nec_wrapl(long double phase) [[unsequenced]] {
28 return phase - floorl(phase);
29}
30
32[[nodiscard, gnu::const]]
33inline double nec_wrap(double phase) [[unsequenced]] {
34 return phase - floor(phase);
35}
36
38[[nodiscard, gnu::const]]
39inline float nec_wrapf(float phase) [[unsequenced]] {
40 return phase - floorf(phase);
41}
42
50[[gnu::reproducible, gnu::nonnull]]
51inline void nec_fill_wrapl(
52 size_t len,
53#ifdef __cplusplus
54 const long double *__restrict phase,
55 long double *__restrict output
56#else
57 const long double phase[restrict static len],
58 long double output[restrict static len]
59#endif
60) [[reproducible]] {
61 assume(len > 0);
62 for (size_t i = 0; i < len; ++i) {
63 output[i] = nec_wrapl(phase[i]);
64 }
65}
66
68[[gnu::reproducible, gnu::nonnull]]
69inline void nec_fill_wrap(
70 size_t len,
71#ifdef __cplusplus
72 const double *__restrict phase,
73 double *__restrict output
74#else
75 const double phase[restrict static len],
76 double output[restrict static len]
77#endif
78) [[reproducible]] {
79 assume(len > 0);
80 #pragma omp simd
81 for (size_t i = 0; i < len; ++i) {
82 output[i] = nec_wrap(phase[i]);
83 }
84}
85
87[[gnu::reproducible, gnu::nonnull]]
88inline void nec_fill_wrapf(
89 size_t len,
90#ifdef __cplusplus
91 const float *__restrict phase,
92 float *__restrict output
93#else
94 const float phase[restrict static len],
95 float output[restrict static len]
96#endif
97) [[reproducible]] {
98 assume(len > 0);
99 #pragma omp simd
100 for (size_t i = 0; i < len; ++i) {
101 output[i] = nec_wrapf(phase[i]);
102 }
103}
104
116[[nodiscard, gnu::const]]
117inline long double nec_analog_sawtoothl(long double phase) [[unsequenced]] {
118 assume(0.l <= phase && phase < 1.l);
119 return (-4.l * phase + 1.5l) / (phase + 1.5l);
120}
121
123[[nodiscard, gnu::const]]
124inline double nec_analog_sawtooth(double phase) [[unsequenced]] {
125 assume(0.0 <= phase && phase < 1.0);
126 return (-4.0 * phase + 1.5) / (phase + 1.5);
127}
128
130[[nodiscard, gnu::const]]
131inline float nec_analog_sawtoothf(float phase) [[unsequenced]] {
132 assume(0.f <= phase && phase < 1.f);
133 return (-4.f * phase + 1.5f) / (phase + 1.5f);
134}
135
143[[gnu::reproducible, gnu::nonnull]]
145 size_t len,
146#ifdef __cplusplus
147 const long double *__restrict phase,
148 long double *__restrict output
149#else
150 const long double phase[restrict static len],
151 long double output[restrict static len]
152#endif
153) [[reproducible]] {
154 assume(len > 0);
155 for (size_t i = 0; i < len; ++i) {
156 output[i] = nec_analog_sawtoothl(phase[i]);
157 }
158}
159
161[[gnu::reproducible, gnu::nonnull]]
163 size_t len,
164#ifdef __cplusplus
165 const double *__restrict phase,
166 double *__restrict output
167#else
168 const double phase[restrict static len],
169 double output[restrict static len]
170#endif
171) [[reproducible]] {
172 assume(len > 0);
173 #pragma omp simd
174 for (size_t i = 0; i < len; ++i) {
175 output[i] = nec_analog_sawtooth(phase[i]);
176 }
177}
178
180[[gnu::reproducible, gnu::nonnull]]
182 size_t len,
183#ifdef __cplusplus
184 const float *__restrict phase,
185 float *__restrict output
186#else
187 const float phase[restrict static len],
188 float output[restrict static len]
189#endif
190) [[reproducible]] {
191 assume(len > 0);
192 #pragma omp simd
193 for (size_t i = 0; i < len; ++i) {
194 output[i] = nec_analog_sawtoothf(phase[i]);
195 }
196}
197
210[[nodiscard, gnu::const]]
211inline long double nec_analog_squarel(long double phase, long double duty) [[unsequenced]] {
212 assume(0.l <= phase && phase < 1.l);
213 assume(0.l <= duty && duty <= 1.l);
214 const auto amplitude = (-phase + 6.l) / (4.l * phase + 6.l);
215 return copysignl(amplitude, duty - phase);
216}
217
219[[nodiscard, gnu::const]]
220inline double nec_analog_square(double phase, double duty) [[unsequenced]] {
221 assume(0.0 <= phase && phase < 1.0);
222 assume(0.0 <= duty && duty <= 1.0);
223 const auto amplitude = (-phase + 6.0) / (4.0 * phase + 6.0);
224 return copysign(amplitude, duty - phase);
225}
226
228[[nodiscard, gnu::const]]
229inline float nec_analog_squaref(float phase, float duty) [[unsequenced]] {
230 assume(0.f <= phase && phase < 1.f);
231 assume(0.f <= duty && duty <= 1.f);
232 const auto amplitude = (-phase + 6.f) / (4.f * phase + 6.f);
233 return copysignf(amplitude, duty - phase);
234}
235
244[[gnu::reproducible, gnu::nonnull]]
246 size_t len,
247#ifdef __cplusplus
248 const long double *__restrict phase,
249 const long double *__restrict duty,
250 long double *__restrict output
251#else
252 const long double phase[restrict static len],
253 const long double duty[restrict static len],
254 long double output[restrict static len]
255#endif
256) [[reproducible]] {
257 assume(len > 0);
258 for (size_t i = 0; i < len; ++i) {
259 output[i] = nec_analog_squarel(phase[i], duty[i]);
260 }
261}
262
264[[gnu::reproducible, gnu::nonnull]]
266 size_t len,
267#ifdef __cplusplus
268 const double *__restrict phase,
269 const double *__restrict duty,
270 double *__restrict output
271#else
272 const double phase[restrict static len],
273 const double duty[restrict static len],
274 double output[restrict static len]
275#endif
276) [[reproducible]] {
277 assume(len > 0);
278 #pragma omp simd
279 for (size_t i = 0; i < len; ++i) {
280 output[i] = nec_analog_square(phase[i], duty[i]);
281 }
282}
283
285[[gnu::reproducible, gnu::nonnull]]
287 size_t len,
288#ifdef __cplusplus
289 const float *__restrict phase,
290 const float *__restrict duty,
291 float *__restrict output
292#else
293 const float phase[restrict static len],
294 const float duty[restrict static len],
295 float output[restrict static len]
296#endif
297) [[reproducible]] {
298 assume(len > 0);
299 #pragma omp simd
300 for (size_t i = 0; i < len; ++i) {
301 output[i] = nec_analog_squaref(phase[i], duty[i]);
302 }
303}
304
316[[nodiscard, gnu::const]]
317inline long double nec_analog_trianglel(long double phase) [[unsequenced]] {
318 assume(0.l <= phase && phase < 1.l);
319 return 2.l * fabsl(nec_analog_sawtoothl(phase)) - 1.l;
320}
321
323[[nodiscard, gnu::const]]
324inline double nec_analog_triangle(double phase) [[unsequenced]] {
325 assume(0.0 <= phase && phase < 1.0);
326 return 2.0 * fabs(nec_analog_sawtooth(phase)) - 1.0;
327}
328
330[[nodiscard, gnu::const]]
331inline float nec_analog_trianglef(float phase) [[unsequenced]] {
332 assume(0.f <= phase && phase < 1.f);
333 return 2.f * fabsf(nec_analog_sawtoothf(phase)) - 1.f;
334}
335
343[[gnu::reproducible, gnu::nonnull]]
345 size_t len,
346#ifdef __cplusplus
347 const long double *__restrict phase,
348 long double *__restrict output
349#else
350 const long double phase[restrict static len],
351 long double output[restrict static len]
352#endif
353) [[reproducible]] {
354 assume(len > 0);
355 for (size_t i = 0; i < len; ++i) {
356 output[i] = nec_analog_trianglel(phase[i]);
357 }
358}
359
361[[gnu::reproducible, gnu::nonnull]]
363 size_t len,
364#ifdef __cplusplus
365 const double *__restrict phase,
366 double *__restrict output
367#else
368 const double phase[restrict static len],
369 double output[restrict static len]
370#endif
371) [[reproducible]] {
372 assume(len > 0);
373 #pragma omp simd
374 for (size_t i = 0; i < len; ++i) {
375 output[i] = nec_analog_triangle(phase[i]);
376 }
377}
378
380[[gnu::reproducible, gnu::nonnull]]
382 size_t len,
383#ifdef __cplusplus
384 const float *__restrict phase,
385 float *__restrict output
386#else
387 const float phase[restrict static len],
388 float output[restrict static len]
389#endif
390) [[reproducible]] {
391 assume(len > 0);
392 #pragma omp simd
393 for (size_t i = 0; i < len; ++i) {
394 output[i] = nec_analog_trianglef(phase[i]);
395 }
396}
397
408[[nodiscard, gnu::const]]
409inline long double nec_paraboll(long double phase) [[unsequenced]] {
410 assume(0.l <= phase && phase < 1.l);
411 const auto x = 4.l * phase - 2.l;
412 return x * (fabsl(x) - 2.l);
413}
414
416[[nodiscard, gnu::const]]
417inline double nec_parabol(double phase) [[unsequenced]] {
418 assume(0.0 <= phase && phase < 1.0);
419 const auto x = 4.0 * phase - 2.0;
420 return x * (fabs(x) - 2.0);
421}
422
424[[nodiscard, gnu::const]]
425inline float nec_parabolf(float phase) [[unsequenced]] {
426 assume(0.f <= phase && phase < 1.f);
427 const auto x = 4.f * phase - 2.f;
428 return x * (fabsf(x) - 2.f);
429}
430
438[[gnu::reproducible, gnu::nonnull]]
440 size_t len,
441#ifdef __cplusplus
442 const long double *__restrict phase,
443 long double *__restrict output
444#else
445 const long double phase[restrict static len],
446 long double output[restrict static len]
447#endif
448) [[reproducible]] {
449 assume(len > 0);
450 for (size_t i = 0; i < len; ++i) {
451 output[i] = nec_paraboll(phase[i]);
452 }
453}
454
456[[gnu::reproducible, gnu::nonnull]]
458 size_t len,
459#ifdef __cplusplus
460 const double *__restrict phase,
461 double *__restrict output
462#else
463 const double phase[restrict static len],
464 double output[restrict static len]
465#endif
466) [[reproducible]] {
467 assume(len > 0);
468 #pragma omp simd
469 for (size_t i = 0; i < len; ++i) {
470 output[i] = nec_parabol(phase[i]);
471 }
472}
473
475[[gnu::reproducible, gnu::nonnull]]
477 size_t len,
478#ifdef __cplusplus
479 const float *__restrict phase,
480 float *__restrict output
481#else
482 const float phase[restrict static len],
483 float output[restrict static len]
484#endif
485) [[reproducible]] {
486 assume(len > 0);
487 #pragma omp simd
488 for (size_t i = 0; i < len; ++i) {
489 output[i] = nec_parabolf(phase[i]);
490 }
491}
492
512[[nodiscard, gnu::const]]
513inline long double nec_sinl(long double phase) [[unsequenced]] {
514 const auto p = nec_paraboll(phase);
515 return 0.225l * p * (fabsl(p) - 1.l) + p;
516}
517
519[[nodiscard, gnu::const]]
520inline double nec_sin(double phase) [[unsequenced]] {
521 const auto p = nec_parabol(phase);
522 return 0.225 * p * (fabs(p) - 1.0) + p;
523}
524
526[[nodiscard, gnu::const]]
527inline float nec_sinf(float phase) [[unsequenced]] {
528 const auto p = nec_parabolf(phase);
529 return 0.225f * p * (fabsf(p) - 1.f) + p;
530}
531
539[[gnu::reproducible, gnu::nonnull]]
540inline void nec_fill_sinl(
541 size_t len,
542#ifdef __cplusplus
543 const long double *__restrict phase,
544 long double *__restrict output
545#else
546 const long double phase[restrict static len],
547 long double output[restrict static len]
548#endif
549) [[reproducible]] {
550 assume(len > 0);
551 for (size_t i = 0; i < len; ++i) {
552 output[i] = nec_sinl(phase[i]);
553 }
554}
555
557[[gnu::reproducible, gnu::nonnull]]
558inline void nec_fill_sin(
559 size_t len,
560#ifdef __cplusplus
561 const double *__restrict phase,
562 double *__restrict output
563#else
564 const double phase[restrict static len],
565 double output[restrict static len]
566#endif
567) [[reproducible]] {
568 assume(len > 0);
569 #pragma omp simd
570 for (size_t i = 0; i < len; ++i) {
571 output[i] = nec_sin(phase[i]);
572 }
573}
574
576[[gnu::reproducible, gnu::nonnull]]
577inline void nec_fill_sinf(
578 size_t len,
579#ifdef __cplusplus
580 const float *__restrict phase,
581 float *__restrict output
582#else
583 const float phase[restrict static len],
584 float output[restrict static len]
585#endif
586) [[reproducible]] {
587 assume(len > 0);
588 #pragma omp simd
589 for (size_t i = 0; i < len; ++i) {
590 output[i] = nec_sinf(phase[i]);
591 }
592}
593
598[[nodiscard, gnu::const]]
599inline long double nec_circlel(long double phase) [[unsequenced]] {
600 const auto p = nec_paraboll(phase);
601 return copysignl(sqrtl(fabsl(p)), p);
602}
603
605[[nodiscard, gnu::const]]
606inline double nec_circle(double phase) [[unsequenced]] {
607 const auto p = nec_parabol(phase);
608 return copysign(sqrt(fabs(p)), p);
609}
610
612[[nodiscard, gnu::const]]
613inline float nec_circlef(float phase) [[unsequenced]] {
614 const auto p = nec_parabolf(phase);
615 return copysignf(sqrtf(fabsf(p)), p);
616}
617
625[[gnu::reproducible, gnu::nonnull]]
627 size_t len,
628#ifdef __cplusplus
629 const long double *__restrict phase,
630 long double *__restrict output
631#else
632 const long double phase[restrict static len],
633 long double output[restrict static len]
634#endif
635) [[reproducible]] {
636 assume(len > 0);
637 for (size_t i = 0; i < len; ++i) {
638 output[i] = nec_circlel(phase[i]);
639 }
640}
641
643[[gnu::reproducible, gnu::nonnull]]
644inline void nec_fill_circle(
645 size_t len,
646#ifdef __cplusplus
647 const double *__restrict phase,
648 double *__restrict output
649#else
650 const double phase[restrict static len],
651 double output[restrict static len]
652#endif
653) [[reproducible]] {
654 assume(len > 0);
655 #pragma omp simd
656 for (size_t i = 0; i < len; ++i) {
657 output[i] = nec_circle(phase[i]);
658 }
659}
660
662[[gnu::reproducible, gnu::nonnull]]
664 size_t len,
665#ifdef __cplusplus
666 const float *__restrict phase,
667 float *__restrict output
668#else
669 const float phase[restrict static len],
670 float output[restrict static len]
671#endif
672) [[reproducible]] {
673 assume(len > 0);
674 #pragma omp simd
675 for (size_t i = 0; i < len; ++i) {
676 output[i] = nec_circlef(phase[i]);
677 }
678}
679
683[[nodiscard, gnu::const]]
684inline long double nec_sawtoothl(long double phase) [[unsequenced]] {
685 assume(0.l <= phase && phase < 1.l);
686 return -2.l * phase + 1.l;
687}
688
690[[nodiscard, gnu::const]]
691inline double nec_sawtooth(double phase) [[unsequenced]] {
692 assume(0.0 <= phase && phase < 1.0);
693 return -2.0 * phase + 1.0;
694}
695
697[[nodiscard, gnu::const]]
698inline float nec_sawtoothf(float phase) [[unsequenced]] {
699 assume(0.f <= phase && phase < 1.f);
700 return -2.f * phase + 1.f;
701}
702
710[[gnu::reproducible, gnu::nonnull]]
712 size_t len,
713#ifdef __cplusplus
714 const long double *__restrict phase,
715 long double *__restrict output
716#else
717 const long double phase[restrict static len],
718 long double output[restrict static len]
719#endif
720) [[reproducible]] {
721 assume(len > 0);
722 for (size_t i = 0; i < len; ++i) {
723 output[i] = nec_sawtoothl(phase[i]);
724 }
725}
726
728[[gnu::reproducible, gnu::nonnull]]
730 size_t len,
731#ifdef __cplusplus
732 const double *__restrict phase,
733 double *__restrict output
734#else
735 const double phase[restrict static len],
736 double output[restrict static len]
737#endif
738) [[reproducible]] {
739 assume(len > 0);
740 #pragma omp simd
741 for (size_t i = 0; i < len; ++i) {
742 output[i] = nec_sawtooth(phase[i]);
743 }
744}
745
747[[gnu::reproducible, gnu::nonnull]]
749 size_t len,
750#ifdef __cplusplus
751 const float *__restrict phase,
752 float *__restrict output
753#else
754 const float phase[restrict static len],
755 float output[restrict static len]
756#endif
757) [[reproducible]] {
758 assume(len > 0);
759 #pragma omp simd
760 for (size_t i = 0; i < len; ++i) {
761 output[i] = nec_sawtoothf(phase[i]);
762 }
763}
764
769[[nodiscard, gnu::const]]
770inline long double nec_squarel(long double phase, long double duty) [[unsequenced]] {
771 assume(0.l <= phase && phase < 1.l);
772 assume(0.l <= duty && duty <= 1.l);
773 return copysignl(1.l, duty - phase);
774}
775
777[[nodiscard, gnu::const]]
778inline double nec_square(double phase, double duty) [[unsequenced]] {
779 assume(0.0 <= phase && phase < 1.0);
780 assume(0.0 <= duty && duty <= 1.0);
781 return copysign(1.0, duty - phase);
782}
783
785[[nodiscard, gnu::const]]
786inline float nec_squaref(float phase, float duty) [[unsequenced]] {
787 assume(0.f <= phase && phase < 1.f);
788 assume(0.f <= duty && duty <= 1.f);
789 return copysignf(1.f, duty - phase);
790}
791
800[[gnu::reproducible, gnu::nonnull]]
802 size_t len,
803#ifdef __cplusplus
804 const long double *__restrict phase,
805 const long double *__restrict duty,
806 long double *__restrict output
807#else
808 const long double phase[restrict static len],
809 const long double duty[restrict static len],
810 long double output[restrict static len]
811#endif
812) [[reproducible]] {
813 assume(len > 0);
814 for (size_t i = 0; i < len; ++i) {
815 output[i] = nec_squarel(phase[i], duty[i]);
816 }
817}
818
820[[gnu::reproducible, gnu::nonnull]]
821inline void nec_fill_square(
822 size_t len,
823#ifdef __cplusplus
824 const double *__restrict phase,
825 const double *__restrict duty,
826 double *__restrict output
827#else
828 const double phase[restrict static len],
829 const double duty[restrict static len],
830 double output[restrict static len]
831#endif
832) [[reproducible]] {
833 assume(len > 0);
834 #pragma omp simd
835 for (size_t i = 0; i < len; ++i) {
836 output[i] = nec_square(phase[i], duty[i]);
837 }
838}
839
841[[gnu::reproducible, gnu::nonnull]]
843 size_t len,
844#ifdef __cplusplus
845 const float *__restrict phase,
846 const float *__restrict duty,
847 float *__restrict output
848#else
849 const float phase[restrict static len],
850 const float duty[restrict static len],
851 float output[restrict static len]
852#endif
853) [[reproducible]] {
854 assume(len > 0);
855 #pragma omp simd
856 for (size_t i = 0; i < len; ++i) {
857 output[i] = nec_squaref(phase[i], duty[i]);
858 }
859}
860
864[[nodiscard, gnu::const]]
865inline long double nec_trianglel(long double phase) [[unsequenced]] {
866 assume(0.l <= phase && phase < 1.l);
867 return 2.l * fabsl(nec_sawtoothl(phase)) - 1.l;
868}
869
871[[nodiscard, gnu::const]]
872inline double nec_triangle(double phase) [[unsequenced]] {
873 assume(0.0 <= phase && phase < 1.0);
874 return 2.0 * fabs(nec_sawtooth(phase)) - 1.0;
875}
876
878[[nodiscard, gnu::const]]
879inline float nec_trianglef(float phase) [[unsequenced]] {
880 assume(0.f <= phase && phase < 1.f);
881 return 2.f * fabsf(nec_sawtoothf(phase)) - 1.f;
882}
883
891[[gnu::reproducible, gnu::nonnull]]
893 size_t len,
894#ifdef __cplusplus
895 const long double *__restrict phase,
896 long double *__restrict output
897#else
898 const long double phase[restrict static len],
899 long double output[restrict static len]
900#endif
901) [[reproducible]] {
902 assume(len > 0);
903 for (size_t i = 0; i < len; ++i) {
904 output[i] = nec_trianglel(phase[i]);
905 }
906}
907
909[[gnu::reproducible, gnu::nonnull]]
911 size_t len,
912#ifdef __cplusplus
913 const double *__restrict phase,
914 double *__restrict output
915#else
916 const double phase[restrict static len],
917 double output[restrict static len]
918#endif
919) [[reproducible]] {
920 assume(len > 0);
921 #pragma omp simd
922 for (size_t i = 0; i < len; ++i) {
923 output[i] = nec_triangle(phase[i]);
924 }
925}
926
928[[gnu::reproducible, gnu::nonnull]]
930 size_t len,
931#ifdef __cplusplus
932 const float *__restrict phase,
933 float *__restrict output
934#else
935 const float phase[restrict static len],
936 float output[restrict static len]
937#endif
938) [[reproducible]] {
939 assume(len > 0);
940 #pragma omp simd
941 for (size_t i = 0; i < len; ++i) {
942 output[i] = nec_trianglef(phase[i]);
943 }
944}
#define nec_fill_analog_square(len, phase, duty, output)
Fills a buffer with an analog-like square waveform.
Definition tgwaveforms.h:50
#define nec_analog_square(phase, duty)
Analog-like square waveform.
Definition tgwaveforms.h:43
#define nec_triangle(phase)
Basic triangle waveform.
Definition tgwaveforms.h:141
#define nec_fill_triangle(len, phase, output)
Fills a buffer with a triangle waveform.
Definition tgwaveforms.h:148
#define nec_fill_square(len, phase, duty, output)
Fills a buffer with a square waveform.
Definition tgwaveforms.h:134
#define nec_square(phase, duty)
Basic square waveform.
Definition tgwaveforms.h:127
#define nec_sawtooth(phase)
Basic sawtooth waveform.
Definition tgwaveforms.h:113
#define nec_wrap(phase)
Maps an arbitrary phase into the domain [0, 1).
Definition tgwaveforms.h:15
#define nec_circle(phase)
Circle waveform function.
Definition tgwaveforms.h:99
#define nec_fill_sawtooth(len, phase, output)
Fills a buffer with a sawtooth waveform.
Definition tgwaveforms.h:120
#define nec_analog_sawtooth(phase)
Analog-like sawtooth waveform.
Definition tgwaveforms.h:29
#define nec_fill_wrap(len, phase, output)
Maps a buffer of arbitrary phases into the domain [0, 1).
Definition tgwaveforms.h:22
#define nec_sin(phase)
Accurate sine approximation waveform.
Definition tgwaveforms.h:85
#define nec_analog_triangle(phase)
Analog-like triangle waveform.
Definition tgwaveforms.h:57
#define nec_fill_analog_triangle(len, phase, output)
Fills a buffer with an analog-like triangle waveform.
Definition tgwaveforms.h:64
#define nec_fill_circle(len, phase, output)
Fills a buffer with a circle waveform.
Definition tgwaveforms.h:106
#define nec_fill_sin(len, phase, output)
Fills a buffer with an accurate sine approximation waveform.
Definition tgwaveforms.h:92
#define nec_fill_analog_sawtooth(len, phase, output)
Fills a buffer with an analog-like sawtooth waveform.
Definition tgwaveforms.h:36
#define nec_parabol(phase)
Fast sine approximation waveform.
Definition tgwaveforms.h:71
#define nec_fill_parabol(len, phase, output)
Fills a buffer with a fast sine approximation waveform.
Definition tgwaveforms.h:78
void nec_fill_wrapf(size_t len, const float phase[restrict static len], float output[restrict static len])
Maps a buffer of arbitrary phases into the domain [0, 1).
Definition waveforms.h:88
long double nec_analog_sawtoothl(long double phase)
Analog-like sawtooth waveform.
Definition waveforms.h:117
void nec_fill_paraboll(size_t len, const long double phase[restrict static len], long double output[restrict static len])
Fills a buffer with a fast sine approximation waveform.
Definition waveforms.h:439
void nec_fill_squarel(size_t len, const long double phase[restrict static len], const long double duty[restrict static len], long double output[restrict static len])
Fills a buffer with a square waveform.
Definition waveforms.h:801
long double nec_sawtoothl(long double phase)
Basic sawtooth waveform.
Definition waveforms.h:684
long double nec_trianglel(long double phase)
Basic triangle waveform.
Definition waveforms.h:865
void nec_fill_sinf(size_t len, const float phase[restrict static len], float output[restrict static len])
Fills a buffer with an accurate sine approximation waveform.
Definition waveforms.h:577
float nec_circlef(float phase)
Circle waveform function.
Definition waveforms.h:613
void nec_fill_circlef(size_t len, const float phase[restrict static len], float output[restrict static len])
Fills a buffer with a circle waveform.
Definition waveforms.h:663
long double nec_wrapl(long double phase)
Maps an arbitrary phase into the domain [0, 1).
Definition waveforms.h:27
float nec_sawtoothf(float phase)
Basic sawtooth waveform.
Definition waveforms.h:698
long double nec_paraboll(long double phase)
Fast sine approximation waveform.
Definition waveforms.h:409
long double nec_sinl(long double phase)
Accurate sine approximation waveform.
Definition waveforms.h:513
void nec_fill_analog_trianglef(size_t len, const float phase[restrict static len], float output[restrict static len])
Fills a buffer with an analog-like triangle waveform.
Definition waveforms.h:381
long double nec_analog_trianglel(long double phase)
Analog-like triangle waveform.
Definition waveforms.h:317
void nec_fill_sawtoothl(size_t len, const long double phase[restrict static len], long double output[restrict static len])
Fills a buffer with a sawtooth waveform.
Definition waveforms.h:711
float nec_trianglef(float phase)
Basic triangle waveform.
Definition waveforms.h:879
void nec_fill_analog_sawtoothl(size_t len, const long double phase[restrict static len], long double output[restrict static len])
Fills a buffer with an analog-like sawtooth waveform.
Definition waveforms.h:144
float nec_analog_squaref(float phase, float duty)
Analog-like square waveform.
Definition waveforms.h:229
void nec_fill_trianglel(size_t len, const long double phase[restrict static len], long double output[restrict static len])
Fills a buffer with a triangle waveform.
Definition waveforms.h:892
void nec_fill_sawtoothf(size_t len, const float phase[restrict static len], float output[restrict static len])
Fills a buffer with a sawtooth waveform.
Definition waveforms.h:748
void nec_fill_analog_squarel(size_t len, const long double phase[restrict static len], const long double duty[restrict static len], long double output[restrict static len])
Fills a buffer with an analog-like square waveform.
Definition waveforms.h:245
void nec_fill_analog_trianglel(size_t len, const long double phase[restrict static len], long double output[restrict static len])
Fills a buffer with an analog-like triangle waveform.
Definition waveforms.h:344
void nec_fill_circlel(size_t len, const long double phase[restrict static len], long double output[restrict static len])
Fills a buffer with a circle waveform.
Definition waveforms.h:626
float nec_wrapf(float phase)
Maps an arbitrary phase into the domain [0, 1).
Definition waveforms.h:39
long double nec_circlel(long double phase)
Circle waveform function.
Definition waveforms.h:599
void nec_fill_sinl(size_t len, const long double phase[restrict static len], long double output[restrict static len])
Fills a buffer with an accurate sine approximation waveform.
Definition waveforms.h:540
void nec_fill_squaref(size_t len, const float phase[restrict static len], const float duty[restrict static len], float output[restrict static len])
Fills a buffer with a square waveform.
Definition waveforms.h:842
float nec_parabolf(float phase)
Fast sine approximation waveform.
Definition waveforms.h:425
void nec_fill_wrapl(size_t len, const long double phase[restrict static len], long double output[restrict static len])
Maps a buffer of arbitrary phases into the domain [0, 1).
Definition waveforms.h:51
void nec_fill_trianglef(size_t len, const float phase[restrict static len], float output[restrict static len])
Fills a buffer with a triangle waveform.
Definition waveforms.h:929
void nec_fill_analog_squaref(size_t len, const float phase[restrict static len], const float duty[restrict static len], float output[restrict static len])
Fills a buffer with an analog-like square waveform.
Definition waveforms.h:286
float nec_sinf(float phase)
Accurate sine approximation waveform.
Definition waveforms.h:527
float nec_analog_trianglef(float phase)
Analog-like triangle waveform.
Definition waveforms.h:331
void nec_fill_analog_sawtoothf(size_t len, const float phase[restrict static len], float output[restrict static len])
Fills a buffer with an analog-like sawtooth waveform.
Definition waveforms.h:181
float nec_analog_sawtoothf(float phase)
Analog-like sawtooth waveform.
Definition waveforms.h:131
float nec_squaref(float phase, float duty)
Basic square waveform.
Definition waveforms.h:786
long double nec_analog_squarel(long double phase, long double duty)
Analog-like square waveform.
Definition waveforms.h:211
long double nec_squarel(long double phase, long double duty)
Basic square waveform.
Definition waveforms.h:770
void nec_fill_parabolf(size_t len, const float phase[restrict static len], float output[restrict static len])
Fills a buffer with a fast sine approximation waveform.
Definition waveforms.h:476