Commit graph

105 commits

Author SHA1 Message Date
Dan Halbert
40e4e97368 Merge branch '9.0.x' of https://github.com/adafruit/circuitpython into 9.0.5-merge-to-main 2024-05-22 10:18:56 -04:00
49cbbd198a Fix chaining non-built-in exceptions 2024-05-21 16:41:39 -04:00
41eee0d5ea Add tests for chained exceptions (failing) 2024-05-21 16:41:39 -04:00
9e878f7b3d synthio: Calculate LFO.value at construction
Originally, the only (non-debug) way to make an LFO calculate its value
was to associate it with a playing synthesizer.

This posed a problem for LFOs that had "power on values" other than 0,
and where the value was used other than to internally drive a note
property.

Now, an initial, possibly non-zero value is calculated at object
construction time:

```py
>>> l = synthio.LFO(offset = 1)
>>> l.value
1.0
```

Note that this happens just once at construction; it does not happen when
updating LFO properties:
```py
>>> l.offset = 2
>>> l.value
1.0
```
2024-05-14 18:27:57 -05:00
1be36bd7cb Add floppyio to unix port, test mfm decoding 2024-04-02 15:42:28 -05:00
ce64daa86e settings.toml: explicitly check that strings must be quoted 2024-03-29 09:20:30 -05:00
foamyguy
3c969c41ef remove if, remove +/- 1, add blit test 2024-02-05 09:32:22 -06:00
8b30494146 Fix copying B to G in bitmapfilter.blend 2024-01-30 10:45:56 -06:00
e089f323f1 Update expected result with the additional test vectors 2024-01-29 16:07:08 -06:00
943825f8be Add bitmapfilter.blend
This can perform arbitrary channel mixing between two images.
Alpha blend & maximum functions are demonstrated in the test.
However, it should make most of the usual photo editing blends
possible. (for dissolve, fill a mask bitmap with random values,
which may be expensive to do from circuitpython code; we can
specifically accelerate it if we need to)
2024-01-29 11:15:35 -06:00
961a63b3ee
Require use of the ChannelMixer / ChannelScaler types in mix()
.. and update the test accordingly, fixing a bug discovered in the
process.
2024-01-18 17:16:44 -06:00
2e9e3fe3ab
tests: Remove file that should not have been added. 2024-01-16 14:58:41 -06:00
0c36c1558e
Remove morph9, we're tight on flash space as it is
.. and no specific use case for morph9 is known that can't be done
with mix+morph.

Saves ~1800 bytes on Memento
2024-01-15 14:08:13 -06:00
42a822d543
remove unused code 2024-01-15 11:36:38 -06:00
6e553e763c
Add, test morph9
morph9 is a form of morph which performs 9 different convolutions,
like a version of mix where each coefficient is a (2n+1)x(2n+1) matrix.

Most use cases are covered by morph-then-mix, but some advanced operations
may be more efficient to implement via morph9.
2024-01-12 17:32:45 -06:00
6d30ff527a
Add false_color 2024-01-12 10:48:26 -06:00
ff22baa37f
Add lookup table (LUT) 2024-01-11 14:40:01 -06:00
415432e942
Fix solarize to operate in YUV, add test 2024-01-11 14:37:36 -06:00
790e8902f8
Use a test pattern for mix filter, not blinka 2024-01-11 11:59:45 -06:00
7e1c05edf5
morph: accommodate fractional add values 2024-01-09 17:11:53 -06:00
e02c72b0da
Update morph test to use the factored out bitmap routine 2024-01-09 15:01:10 -06:00
36411203ff
Add bitmapfilter.mix
This allows operations between channels in an image. It can be used for
the following use cases:
 * Conversion to B&W or sepia
 * Adding color casts
 * Mixing or swapping arbitrary channels
 * Inverting or scaling arbitrary channels
2024-01-09 15:00:42 -06:00
214ebc3955
morph improvements
* weight can be any sequence (& test it)
 * improve error message
 * correct documentation of ``mask`` vs copypaste from openmv
2024-01-08 08:57:20 -06:00
7e23fac766
bitmapfilter: refine morph, add docs 2024-01-06 13:34:42 -06:00
75be426377
Add "bitmapfilter"
bitmapfilter.morph is taken from openmv's imlib.

