From 0aeb3c23dfb79d709678179deccb26fd8105975e Mon Sep 17 00:00:00 2001 From: Jens Ahrensfeld Date: Fri, 31 Jul 2026 18:23:53 +0200 Subject: [PATCH] synth: rename blit.c/blit.h to blep.c/blep.h to match actual algorithm The oscillator core implements minBLEP-style synthesis (naive waveform plus a precomputed band-limited step correction table, ppBLEP) rather than classic impulse-train BLIT synthesis, despite the old BLIT_* naming. Renamed the source files and all BLIT_* identifiers to BLEP_* throughout src/synth (blep.c/h, vco.c/h, synth_defs.h, config.mk) and updated the CLAUDE.md/TODO.md references accordingly. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01262jWgCmReCRdUi6u9cRYa --- CLAUDE.md | 2 +- TODO.md | 2 +- src/synth/{blit.c => blep.c} | 122 +++++++++++++++++------------------ src/synth/{blit.h => blep.h} | 50 +++++++------- src/synth/config.mk | 2 +- src/synth/synth_defs.h | 10 +-- src/synth/vco.c | 28 ++++---- src/synth/vco.h | 6 +- 8 files changed, 111 insertions(+), 111 deletions(-) rename src/synth/{blit.c => blep.c} (70%) rename src/synth/{blit.h => blep.h} (56%) diff --git a/CLAUDE.md b/CLAUDE.md index bab9b30..c12d821 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -32,7 +32,7 @@ There are no automated tests in this repo; verification is manual, by building, The codebase has a hard split between a **portable C DSP core** and a **C++/JUCE plugin shell**, built as separate sub-Makefiles and linked together: -- `src/synth/` — pure C DSP engine (no JUCE, no C++). Oscillators (`vco.c`, BLIT-based band-limited synthesis in `blit.c`), wavetables (`wavetable.c`, `mw_wave_data.c` — Waldorf Microwave/PPG-style wavetables), filter (`vcf.c`), envelopes (`env.c`), LFOs (`lfo.c`), noise (`noise.c`), and parameter scaling (`param_scale.c`). `synth_float_t` is a build-time typedef (`double` on Linux, `float` on Windows — set via `-Dsynth_float_t=...` in the Makefiles). +- `src/synth/` — pure C DSP engine (no JUCE, no C++). Oscillators (`vco.c`, BLEP-based band-limited synthesis in `blep.c`), wavetables (`wavetable.c`, `mw_wave_data.c` — Waldorf Microwave/PPG-style wavetables), filter (`vcf.c`), envelopes (`env.c`), LFOs (`lfo.c`), noise (`noise.c`), and parameter scaling (`param_scale.c`). `synth_float_t` is a build-time typedef (`double` on Linux, `float` on Windows — set via `-Dsynth_float_t=...` in the Makefiles). - `voice.h`/`voice.c` is the center of this layer: a `voice_t` (per-voice state: 2 VCOs, 4 LFOs, 4 envelopes, 1 VCF) driven by a shared `voice_common_t` (global LFO/env/VCF/noise tables and shared per-block buffers, to avoid recomputing identical modulation sources per voice). All per-voice parameters are addressed by the flat `VOICE_PARAM_*` enum in `voice.h`; modulation routing (FM/AM/PWM sources for oscillators, filter cutoff/Q sources) is expressed as source/amount/op triples pointing into `VOICE_MOD_SRC_*`. - Voice audio rendering can run multi-threaded: `JaySynthThread` (in `src/plug/JaySynth.h`) splits the voice array across CPU cores, each thread calling `VoiceProcessDataV`. - `src/plug/` — the JUCE `AudioProcessor`/`Synthesiser` plugin implementation, C++11. diff --git a/TODO.md b/TODO.md index 0076495..a458bf1 100644 --- a/TODO.md +++ b/TODO.md @@ -22,7 +22,7 @@ Findings from a code-review pass over `src/plug` and `src/synth` (2026-07-27, br ## Memory management (fixed) - [x] **`new[]`/`delete` mismatches (UB) in `JaySynth`'s destructor** — `m_pVoices`, `pPer_voice_controls`, `pCurrNoteInfos`, `humanize_voice_param[i]`, `ppHumanizedSliders[i]`, `m_ppAudioThread`, `m_ppEventAudioThreadRdy` (`src/plug/JaySynth.cpp`) all now freed with `delete[]` to match their `new T[n]` allocations. Also found and fixed the same pattern via `ScopedPointer` in `PluginProcessor.cpp` (`setStateInformation`/`setCurrentProgramStateInformation`) — `ScopedPointer` always calls scalar `delete` (per JUCE's own doc comment), so `ScopedPointer pUncompressedData = new char[...]` was the same bug; replaced with `HeapBlock`, JUCE's array-owning smart pointer. -- [x] **`malloc` was never null-checked** across the C DSP core. Added a shared `SynthCheckAlloc()` helper (`synth_defs.h`/`synth_debug.c`) that aborts with a clear diagnostic instead of returning NULL, and wrapped all 24 `malloc` call sites across `env.c`, `lfo.c`, `vcf.c`, `vco.c`, `blit.c`, `wavetable.c`, `voice.c`, `param_scale.c`. All are one-time init/bufsize-change calls, never in the per-block render path, so this adds no real-time overhead. +- [x] **`malloc` was never null-checked** across the C DSP core. Added a shared `SynthCheckAlloc()` helper (`synth_defs.h`/`synth_debug.c`) that aborts with a clear diagnostic instead of returning NULL, and wrapped all 24 `malloc` call sites across `env.c`, `lfo.c`, `vcf.c`, `vco.c`, `blep.c`, `wavetable.c`, `voice.c`, `param_scale.c`. All are one-time init/bufsize-change calls, never in the per-block render path, so this adds no real-time overhead. ## Patch/Bank import-export (fixed) diff --git a/src/synth/blit.c b/src/synth/blep.c similarity index 70% rename from src/synth/blit.c rename to src/synth/blep.c index 92f9093..a348e5d 100644 --- a/src/synth/blit.c +++ b/src/synth/blep.c @@ -8,7 +8,7 @@ #include "noise.h" #include "synth_defs.h" -#include "blit.h" +#include "blep.h" #include "fir/fir2.h" #include "synth_types.h" #include "vector_utils.h" @@ -48,15 +48,15 @@ UINT32 umax(UINT32 x, UINT32 y) return y; } -void IP_ModInit(blit_common_t *pCom) +void IP_ModInit(blep_common_t *pCom) { INT32 n, k; synth_float_t *pN_K = pCom->N_K; synth_float_t *pK = pCom->K; - for (n=0; n <= BLIT_INTEROLATION_ORDER; n++) + for (n=0; n <= BLEP_INTEROLATION_ORDER; n++) { - for (k=0; k <= BLIT_INTEROLATION_ORDER; k++) + for (k=0; k <= BLEP_INTEROLATION_ORDER; k++) { if (k == n) continue; @@ -67,7 +67,7 @@ void IP_ModInit(blit_common_t *pCom) } } -synth_float_t IP_Process(blit_t *pObj, synth_float_t *pLUT, synth_float_t m) +synth_float_t IP_Process(blep_t *pObj, synth_float_t *pLUT, synth_float_t m) { INT32 mi, j; INT32 n, k; @@ -78,11 +78,11 @@ synth_float_t IP_Process(blit_t *pObj, synth_float_t *pLUT, synth_float_t m) mi = (INT32)m; delay = m - (synth_float_t)mi; - j = (INT32)BLIT_INTEROLATION_ORDER; - for (n=0; n <= BLIT_INTEROLATION_ORDER; n++) + j = (INT32)BLEP_INTEROLATION_ORDER; + for (n=0; n <= BLEP_INTEROLATION_ORDER; n++) { hn = (synth_float_t)1; - for (k=0; k < BLIT_INTEROLATION_ORDER; k++) + for (k=0; k < BLEP_INTEROLATION_ORDER; k++) { hn *= (*(pN_K++) * (delay - *(pK++))); } @@ -92,7 +92,7 @@ synth_float_t IP_Process(blit_t *pObj, synth_float_t *pLUT, synth_float_t m) return y; } -void BLIT_process_misc(blit_t *pObj) +void BLEP_process_misc(blep_t *pObj) { if (pObj->misc_process_downsammple_counter) { @@ -100,9 +100,9 @@ void BLIT_process_misc(blit_t *pObj) return; } - pObj->misc_process_downsammple_counter = BLIT_MISC_PROCESS_DOWN_SAMPLE; + pObj->misc_process_downsammple_counter = BLEP_MISC_PROCESS_DOWN_SAMPLE; - const synth_float_t alpha = BLIT_JITTER_ERROR*BLIT_MISC_PROCESS_DOWN_SAMPLE; + const synth_float_t alpha = BLEP_JITTER_ERROR*BLEP_MISC_PROCESS_DOWN_SAMPLE; synth_float_t pm = Noise_Uniform(&pObj->pCom->noise, 1, 0); if (pm > 0) @@ -116,7 +116,7 @@ void BLIT_process_misc(blit_t *pObj) } -void BLIT_freq_update(blit_t *pObj, synth_float_t scale) +void BLEP_freq_update(blep_t *pObj, synth_float_t scale) { synth_float_t p; @@ -126,44 +126,44 @@ void BLIT_freq_update(blit_t *pObj, synth_float_t scale) p = pObj->fs/(scale * pObj->fm * (1 + pObj->jitter)); pObj->dx = (synth_float_t)1.0/p; - pObj->m = umin(BLIT_NUM_HARM_MAX-1, (UINT32)((synth_float_t)SYNTH_BANDWIDTH*2.0*(int)((p/2)) + 0)); + pObj->m = umin(BLEP_NUM_HARM_MAX-1, (UINT32)((synth_float_t)SYNTH_BANDWIDTH*2.0*(int)((p/2)) + 0)); } // -------------------------------------------------------------- // Exported functions // -------------------------------------------------------------- -void BLIT_ModInit(blit_common_t *pCom) +void BLEP_ModInit(blep_common_t *pCom) { int m, n; synth_float_t **ppKaiser; synth_float_t x, dx, a, b, blit, blep; // Calculate table sizes - pCom->pTableSizes = (UINT32*)SynthCheckAlloc(malloc(BLIT_NUM_HARM_MAX*sizeof(UINT32))); - for (m=0; m < BLIT_NUM_HARM_MAX; m++) + pCom->pTableSizes = (UINT32*)SynthCheckAlloc(malloc(BLEP_NUM_HARM_MAX*sizeof(UINT32))); + for (m=0; m < BLEP_NUM_HARM_MAX; m++) { - pCom->pTableSizes[m] = m*BLIT_TABLE_OVERSAMPLING; - if (pCom->pTableSizes[m] < BLIT_TABLE_SIZE_MIN) - pCom->pTableSizes[m] = BLIT_TABLE_SIZE_MIN; + pCom->pTableSizes[m] = m*BLEP_TABLE_OVERSAMPLING; + if (pCom->pTableSizes[m] < BLEP_TABLE_SIZE_MIN) + pCom->pTableSizes[m] = BLEP_TABLE_SIZE_MIN; } // Generate Kaiser window - ppKaiser = (synth_float_t**)SynthCheckAlloc(malloc(BLIT_NUM_HARM_MAX*sizeof(synth_float_t*))); - for (m=0; m < BLIT_NUM_HARM_MAX; m++) + ppKaiser = (synth_float_t**)SynthCheckAlloc(malloc(BLEP_NUM_HARM_MAX*sizeof(synth_float_t*))); + for (m=0; m < BLEP_NUM_HARM_MAX; m++) { ppKaiser[m] = (synth_float_t*)SynthCheckAlloc(malloc(pCom->pTableSizes[m]*sizeof(synth_float_t))); CalcKaiser(NULL, ppKaiser[m], 8.f, pCom->pTableSizes[m]); } // Allocate BLIT table - pCom->ppBLEP = (synth_float_t**)SynthCheckAlloc(malloc(BLIT_NUM_HARM_MAX*sizeof(synth_float_t*))); - for (m=0; m < BLIT_NUM_HARM_MAX; m++) + pCom->ppBLEP = (synth_float_t**)SynthCheckAlloc(malloc(BLEP_NUM_HARM_MAX*sizeof(synth_float_t*))); + for (m=0; m < BLEP_NUM_HARM_MAX; m++) { pCom->ppBLEP[m] = (synth_float_t*)SynthCheckAlloc(malloc(pCom->pTableSizes[m]*sizeof(synth_float_t))); } // Generate BLIT - for (m=0; m < BLIT_NUM_HARM_MAX; m++) + for (m=0; m < BLEP_NUM_HARM_MAX; m++) { dx = (synth_float_t)1/(pCom->pTableSizes[m]); x = -0.5; @@ -184,18 +184,18 @@ void BLIT_ModInit(blit_common_t *pCom) } /* - m = BLIT_NUM_HARM_MAX/2; - for (n=0; n < BLIT_TABLE_SIZE; n++) + m = BLEP_NUM_HARM_MAX/2; + for (n=0; n < BLEP_TABLE_SIZE; n++) { SynthDebug("BLEP[%d][%d] = %.14f\n", m, n, pCom->ppBLEP[m][n]); } - for (n=0; n < BLIT_TABLE_SIZE; n++) + for (n=0; n < BLEP_TABLE_SIZE; n++) { SynthDebug("Kaiser[%d] = %.14f\n", n, pKaiser[n]); } */ - for (m=0; m < BLIT_NUM_HARM_MAX; m++) + for (m=0; m < BLEP_NUM_HARM_MAX; m++) { free(ppKaiser[m]); } @@ -205,13 +205,13 @@ void BLIT_ModInit(blit_common_t *pCom) IP_ModInit(pCom); } -void BLIT_ModFree(blit_common_t *pCom) +void BLEP_ModFree(blep_common_t *pCom) { int m; if (pCom->ppBLEP) { - for (m=0; m < BLIT_NUM_HARM_MAX; m++) + for (m=0; m < BLEP_NUM_HARM_MAX; m++) { free(pCom->ppBLEP[m]); } @@ -220,25 +220,25 @@ void BLIT_ModFree(blit_common_t *pCom) free(pCom->pTableSizes); } -void BLIT_Init(blit_t *pObj, blit_common_t *pCom, synth_float_t fs) +void BLEP_Init(blep_t *pObj, blep_common_t *pCom, synth_float_t fs) { pObj->pCom = pCom; Noise_Init(&pCom->noise, 0x31101970); pObj->fs = fs; pObj->dutycycle = 0.5; - BLIT_Reset(pObj, 0); + BLEP_Reset(pObj, 0); pObj->bufsize = 0; - BLIT_SetBufsize(pObj, SYNTH_MAX_BUFSIZE); - BLIT_Prepare(pObj, SYNTH_MAX_BUFSIZE); + BLEP_SetBufsize(pObj, SYNTH_MAX_BUFSIZE); + BLEP_Prepare(pObj, SYNTH_MAX_BUFSIZE); } -void BLIT_Free(blit_t *pObj) +void BLEP_Free(blep_t *pObj) { - BLIT_SetBufsize(pObj, 0); + BLEP_SetBufsize(pObj, 0); } -void BLIT_SetBufsize(blit_t *pObj, UINT32 size) +void BLEP_SetBufsize(blep_t *pObj, UINT32 size) { if (pObj->bufsize == size) return; @@ -250,13 +250,13 @@ void BLIT_SetBufsize(blit_t *pObj, UINT32 size) } -void BLIT_SetFS(blit_t *pObj, synth_float_t fs) +void BLEP_SetFS(blep_t *pObj, synth_float_t fs) { pObj->fs = fs; pObj->freq_update_req = 1; } -void BLIT_Prepare(blit_t *pObj, UINT32 len) +void BLEP_Prepare(blep_t *pObj, UINT32 len) { synth_float_t pitch_buf[SYNTH_MAX_BUFSIZE]; synth_float_t out_buf[SYNTH_MAX_BUFSIZE]; @@ -265,12 +265,12 @@ void BLIT_Prepare(blit_t *pObj, UINT32 len) // Let Oscillators run with different pitches to randomize phase Add_inplace_VS(pitch_buf, 0, 8*440.0*(1+0.01*(synth_float_t)rand()/RAND_MAX), len); - BLIT_Process_SAW_Vector(pObj, pitch_buf, NULL, NULL, NULL, out_buf, len); - BLIT_Process_SQR_Vector(pObj, pitch_buf, NULL, NULL, NULL, NULL, out_buf, len); - BLIT_Process_TRI_Vector(pObj, pitch_buf, NULL, NULL, NULL, out_buf, len); + BLEP_Process_SAW_Vector(pObj, pitch_buf, NULL, NULL, NULL, out_buf, len); + BLEP_Process_SQR_Vector(pObj, pitch_buf, NULL, NULL, NULL, NULL, out_buf, len); + BLEP_Process_TRI_Vector(pObj, pitch_buf, NULL, NULL, NULL, out_buf, len); } -void BLIT_Reset(blit_t *pObj, synth_float_t phase) +void BLEP_Reset(blep_t *pObj, synth_float_t phase) { pObj->saw_x = fmod(0.5f + phase, 1); pObj->sqr_x1 = fmod(0.5f + phase, 1); @@ -284,25 +284,25 @@ void BLIT_Reset(blit_t *pObj, synth_float_t phase) pObj->pwm = 0; pObj->pulse_offset = 0; // ToDo: Adjust according to phase pObj->jitter = 0; - pObj->misc_process_downsammple_counter = BLIT_MISC_PROCESS_DOWN_SAMPLE; + pObj->misc_process_downsammple_counter = BLEP_MISC_PROCESS_DOWN_SAMPLE; } -void BLIT_Start(blit_t *pObj) +void BLEP_Start(blep_t *pObj) { pObj->freq_update_req = 1; } -void BLIT_SetDutyCycle(blit_t *pObj, synth_float_t duty_cycle) +void BLEP_SetDutyCycle(blep_t *pObj, synth_float_t duty_cycle) { pObj->dutycycle = duty_cycle; } -void BLIT_Process_SAW_Vector(blit_t *pObj, synth_float_t *pPitch, synth_float_t *pCV_fm, UINT32 *pSyncIn, UINT32 *pSyncOut, synth_float_t *pOut, UINT32 len) +void BLEP_Process_SAW_Vector(blep_t *pObj, synth_float_t *pPitch, synth_float_t *pCV_fm, UINT32 *pSyncIn, UINT32 *pSyncOut, synth_float_t *pOut, UINT32 len) { UINT32 i, is_slave, m; synth_float_t out; synth_float_t blep, n; - blit_common_t *pCom = pObj->pCom; + blep_common_t *pCom = pObj->pCom; is_slave = (pSyncIn != NULL) && (pSyncOut == NULL); @@ -312,10 +312,10 @@ void BLIT_Process_SAW_Vector(blit_t *pObj, synth_float_t *pPitch, synth_float_t // Create output for (i=0; i< len; i++) { - BLIT_process_misc(pObj); + BLEP_process_misc(pObj); if (pObj->freq_update_req) { - BLIT_freq_update(pObj, pPitch[i]); + BLEP_freq_update(pObj, pPitch[i]); } if (pObj->saw_x >= (synth_float_t)0.5) @@ -325,7 +325,7 @@ void BLIT_Process_SAW_Vector(blit_t *pObj, synth_float_t *pPitch, synth_float_t { pObj->fm = (synth_float_t)pow((synth_float_t)2, pCV_fm[i]); } - BLIT_freq_update(pObj, pPitch[i]); + BLEP_freq_update(pObj, pPitch[i]); } m = pObj->m; @@ -341,12 +341,12 @@ void BLIT_Process_SAW_Vector(blit_t *pObj, synth_float_t *pPitch, synth_float_t } } -void BLIT_Process_SQR_Vector(blit_t *pObj, synth_float_t *pPitch, synth_float_t *pCV_fm, synth_float_t *pCV_pwm, UINT32 *pSyncIn, UINT32 *pSyncOut, synth_float_t *pOut, UINT32 len) +void BLEP_Process_SQR_Vector(blep_t *pObj, synth_float_t *pPitch, synth_float_t *pCV_fm, synth_float_t *pCV_pwm, UINT32 *pSyncIn, UINT32 *pSyncOut, synth_float_t *pOut, UINT32 len) { UINT32 i, is_slave, m; synth_float_t blep1, blep2, n; synth_float_t dutycycle; - blit_common_t *pCom = pObj->pCom; + blep_common_t *pCom = pObj->pCom; is_slave = (pSyncIn != NULL) && (pSyncOut == NULL); @@ -356,10 +356,10 @@ void BLIT_Process_SQR_Vector(blit_t *pObj, synth_float_t *pPitch, synth_float_t // Create output for (i=0; i< len; i++) { - BLIT_process_misc(pObj); + BLEP_process_misc(pObj); if (pObj->freq_update_req) { - BLIT_freq_update(pObj, pPitch[i]); + BLEP_freq_update(pObj, pPitch[i]); } if (pObj->sqr_x1 >= (synth_float_t)0.5) @@ -378,7 +378,7 @@ void BLIT_Process_SQR_Vector(blit_t *pObj, synth_float_t *pPitch, synth_float_t pObj->pulse_offset = 2*(dutycycle-0.5); pObj->sqr_x2 = pObj->sqr_x1 + dutycycle - 1; pObj->sqr_pol2 = pObj->sqr_pol1; - BLIT_freq_update(pObj, pPitch[i]); + BLEP_freq_update(pObj, pPitch[i]); } while (pObj->sqr_x2 >= (synth_float_t)0.5) { @@ -412,12 +412,12 @@ void BLIT_Process_SQR_Vector(blit_t *pObj, synth_float_t *pPitch, synth_float_t } } -void BLIT_Process_TRI_Vector(blit_t *pObj, synth_float_t *pPitch, synth_float_t *pCV_fm, UINT32 *pSyncIn, UINT32 *pSyncOut, synth_float_t *pOut, UINT32 len) +void BLEP_Process_TRI_Vector(blep_t *pObj, synth_float_t *pPitch, synth_float_t *pCV_fm, UINT32 *pSyncIn, UINT32 *pSyncOut, synth_float_t *pOut, UINT32 len) { UINT32 i, is_slave, m; synth_float_t out; synth_float_t blep, n; - blit_common_t *pCom = pObj->pCom; + blep_common_t *pCom = pObj->pCom; is_slave = (pSyncIn != NULL) && (pSyncOut == NULL); @@ -426,10 +426,10 @@ void BLIT_Process_TRI_Vector(blit_t *pObj, synth_float_t *pPitch, synth_float_t for (i=0; i< len; i++) { - BLIT_process_misc(pObj); + BLEP_process_misc(pObj); if (pObj->freq_update_req) { - BLIT_freq_update(pObj, pPitch[i]); + BLEP_freq_update(pObj, pPitch[i]); } if (pObj->tri_x >= (synth_float_t)0.5) @@ -440,7 +440,7 @@ void BLIT_Process_TRI_Vector(blit_t *pObj, synth_float_t *pPitch, synth_float_t { pObj->fm = (synth_float_t)pow((synth_float_t)2, pCV_fm[i]); } - BLIT_freq_update(pObj, 2*pPitch[i]); + BLEP_freq_update(pObj, 2*pPitch[i]); } m = pObj->m; diff --git a/src/synth/blit.h b/src/synth/blep.h similarity index 56% rename from src/synth/blit.h rename to src/synth/blep.h index 1263b88..e3d6ea2 100644 --- a/src/synth/blit.h +++ b/src/synth/blep.h @@ -1,32 +1,32 @@ // -------------------------------------------------------------- // -------------------------------------------------------------- -#ifndef _BLIT_H_ -#define _BLIT_H_ +#ifndef _BLEP_H_ +#define _BLEP_H_ #include "synth_defs.h" #include "noise.h" #include "synth_types.h" -#define BLIT_MISC_PROCESS_DOWN_SAMPLE 2 -#define BLIT_JITTER_ERROR 0.0000001 +#define BLEP_MISC_PROCESS_DOWN_SAMPLE 2 +#define BLEP_JITTER_ERROR 0.0000001 // -------------------------------------------------------------- // Types // -------------------------------------------------------------- -typedef struct _sblit_common_t +typedef struct _sblep_common_t { UINT32 *pTableSizes; synth_float_t **ppBLEP; - synth_float_t N_K[(BLIT_INTEROLATION_ORDER+0)*(BLIT_INTEROLATION_ORDER+1)]; - synth_float_t K[(BLIT_INTEROLATION_ORDER+0)*(BLIT_INTEROLATION_ORDER+1)]; + synth_float_t N_K[(BLEP_INTEROLATION_ORDER+0)*(BLEP_INTEROLATION_ORDER+1)]; + synth_float_t K[(BLEP_INTEROLATION_ORDER+0)*(BLEP_INTEROLATION_ORDER+1)]; noise_gen_t noise; -} blit_common_t; +} blep_common_t; -typedef struct _sblit_t +typedef struct _sblep_t { - blit_common_t *pCom; + blep_common_t *pCom; synth_float_t fs, fm, pwm, dutycycle, pulse_offset; synth_float_t saw_x, x2, dx; synth_float_t sqr_x1, sqr_x2, tri; @@ -35,7 +35,7 @@ typedef struct _sblit_t UINT32 freq_update_req, bufsize; synth_float_t jitter; UINT32 misc_process_downsammple_counter; -} blit_t; +} blep_t; // -------------------------------------------------------------- #if defined(__cplusplus) @@ -45,19 +45,19 @@ extern "C" { // -------------------------------------------------------------- // Exported functions // -------------------------------------------------------------- -void BLIT_ModInit(blit_common_t *pCom); -void BLIT_ModFree(blit_common_t *pCom); -void BLIT_Init(blit_t *pObj, blit_common_t *pCom, synth_float_t fs); -void BLIT_Free(blit_t *pObj); -void BLIT_SetBufsize(blit_t *pObj, UINT32 size); -void BLIT_SetFS(blit_t *pObj, synth_float_t fs); -void BLIT_Reset(blit_t *pObj, synth_float_t phase); -void BLIT_Start(blit_t *pObj); -void BLIT_Prepare(blit_t *pObj, UINT32 len); -void BLIT_SetDutyCycle(blit_t *pObj, synth_float_t duty_cycle); -void BLIT_Process_SAW_Vector(blit_t *pObj, synth_float_t *pPitch, synth_float_t *pCV_fm, UINT32 *pSyncIn, UINT32 *pSyncOut, synth_float_t *pOut, UINT32 len); -void BLIT_Process_SQR_Vector(blit_t *pObj, synth_float_t *pPitch, synth_float_t *pCV_fm, synth_float_t *pCV_pwm, UINT32 *pSyncIn, UINT32 *pSyncOut, synth_float_t *pOut, UINT32 len); -void BLIT_Process_TRI_Vector(blit_t *pObj, synth_float_t *pPitch, synth_float_t *pCV_fm, UINT32 *pSyncIn, UINT32 *pSyncOut, synth_float_t *pOut, UINT32 len); +void BLEP_ModInit(blep_common_t *pCom); +void BLEP_ModFree(blep_common_t *pCom); +void BLEP_Init(blep_t *pObj, blep_common_t *pCom, synth_float_t fs); +void BLEP_Free(blep_t *pObj); +void BLEP_SetBufsize(blep_t *pObj, UINT32 size); +void BLEP_SetFS(blep_t *pObj, synth_float_t fs); +void BLEP_Reset(blep_t *pObj, synth_float_t phase); +void BLEP_Start(blep_t *pObj); +void BLEP_Prepare(blep_t *pObj, UINT32 len); +void BLEP_SetDutyCycle(blep_t *pObj, synth_float_t duty_cycle); +void BLEP_Process_SAW_Vector(blep_t *pObj, synth_float_t *pPitch, synth_float_t *pCV_fm, UINT32 *pSyncIn, UINT32 *pSyncOut, synth_float_t *pOut, UINT32 len); +void BLEP_Process_SQR_Vector(blep_t *pObj, synth_float_t *pPitch, synth_float_t *pCV_fm, synth_float_t *pCV_pwm, UINT32 *pSyncIn, UINT32 *pSyncOut, synth_float_t *pOut, UINT32 len); +void BLEP_Process_TRI_Vector(blep_t *pObj, synth_float_t *pPitch, synth_float_t *pCV_fm, UINT32 *pSyncIn, UINT32 *pSyncOut, synth_float_t *pOut, UINT32 len); #if defined(__cplusplus) } @@ -65,4 +65,4 @@ void BLIT_Process_TRI_Vector(blit_t *pObj, synth_float_t *pPitch, synth_float_t #endif // -------------------------------------------------------------- -#endif // _BLIT_H_ +#endif // _BLEP_H_ diff --git a/src/synth/config.mk b/src/synth/config.mk index cca53c4..2e35268 100644 --- a/src/synth/config.mk +++ b/src/synth/config.mk @@ -1,6 +1,6 @@ NAME := synth -GCC_SRCS := blit.c +GCC_SRCS := blep.c GCC_SRCS += env.c GCC_SRCS += lfo.c GCC_SRCS += mw_wave_data.c diff --git a/src/synth/synth_defs.h b/src/synth/synth_defs.h index c172569..78a6457 100644 --- a/src/synth/synth_defs.h +++ b/src/synth/synth_defs.h @@ -33,11 +33,11 @@ #define FILTER_TABLE_SIZE (4096) #define FILTER_INTEROLATION_ORDER 1 -#define BLIT_NUM_HARM_MAX (900) -#define BLIT_TABLE_SIZE_MIN (1024) -#define BLIT_TABLE_SIZE_MAX (4096) -#define BLIT_TABLE_OVERSAMPLING (4) -#define BLIT_INTEROLATION_ORDER (2) +#define BLEP_NUM_HARM_MAX (900) +#define BLEP_TABLE_SIZE_MIN (1024) +#define BLEP_TABLE_SIZE_MAX (4096) +#define BLEP_TABLE_OVERSAMPLING (4) +#define BLEP_INTEROLATION_ORDER (2) #define SYNTH_LIMITER_RISE_TIME 0.010 //s #define SYNTH_LIMITER_FALL_TIME 1.000 //s diff --git a/src/synth/vco.c b/src/synth/vco.c index bf17156..8d3eea5 100644 --- a/src/synth/vco.c +++ b/src/synth/vco.c @@ -4,7 +4,7 @@ #include #include "synth_defs.h" -#include "blit.h" +#include "blep.h" #include "vco.h" #include "wavetable.h" @@ -16,12 +16,12 @@ // -------------------------------------------------------------- void VCO_ModInit(vco_common_t *pCom) { - BLIT_ModInit(&pCom->blit); + BLEP_ModInit(&pCom->blep); } void VCO_ModFree(vco_common_t *pCom) { - BLIT_ModFree(&pCom->blit); + BLEP_ModFree(&pCom->blep); } void VCO_Init(osc_t *pObj, UINT32 id, vco_common_t *pCom, synth_float_t fs) @@ -42,7 +42,7 @@ void VCO_Init(osc_t *pObj, UINT32 id, vco_common_t *pCom, synth_float_t fs) pObj->param[OSC_PARAM2_WAVEFORM] = OSC_WAVEFORM_SAWTOOTH; Sine_Init(&pObj->sine, fs); - BLIT_Init(&pObj->blep, &pCom->blit, fs); + BLEP_Init(&pObj->blep, &pCom->blep, fs); WT_Init(&pObj->wt, id, &pCom->wt, fs); pObj->impulse = OSC_IMPULS_HEIGHT; } @@ -50,7 +50,7 @@ void VCO_Init(osc_t *pObj, UINT32 id, vco_common_t *pCom, synth_float_t fs) void VCO_Free(osc_t *pObj) { Sine_Free(&pObj->sine); - BLIT_Free(&pObj->blep); + BLEP_Free(&pObj->blep); WT_Free(&pObj->wt); VCO_SetBufsize(pObj, 0); @@ -65,14 +65,14 @@ void VCO_SetFS(osc_t *pObj, synth_float_t fs) { pObj->fs = fs; Sine_SetFS(&pObj->sine, fs); - BLIT_SetFS(&pObj->blep, fs); + BLEP_SetFS(&pObj->blep, fs); WT_SetFS(&pObj->wt, fs); } void VCO_SetBufsize(osc_t *pObj, UINT32 size) { - BLIT_SetBufsize(&pObj->blep, size); + BLEP_SetBufsize(&pObj->blep, size); if (pObj->bufsize == size) return; @@ -94,7 +94,7 @@ void VCO_SetBufsize(osc_t *pObj, UINT32 size) void VCO_Reset(osc_t *pObj, synth_float_t phase) { Sine_Reset(&pObj->sine, phase); - BLIT_Reset(&pObj->blep, phase); + BLEP_Reset(&pObj->blep, phase); WT_Reset(&pObj->wt, phase); pObj->impulse = OSC_IMPULS_HEIGHT; } @@ -102,7 +102,7 @@ void VCO_Reset(osc_t *pObj, synth_float_t phase) void VCO_Start(osc_t *pObj) { Sine_Start(&pObj->sine); - BLIT_Start(&pObj->blep); + BLEP_Start(&pObj->blep); WT_Start(&pObj->wt); } @@ -124,13 +124,13 @@ void VCO_Param2Set(osc_t *pObj, UINT32 type, synth_float_t value) WT_Param2Set(&pObj->wt, WT_PARAM2_WAVETABLE_ID, wt_table); } Sine_Prepare(&pObj->sine); - BLIT_Prepare(&pObj->blep, 1024); + BLEP_Prepare(&pObj->blep, 1024); WT_Prepare(&pObj->wt); break; case OSC_PARAM2_DUTYCYCLE: pObj->param[type] = value; - BLIT_SetDutyCycle(&pObj->blep, value); + BLEP_SetDutyCycle(&pObj->blep, value); WT_Param2Set(&pObj->wt, WT_PARAM2_WAVETABLE_ENTRY, value); break; @@ -155,17 +155,17 @@ void VCO_ProcessDataV(osc_t *pObj, synth_float_t *pPitch, synth_float_t *pCV_fm, // Create output if (pObj->param[OSC_PARAM2_WAVEFORM] == OSC_WAVEFORM_SAWTOOTH) { - BLIT_Process_SAW_Vector(&pObj->blep, pPitch, pCV_fm, pSyncIn, pSyncOut, pObj->pOut, len); + BLEP_Process_SAW_Vector(&pObj->blep, pPitch, pCV_fm, pSyncIn, pSyncOut, pObj->pOut, len); } if (pObj->param[OSC_PARAM2_WAVEFORM] == OSC_WAVEFORM_SQUARE) { - BLIT_Process_SQR_Vector(&pObj->blep, pPitch, pCV_fm, pCV_pwm, pSyncIn, pSyncOut, pObj->pOut, len); + BLEP_Process_SQR_Vector(&pObj->blep, pPitch, pCV_fm, pCV_pwm, pSyncIn, pSyncOut, pObj->pOut, len); } if (pObj->param[OSC_PARAM2_WAVEFORM] == OSC_WAVEFORM_TRIANGLE) { - BLIT_Process_TRI_Vector(&pObj->blep, pPitch, pCV_fm, pSyncIn, pSyncOut, pObj->pOut, len); + BLEP_Process_TRI_Vector(&pObj->blep, pPitch, pCV_fm, pSyncIn, pSyncOut, pObj->pOut, len); } if (pObj->param[OSC_PARAM2_WAVEFORM] == OSC_WAVEFORM_SINE) diff --git a/src/synth/vco.h b/src/synth/vco.h index 5bbbcf3..4260495 100644 --- a/src/synth/vco.h +++ b/src/synth/vco.h @@ -5,7 +5,7 @@ #include "synth_types.h" #include "sine.h" -#include "blit.h" +#include "blep.h" #include "wavetable.h" #define OSC_RECALC_THRESH 0.001f @@ -34,7 +34,7 @@ enum typedef struct _svco_common_t { - blit_common_t blit; + blep_common_t blep; wt_common_t wt; } vco_common_t; @@ -45,7 +45,7 @@ typedef struct _sosc_t vco_common_t *pCom; synth_float_t param[OSC_NUM_PARAMS]; synth_float_t fs; - blit_t blep; + blep_t blep; wt_t wt; UINT32 bufsize; synth_float_t *pOut;