cignal 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. cignal-0.0.1/CHANGELOG.md +40 -0
  2. cignal-0.0.1/LICENSE +21 -0
  3. cignal-0.0.1/PKG-INFO +183 -0
  4. cignal-0.0.1/README.md +162 -0
  5. cignal-0.0.1/pyproject.toml +75 -0
  6. cignal-0.0.1/pyproject.toml.orig +63 -0
  7. cignal-0.0.1/src/cignal/__init__.py +5 -0
  8. cignal-0.0.1/src/cignal/build.py +229 -0
  9. cignal-0.0.1/src/cignal/cli.py +71 -0
  10. cignal-0.0.1/src/cignal/compiler.py +1942 -0
  11. cignal-0.0.1/src/cignal/diagnostics.py +136 -0
  12. cignal-0.0.1/src/cignal/kernel.py +230 -0
  13. cignal-0.0.1/src/cignal/shims/__init__.py +0 -0
  14. cignal-0.0.1/src/cignal/shims/bench.c.in +50 -0
  15. cignal-0.0.1/src/cignal/shims/driver.c.in +123 -0
  16. cignal-0.0.1/src/cignal/shims/ftz.h.in +35 -0
  17. cignal-0.0.1/src/cignal/shims/pd.c.in +91 -0
  18. cignal-0.0.1/src/cignal/shims/sc.cpp.in +50 -0
  19. cignal-0.0.1/tests/conftest.py +26 -0
  20. cignal-0.0.1/tests/fixtures/biquad.py +35 -0
  21. cignal-0.0.1/tests/fixtures/comb.py +21 -0
  22. cignal-0.0.1/tests/fixtures/denormal.py +12 -0
  23. cignal-0.0.1/tests/fixtures/drive.py +17 -0
  24. cignal-0.0.1/tests/fixtures/echo.py +21 -0
  25. cignal-0.0.1/tests/fixtures/fir.py +29 -0
  26. cignal-0.0.1/tests/fixtures/glide.py +10 -0
  27. cignal-0.0.1/tests/fixtures/lowpass.py +43 -0
  28. cignal-0.0.1/tests/fixtures/mix.py +35 -0
  29. cignal-0.0.1/tests/fixtures/onepole.py +26 -0
  30. cignal-0.0.1/tests/fixtures/ops.py +40 -0
  31. cignal-0.0.1/tests/fixtures/saw.py +13 -0
  32. cignal-0.0.1/tests/fixtures/stereo.py +24 -0
  33. cignal-0.0.1/tests/fixtures/svf.py +31 -0
  34. cignal-0.0.1/tests/fixtures/wavetable.py +20 -0
  35. cignal-0.0.1/tests/sc_support.py +102 -0
  36. cignal-0.0.1/tests/support.py +233 -0
  37. cignal-0.0.1/tests/test_codegen.py +143 -0
  38. cignal-0.0.1/tests/test_diagnostics.py +170 -0
  39. cignal-0.0.1/tests/test_differential.py +73 -0
  40. cignal-0.0.1/tests/test_pd.py +102 -0
  41. cignal-0.0.1/tests/test_realtime_safety.py +27 -0
  42. cignal-0.0.1/tests/test_supercollider.py +124 -0
