From f017ca5a4229c39588e06e9a5d3e79c673aff986 Mon Sep 17 00:00:00 2001 From: Dario Sanfilippo Date: Wed, 7 Apr 2021 16:31:04 +0200 Subject: [PATCH 1/4] better sinusoid and cosinusoid tables generators --- oscillators.lib | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/oscillators.lib b/oscillators.lib index 8bd08409..a3c256c9 100644 --- a/oscillators.lib +++ b/oscillators.lib @@ -65,7 +65,8 @@ pl = library("platform.lib"); // // * `tablesize`: the table size //------------------------------------------------------------ -sinwaveform(tablesize) = float(ba.time)*(2.0*ma.PI)/float(tablesize) : sin; +sinwaveform(tablesize) = + sin(float(ba.period(tablesize)) * (2.0 * ma.PI) / float(tablesize)); //-----------------------`(os.)coswaveform`------------------------ // Cosine waveform ready to use with a `rdtable`. @@ -80,7 +81,8 @@ sinwaveform(tablesize) = float(ba.time)*(2.0*ma.PI)/float(tablesize) : sin; // // * `tablesize`: the table size //------------------------------------------------------------ -coswaveform(tablesize) = float(ba.time)*(2.0*ma.PI)/float(tablesize) : cos; +coswaveform(tablesize) = + cos(float(ba.period(tablesize)) * (2.0 * ma.PI) / float(tablesize)); //-----------------------`(os.)phasor`------------------------ // A simple phasor to be used with a `rdtable`. From 76cbff3781ed4a8df6a71a5db56f282eed35a73c Mon Sep 17 00:00:00 2001 From: Dario Sanfilippo Date: Wed, 7 Apr 2021 16:41:57 +0200 Subject: [PATCH 2/4] added signals.lib --- interpolators.lib | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/interpolators.lib b/interpolators.lib index 084f5de3..b3107bf8 100644 --- a/interpolators.lib +++ b/interpolators.lib @@ -137,6 +137,7 @@ declare version "0.3"; ba = library("basics.lib"); ro = library("routes.lib"); ma = library("maths.lib"); +si = library("signals.lib"); reset(trig) = (trig-trig') <= 0; @@ -492,7 +493,7 @@ declare lagrangeN copyright "Copyright (C) 2021 Dario Sanfilippo declare lagrangeN license "LGPL v3.0 license"; lagrangeN(N, idx) = lagrange_h(N, idx) , - si.bus(N + 1) : ro.interleave(N + 1, 2) : par(i, N + 1, *) :> _; + si.bus(N + 1) : ro.interleave(N + 1, 2) : si.dot(N + 1); // ----------------------------------------------------------------------------- // ---------- `(it.)frdtable(N, S)` -------------------------------------------- From 84e62d590c569d72c7cead0dcede4414764c6de6 Mon Sep 17 00:00:00 2001 From: Dario Sanfilippo Date: Wed, 7 Apr 2021 16:44:55 +0200 Subject: [PATCH 3/4] more concise code with si.dot --- interpolators.lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interpolators.lib b/interpolators.lib index b3107bf8..541f0f02 100644 --- a/interpolators.lib +++ b/interpolators.lib @@ -493,7 +493,7 @@ declare lagrangeN copyright "Copyright (C) 2021 Dario Sanfilippo declare lagrangeN license "LGPL v3.0 license"; lagrangeN(N, idx) = lagrange_h(N, idx) , - si.bus(N + 1) : ro.interleave(N + 1, 2) : si.dot(N + 1); + si.bus(N + 1) : si.dot(N + 1); // ----------------------------------------------------------------------------- // ---------- `(it.)frdtable(N, S)` -------------------------------------------- From ab0aaecdac6ccb5376c40f5a0de22f010aa4804a Mon Sep 17 00:00:00 2001 From: Dario Sanfilippo Date: Wed, 7 Apr 2021 16:47:37 +0200 Subject: [PATCH 4/4] even simpler code as suggested by Oleg --- interpolators.lib | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/interpolators.lib b/interpolators.lib index 541f0f02..5cee296d 100644 --- a/interpolators.lib +++ b/interpolators.lib @@ -491,9 +491,7 @@ declare lagrangeN author "Dario Sanfilippo"; declare lagrangeN copyright "Copyright (C) 2021 Dario Sanfilippo "; declare lagrangeN license "LGPL v3.0 license"; -lagrangeN(N, idx) = - lagrange_h(N, idx) , - si.bus(N + 1) : si.dot(N + 1); +lagrangeN(N, idx) = si.dot(N + 1, lagrange_h(N, idx)); // ----------------------------------------------------------------------------- // ---------- `(it.)frdtable(N, S)` --------------------------------------------