Engine (sequencer, mixer, FX chains, MIDI effects) renders four whole songs like AudioEngine.kt (two bit-exact, two within 9e-6). ProjectIo / SngFormat / PresetIo round-trip the Kotlin-written files; Float.toString is JDK 17's, checked on all 2^32 floats. Params now holds 255-character values (sample ids were cut). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
46 lines
1.6 KiB
C++
46 lines
1.6 KiB
C++
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
#pragma once
|
|
|
|
#include <cstdlib>
|
|
#include <cstring>
|
|
#include "sizzle/Specs.hpp"
|
|
|
|
namespace sizzle {
|
|
|
|
/**
|
|
* A device's settings, the C++ twin of ToolboxSlot's string map: every value is
|
|
* kept as text so `f()` / `s()` read exactly what the Kotlin `slot.float()` /
|
|
* `slot.string()` would. Fixed capacity, no allocation: safe to read from
|
|
* `Effect::update` on the audio thread. Keys are stored by copy, so values can
|
|
* come from a file (tests), a preset, or AU parameters.
|
|
*/
|
|
class Params {
|
|
public:
|
|
static constexpr int kMax = 128;
|
|
static constexpr int kKeyLen = 32;
|
|
static constexpr int kValLen = 256; // sample ids and file paths
|
|
|
|
/** All of [spec]'s defaults, like ToolboxSlot.fill(). */
|
|
void fill(const DeviceSpec &spec);
|
|
void set(const char *key, const char *value);
|
|
void set(const char *key, float value);
|
|
/** Number as Kotlin's String.toFloat would parse it, else [fallback]. */
|
|
float f(const char *key, float fallback = 0.f) const;
|
|
/** The stored text (enum choice name), else [fallback]. */
|
|
const char *s(const char *key, const char *fallback = "") const;
|
|
bool has(const char *key) const { return find(key) >= 0; }
|
|
/** Stored entries in insertion order (for saving state). */
|
|
int size() const { return n_; }
|
|
const char *keyAt(int i) const { return keys_[i]; }
|
|
const char *valueAt(int i) const { return vals_[i]; }
|
|
|
|
private:
|
|
int find(const char *key) const;
|
|
char keys_[kMax][kKeyLen] = {};
|
|
char vals_[kMax][kValLen] = {};
|
|
int n_ = 0;
|
|
};
|
|
|
|
} // namespace sizzle
|