Skip to content

Commit 6bd9dd9

Browse files
authored
Merge pull request #11121 from FoamyGuy/granular_pitch_shift
add GranularPitchShift class
2 parents 3b5efa3 + 8c8f281 commit 6bd9dd9

9 files changed

Lines changed: 928 additions & 0 deletions

File tree

locale/circuitpython.pot

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3724,6 +3724,7 @@ msgid "file must be a file opened in byte mode"
37243724
msgstr ""
37253725

37263726
#: shared-bindings/audiodelays/Chorus.c shared-bindings/audiodelays/Echo.c
3727+
#: shared-bindings/audiodelays/GranularPitchShift.c
37273728
#: shared-bindings/audiodelays/MultiTapDelay.c
37283729
#: shared-bindings/audiodelays/PitchShift.c
37293730
#: shared-bindings/audiofilters/Distortion.c

ports/raspberrypi/boards/archi/mpconfigboard.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,5 @@ FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Register
2020
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_seesaw
2121
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_framebuf
2222
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_SimpleIO
23+
24+
OPTIMIZATION_FLAGS = -O2

ports/unix/variants/coverage/mpconfigvariant.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ SRC_BITMAP := \
3737
shared-bindings/audiodelays/Echo.c \
3838
shared-bindings/audiodelays/Chorus.c \
3939
shared-bindings/audiodelays/PitchShift.c \
40+
shared-bindings/audiodelays/GranularPitchShift.c \
4041
shared-bindings/audiodelays/MultiTapDelay.c \
4142
shared-bindings/audiodelays/__init__.c \
4243
shared-bindings/audiofilters/Distortion.c \
@@ -85,6 +86,7 @@ SRC_BITMAP := \
8586
shared-module/audiodelays/Echo.c \
8687
shared-module/audiodelays/Chorus.c \
8788
shared-module/audiodelays/PitchShift.c \
89+
shared-module/audiodelays/GranularPitchShift.c \
8890
shared-module/audiodelays/MultiTapDelay.c \
8991
shared-module/audiodelays/__init__.c \
9092
shared-module/audiofilters/Distortion.c \

py/circuitpy_defns.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,7 @@ SRC_SHARED_MODULE_ALL = \
713713
audiodelays/Echo.c \
714714
audiodelays/Chorus.c \
715715
audiodelays/PitchShift.c \
716+
audiodelays/GranularPitchShift.c \
716717
audiodelays/MultiTapDelay.c \
717718
audiodelays/__init__.c \
718719
audiofilters/Distortion.c \

shared-bindings/audiodelays/GranularPitchShift.c

Lines changed: 315 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// This file is part of the CircuitPython project: https://circuitpython.org
2+
//
3+
// SPDX-FileCopyrightText: Copyright (c) 2026 Tim Cocks for Adafruit Industries
4+
//
5+
// SPDX-License-Identifier: MIT
6+
7+
#pragma once
8+
9+
#include "shared-module/audiodelays/GranularPitchShift.h"
10+
11+
extern const mp_obj_type_t audiodelays_granular_pitch_shift_type;
12+
13+
void common_hal_audiodelays_granular_pitch_shift_construct(audiodelays_granular_pitch_shift_obj_t *self,
14+
mp_obj_t semitones, mp_obj_t mix, uint32_t grain_size, uint32_t density,
15+
mp_float_t spread, uint32_t buffer_size, uint8_t bits_per_sample, bool samples_signed,
16+
uint8_t channel_count, uint32_t sample_rate);
17+
18+
void common_hal_audiodelays_granular_pitch_shift_deinit(audiodelays_granular_pitch_shift_obj_t *self);
19+
20+
mp_obj_t common_hal_audiodelays_granular_pitch_shift_get_semitones(audiodelays_granular_pitch_shift_obj_t *self);
21+
void common_hal_audiodelays_granular_pitch_shift_set_semitones(audiodelays_granular_pitch_shift_obj_t *self, mp_obj_t semitones);
22+
23+
mp_obj_t common_hal_audiodelays_granular_pitch_shift_get_mix(audiodelays_granular_pitch_shift_obj_t *self);
24+
void common_hal_audiodelays_granular_pitch_shift_set_mix(audiodelays_granular_pitch_shift_obj_t *self, mp_obj_t arg);
25+
26+
mp_float_t common_hal_audiodelays_granular_pitch_shift_get_spread(audiodelays_granular_pitch_shift_obj_t *self);
27+
void common_hal_audiodelays_granular_pitch_shift_set_spread(audiodelays_granular_pitch_shift_obj_t *self, mp_float_t spread);
28+
29+
bool common_hal_audiodelays_granular_pitch_shift_get_playing(audiodelays_granular_pitch_shift_obj_t *self);
30+
void common_hal_audiodelays_granular_pitch_shift_play(audiodelays_granular_pitch_shift_obj_t *self, mp_obj_t sample, bool loop);
31+
void common_hal_audiodelays_granular_pitch_shift_stop(audiodelays_granular_pitch_shift_obj_t *self);

shared-bindings/audiodelays/__init__.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "shared-bindings/audiodelays/Echo.h"
1414
#include "shared-bindings/audiodelays/Chorus.h"
1515
#include "shared-bindings/audiodelays/PitchShift.h"
16+
#include "shared-bindings/audiodelays/GranularPitchShift.h"
1617
#include "shared-bindings/audiodelays/MultiTapDelay.h"
1718

1819
//| """Support for audio delay effects
@@ -26,6 +27,7 @@ static const mp_rom_map_elem_t audiodelays_module_globals_table[] = {
2627
{ MP_ROM_QSTR(MP_QSTR_Echo), MP_ROM_PTR(&audiodelays_echo_type) },
2728
{ MP_ROM_QSTR(MP_QSTR_Chorus), MP_ROM_PTR(&audiodelays_chorus_type) },
2829
{ MP_ROM_QSTR(MP_QSTR_PitchShift), MP_ROM_PTR(&audiodelays_pitch_shift_type) },
30+
{ MP_ROM_QSTR(MP_QSTR_GranularPitchShift), MP_ROM_PTR(&audiodelays_granular_pitch_shift_type) },
2931
{ MP_ROM_QSTR(MP_QSTR_MultiTapDelay), MP_ROM_PTR(&audiodelays_multi_tap_delay_type) },
3032
};
3133

0 commit comments

Comments
 (0)