cwPresetSel.cpp : Added preset selection for playing sequences of presets.
This commit is contained in:
parent
4fb7d26c48
commit
9c0f34e8a5
@ -234,7 +234,11 @@ namespace cw
|
|||||||
case kPresetSelectVarId:
|
case kPresetSelectVarId:
|
||||||
for(unsigned i=0; i<f->presetN; ++i)
|
for(unsigned i=0; i<f->presetN; ++i)
|
||||||
f->presetA[i].playFl = f->presetA[i].preset_idx == presetId ? value : false;
|
f->presetA[i].playFl = f->presetA[i].preset_idx == presetId ? value : false;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case kPresetSeqSelectVarId:
|
||||||
|
if((rc = _validate_preset_id(f, presetId )) == kOkRC )
|
||||||
|
f->presetA[ presetId ].seqFl = value;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kPresetOrderVarId:
|
case kPresetOrderVarId:
|
||||||
@ -269,6 +273,14 @@ namespace cw
|
|||||||
case kPlayBtnVarId:
|
case kPlayBtnVarId:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case kPlaySeqBtnVarId:
|
||||||
|
f->seqAllFl = false;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case kPlaySeqAllBtnVarId:
|
||||||
|
f->seqAllFl = true;
|
||||||
|
break;
|
||||||
|
|
||||||
case kMasterWetInGainVarId:
|
case kMasterWetInGainVarId:
|
||||||
p->master_wet_in_gain = value;
|
p->master_wet_in_gain = value;
|
||||||
break;
|
break;
|
||||||
@ -329,6 +341,11 @@ namespace cw
|
|||||||
valueRef = f->presetA[ presetId ].playFl;
|
valueRef = f->presetA[ presetId ].playFl;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case kPresetSeqSelectVarId:
|
||||||
|
if((rc = _validate_preset_id(f, presetId )) == kOkRC )
|
||||||
|
valueRef = f->presetA[ presetId ].seqFl;
|
||||||
|
break;
|
||||||
|
|
||||||
case kPresetOrderVarId:
|
case kPresetOrderVarId:
|
||||||
if((rc = _validate_preset_id(f, presetId )) == kOkRC )
|
if((rc = _validate_preset_id(f, presetId )) == kOkRC )
|
||||||
valueRef = f->presetA[ presetId ].order;
|
valueRef = f->presetA[ presetId ].order;
|
||||||
@ -361,6 +378,13 @@ namespace cw
|
|||||||
case kPlayBtnVarId:
|
case kPlayBtnVarId:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case kPlaySeqBtnVarId:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case kPlaySeqAllBtnVarId:
|
||||||
|
valueRef = f->seqAllFl;
|
||||||
|
break;
|
||||||
|
|
||||||
case kMasterWetInGainVarId:
|
case kMasterWetInGainVarId:
|
||||||
valueRef = p->master_wet_in_gain;
|
valueRef = p->master_wet_in_gain;
|
||||||
break;
|
break;
|
||||||
@ -769,8 +793,8 @@ bool cw::preset_sel::track_timestamp( handle_t h, const time::spec_t& ts, const
|
|||||||
|
|
||||||
time::spec_t t0;
|
time::spec_t t0;
|
||||||
time::setZero(t0);
|
time::setZero(t0);
|
||||||
unsigned elapsedMs = time::elapsedMs(t0,ts);
|
//unsigned elapsedMs = time::elapsedMs(t0,ts);
|
||||||
double mins = elapsedMs / 60000.0;
|
//double mins = elapsedMs / 60000.0;
|
||||||
|
|
||||||
|
|
||||||
// if this is the first call to 'track_timestamp()'.
|
// if this is the first call to 'track_timestamp()'.
|
||||||
@ -802,15 +826,54 @@ bool cw::preset_sel::track_timestamp( handle_t h, const time::spec_t& ts, const
|
|||||||
return frag_changed_fl;
|
return frag_changed_fl;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned cw::preset_sel::fragment_play_preset_index( const frag_t* frag )
|
unsigned cw::preset_sel::fragment_play_preset_index( const frag_t* frag, unsigned preset_seq_idx )
|
||||||
{
|
{
|
||||||
|
unsigned n = 0;
|
||||||
|
// for each preset
|
||||||
for(unsigned i=0; i<frag->presetN; ++i)
|
for(unsigned i=0; i<frag->presetN; ++i)
|
||||||
|
{
|
||||||
|
// if 'preset_seq_idx' is not valid ...
|
||||||
|
if( preset_seq_idx==kInvalidIdx )
|
||||||
|
{
|
||||||
|
// ...then select the first preset whose 'playFl' is set.
|
||||||
if( frag->presetA[i].playFl )
|
if( frag->presetA[i].playFl )
|
||||||
return frag->presetA[i].preset_idx;
|
return frag->presetA[i].preset_idx;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// ... otherwise select the 'nth' preset whose 'seqFl' is set
|
||||||
|
if( frag->presetA[i].seqFl || frag->seqAllFl )
|
||||||
|
{
|
||||||
|
if( n == preset_seq_idx )
|
||||||
|
return frag->presetA[i].preset_idx;
|
||||||
|
++n;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return kInvalidIdx;
|
return kInvalidIdx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned cw::preset_sel::fragment_seq_count( handle_t h, unsigned fragId )
|
||||||
|
{
|
||||||
|
rc_t rc = kOkRC;
|
||||||
|
preset_sel_t* p = _handleToPtr(h);
|
||||||
|
frag_t* f = nullptr;
|
||||||
|
unsigned n = 0;
|
||||||
|
|
||||||
|
if((rc = _find_frag(p,fragId,f)) != kOkRC )
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if( f->seqAllFl )
|
||||||
|
return f->presetN;
|
||||||
|
|
||||||
|
for(unsigned i=0; i<f->presetN; ++i)
|
||||||
|
if( f->presetA[i].seqFl )
|
||||||
|
++n;
|
||||||
|
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
cw::rc_t cw::preset_sel::write( handle_t h, const char* fn )
|
cw::rc_t cw::preset_sel::write( handle_t h, const char* fn )
|
||||||
{
|
{
|
||||||
|
@ -11,6 +11,7 @@ namespace cw
|
|||||||
typedef struct preset_str
|
typedef struct preset_str
|
||||||
{
|
{
|
||||||
bool playFl; // play this preset
|
bool playFl; // play this preset
|
||||||
|
bool seqFl; // play this preset during sequencing.
|
||||||
unsigned preset_idx; // preset index into preset_labelA[].
|
unsigned preset_idx; // preset index into preset_labelA[].
|
||||||
unsigned order; //
|
unsigned order; //
|
||||||
} preset_t;
|
} preset_t;
|
||||||
@ -34,6 +35,7 @@ namespace cw
|
|||||||
unsigned presetN;
|
unsigned presetN;
|
||||||
|
|
||||||
bool uiSelectFl;
|
bool uiSelectFl;
|
||||||
|
bool seqAllFl; // Set if all preset.seqFl's should be treated as though they are set to true.
|
||||||
|
|
||||||
struct frag_str* link;
|
struct frag_str* link;
|
||||||
struct frag_str* prev;
|
struct frag_str* prev;
|
||||||
@ -51,10 +53,13 @@ namespace cw
|
|||||||
kBegPlayLocVarId,
|
kBegPlayLocVarId,
|
||||||
kEndPlayLocVarId,
|
kEndPlayLocVarId,
|
||||||
kPlayBtnVarId,
|
kPlayBtnVarId,
|
||||||
|
kPlaySeqBtnVarId,
|
||||||
|
kPlaySeqAllBtnVarId,
|
||||||
kNoteVarId,
|
kNoteVarId,
|
||||||
|
|
||||||
kPresetOrderVarId, // preset order value
|
kPresetOrderVarId, // preset order value
|
||||||
kPresetSelectVarId, // select a preset to play
|
kPresetSelectVarId, // select a preset to play
|
||||||
|
kPresetSeqSelectVarId, // sequence preset selections to play
|
||||||
kPlayEnableVarId, // include in the segment to play
|
kPlayEnableVarId, // include in the segment to play
|
||||||
kDryFlVarId, // play this fragment dry
|
kDryFlVarId, // play this fragment dry
|
||||||
|
|
||||||
@ -111,7 +116,10 @@ namespace cw
|
|||||||
bool track_timestamp( handle_t h, const time::spec_t& ts, const cw::preset_sel::frag_t*& frag_Ref );
|
bool track_timestamp( handle_t h, const time::spec_t& ts, const cw::preset_sel::frag_t*& frag_Ref );
|
||||||
|
|
||||||
// Return the preset index marked to play on this fragment.
|
// Return the preset index marked to play on this fragment.
|
||||||
unsigned fragment_play_preset_index( const frag_t* frag );
|
unsigned fragment_play_preset_index( const frag_t* frag, unsigned preset_seq_idx=kInvalidIdx );
|
||||||
|
|
||||||
|
// Return the count of presets whose 'seqFl' is set.
|
||||||
|
unsigned fragment_seq_count( handle_t h, unsigned fragId );
|
||||||
|
|
||||||
rc_t write( handle_t h, const char* fn );
|
rc_t write( handle_t h, const char* fn );
|
||||||
rc_t read( handle_t h, const char* fn );
|
rc_t read( handle_t h, const char* fn );
|
||||||
|
Loading…
Reference in New Issue
Block a user