Files
sizzletracker-android/ios/core/include/sizzle/Params.hpp
T
ReactorcoremeltdownandClaude Opus 5.5 dcf85ba915 iOS 0.1.0: the eight audio effects as AUv3 plugins on a C++ core
C++ ports of the Kotlin effects, checked against audio the Kotlin code renders
(25 scenarios, IosGoldenExport); an Objective-C++ AUv3 wrapper checked on the
Mac against the core (parameters, presets, saved state); a container app that
checks each plugin on the device. Built as a TrollStore .ipa.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 20:47:06 +01:00

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 = 96;
static constexpr int kKeyLen = 24;
static constexpr int kValLen = 32;
/** 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