SM-26 synthesizer: initial implementation

This commit is contained in:
SM-26 2026-09-11 16:38:28 +02:00
commit 8734ac25f1
18 changed files with 2619 additions and 0 deletions

71
Source/SynthParams.h Normal file
View file

@ -0,0 +1,71 @@
#pragma once
#include <JuceHeader.h>
#include <array>
namespace sm26 {
enum ParamId : int {
PO1WAVE = 0, PO2WAVE, PO1OCT, PO1CT, PO2OCT, PO2CT,
PMIX, PNOISE, PCUTOFF, PRES, PFENV, PFTYPE,
PATK, PDEC, PSUS, PREL,
PDTIME, PDSTEPS, PDSYNC, PDFB, PDMIX,
PDRIVE, PGLIDE, PMASTER,
kNumParams
};
static constexpr int kNumKnobs = 4;
struct ControlDef {
const char* name;
int param = 0;
float lo = 0.0f;
float hi = 1.0f;
};
struct Preset {
const char* name;
const char* category;
std::array<float, kNumParams> base;
std::array<ControlDef, kNumKnobs> ctl;
};
inline std::array<float, kNumParams> defaultParams()
{
std::array<float, kNumParams> d{};
d[PO1WAVE] = 0.0f; d[PO2WAVE] = 0.0f;
d[PO1OCT] = 0.50f; d[PO1CT] = 0.50f;
d[PO2OCT] = 0.50f; d[PO2CT] = 0.54f;
d[PMIX] = 0.18f; d[PNOISE] = 0.02f;
d[PCUTOFF] = 0.68f; d[PRES] = 0.22f;
d[PFENV] = 0.38f; d[PFTYPE] = 0.0f;
d[PATK] = 0.12f; d[PDEC] = 0.48f;
d[PSUS] = 0.50f; d[PREL] = 0.55f;
d[PDTIME] = 0.30f; d[PDSTEPS]= 6.0f;
d[PDSYNC] = 1.0f; d[PDFB] = 0.42f;
d[PDMIX] = 0.42f; d[PDRIVE] = 0.16f;
d[PGLIDE] = 0.0f; d[PMASTER]= 0.70f;
return d;
}
const char* paramShortName(int id);
const char* paramUnit(int id);
float paramReal(int id, float n01);
inline float clamp01(float v) { return v < 0.f ? 0.f : (v > 1.f ? 1.f : v); }
int paramFilterType(float n01);
String formatParamReal(int id, float n01);
int paramWaveIndex(float n01);
float unwrapParameter(int id, float n01);
String formatTimeMs(float ms);
String formatFreq(float hz);
String formatPercent(float v);
const char* waveName(int w);
const char* const* stepsLabels();
const float* stepsBeats();
int stepsPerBeatFor(float stepIndex);
} // namespace sm26