2024-12-01 19:35:24 +00:00
|
|
|
//| Copyright: (C) 2020-2024 Kevin Larke <contact AT larke DOT org>
|
|
|
|
//| License: GNU GPL version 3.0 or above. See the accompanying LICENSE file.
|
2021-11-06 02:26:55 +00:00
|
|
|
#ifndef cwPresetSel_h
|
|
|
|
#define cwPresetSel_h
|
|
|
|
|
|
|
|
|
|
|
|
namespace cw
|
|
|
|
{
|
|
|
|
namespace preset_sel
|
|
|
|
{
|
|
|
|
typedef handle< struct preset_sel_str > handle_t;
|
|
|
|
|
|
|
|
typedef struct preset_str
|
|
|
|
{
|
|
|
|
bool playFl; // play this preset
|
2022-05-21 15:22:22 +00:00
|
|
|
bool seqFl; // play this preset during sequencing.
|
2021-11-06 02:26:55 +00:00
|
|
|
unsigned preset_idx; // preset index into preset_labelA[].
|
2024-01-06 13:43:42 +00:00
|
|
|
unsigned order; // selection label
|
2024-01-13 15:12:49 +00:00
|
|
|
char* alt_str; // 'alt' label
|
2021-11-06 02:26:55 +00:00
|
|
|
} preset_t;
|
|
|
|
|
|
|
|
typedef struct frag_str
|
|
|
|
{
|
2021-12-26 03:17:10 +00:00
|
|
|
unsigned fragId; // Unique fragment id
|
|
|
|
unsigned guiUuId; // GUI UUId associated with this fragment
|
2021-12-12 21:46:12 +00:00
|
|
|
unsigned endLoc; // The endLoc is included in this fragment. The begin loc is f->prev->endLoc+1
|
|
|
|
time::spec_t endTimestamp;
|
2021-11-06 02:26:55 +00:00
|
|
|
|
2021-12-28 01:29:37 +00:00
|
|
|
double igain;
|
|
|
|
double ogain;
|
2021-11-06 02:26:55 +00:00
|
|
|
double wetDryGain;
|
|
|
|
double fadeOutMs;
|
2021-12-28 01:29:37 +00:00
|
|
|
unsigned begPlayLoc;
|
|
|
|
unsigned endPlayLoc;
|
|
|
|
char* note;
|
2021-11-06 02:26:55 +00:00
|
|
|
|
2024-05-04 22:22:07 +00:00
|
|
|
bool dryOnlyFl; // there is one active preset and it is dry
|
|
|
|
bool drySelectedFl; // the dry preset was selected ('playFl' is set)
|
|
|
|
|
2023-12-03 16:20:38 +00:00
|
|
|
preset_t* presetA; // presetA[ presetN ] - status of each preset
|
2021-11-06 02:26:55 +00:00
|
|
|
unsigned presetN;
|
2021-11-14 17:00:17 +00:00
|
|
|
|
2024-04-29 13:47:35 +00:00
|
|
|
// altPresetIdxA[ alt_count() ] selected preset idx for each alt.
|
|
|
|
unsigned* altPresetIdxA;
|
2023-12-03 16:20:38 +00:00
|
|
|
|
2021-11-14 17:00:17 +00:00
|
|
|
bool uiSelectFl;
|
2022-05-21 15:22:22 +00:00
|
|
|
bool seqAllFl; // Set if all preset.seqFl's should be treated as though they are set to true.
|
2021-11-14 17:00:17 +00:00
|
|
|
|
2021-11-06 02:26:55 +00:00
|
|
|
struct frag_str* link;
|
2021-12-12 21:46:12 +00:00
|
|
|
struct frag_str* prev;
|
2021-11-06 02:26:55 +00:00
|
|
|
} frag_t;
|
|
|
|
|
|
|
|
enum {
|
2021-12-26 03:17:10 +00:00
|
|
|
kGuiUuIdVarId,
|
|
|
|
kBegLocVarId,
|
2021-11-06 02:26:55 +00:00
|
|
|
kEndLocVarId,
|
2021-12-28 01:29:37 +00:00
|
|
|
kInGainVarId,
|
|
|
|
kOutGainVarId,
|
2021-11-06 02:26:55 +00:00
|
|
|
kFadeOutMsVarId,
|
|
|
|
kWetGainVarId,
|
2021-12-28 01:29:37 +00:00
|
|
|
kBegPlayLocVarId,
|
|
|
|
kEndPlayLocVarId,
|
|
|
|
kPlayBtnVarId,
|
2022-05-21 15:22:22 +00:00
|
|
|
kPlaySeqBtnVarId,
|
|
|
|
kPlaySeqAllBtnVarId,
|
2021-12-28 01:29:37 +00:00
|
|
|
kNoteVarId,
|
2021-11-06 02:26:55 +00:00
|
|
|
|
2023-12-03 16:20:38 +00:00
|
|
|
kPresetOrderVarId, // preset order number
|
|
|
|
kPresetAltVarId, // preset alternative string
|
|
|
|
kPresetSelectVarId, // select a preset to play (play flag)
|
|
|
|
kPresetSeqSelectVarId, // sequence preset selections to play (seq flag)
|
2022-01-03 01:24:58 +00:00
|
|
|
|
|
|
|
kBaseMasterVarId, // All 'master' variables have id's greater than kBaseMasterVarId
|
|
|
|
kMasterWetInGainVarId,
|
|
|
|
kMasterWetOutGainVarId,
|
|
|
|
kMasterDryGainVarId,
|
|
|
|
kMasterSyncDelayMsVarId
|
2021-11-06 02:26:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
rc_t create( handle_t& hRef, const object_t* cfg );
|
|
|
|
rc_t destroy( handle_t& hRef );
|
|
|
|
|
|
|
|
unsigned preset_count( handle_t h );
|
|
|
|
const char* preset_label( handle_t h, unsigned preset_idx );
|
2023-12-03 16:20:38 +00:00
|
|
|
|
2024-03-09 20:12:56 +00:00
|
|
|
// Return preset_order[ preset_count() ] w/ all order's = 1
|
|
|
|
const flow::preset_order_t* preset_order_array( handle_t h );
|
|
|
|
|
2023-12-03 16:20:38 +00:00
|
|
|
// Count/label of alternatives (alt_idx==0 is 'no alternative selected)
|
|
|
|
unsigned alt_count( handle_t h );
|
|
|
|
const char* alt_label( handle_t h, unsigned alt_idx );
|
2023-12-05 20:34:25 +00:00
|
|
|
|
|
|
|
void get_loc_range( handle_t h, unsigned& minLocRef, unsigned& maxLocRef );
|
2023-12-03 16:20:38 +00:00
|
|
|
|
2021-12-12 21:46:12 +00:00
|
|
|
unsigned fragment_count( handle_t h );
|
2021-11-06 02:26:55 +00:00
|
|
|
const frag_t* get_fragment_base( handle_t h );
|
2021-12-12 21:46:12 +00:00
|
|
|
const frag_t* get_fragment( handle_t h, unsigned fragId );
|
2021-12-26 03:17:10 +00:00
|
|
|
const frag_t* gui_id_to_fragment(handle_t h, unsigned guiUuId );
|
2021-12-30 02:45:19 +00:00
|
|
|
|
|
|
|
unsigned frag_to_gui_id( handle_t h, unsigned fragId, bool showErrorFl=true );
|
|
|
|
unsigned gui_to_frag_id( handle_t h, unsigned guiUuId, bool showErrorFl=true );
|
2024-05-11 16:10:43 +00:00
|
|
|
unsigned loc_to_gui_id( handle_t h, unsigned loc );
|
2021-11-14 17:00:17 +00:00
|
|
|
|
2021-12-26 03:17:10 +00:00
|
|
|
rc_t create_fragment( handle_t h, unsigned end_loc, time::spec_t endTimestamp, unsigned& fragIdRef );
|
2021-11-06 02:26:55 +00:00
|
|
|
rc_t delete_fragment( handle_t h, unsigned fragId );
|
|
|
|
|
2022-12-12 17:26:26 +00:00
|
|
|
bool is_fragment_end_loc( handle_t h, unsigned loc );
|
2022-01-22 14:43:52 +00:00
|
|
|
|
2023-12-03 16:20:38 +00:00
|
|
|
rc_t set_alternative( handle_t h, unsigned alt_idx );
|
|
|
|
|
2022-01-22 14:43:52 +00:00
|
|
|
// Return the fragment id of the 'selected' fragment.
|
2021-11-14 17:00:17 +00:00
|
|
|
unsigned ui_select_fragment_id( handle_t h );
|
2022-01-22 14:43:52 +00:00
|
|
|
|
|
|
|
// Set the 'select_flag' on this fragment and remove it from all others.
|
2021-12-12 21:46:12 +00:00
|
|
|
void ui_select_fragment( handle_t h, unsigned fragId, bool selectFl );
|
2021-11-14 17:00:17 +00:00
|
|
|
|
|
|
|
|
2021-11-06 02:26:55 +00:00
|
|
|
rc_t set_value( handle_t h, unsigned fragId, unsigned varId, unsigned presetId, bool value );
|
|
|
|
rc_t set_value( handle_t h, unsigned fragId, unsigned varId, unsigned presetId, unsigned value );
|
|
|
|
rc_t set_value( handle_t h, unsigned fragId, unsigned varId, unsigned presetId, double value );
|
2021-12-28 01:29:37 +00:00
|
|
|
rc_t set_value( handle_t h, unsigned fragId, unsigned varId, unsigned presetId, const char* value );
|
2021-11-06 02:26:55 +00:00
|
|
|
|
2021-12-28 01:29:37 +00:00
|
|
|
rc_t get_value( handle_t h, unsigned fragId, unsigned varId, unsigned presetId, bool& valueRef );
|
|
|
|
rc_t get_value( handle_t h, unsigned fragId, unsigned varId, unsigned presetId, unsigned& valueRef );
|
|
|
|
rc_t get_value( handle_t h, unsigned fragId, unsigned varId, unsigned presetId, double& valueRef );
|
|
|
|
rc_t get_value( handle_t h, unsigned fragId, unsigned varId, unsigned presetId, const char*& valueRef );
|
2021-12-12 21:46:12 +00:00
|
|
|
|
|
|
|
// Call this function to determine which fragment the timestamp 'ts' is contained by.
|
2021-12-28 01:29:37 +00:00
|
|
|
// This function is optimized to be called in time sensitive functions where 'ts' is expected to be increasing.
|
2021-12-12 21:46:12 +00:00
|
|
|
// If 'ts' is past the last defined fragment then the last fragment is returned.
|
|
|
|
// If no fragments are defined 'frag_Ref' is set to nullptr.
|
|
|
|
// The return value is true when the value of frag_Ref changes from the previous call.
|
2022-05-06 20:06:24 +00:00
|
|
|
void track_timestamp_reset( handle_t h );
|
2021-12-12 21:46:12 +00:00
|
|
|
bool track_timestamp( handle_t h, const time::spec_t& ts, const cw::preset_sel::frag_t*& frag_Ref );
|
|
|
|
|
2022-10-15 13:24:53 +00:00
|
|
|
// Same as track_timestamp_???() but tracks the score 'loc' instead of timestamp.
|
2022-10-01 22:52:12 +00:00
|
|
|
void track_loc_reset( handle_t h );
|
|
|
|
bool track_loc( handle_t h, unsigned loc, const cw::preset_sel::frag_t*& frag_Ref );
|
|
|
|
|
2021-12-12 21:46:12 +00:00
|
|
|
// Return the preset index marked to play on this fragment.
|
2023-01-21 16:49:07 +00:00
|
|
|
unsigned fragment_play_preset_index( handle_t h, const frag_t* frag, unsigned preset_seq_idx=kInvalidIdx );
|
2022-05-21 15:22:22 +00:00
|
|
|
|
|
|
|
// Return the count of presets whose 'seqFl' is set.
|
|
|
|
unsigned fragment_seq_count( handle_t h, unsigned fragId );
|
2024-04-29 13:47:35 +00:00
|
|
|
|
2024-05-04 14:27:51 +00:00
|
|
|
enum {
|
2024-05-04 22:22:07 +00:00
|
|
|
kAllActiveFl = 0x01,
|
|
|
|
kDryPriorityFl = 0x02,
|
|
|
|
kDrySelectedFl = 0x04
|
2024-05-04 14:27:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const flow::preset_order_t* fragment_active_presets( handle_t h, const frag_t* f, unsigned flags, unsigned& count_ref );
|
2021-11-06 02:26:55 +00:00
|
|
|
|
|
|
|
rc_t write( handle_t h, const char* fn );
|
|
|
|
rc_t read( handle_t h, const char* fn );
|
2021-12-12 21:46:12 +00:00
|
|
|
rc_t report( handle_t h );
|
2023-11-26 20:27:29 +00:00
|
|
|
rc_t report_presets( handle_t h );
|
2023-09-13 00:28:29 +00:00
|
|
|
|
|
|
|
rc_t translate_frags( const object_t* obj );
|
2021-11-06 02:26:55 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|