@@ -0,0 +1,40 @@
1
+ # Changelog
2
+
3
+ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). Versions follow [Semantic Versioning](https://semver.org/).
4
+
5
+ ## [Unreleased]
6
+
7
+ ## [0.0.1]
8
+
9
+ First version. Milestones M0 to M5 are in [`docs/dev/spec.md`](docs/dev/spec.md) section 14.
10
+
11
+ ### Added
12
+
13
+ - Compiler from a static Python subset to C99. Kernels have typed fields (`f32`, `f64`, `i32`, `bool`), `init`, `control` (per block) and `tick` (per sample).
14
+
15
+ - Kernel ABI: a state struct, `init`, `reset`, `process`, `set_param`, named setters and `info`. No allocation, locks or I/O in `process`.
16
+
17
+ - Parameters with ranges and optional per-sample smoothing. Sub-kernels as fields, several inputs and outputs, tuple returns.
18
+
19
+ - `Array` and `Delay` with build-time sizes. Indices must be provably in range; there are no runtime checks.
20
+
21
+ - `@table`: module-level functions sampled in CPython at build time, interpolated linearly.
22
+
23
+ - Python semantics for `//`, `%`, `**`, shifts and chained comparisons. `i32` arithmetic wraps at 32 bits, where plain C signed overflow is undefined.
24
+
25
+ - Module-level functions, compiled only when a kernel calls them. `while`, with a `CIGNAL.UNBOUNDED_LOOP` warning.
26
+
27
+ - CLI: `cignal check` (text or JSON diagnostics) and `cignal build` with `--shim none|driver|pd|sc` and `--prefix`.
28
+
29
+ - Pd external and SuperCollider UGen shims, plus an sclang class file. Both shims flush denormals to zero while the kernel runs. macOS Pd 0.57 does not flush, and Debian Pd 0.55 does.
30
+
31
+ - Differential tests:
32
+ - the `double` build against CPython, bit for bit;
33
+
34
+ - the `float` build against the `double` build, SNR >= 100 dB;
35
+
36
+ - six block-size patterns, identical output;
37
+
38
+ - Pd and scsynth against the driver, bit for bit, with mid-stream parameter changes and resets.
39
+
40
+ - Linux test images for arm64 and x86-64 (`make test-linux`), and `make bench` with hand-written C references.
cignal-0.0.1/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Shakeeb Alireza
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
cignal-0.0.1/PKG-INFO ADDED
@@ -0,0 +1,183 @@
1
+ Metadata-Version: 2.4
2
+ Name: cignal
3
+ Version: 0.0.1
4
+ Summary: Compile DSP kernels written in static Python to C99
5
+ Keywords: python,library
6
+ Author: Shakeeb Alireza
7
+ Author-email: Shakeeb Alireza <shakfu@users.noreply.github.com>
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: Programming Language :: Python :: 3.13
14
+ Classifier: Programming Language :: Python :: 3.14
15
+ Classifier: Programming Language :: Python :: 3.15
16
+ Classifier: Programming Language :: Python :: Implementation :: CPython
17
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
18
+ Classifier: Typing :: Typed
19
+ Requires-Python: >=3.12
20
+ Description-Content-Type: text/markdown
21
+
22
+ # cignal
23
+
24
+ cignal compiles DSP kernels written in a static subset of Python to C99, for real-time audio hosts. The same source runs unchanged under CPython, as the reference model the C is tested against.
25
+
26
+ - One C99 kernel ABI: a state struct, `init`, `process`, `set_param`, `reset`. No allocation, locks or I/O in the processing path.
27
+
28
+ - Host shims for [Pd](https://puredata.info/) externals and [SuperCollider](https://supercollider.github.io/) UGens, plus a standalone test driver.
29
+
30
+ - Compiled with `double` in place of `f32`, the C matches CPython bit for bit. The test suite checks this for every fixture on macOS (clang) and Linux (GCC, glibc).
31
+
32
+ The design follows [Vult](https://github.com/vult-dsp/vult). The full specification, with the reasons for each choice, is in [`docs/dev/spec.md`](docs/dev/spec.md).
33
+
34
+ Status: pre-release. Nothing is published to PyPI yet.
35
+
36
+ ## Requirements
37
+
38
+ - Python 3.12 or later, and [uv](https://docs.astral.sh/uv/).
39
+
40
+ - A C99 compiler (`cc`, or `$CC`). The SuperCollider shim also needs a C++17 compiler (`c++`, or `$CXX`).
41
+
42
+ - For Pd externals: Pd's `m_pd.h` (found in `/usr/include/pd`, a macOS `Pd*.app`, or `$PD_INCLUDE`).
43
+
44
+ - For SuperCollider UGens: the SuperCollider plugin headers (`/usr/include/SuperCollider`, or `$SC_INCLUDE`).
45
+
46
+ ```sh
47
+ uv sync
48
+ ```
49
+
50
+ ## A kernel
51
+
52
+ ```python
53
+ import math
54
+
55
+ from cignal import Kernel, f32, param
56
+
57
+
58
+ class Section(Kernel):
59
+ b0: f32 = 1.0
60
+ b1: f32 = 0.0
61
+ b2: f32 = 0.0
62
+ a1: f32 = 0.0
63
+ a2: f32 = 0.0
64
+ z1: f32 = 0.0
65
+ z2: f32 = 0.0
66
+
67
+ def tick(self, x: f32) -> f32:
68
+ y = self.b0 * x + self.z1
69
+ self.z1 = self.b1 * x - self.a1 * y + self.z2
70
+ self.z2 = self.b2 * x - self.a2 * y
71
+ return y
72
+
73
+
74
+ class Lowpass(Kernel):
75
+ cutoff: f32 = param(1000.0, lo=20.0, hi=20000.0)
76
+ q: f32 = param(0.707, lo=0.1, hi=20.0)
77
+ section: Section # a sub-kernel: its state is part of Lowpass's struct
78
+
79
+ def control(self) -> None: # once per block
80
+ w = 2.0 * math.pi * self.cutoff / self.sample_rate
81
+ alpha = math.sin(w) / (2.0 * self.q)
82
+ c = math.cos(w)
83
+ a0 = 1.0 + alpha
84
+ self.section.b0 = (1.0 - c) / 2.0 / a0
85
+ self.section.b1 = (1.0 - c) / a0
86
+ self.section.b2 = self.section.b0
87
+ self.section.a1 = -2.0 * c / a0
88
+ self.section.a2 = (1.0 - alpha) / a0
89
+
90
+ def tick(self, x: f32) -> f32: # once per sample
91
+ return self.section.tick(x)
92
+ ```
93
+
94
+ As Python:
95
+
96
+ ```python
97
+ lp = Lowpass(sample_rate=48000)
98
+ lp.set_param("cutoff", 500.0)
99
+ out = lp.process([[1.0] + [0.0] * 63], 64) # one list per input channel
100
+ ```
101
+
102
+ Fields are state. `tick` sets the inputs and outputs: its parameters are input samples, and it returns one sample or a tuple. `init` runs once, and again on `reset`.
103
+
104
+ ## Build
105
+
106
+ ```sh
107
+ uv run cignal check lowpass.py # diagnostics only
108
+ uv run cignal build lowpass.py -o out # out/lowpass.h, out/lowpass.c
109
+ uv run cignal build lowpass.py -o out --shim pd # out/lowpass~.pd_darwin (or .pd_linux)
110
+ uv run cignal build lowpass.py -o out --shim sc # out/CignalLowpass.so (.scx) and CignalLowpass.sc
111
+ uv run cignal build lowpass.py -o out --prefix fx_ # fx_Lowpass, fx_Section, ...
112
+ ```
113
+
114
+ A file with several kernels needs `--kernel NAME`, unless only one of them is not a field of another.
115
+
116
+ - **Pd.** Inlets are the signal inputs, then one float inlet per parameter. Creation arguments set the parameters in order, and a `reset` message clears state. Pick a name that is not a Pd built-in with `--pd-name`: `biquad~` would load Pd's own object, without an error.
117
+
118
+ - **SuperCollider.** Copy the plugin and the `.sc` class file into an extensions folder. UGen inputs are the signal inputs, then one input per parameter: `CignalLowpass.ar(sig, 800, 2)`. Parameters are read once per block. `/u_cmd node ugen "reset"` clears state.
119
+
120
+ Both shims flush denormals to zero while the kernel runs, and restore the host's mode afterwards.
121
+
122
+ ## Things that differ from plain Python
123
+
124
+ - **Types are explicit.** `f32`, `f64`, `i32`, `bool`. A bare `float` or `int` annotation is an error. Mixing types without a cast (`f32(x)`) is an error; literals adapt.
125
+
126
+ - **Python semantics win** where C differs. `//` and `%` floor, as in Python; `-7 // 2` is `-4`. `>>` floors on negative values.
127
+
128
+ - **`i32` wraps** at 32 bits in C. CPython ints do not, so a value that leaves `i32` range is outside the contract, unless it is masked back into range.
129
+
130
+ - **Sizes are build-time constants.** `Array[f32, 16]`, `Delay[f32, MAX]`, `@table(size=512, ...)`. Module-level constants and `math` expressions on them are folded in CPython.
131
+
132
+ - **Array indices must be provably in range.** Use a constant, a `range` loop variable with constant bounds, or `e % N`. Anything else is a compile error, and there are no runtime bounds checks.
133
+
134
+ - **`Delay.read(d)` counts from 1.** `read(1)` is the newest sample, so `read(D)` before `write(x)` delays by exactly D samples.
135
+
136
+ - **Smoothed parameters** (`param(..., smooth=0.01)`) glide per sample. `control` may not read them, because the value it saw would depend on block size.
137
+
138
+ - **Tables** (`@table(size=..., lo=..., hi=...)` on a module-level function) are sampled in CPython at build time and interpolated linearly. The function body can use anything, SciPy included.
139
+
140
+ - **Module-level functions** called from kernels are compiled; others, such as build-time filter design, are left alone.
141
+
142
+ - **`while` compiles, with a warning:** its termination is not checked against the audio deadline.
143
+
144
+ ## Performance
145
+
146
+ `K_process` matches hand-written C for a biquad on clang and GCC, and beats it for a 16-tap FIR. `make bench` prints ns per sample for every fixture. Float `%` inside a recursion is slow on clang. For a phase accumulator whose increment is in [0, 1), use `phase += inc; if phase >= 1.0: phase -= 1.0`. See spec section 9.5.
147
+
148
+ ## Tests
149
+
150
+ ```sh
151
+ make test # pytest; Pd and SuperCollider tests skip when not installed
152
+ make lint type-check
153
+ make linux-image test-linux # Debian in an Apple `container` VM: GCC, glibc, Pd 0.55, SuperCollider 3.13
154
+ make linux-image test-linux ARCH=amd64
155
+ make bench
156
+ ```
157
+
158
+ Each fixture in `tests/fixtures/` is compiled and checked four ways:
159
+
160
+ - the `double` build against CPython, bit for bit;
161
+
162
+ - the `float` build against the `double` build, SNR >= 100 dB;
163
+
164
+ - six block-size patterns, which must give identical output;
165
+
166
+ - in Pd and in SuperCollider, against the driver, bit for bit, with mid-stream parameter changes and resets.
167
+
168
+ ## Layout
169
+
170
+ ```text
171
+ src/cignal/kernel.py the Python runtime: Kernel, param, Array, Delay, table
172
+ src/cignal/compiler.py source -> typed walk -> C
173
+ src/cignal/build.py writing C, rendering shims, invoking the compiler
174
+ src/cignal/shims/ driver, Pd, SuperCollider, benchmark and flush-to-zero templates
175
+ tests/ fixtures and the differential, host, diagnostics and codegen tests
176
+ bench/ the benchmark runner and hand-written C references
177
+ ci/linux.Containerfile the Linux test image
178
+ docs/dev/spec.md the specification
179
+ ```
180
+
181
+ ## License
182
+
183
+ MIT. See [LICENSE](LICENSE).
cignal-0.0.1/README.md ADDED
@@ -0,0 +1,162 @@
1
+ # cignal
2
+
3
+ cignal compiles DSP kernels written in a static subset of Python to C99, for real-time audio hosts. The same source runs unchanged under CPython, as the reference model the C is tested against.
4
+
5
+ - One C99 kernel ABI: a state struct, `init`, `process`, `set_param`, `reset`. No allocation, locks or I/O in the processing path.
6
+
7
+ - Host shims for [Pd](https://puredata.info/) externals and [SuperCollider](https://supercollider.github.io/) UGens, plus a standalone test driver.
8
+
9
+ - Compiled with `double` in place of `f32`, the C matches CPython bit for bit. The test suite checks this for every fixture on macOS (clang) and Linux (GCC, glibc).
10
+
11
+ The design follows [Vult](https://github.com/vult-dsp/vult). The full specification, with the reasons for each choice, is in [`docs/dev/spec.md`](docs/dev/spec.md).
12
+
13
+ Status: pre-release. Nothing is published to PyPI yet.
14
+
15
+ ## Requirements
16
+
17
+ - Python 3.12 or later, and [uv](https://docs.astral.sh/uv/).
18
+
19
+ - A C99 compiler (`cc`, or `$CC`). The SuperCollider shim also needs a C++17 compiler (`c++`, or `$CXX`).
20
+
21
+ - For Pd externals: Pd's `m_pd.h` (found in `/usr/include/pd`, a macOS `Pd*.app`, or `$PD_INCLUDE`).
22
+
23
+ - For SuperCollider UGens: the SuperCollider plugin headers (`/usr/include/SuperCollider`, or `$SC_INCLUDE`).
24
+
25
+ ```sh
26
+ uv sync
27
+ ```
28
+
29
+ ## A kernel
30
+
31
+ ```python
32
+ import math
33
+
34
+ from cignal import Kernel, f32, param
35
+
36
+
37
+ class Section(Kernel):
38
+ b0: f32 = 1.0
39
+ b1: f32 = 0.0
40
+ b2: f32 = 0.0
41
+ a1: f32 = 0.0
42
+ a2: f32 = 0.0
43
+ z1: f32 = 0.0
44
+ z2: f32 = 0.0
45
+
46
+ def tick(self, x: f32) -> f32:
47
+ y = self.b0 * x + self.z1
48
+ self.z1 = self.b1 * x - self.a1 * y + self.z2
49
+ self.z2 = self.b2 * x - self.a2 * y
50
+ return y
51
+
52
+
53
+ class Lowpass(Kernel):
54
+ cutoff: f32 = param(1000.0, lo=20.0, hi=20000.0)
55
+ q: f32 = param(0.707, lo=0.1, hi=20.0)
56
+ section: Section # a sub-kernel: its state is part of Lowpass's struct
57
+
58
+ def control(self) -> None: # once per block
59
+ w = 2.0 * math.pi * self.cutoff / self.sample_rate
60
+ alpha = math.sin(w) / (2.0 * self.q)
61
+ c = math.cos(w)
62
+ a0 = 1.0 + alpha
63
+ self.section.b0 = (1.0 - c) / 2.0 / a0
64
+ self.section.b1 = (1.0 - c) / a0
65
+ self.section.b2 = self.section.b0
66
+ self.section.a1 = -2.0 * c / a0
67
+ self.section.a2 = (1.0 - alpha) / a0
68
+
69
+ def tick(self, x: f32) -> f32: # once per sample
70
+ return self.section.tick(x)
71
+ ```
72
+
73
+ As Python:
74
+
75
+ ```python
76
+ lp = Lowpass(sample_rate=48000)
77
+ lp.set_param("cutoff", 500.0)
78
+ out = lp.process([[1.0] + [0.0] * 63], 64) # one list per input channel
79
+ ```
80
+
81
+ Fields are state. `tick` sets the inputs and outputs: its parameters are input samples, and it returns one sample or a tuple. `init` runs once, and again on `reset`.
82
+
83
+ ## Build
84
+
85
+ ```sh
86
+ uv run cignal check lowpass.py # diagnostics only
87
+ uv run cignal build lowpass.py -o out # out/lowpass.h, out/lowpass.c
88
+ uv run cignal build lowpass.py -o out --shim pd # out/lowpass~.pd_darwin (or .pd_linux)
89
+ uv run cignal build lowpass.py -o out --shim sc # out/CignalLowpass.so (.scx) and CignalLowpass.sc
90
+ uv run cignal build lowpass.py -o out --prefix fx_ # fx_Lowpass, fx_Section, ...
91
+ ```
92
+
93
+ A file with several kernels needs `--kernel NAME`, unless only one of them is not a field of another.
94
+
95
+ - **Pd.** Inlets are the signal inputs, then one float inlet per parameter. Creation arguments set the parameters in order, and a `reset` message clears state. Pick a name that is not a Pd built-in with `--pd-name`: `biquad~` would load Pd's own object, without an error.
96
+
97
+ - **SuperCollider.** Copy the plugin and the `.sc` class file into an extensions folder. UGen inputs are the signal inputs, then one input per parameter: `CignalLowpass.ar(sig, 800, 2)`. Parameters are read once per block. `/u_cmd node ugen "reset"` clears state.
98
+
99
+ Both shims flush denormals to zero while the kernel runs, and restore the host's mode afterwards.
100
+
101
+ ## Things that differ from plain Python
102
+
103
+ - **Types are explicit.** `f32`, `f64`, `i32`, `bool`. A bare `float` or `int` annotation is an error. Mixing types without a cast (`f32(x)`) is an error; literals adapt.
104
+
105
+ - **Python semantics win** where C differs. `//` and `%` floor, as in Python; `-7 // 2` is `-4`. `>>` floors on negative values.
106
+
107
+ - **`i32` wraps** at 32 bits in C. CPython ints do not, so a value that leaves `i32` range is outside the contract, unless it is masked back into range.
108
+
109
+ - **Sizes are build-time constants.** `Array[f32, 16]`, `Delay[f32, MAX]`, `@table(size=512, ...)`. Module-level constants and `math` expressions on them are folded in CPython.
110
+
111
+ - **Array indices must be provably in range.** Use a constant, a `range` loop variable with constant bounds, or `e % N`. Anything else is a compile error, and there are no runtime bounds checks.
112
+
113
+ - **`Delay.read(d)` counts from 1.** `read(1)` is the newest sample, so `read(D)` before `write(x)` delays by exactly D samples.
114
+
115
+ - **Smoothed parameters** (`param(..., smooth=0.01)`) glide per sample. `control` may not read them, because the value it saw would depend on block size.
116
+
117
+ - **Tables** (`@table(size=..., lo=..., hi=...)` on a module-level function) are sampled in CPython at build time and interpolated linearly. The function body can use anything, SciPy included.
118
+
119
+ - **Module-level functions** called from kernels are compiled; others, such as build-time filter design, are left alone.
120
+
121
+ - **`while` compiles, with a warning:** its termination is not checked against the audio deadline.
122
+
123
+ ## Performance
124
+
125
+ `K_process` matches hand-written C for a biquad on clang and GCC, and beats it for a 16-tap FIR. `make bench` prints ns per sample for every fixture. Float `%` inside a recursion is slow on clang. For a phase accumulator whose increment is in [0, 1), use `phase += inc; if phase >= 1.0: phase -= 1.0`. See spec section 9.5.
126
+
127
+ ## Tests
128
+
129
+ ```sh
130
+ make test # pytest; Pd and SuperCollider tests skip when not installed
131
+ make lint type-check
132
+ make linux-image test-linux # Debian in an Apple `container` VM: GCC, glibc, Pd 0.55, SuperCollider 3.13
133
+ make linux-image test-linux ARCH=amd64
134
+ make bench
135
+ ```
136
+
137
+ Each fixture in `tests/fixtures/` is compiled and checked four ways:
138
+
139
+ - the `double` build against CPython, bit for bit;
140
+
141
+ - the `float` build against the `double` build, SNR >= 100 dB;
142
+
143
+ - six block-size patterns, which must give identical output;
144
+
145
+ - in Pd and in SuperCollider, against the driver, bit for bit, with mid-stream parameter changes and resets.
146
+
147
+ ## Layout
148
+
149
+ ```text
150
+ src/cignal/kernel.py the Python runtime: Kernel, param, Array, Delay, table
151
+ src/cignal/compiler.py source -> typed walk -> C
152
+ src/cignal/build.py writing C, rendering shims, invoking the compiler
153
+ src/cignal/shims/ driver, Pd, SuperCollider, benchmark and flush-to-zero templates
154
+ tests/ fixtures and the differential, host, diagnostics and codegen tests
155
+ bench/ the benchmark runner and hand-written C references
156
+ ci/linux.Containerfile the Linux test image
157
+ docs/dev/spec.md the specification
158
+ ```
159
+
160
+ ## License
161
+
162
+ MIT. See [LICENSE](LICENSE).
@@ -0,0 +1,75 @@
1
+ [project]
2
+ name = "cignal"
3
+ version = "0.0.1"
4
+ description = "Compile DSP kernels written in static Python to C99"
5
+ readme = "README.md"
6
+ license = "MIT"
7
+ license-files = ["LICENSE"]
8
+ requires-python = ">=3.12"
9
+ keywords = [
10
+ "python",
11
+ "library",
12
+ ]
13
+ dependencies = []
14
+ classifiers = [
15
+ "Development Status :: 3 - Alpha",
16
+ "Programming Language :: Python :: 3",
17
+ "Programming Language :: Python :: 3.12",
18
+ "Programming Language :: Python :: 3.13",
19
+ "Programming Language :: Python :: 3.14",
20
+ "Programming Language :: Python :: 3.15",
21
+ "Programming Language :: Python :: Implementation :: CPython",
22
+ "Programming Language :: Python :: Implementation :: PyPy",
23
+ "Typing :: Typed",
24
+ ]
25
+
26
+ [[project.authors]]
27
+ name = "Shakeeb Alireza"
28
+ email = "shakfu@users.noreply.github.com"
29
+
30
+ [project.scripts]
31
+ cignal = "cignal.cli:main"
32
+
33
+ [dependency-groups]
34
+ dev = [
35
+ "mypy>=2.4.1",
36
+ "pytest>=9.2.0",
37
+ "pytest-cov>=7.1.0",
38
+ "ruff>=0.17.6",
39
+ "twine>=7.0.0",
40
+ ]
41
+
42
+ [build-system]
43
+ requires = ["uv_build>=0.13.9,<0.14"]
44
+ build-backend = "uv_build"
45
+
46
+ [tool.uv.build-backend]
47
+ module-name = "cignal"
48
+ module-root = "src"
49
+ source-include = [
50
+ "tests/**",
51
+ "CHANGELOG.md",
52
+ "LICENSE",
53
+ ]
54
+
55
+ [tool.pytest.ini_options]
56
+ addopts = "-ra -q --strict-markers --strict-config"
57
+ testpaths = ["tests"]
58
+
59
+ [tool.mypy]
60
+ strict = true
61
+ files = ["src/cignal"]
62
+
63
+ [tool.ruff]
64
+ line-length = 120
65
+ src = ["src"]
66
+
67
+ [tool.ruff.lint]
68
+ select = [
69
+ "E",
70
+ "F",
71
+ "I",
72
+ "B",
73
+ "UP",
74
+ ]
75
+ ignore = ["UP040"]
@@ -0,0 +1,63 @@
1
+ [project]
2
+ name = "cignal"
3
+ version = "0.0.1"
4
+ description = "Compile DSP kernels written in static Python to C99"
5
+ readme = "README.md"
6
+ license = "MIT"
7
+ license-files = ["LICENSE"]
8
+ authors = [
9
+ { name = "Shakeeb Alireza", email = "shakfu@users.noreply.github.com" }
10
+ ]
11
+ requires-python = ">=3.12"
12
+ keywords = ["python", "library"]
13
+ # This project intentionally has no runtime dependencies.
14
+ dependencies = []
15
+ classifiers = [
16
+ "Development Status :: 3 - Alpha",
17
+ "Programming Language :: Python :: 3",
18
+ "Programming Language :: Python :: 3.12",
19
+ "Programming Language :: Python :: 3.13",
20
+ "Programming Language :: Python :: 3.14",
21
+ "Programming Language :: Python :: 3.15",
22
+ "Programming Language :: Python :: Implementation :: CPython",
23
+ "Programming Language :: Python :: Implementation :: PyPy",
24
+ "Typing :: Typed",
25
+ ]
26
+
27
+ [project.scripts]
28
+ cignal = "cignal.cli:main"
29
+
30
+ [dependency-groups]
31
+ dev = [
32
+ "mypy>=2.4.1",
33
+ "pytest>=9.2.0",
34
+ "pytest-cov>=7.1.0",
35
+ "ruff>=0.17.6",
36
+ "twine>=7.0.0",
37
+ ]
38
+
39
+ [build-system]
40
+ requires = ["uv_build>=0.13.9,<0.14"]
41
+ build-backend = "uv_build"
42
+
43
+ [tool.uv.build-backend]
44
+ module-name = "cignal"
45
+ module-root = "src"
46
+ source-include = ["tests/**", "CHANGELOG.md", "LICENSE"]
47
+
48
+ [tool.pytest.ini_options]
49
+ addopts = "-ra -q --strict-markers --strict-config"
50
+ testpaths = ["tests"]
51
+
52
+ [tool.mypy]
53
+ strict = true
54
+ files = ["src/cignal"]
55
+
56
+ [tool.ruff]
57
+ line-length = 120
58
+ src = ["src"]
59
+
60
+ [tool.ruff.lint]
61
+ select = ["E", "F", "I", "B", "UP"]
62
+ # `type f32 = float` is not callable, and kernels call f32(x) at runtime.
63
+ ignore = ["UP040"]
@@ -0,0 +1,5 @@
1
+ """Compile DSP kernels written in static Python to C99."""
2
+
3
+ from .kernel import Array, Delay, Kernel, f32, f64, i32, param, table
4
+
5
+ __all__ = ["Array", "Delay", "Kernel", "f32", "f64", "i32", "param", "table"]