Files
sizzletracker-android/core/include/sizzle/Params.hpp
T
ReactorcoremeltdownandClaude Opus 5.5 6688718bed 0.39.0 (73): export and import MIDI mappings as .szm text (Android and iOS)
- SIZZLE-MIDIMAP 1 format: TYPE, NAME, one parameter=CC line each
- core/src/io/MidiMapIo (iOS) and io/MidiMapIo.kt (Android), tested on one
  shared fixture (midimap_test, MidiMapIoTest)
- EXPORT / IMPORT in each device's MIDI learn panel on both platforms
- Params::remove; iOS clears a mapping by removing it
- ios/Makefile regenerates the Xcode project when source folders change

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 16:31:46 +01:00

48 lines
1.7 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);
/** Drop [key] (Kotlin's values.remove); the others keep their order. */
void remove(const char *key);
/** 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