Skip to content
Draft
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
2 changes: 1 addition & 1 deletion .github/workflows/c-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
- name: Build and test
env:
AMY_TEST_THRESHOLD_DB: "-70.0"
run: make test
run: make ctest && make test

web:
# Build the emscripten / WASM target (`make web`) so breaks there are caught.
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ check-c-api:
$(PYTHON) scripts/gen_pcm_presets_js.py --check

SOURCES += src/algorithms.c src/amy.c src/envelope.c src/examples.c src/parse.c \
src/filters.c src/oscillators.c src/pcm.c src/interp_partials.c src/custom.c \
src/filters.c src/oscillators.c src/pcm.c src/pcm_stream.c src/interp_partials.c src/custom.c \
src/delay.c src/log2_exp2.c src/patches.c src/transfer.c src/sequencer.c \
src/libminiaudio-audio.c src/instrument.c src/amy_midi.c src/api.c src/midi_mappings.c \
src/cv_trigger.c
Expand Down Expand Up @@ -127,7 +127,7 @@ CTESTS = tests/test_clock_wrap tests/test_sequencer_active tests/test_sequencer_
tests/test_bus_config tests/test_patch_slots \
tests/test_synth_readout tests/test_log2_lut tests/test_clone_on_grow \
tests/test_timebase_reset tests/test_osc_free_on_release \
tests/test_voice_osc_range
tests/test_voice_osc_range tests/test_pcm_stream

# Static pattern rules, so these win over the generic %.o: %.c above (which
# would compile without -Isrc and fail to find amy.h).
Expand Down
2 changes: 1 addition & 1 deletion daisy/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ OPT = -O3

# Sources
CPP_SOURCES = amy_daisy.cpp
C_SOURCES = ${AMY}/amy.c ${AMY}/oscillators.c ${AMY}/algorithms.c ${AMY}/envelope.c ${AMY}/examples.c ${AMY}/filters.c ${AMY}/pcm.c ${AMY}/custom.c ${AMY}/delay.c ${AMY}/log2_exp2.c ${AMY}/patches.c ${AMY}/api.c ${AMY}/sequencer.c ${AMY}/amy_midi.c ${AMY}/instrument.c ${AMY}/parse.c ${AMY}/transfer.c ${AMY}/interp_partials.c ${AMY}/midi_mappings.c
C_SOURCES = ${AMY}/amy.c ${AMY}/oscillators.c ${AMY}/algorithms.c ${AMY}/envelope.c ${AMY}/examples.c ${AMY}/filters.c ${AMY}/pcm.c ${AMY}/pcm_stream.c ${AMY}/custom.c ${AMY}/delay.c ${AMY}/log2_exp2.c ${AMY}/patches.c ${AMY}/api.c ${AMY}/sequencer.c ${AMY}/amy_midi.c ${AMY}/instrument.c ${AMY}/parse.c ${AMY}/transfer.c ${AMY}/interp_partials.c ${AMY}/midi_mappings.c


C_INCLUDES += -I${AMY} -DAMY_DAISY -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wpointer-arith -Wno-float-conversion -Wno-missing-declarations
Expand Down
1 change: 1 addition & 0 deletions godot/SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ amy_sources = [
"parse.c",
"patches.c",
"pcm.c",
"pcm_stream.c",
"sequencer.c",
"transfer.c",
]
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import subprocess
import sys
# the c++ extension module
sources = ['algorithms.c', 'amy.c', 'delay.c', 'envelope.c', 'filters.c', 'parse.c', 'sequencer.c', 'transfer.c', 'midi_mappings.c', 'custom.c', 'patches.c', 'libminiaudio-audio.c', 'oscillators.c', 'interp_partials.c', 'pcm.c', 'pyamy.c', 'log2_exp2.c', 'instrument.c', 'amy_midi.c', 'api.c', 'cv_trigger.c']
sources = ['algorithms.c', 'amy.c', 'delay.c', 'envelope.c', 'filters.c', 'parse.c', 'sequencer.c', 'transfer.c', 'midi_mappings.c', 'custom.c', 'patches.c', 'libminiaudio-audio.c', 'oscillators.c', 'interp_partials.c', 'pcm.c', 'pcm_stream.c', 'pyamy.c', 'log2_exp2.c', 'instrument.c', 'amy_midi.c', 'api.c', 'cv_trigger.c']

