Skip to content

Commit

Permalink
codal_port/microbit_soundeffect: Add comments for CODAL fx constants.
Browse files Browse the repository at this point in the history
It's not possible to include the CODAL header file that defines these
constants because that header file is C++.

Signed-off-by: Damien George <damien@micropython.org>
  • Loading branch information
dpgeorge committed Aug 22, 2024
1 parent d7f0a29 commit 251bd63
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions src/codal_port/microbit_soundeffect.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
*/

#include "py/runtime.h"
#include "microbithal.h"
#include "modmicrobit.h"
#include "modaudio.h"

Expand Down Expand Up @@ -69,14 +70,6 @@
#define SOUND_EFFECT_FX_VIBRATO (1)
#define SOUND_EFFECT_FX_WARBLE (3)

// These default fx values are the same as used by MakeCode.
#define SOUND_EFFECT_FX_VIBRATO_DEFAULT_PARAM (2)
#define SOUND_EFFECT_FX_TREMOLO_DEFAULT_PARAM (3)
#define SOUND_EFFECT_FX_WARBLE_DEFAULT_PARAM (2)
#define SOUND_EFFECT_FX_VIBRATO_DEFAULT_STEPS (512)
#define SOUND_EFFECT_FX_TREMOLO_DEFAULT_STEPS (900)
#define SOUND_EFFECT_FX_WARBLE_DEFAULT_STEPS (700)

#define SOUND_EFFECT_DEFAULT_FREQ_START (500)
#define SOUND_EFFECT_DEFAULT_FREQ_END (2500)
#define SOUND_EFFECT_DEFAULT_DURATION (500)
Expand Down Expand Up @@ -125,15 +118,15 @@ static const soundeffect_attr_t soundeffect_attr_table[] = {
};

static const uint8_t fx_default_param[] = {
[SOUND_EFFECT_FX_VIBRATO] = SOUND_EFFECT_FX_VIBRATO_DEFAULT_PARAM,
[SOUND_EFFECT_FX_TREMOLO] = SOUND_EFFECT_FX_TREMOLO_DEFAULT_PARAM,
[SOUND_EFFECT_FX_WARBLE] = SOUND_EFFECT_FX_WARBLE_DEFAULT_PARAM,
[SOUND_EFFECT_FX_VIBRATO] = MICROBIT_HAL_SFX_DEFAULT_VIBRATO_PARAM,
[SOUND_EFFECT_FX_TREMOLO] = MICROBIT_HAL_SFX_DEFAULT_TREMOLO_PARAM,
[SOUND_EFFECT_FX_WARBLE] = MICROBIT_HAL_SFX_DEFAULT_WARBLE_PARAM,
};

static const uint16_t fx_default_steps[] = {
[SOUND_EFFECT_FX_VIBRATO] = SOUND_EFFECT_FX_VIBRATO_DEFAULT_STEPS,
[SOUND_EFFECT_FX_TREMOLO] = SOUND_EFFECT_FX_TREMOLO_DEFAULT_STEPS,
[SOUND_EFFECT_FX_WARBLE] = SOUND_EFFECT_FX_WARBLE_DEFAULT_STEPS,
[SOUND_EFFECT_FX_VIBRATO] = MICROBIT_HAL_SFX_DEFAULT_VIBRATO_STEPS,
[SOUND_EFFECT_FX_TREMOLO] = MICROBIT_HAL_SFX_DEFAULT_TREMOLO_STEPS,
[SOUND_EFFECT_FX_WARBLE] = MICROBIT_HAL_SFX_DEFAULT_WARBLE_STEPS,
};

const char *microbit_soundeffect_get_sound_expr_data(mp_obj_t self_in) {
Expand Down

0 comments on commit 251bd63

Please sign in to comment.