IKitManager
#include "crosspad/kit/IKitManager.hpp"Generated from crosspad/kit/IKitManager.hpp in crosspad-core. Edit the header’s doxygen comments to change this page.
Recipes that use it: Play a sample
crosspad::KitLoadResult
Section titled “crosspad::KitLoadResult”Result of a kit load operation.
| Field | Type | Description |
|---|---|---|
success | bool | |
error | std::string | Empty on success, describes failure otherwise. |
padsLoaded | int | Number of pads with valid sample references. |
Declared in crosspad/kit/IKitManager.hpp:10.
crosspad::IKitManager
Section titled “crosspad::IKitManager”Abstract interface for kit management and persistence.
Provides platform-independent kit enumeration, selection, discovery, loading, and saving. Platform implementations handle storage (SD card, filesystem, etc.) and audio engine integration.
Used in Play a sample.
Members
| Member | Description |
|---|---|
getKitCount | |
getKit | |
getCurrentKit | |
getCurrentKitId | |
setCurrentKitId | |
isLoading | |
listKits | Scan rootDir for kit directories containing kit.json (or <dirname>.json). |
scanKits | Same scan, no copy: rebuilds the list read back through getKitCount() and getKit(). |
loadKit | Full-parse a kit: read JSON, parse metadata + pads array. |
saveKit | Serialize kit metadata + pads back to JSON on disk. |
addKit | Take a kit.json written since the last scan into the list, so it is there without a restart; its id, or -1 when the list is full or the file will not parse. |
saveKitInfo | What a kit says about itself its name, who made it, what it is and the tempo it counts back into its own JSON. |
removeKit | The kit at id gone: its JSON, the folder it had to itself with whatever it kept in there, and its place in the list. |
releaseRetiredKit | Free the sample payload of the kit that stopped being current at the last loadKit(), if any. |
Methods
getKitCount
Section titled “getKitCount”virtual int getKitCount() const =0getKit
Section titled “getKit”virtual KitInfo * getKit(int id) = 0getCurrentKit
Section titled “getCurrentKit”virtual KitInfo * getCurrentKit() = 0Used in Play a sample.
getCurrentKitId
Section titled “getCurrentKitId”virtual int getCurrentKitId() const =0setCurrentKitId
Section titled “setCurrentKitId”virtual void setCurrentKitId(int id) = 0isLoading
Section titled “isLoading”virtual bool isLoading() const =0listKits
Section titled “listKits”virtual std::vector< KitInfo > listKits(const std::string &rootDir) = 0Scan rootDir for kit directories containing kit.json (or <dirname>.json).
Returns metadata-only KitInfo entries (pads NOT parsed).
scanKits
Section titled “scanKits”virtual void scanKits(const std::string &rootDir)Same scan, no copy: rebuilds the list read back through getKitCount() and getKit().
Use it when the caller only wants the card scanned: it avoids copying every KitInfo, which matters on a card with many kits.
loadKit
Section titled “loadKit”virtual KitLoadResult loadKit(KitInfo &kit) = 0Full-parse a kit: read JSON, parse metadata + pads array.
kit.path must already be set before calling.
saveKit
Section titled “saveKit”virtual bool saveKit(const KitInfo &kit) = 0Serialize kit metadata + pads back to JSON on disk.
addKit
Section titled “addKit”virtual int addKit(const std::string &kitJsonPath)Take a kit.json written since the last scan into the list, so it is there without a restart; its id, or -1 when the list is full or the file will not parse.
A path already in the list returns its id. Whoever wrote the file calls this the Slicer does, and so does the browser when it makes an empty kit.
saveKitInfo
Section titled “saveKitInfo”virtual bool saveKitInfo(int id, const KitInfo &meta)What a kit says about itself its name, who made it, what it is and the tempo it counts back into its own JSON.
Only those four fields are taken from meta.
Not saveKit(): that serialises the KitInfo it is handed, pads and all, and a kit that has only been listed has no pad data. Here the file is read first and its pads are written back exactly as they were.
removeKit
Section titled “removeKit”virtual bool removeKit(int id)The kit at id gone: its JSON, the folder it had to itself with whatever it kept in there, and its place in the list.
Refuses the kit that is current that one is playing and refuses a folder another listed kit lives under, which is the kits root or a pack and would take their kits with it.
The entry is blanked rather than erased: a KitInfo* handed out by getKit() stays valid and no id shifts under code that cached one (see releaseRetiredKit() for what reads a kit across a card read). A blanked entry has an empty path, getKitCount() still counts it, and the next scan is simply without it so anything walking the list skips a kit whose path is empty.
releaseRetiredKit
Section titled “releaseRetiredKit”virtual void releaseRetiredKit()Free the sample payload of the kit that stopped being current at the last loadKit(), if any.
Deliberately not done inside loadKit(). A KitInfo* handed out by getCurrentKit() stays valid, but its pads[].samples vectors are freed by this call — and the GUI holds such a pointer across blocking reads, because drawing a waveform goes to the SD card. Call this from the same thread that reads kit pad data: then it can only run between callbacks, never inside one.
Default is a no-op — an implementation that keeps every kit parsed has nothing to retire.
Declared in crosspad/kit/IKitManager.hpp:23.