for i in range(len(sources)):
sources[i] = "src/"+sources[i]
Expand Down
18 changes: 17 additions & 1 deletion src/pcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "amy.h"
#include "transfer.h"
#include "pcm_stream_internal.h"

#ifdef __EMSCRIPTEN__
#include "emscripten.h"
Expand Down Expand Up @@ -124,6 +125,10 @@ memorypcm_preset_t * get_preset_for_preset_number(uint16_t preset_number,
}

const int16_t *pcm_get_sample_ram_for_preset(uint16_t preset_number, uint32_t *length) {
if (pcm_stream_preset_registered(preset_number)) {
if (length != NULL) *length = 0;
return NULL;
}
memorypcm_preset_t rom_local;
memorypcm_preset_t *preset = get_preset_for_preset_number(preset_number, &rom_local);
if (length != NULL) {
Expand Down Expand Up @@ -208,6 +213,11 @@ bool pcm_loop_config_allowed(uint16_t osc, uint16_t mode, uint16_t preset_number
// mode means nothing outside PCM, so don't second-guess other waves.
if (synth[osc]->wave != PCM) return true;
if (!mode_is_looping(mode)) return true;
if (pcm_stream_preset_registered(preset_number)) {
fprintf(stderr, "amy: appendable PCM stream preset %d cannot use PCM_LOOP modes; "
"queue loop data again from the producer instead\n", preset_number);
return false;
}
const char *filename = NULL;
if (!preset_is_file(preset_number, &filename)) return true;
if (mode_is_the_new_part) {
Expand Down Expand Up @@ -546,6 +556,7 @@ static SAMPLE render_pcm_stretch(SAMPLE *buf, uint16_t osc, memorypcm_preset_t *
}

void pcm_note_on(uint16_t osc) {
if (pcm_stream_note_on(osc)) return;
if(AMY_IS_SET(synth[osc]->preset)) {
memorypcm_preset_t rom_local;
memorypcm_preset_t *preset =
Expand Down Expand Up @@ -620,6 +631,7 @@ void pcm_mod_trigger(uint16_t osc) {


void pcm_note_off(uint16_t osc) {
if (pcm_stream_note_off(osc)) return;
if(AMY_IS_SET(synth[osc]->preset)) {
if (msynth[osc]->state == PCM_PLAY_STOP
|| msynth[osc]->state == PCM_LOOP_STOP) {
Expand Down Expand Up @@ -669,6 +681,8 @@ uint32_t fill_sample_from_file(memorypcm_preset_t *preset_p, uint32_t frames_nee
}

SAMPLE render_pcm(SAMPLE* buf, uint16_t osc) {
SAMPLE stream_max = 0;
if (pcm_stream_render(buf, osc, &stream_max)) return stream_max;
if(AMY_IS_SET(synth[osc]->preset)) {
SAMPLE max_value = 0;
memorypcm_preset_t rom_local;
Expand Down Expand Up @@ -746,7 +760,7 @@ SAMPLE render_pcm(SAMPLE* buf, uint16_t osc) {
msynth[osc]->loopstart = preset->loopstart;
msynth[osc]->loopend = preset->loopend;
}
//fprintf(stderr, "time %.3f sample %d LOOP: old_index %d new_index %d phase 0x%lx\n", amy_global.time, i, base_index, base_index_base, phase);
//fprintf(stderr, "time %.3f sample %d LOOP: old_index %d new_index %d phase 0x%lx\n", amy_global.time, i, base_index, sample_length, base_index_base, phase);
base_index = base_index_base;
} else if(base_index >= sample_length) { // end
synth[osc]->status = SYNTH_OFF;// is this right?
Expand Down Expand Up @@ -908,6 +922,7 @@ int16_t * pcm_load(uint16_t preset_number, uint32_t length, uint32_t samplerate,
}

void pcm_unload_preset(uint16_t preset_number) {
pcm_stream_unregister_preset(preset_number);
// run through the LL looking for the preset
memorypcm_ll_t **preset_pointer = &memorypcm_ll_start;
while(*preset_pointer != NULL) {
Expand All @@ -927,6 +942,7 @@ void pcm_unload_preset(uint16_t preset_number) {
}

void pcm_unload_all_presets() {
pcm_stream_unregister_all();
memorypcm_ll_t *preset_pointer = memorypcm_ll_start;
while(preset_pointer != NULL) {
memorypcm_ll_t *next_pointer = preset_pointer->next;
Expand Down
Loading