This is useful for generating FIR filters using code snippets generated at
https://fiiir.com/ (at least those with a rectangular window type; other
window types need additional functions but we can revisit it later if needed)
I think this will come in handy for folks who are using the advanced
features of our audio synthesizer module, synthio.
e.g., the following block now gives highly similar results on ulab
or numpy:
```py
try:
import numpy as np
except:
from ulab import numpy as np
# Example code, computes the coefficients of a low-pass windowed-sinc filter.
# Configuration.
fS = 48000 # Sampling rate.
fL = 4000 # Cutoff frequency.
N = 23 # Filter length, must be odd.
# Compute sinc filter.
h = np.sinc(2 * fL / fS * (np.arange(N) - (N - 1) / 2))
# Normalize to get unity gain.
h /= np.sum(h)
# Applying the filter to a signal s can be as simple as writing
# s = np.convolve(s, h)
A given use of ULAB_DEFINE_FLOAT_CONST may already have the correct form
of the float constant, so wrapping it in MICROPY_FLOAT_CONST may be the
wrong thing to do. So let the user of ULAB_DEFINE_FLOAT_CONST control how
the constant is formed.
Signed-off-by: Damien George <damien.p.george@gmail.com>
REPR_A is used for e.g., broadcom build raspberrypi_pi4b.
This is a trick, so that the appended 'f' is attached to the "0.".
Without this, a diagnostic occurred:
```
../../extmod/ulab/code/numpy/../ndarray.h:27:34: error: invalid suffix "FF" on floating constant
```
REPR_A is used for e.g., broadcom build raspberrypi_pi4b.
This is a trick, so that the appended 'f' is attached to the "0.".
Infinity plus zero is still zero, and nan plus zero is still zero.
Without this, a diagnostic occurred:
```
../../extmod/ulab/code/numpy/numpy.c:64:60: error: pasting ")" and "F" does not give a valid preprocessing token
```
* Properly register submodules of ulab
This is related to
* https://github.com/adafruit/circuitpython/issues/6066
in which, after the merge of 1.18 into CircuitPython, we lost the ability
to import submodules of built-in modules.
While reconstructing the changes we had made locally to enable this,
I discovered that there was an easier way: simply register the dotted
module names via MP_REGISTER_MODULE.
* Fix finding processor count when no `python` executable is installed
debian likes to install only `python3`, and not `python` (which was,
for many decades, python2).
This was previously done for `build.sh` but not for `build-cp.sh`.
* Only use this submodule feature in CircuitPython
.. as it does not work properly in MicroPython.
Also, modules to be const. This saves a small amount of RAM
* Fix -Werror=undef diagnostic
Most CircuitPython ports build with -Werror=undef, so that use of an
undefined preprocessor flag is an error. Also, CircuitPython's micropython
version is old enough that MICROPY_VERSION is not (ever) defined.
Defensively check for this macro being defined, and use the older style
of MP_REGISTER_MODULE when it is not.
* Fix -Werror=discarded-qualifiers diagnostics
Most CircuitPython ports build with -Werror=discarded-qualifiers.
This detected a problem where string constants were passed to functions
with non-constant parameter types.
* bump version number
* Use MicroPython-compatible registration of submodules
* straggler
* Remove spurious casts
these were build errors for micropython
* Run tests for both nanbox and regular variant during CI
* Fix use of object pointers so code builds with MICROPY_OBJ_REPR_D
Signed-off-by: Damien George <damien.p.george@gmail.com>
* Fix use of float constants so they work with MICROPY_OBJ_REPR_D
Signed-off-by: Damien George <damien.p.george@gmail.com>
* Use new float-const macros to simplify definitions of e,inf,nan,pi.
Signed-off-by: Damien George <damien.p.george@gmail.com>
* Add support for MICROPY_OBJ_REPR_C
Signed-off-by: Damien George <damien.p.george@gmail.com>
* Add unix-nanbox build to build.sh script
Building nanbox requires gcc-multilib because it forces 32-bit mode.
Signed-off-by: Damien George <damien.p.george@gmail.com>
* Bump version to 5.0.8
Signed-off-by: Damien George <damien.p.george@gmail.com>
* Move most documentation out of the ulab base module.
* float -> _float
* ulab.ndarray -> ulab.numpy.ndarray
This still does not build unless it is taken together with a modification
to CircuitPython that _also_ moves references to ulab.numpy.
Because of this, this PR will continue to show red. The suitability of
the changes can be gaged by looking at the related CircuitPython PR build
or by running locally the build-cp.sh script with the right ref checked
out in circuitpython/
Originally, math constants are implemented for MICROPY_OBJ_REPR = A and B.
Modify float object representations to work with MICROPY_OBJ_REPR = C and D.
.. this fixes a problem in CircuitPython where building the docs would say
"../shared-bindings/ulab/numpy/approx/index.rst: WARNING: document isn't included in any toctree"