It is substantially faster than blur/sharpen implemented in ulab,
by up to 10x. It also avoids making many allocations.
2024-01-05 14:16:00 -06:00
35258215ca
Correct y= argument of JpegDecoder.decode
.. update the tests as well. Don't dump the bitmap when the bitmaps
already compared equal for the crop and position tests.
2024-01-04 13:11:32 -06:00
7724ce3a3d
Test using an IO adapter; remove redundant BytesIO tests 2023-12-24 10:50:01 -06:00
5dd689c38a
jpegio: add bitmaptools.blit like clipping to decode 2023-12-24 10:50:00 -06:00
8d288f9623
jpegio: split open & decode; add support for decoding from files; add test 2023-12-24 10:50:00 -06:00
10907c3521
Add a new test of decoding jpeg image 2023-12-24 10:49:59 -06:00
9477574dfc
Add codeop.compile_command
This function in standard Python is a building block for custom REPLs:
```python
from codeop import compile_command

print("Repl in (Circuit-)Python")
ns = {}

PS1="<<< "
PS2=",,, "
command = ""
while True:
    line = input(PS2 if command else PS1)
    if command:
        command = command + "\n" + line
    else:
        command = line
    try:
        if (code := compile_command(command)):
            command = ""
            exec(code, ns)
    except Exception as e:
        command = ""
        print(e)
```
2023-12-14 09:23:23 -06:00
19df6adf4c
Update expected test results
some of the numbers have the last two digits changed, it's just noise.
2023-11-21 08:54:08 -06:00
5790785eae
endorse updated result 2023-11-21 08:54:08 -06:00
5fd8630654
tests: update synthesizer_note test with new expected output 2023-11-21 08:54:07 -06:00
5dc1d389d1
tests: restore getenv_int tests 2023-11-21 08:54:07 -06:00
c92ad33a9c
synthio: allow negative amplitudes
Previously, negative amplitudes were clamped to zero.
Now, they are allowed to range from -ALMOST_ONE to +ALMOST_ONE.
This is useful in certain circumstances, such as using synthio
to create CV-like outputs that can be positive or negative, by
using the amplitude property of the note.
2023-11-21 08:54:07 -06:00
Dan Halbert
88c22d5052 remove last uses of 'u' prefix 2023-08-22 12:57:47 -04:00
60b233f160
document EnvelopeState 2023-07-20 16:26:07 -05:00
346f08f8b9
synthio: Add Synthesizer.note_state
This enables the specific use case of checking whether a note's release
phase has ended, but is also potentially useful to implement a sort of
"voice stealing" algorithm in Python code, which can take account of
the note's envelope state as well as other factors specific to the
program.
2023-07-20 13:16:00 -05:00
e8c7b4a9f4
test a zero-byte environment file 2023-07-07 11:28:42 -05:00
a999e40935 synthio: reorganize the order of operations
Apply envelope & panning after biquad filtering.

This may fix the weird popping problem. It also reduces the number
of operations that are done "in stereo", so it could help performance.

It also fixes a previously unnoticed problem where a ring-modulated
waveform had 2x the amplitude of an un-modulated waveform.

The test differences look large but it's because some values got changed
in the LSB after the mathematical divisions were moved around.
2023-05-31 14:22:43 -05:00
51027974e5
synthio: apply biquad filters during synthesis 2023-05-29 10:53:48 -05:00
fed8d5825b
synthio: add biquad filter type & basic filter calculations
the filter cannot be applied as yet.
2023-05-29 09:50:18 -05:00
eda43d7474
Add some more Note tests 2023-05-24 10:00:12 -05:00
1059c99f6e
synthio: Add tests of each varying lfo input
I looked at all the results and they pleased me
2023-05-22 10:45:28 -05:00
3790fd4117
synthio: Add tests of all synthio math blocks
I plotted and eyeballed these and they all looked plausible
2023-05-22 10:45:21 -05:00
78e75f6977
synthio: enable additional LFO test cases 2023-05-21 13:22:49 -05:00
823a02c0b7
synthio: Add a new test of synthio.LFO 2023-05-21 13:22:49 -05:00
c435c469f4
synthio: simplify block logic a bit by converting from float just once 2023-05-18 11:55:01 -05:00
391438102b
synthio: Finish implementing Math blocks 2023-05-17 16:32:20 -05:00