Files
dusk/src/dusk/rpg/cutscene/item/audio/cutsceneaudiosetloop.h
T
YourWishesandClaude Sonnet 5 083deb8357 Move cutscene item type enum and authoring macros to their own headers
cutsceneitemtype_t moves from cutsceneitem.h into cutsceneitembase.h,
alongside a new CUTSCENE_ITEM(TYPE, UNION_NAME, ...) shorthand that
fills in a cutsceneitem_t literal's .type and union member together.

Every CUTSCENE_* authoring macro (CUTSCENE_WAIT, CUTSCENE_TEXT,
CUTSCENE_AUDIO_PLAY, etc.) moves out of the single, ever-growing
cutscene.h into the header of the item type it actually authors,
built on top of CUTSCENE_ITEM. cutscene.h now only holds cutscene_t
itself plus the CUTSCENE/CUTSCENE_REFERENCE/CUTSCENE_CUTSCENE macros,
which aren't tied to any one item type. Every relocated macro also
gained a proper JSDoc-style comment block with @param tags.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
2026-09-12 22:30:23 -05:00

80 lines
2.1 KiB
C

/**
* Copyright (c) 2026 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "audio/mixer/audiomixerchannel.h"
#include "rpg/cutscene/item/cutsceneitembase.h"
typedef struct {
audiomixerchannel_t channel;
bool_t looping;
uint8_t loopCount;
float_t loopStart;
float_t loopTo;
} cutsceneaudiosetloop_t;
/**
* Applies new looping behaviour immediately, via audioMixerSetLoop().
*
* @param CHANNEL audiomixerchannel_t to adjust.
* @param LOOPING Whether the clip loops.
* @param LOOP_COUNT Number of loop repeats (0 = infinite, if LOOPING).
* @param LOOP_START Loop region start in seconds, or -1.0f for the clip
* start.
* @param LOOP_TO Loop region end/return point in seconds.
*/
#define CUTSCENE_AUDIO_SET_LOOP( \
CHANNEL, LOOPING, LOOP_COUNT, LOOP_START, LOOP_TO \
) \
CUTSCENE_ITEM(CUTSCENE_ITEM_TYPE_AUDIO_SET_LOOP, audioSetLoop, { \
.channel = CHANNEL, \
.looping = LOOPING, \
.loopCount = LOOP_COUNT, \
.loopStart = LOOP_START, \
.loopTo = LOOP_TO \
})
/**
* Starts an audio set-loop step (applies the new looping behaviour
* immediately, via audioMixerSetLoop()).
*
* @param item The cutscene item.
* @param data Runtime data storage.
*/
void cutsceneAudioSetLoopStart(
const cutsceneitem_t *item,
cutsceneitemdata_t *data
);
/**
* Updates an audio set-loop step (always completes immediately).
*
* @param item The cutscene item.
* @param data Runtime data storage.
* @returns true always.
*/
bool_t cutsceneAudioSetLoopUpdate(
const cutsceneitem_t *item,
cutsceneitemdata_t *data
);
/**
* Parses an AUDIO_SET_LOOP cutscene item's JSON fields into item.
*
* @param itemObj The item's JSON object.
* @param item Destination item, already zeroed by the caller.
* @param pool Unused (AUDIO_SET_LOOP needs no pool storage).
* @param poolOffset Unused (AUDIO_SET_LOOP needs no pool storage).
* @return Error code indicating success or failure of the parse.
*/
errorret_t cutsceneAudioSetLoopLoad(
yyjson_val *itemObj,
cutsceneitem_t *item,
uint8_t *pool,
size_t *poolOffset
);