Skip to content

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

Result of a kit load operation.

FieldTypeDescription
successbool
errorstd::stringEmpty on success, describes failure otherwise.
padsLoadedintNumber of pads with valid sample references.

Declared in crosspad/kit/IKitManager.hpp:10.

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

MemberDescription
getKitCount
getKit
getCurrentKit
getCurrentKitId
setCurrentKitId
isLoading
listKitsScan rootDir for kit directories containing kit.json (or <dirname>.json).
scanKitsSame scan, no copy: rebuilds the list read back through getKitCount() and getKit().
loadKitFull-parse a kit: read JSON, parse metadata + pads array.
saveKitSerialize kit metadata + pads back to JSON on disk.
addKitTake 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.
saveKitInfoWhat a kit says about itself its name, who made it, what it is and the tempo it counts back into its own JSON.
removeKitThe kit at id gone: its JSON, the folder it had to itself with whatever it kept in there, and its place in the list.
releaseRetiredKitFree the sample payload of the kit that stopped being current at the last loadKit(), if any.

Methods

virtual int getKitCount() const =0
virtual KitInfo * getKit(int id) = 0
virtual KitInfo * getCurrentKit() = 0

Used in Play a sample.

virtual int getCurrentKitId() const =0
virtual void setCurrentKitId(int id) = 0
virtual bool isLoading() const =0
virtual std::vector< KitInfo > listKits(const std::string &rootDir) = 0

Scan rootDir for kit directories containing kit.json (or <dirname>.json).

Returns metadata-only KitInfo entries (pads NOT parsed).

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.

virtual KitLoadResult loadKit(KitInfo &kit) = 0

Full-parse a kit: read JSON, parse metadata + pads array.

kit.path must already be set before calling.

virtual bool saveKit(const KitInfo &kit) = 0

Serialize kit metadata + pads back to JSON on disk.

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.

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.

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.

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.