Skip to content

Audio Effect Reverb #10196

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions locale/circuitpython.pot
Original file line number Diff line number Diff line change
Expand Up @@ -2575,6 +2575,11 @@ msgstr ""

#: shared-bindings/audiodelays/Echo.c shared-bindings/audiodelays/PitchShift.c
#: shared-bindings/audiofilters/Distortion.c
#: shared-bindings/audiodelays/Reverb.c
msgid "bits_per_sample must be 16"
msgstr ""

#: shared-bindings/audiodelays/Echo.c shared-bindings/audiofilters/Distortion.c
#: shared-bindings/audiofilters/Filter.c shared-bindings/audiomixer/Mixer.c
msgid "bits_per_sample must be 8 or 16"
msgstr ""
Expand Down Expand Up @@ -3992,6 +3997,10 @@ msgstr ""
msgid "rsplit(None,n)"
msgstr ""

#: shared-bindings/audiodelays/Reverb.c
msgid "samples_signed must be true"
msgstr ""

#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
#: ports/raspberrypi/common-hal/audiobusio/PDMIn.c
msgid "sampling rate out of range"
Expand Down
4 changes: 4 additions & 0 deletions ports/unix/variants/coverage/mpconfigvariant.mk
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ SRC_BITMAP := \
shared-bindings/audiofilters/Distortion.c \
shared-bindings/audiofilters/Filter.c \
shared-bindings/audiofilters/__init__.c \
shared-bindings/audiofreeverb/Freeverb.c \
shared-bindings/audiofreeverb/__init__.c \
shared-bindings/audiomixer/__init__.c \
shared-bindings/audiomixer/Mixer.c \
shared-bindings/audiomixer/MixerVoice.c \
Expand Down Expand Up @@ -83,6 +85,8 @@ SRC_BITMAP := \
shared-module/audiofilters/Distortion.c \
shared-module/audiofilters/Filter.c \
shared-module/audiofilters/__init__.c \
shared-module/audiofreeverb/Freeverb.c \
shared-module/audiofreeverb/__init__.c \
shared-module/audiomixer/__init__.c \
shared-module/audiomp3/MP3Decoder.c \
shared-module/audiomixer/Mixer.c \
Expand Down
101 changes: 101 additions & 0 deletions ports/zephyr-cp/cptools/update_board_info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
#!/usr/bin/env python3

import pathlib
import sys
import tomlkit


def find_modules(top_dir, port_dir):
"""Find all available modules in shared-bindings and port bindings."""
modules = set()
for module in sorted(
list(top_dir.glob("shared-bindings/*")) + list(port_dir.glob("bindings/*")),
key=lambda x: x.name,
):
if not module.is_dir():
continue
modules.add(module.name)
return sorted(modules)


def find_board_info_files(port_dir):
"""Find all autogen_board_info.toml files in the port directory."""
return list(port_dir.glob("boards/**/autogen_board_info.toml"))


def update_board_info(board_info_path, available_modules):
"""Update board info file with new modules set to false."""
if not board_info_path.exists():
print(f"Error: Board info file {board_info_path} does not exist", file=sys.stderr)
return False

# Load existing board info
with open(board_info_path, "r", encoding="utf-8") as f:
board_info = tomlkit.load(f)

# Get current modules
current_modules = set(board_info.get("modules", {}))

# Find new modules
new_modules = set(available_modules) - current_modules
if not new_modules:
print(
f"No new modules found for {board_info_path.relative_to(board_info_path.parents[3])}"
)
return True

# Add new modules as disabled in alphabetical order
modules_table = board_info["modules"]
# Get all modules (existing and new) and sort them
all_modules = list(current_modules | new_modules)
all_modules.sort()

# Create a new table with sorted modules
sorted_table = tomlkit.table()
for module in all_modules:
if module in modules_table:
# TODO: Use modules_table.item once tomlkit is released with changes from January 2025
sorted_table[module] = modules_table._value.item(module)
else:
sorted_table[module] = tomlkit.item(False)

# Replace the modules table with the sorted one
board_info["modules"] = sorted_table

# Write updated board info
with open(board_info_path, "w", encoding="utf-8") as f:
tomlkit.dump(board_info, f)

print(
f"Updated {board_info_path.relative_to(board_info_path.parents[3])} with {len(new_modules)} new modules:"
)
for module in sorted(new_modules):
print(f" - {module}")
return True


def main():
# Get repo paths
script_dir = pathlib.Path(__file__).parent
top_dir = script_dir.parents[2] # circuitpython root
port_dir = script_dir.parent # zephyr-cp directory

# Get available modules once
available_modules = find_modules(top_dir, port_dir)

# Update all board info files
board_info_files = find_board_info_files(port_dir)
if not board_info_files:
print("No board info files found")
sys.exit(1)

success = True
for board_info_path in board_info_files:
if not update_board_info(board_info_path, available_modules):
success = False

sys.exit(0 if success else 1)


if __name__ == "__main__":
main()
5 changes: 5 additions & 0 deletions py/circuitpy_defns.mk
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ endif
ifeq ($(CIRCUITPY_AUDIOFILTERS),1)
SRC_PATTERNS += audiofilters/%
endif
ifeq ($(CIRCUITPY_AUDIOFREEVERB),1)
SRC_PATTERNS += audiofreeverb/%
endif
ifeq ($(CIRCUITPY_AUDIOMIXER),1)
SRC_PATTERNS += audiomixer/%
endif
Expand Down Expand Up @@ -637,6 +640,8 @@ SRC_SHARED_MODULE_ALL = \
audiofilters/Distortion.c \
audiofilters/Filter.c \
audiofilters/__init__.c \
audiofreeverb/__init__.c \
audiofreeverb/Freeverb.c \
audioio/__init__.c \
audiomixer/Mixer.c \
audiomixer/MixerVoice.c \
Expand Down
2 changes: 2 additions & 0 deletions py/circuitpy_mpconfig.mk
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ CIRCUITPY_AUDIODELAYS ?= $(CIRCUITPY_AUDIOEFFECTS)
CFLAGS += -DCIRCUITPY_AUDIODELAYS=$(CIRCUITPY_AUDIODELAYS)
CIRCUITPY_AUDIOFILTERS ?= $(CIRCUITPY_AUDIOEFFECTS)
CFLAGS += -DCIRCUITPY_AUDIOFILTERS=$(CIRCUITPY_AUDIOFILTERS)
CIRCUITPY_AUDIOFREEVERB ?= $(CIRCUITPY_AUDIOEFFECTS)
CFLAGS += -DCIRCUITPY_AUDIOFREEVERB=$(CIRCUITPY_AUDIOFREEVERB)

CIRCUITPY_AURORA_EPAPER ?= 0
CFLAGS += -DCIRCUITPY_AURORA_EPAPER=$(CIRCUITPY_AURORA_EPAPER)
Expand Down
Loading
Loading