Extract standalone Playground SDK source foundation

This commit is contained in:
CRTkafa 2026-10-02 23:54:36 +07:00
commit 34ac58b9a2
3567 changed files with 1657902 additions and 0 deletions

43
audio/cadi_bank.h Normal file
View file

@ -0,0 +1,43 @@
#pragma once
#include "core/inflate.h"
#include <cstdint>
#include <span>
#include <string>
#include <string_view>
#include <optional>
#include <unordered_map>
#include <vector>
namespace playground {
enum class CadiKind { OggVorbis, Xml };
enum class CadiChannel { Sfx, Music, Environment };
struct CadiEventInfo {
std::vector<size_t> clips;
CadiChannel channel = CadiChannel::Sfx;
bool loop = false;
};
struct CadiRecord {
uint32_t token = 0; // opaque bank index value
uint32_t offset = 0;
uint32_t size = 0;
CadiKind kind = CadiKind::OggVorbis;
};
// Read-only parser for a caller-supplied CADI audio bank.
class CadiBank {
public:
bool load(Bytes bytes, std::string* error = nullptr);
const std::vector<CadiRecord>& records() const { return records_; }
std::span<const uint8_t> data(size_t index) const;
std::optional<size_t> clipForEvent(std::string_view event) const;
std::vector<size_t> clipsForEvent(std::string_view event) const;
std::optional<CadiEventInfo> eventInfo(std::string_view event) const;
size_t mappedEventCount() const { return eventClips_.size(); }
private:
Bytes bytes_;
std::vector<CadiRecord> records_;
std::unordered_map<std::string,CadiEventInfo> eventClips_;
};
} // namespace playground