|
@@ -1564,26 +1564,18 @@ cmDspRC_t _cmDspXfaderExec(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t*
|
1564
|
1564
|
}
|
1565
|
1565
|
|
1566
|
1566
|
if( p->xfdp->chArray[i].onFl )
|
|
1567
|
+ {
|
1567
|
1568
|
cmDspSetBool(ctx,inst,p->stateBaseXfId+i,true);
|
1568
|
|
-
|
|
1569
|
+ }
|
|
1570
|
+
|
1569
|
1571
|
if( p->xfdp->chArray[i].offFl )
|
|
1572
|
+ {
|
1570
|
1573
|
cmDspSetBool(ctx,inst,p->stateBaseXfId+i,false);
|
1571
|
|
-
|
|
1574
|
+ }
|
|
1575
|
+
|
1572
|
1576
|
// send the gain output
|
1573
|
1577
|
cmDspSetDouble(ctx,inst,p->gainBaseXfId+i,gain);
|
1574
|
1578
|
|
1575
|
|
- /*
|
1576
|
|
- if( gain > 0 )
|
1577
|
|
- printf("(%i %f %i %i %i %f)",
|
1578
|
|
- i,
|
1579
|
|
- gain,
|
1580
|
|
- p->chGateV[i],
|
1581
|
|
- cmDspBool(inst,p->stateBaseXfId+i),
|
1582
|
|
- p->xfdp->chArray[i].gateFl,
|
1583
|
|
- p->xfdp->chArray[i].gain);
|
1584
|
|
- */
|
1585
|
|
-
|
1586
|
|
-
|
1587
|
1579
|
}
|
1588
|
1580
|
|
1589
|
1581
|
if( p->xfdp->onFl )
|
|
@@ -5698,6 +5690,7 @@ cmDspRC_t _cmDspRouter_Reset(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_
|
5698
|
5690
|
unsigned i;
|
5699
|
5691
|
for(i=0; i<p->oChCnt; ++i)
|
5700
|
5692
|
cmDspZeroAudioBuf(ctx,inst,p->baseOutAudioRtId+i);
|
|
5693
|
+
|
5701
|
5694
|
}
|
5702
|
5695
|
|
5703
|
5696
|
return rc;
|
|
@@ -5736,7 +5729,14 @@ cmDspRC_t _cmDspRouter_Recv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t
|
5736
|
5729
|
return kOkDspRC;
|
5737
|
5730
|
}
|
5738
|
5731
|
|
5739
|
|
-
|
|
5732
|
+ /*
|
|
5733
|
+ if( evt->dstVarId == kOutChIdxRtId && cmDsvGetUInt(evt->valuePtr) < p->oChCnt )
|
|
5734
|
+ {
|
|
5735
|
+ const cmChar_t* symLbl = cmSymTblLabel(ctx->stH,inst->symId);
|
|
5736
|
+ cmDspInstErr(ctx,inst,kOkDspRC,"Router: ch:%i %s\n",cmDsvGetUInt(evt->valuePtr),symLbl==NULL?"":symLbl);
|
|
5737
|
+ }
|
|
5738
|
+ */
|
|
5739
|
+
|
5740
|
5740
|
// store the incoming value
|
5741
|
5741
|
if( evt->dstVarId < p->baseBaseOutRtId )
|
5742
|
5742
|
if((rc = cmDspSetEvent(ctx,inst,evt)) != kOkDspRC )
|
|
@@ -5881,8 +5881,8 @@ cmDspInst_t* _cmDspAvailCh_Alloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsig
|
5881
|
5881
|
cmDspSetDefaultBool( ctx, &p->inst, baseGateOutAvId+i, false, false );
|
5882
|
5882
|
}
|
5883
|
5883
|
cmDspSetDefaultUInt( ctx, &p->inst, kModeAvId, 0, kExclusiveModeAvId );
|
5884
|
|
- cmDspSetDefaultUInt( ctx, &p->inst, kChIdxAvId, 0, cmInvalidIdx );
|
5885
|
|
-
|
|
5884
|
+ cmDspSetDefaultUInt( ctx, &p->inst, kChIdxAvId, 0, 0 );
|
|
5885
|
+
|
5886
|
5886
|
va_end(vl1);
|
5887
|
5887
|
|
5888
|
5888
|
return &p->inst;
|
|
@@ -5897,10 +5897,11 @@ cmDspRC_t _cmDspAvailCh_DoReset( cmDspCtx_t* ctx, cmDspInst_t* inst )
|
5897
|
5897
|
{
|
5898
|
5898
|
unsigned i;
|
5899
|
5899
|
cmDspAvailCh_t* p = (cmDspAvailCh_t*)inst;
|
5900
|
|
-
|
|
5900
|
+
|
|
5901
|
+
|
5901
|
5902
|
// ch 0 is the channel receiving parameters
|
5902
|
|
- cmDspSetUInt(ctx,inst,kChIdxAvId,0);
|
5903
|
|
-
|
|
5903
|
+ cmDspSetUInt(ctx,inst,kChIdxAvId,0);
|
|
5904
|
+
|
5904
|
5905
|
for(i=0; i<p->chCnt; ++i)
|
5905
|
5906
|
{
|
5906
|
5907
|
cmDspSetBool(ctx, inst, p->baseDisInAvId + i, i==0); // disable all channels except ch zero
|
|
@@ -5927,14 +5928,16 @@ cmDspRC_t _cmDspAvailCh_Reset(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt
|
5927
|
5928
|
return rc;
|
5928
|
5929
|
}
|
5929
|
5930
|
|
5930
|
|
-void _cmDspAvailCh_SetNextAvailCh( cmDspCtx_t* ctx, cmDspInst_t* inst, bool warnFl )
|
|
5931
|
+void _cmDspAvailCh_SetNextAvailCh( cmDspCtx_t* ctx, cmDspInst_t* inst, bool warnFl, const char* label )
|
5931
|
5932
|
{
|
5932
|
5933
|
cmDspAvailCh_t* p = (cmDspAvailCh_t*)inst;
|
5933
|
5934
|
unsigned i;
|
5934
|
|
-
|
|
5935
|
+
|
|
5936
|
+ // if a valid next avail ch already exists then do nothing
|
5935
|
5937
|
if( p->nextAvailChIdx != cmInvalidIdx )
|
5936
|
5938
|
return;
|
5937
|
5939
|
|
|
5940
|
+ // for each channel
|
5938
|
5941
|
for(i=0; i<p->chCnt; ++i)
|
5939
|
5942
|
{
|
5940
|
5943
|
// the channel's active state is held in the 'dis' variable.
|
|
@@ -5943,15 +5946,18 @@ void _cmDspAvailCh_SetNextAvailCh( cmDspCtx_t* ctx, cmDspInst_t* inst, bool warn
|
5943
|
5946
|
// if ch[i] is the first avail inactive channel
|
5944
|
5947
|
if( !activeFl )
|
5945
|
5948
|
{
|
5946
|
|
- p->nextAvailChIdx = i; // set the next available channel
|
|
5949
|
+ p->nextAvailChIdx = i; // then make it the next available channel
|
5947
|
5950
|
break;
|
5948
|
5951
|
}
|
5949
|
5952
|
|
5950
|
5953
|
}
|
5951
|
5954
|
|
5952
|
5955
|
// if no available channels were found
|
5953
|
|
- if( p->nextAvailChIdx == cmInvalidIdx && warnFl )
|
5954
|
|
- cmDspInstErr(ctx,inst,kInvalidStateDspRC,"No available channels exist.");
|
|
5956
|
+ if( p->nextAvailChIdx == cmInvalidIdx )
|
|
5957
|
+ {
|
|
5958
|
+ if( warnFl )
|
|
5959
|
+ cmDspInstErr(ctx,inst,kInvalidStateDspRC,"No available channels exist.");
|
|
5960
|
+ }
|
5955
|
5961
|
else
|
5956
|
5962
|
{
|
5957
|
5963
|
// Notify the external world which channel is to be used next.
|
|
@@ -5960,7 +5966,7 @@ void _cmDspAvailCh_SetNextAvailCh( cmDspCtx_t* ctx, cmDspInst_t* inst, bool warn
|
5960
|
5966
|
// next available channel rather than the current channel.
|
5961
|
5967
|
// The next available channel will then be faded up with the
|
5962
|
5968
|
// new parameters on the next trigger command.
|
5963
|
|
- cmDspSetUInt(ctx,inst,kChIdxAvId,p->nextAvailChIdx);
|
|
5969
|
+ cmDspSetUInt(ctx,inst,kChIdxAvId,p->nextAvailChIdx);
|
5964
|
5970
|
}
|
5965
|
5971
|
}
|
5966
|
5972
|
|
|
@@ -5971,9 +5977,9 @@ cmDspRC_t _cmDspAvailCh_Exec( cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt
|
5971
|
5977
|
|
5972
|
5978
|
p->audioCycleCnt += 1;
|
5973
|
5979
|
|
5974
|
|
- // Setting the next available channel here solves the problem of doing the
|
|
5980
|
+ // Setting the next available channel here solves the problem of sending the
|
5975
|
5981
|
// first 'ch' output after the program starts executing.
|
5976
|
|
- // The problem is that 'ch' should be set to 0 for at least the first
|
|
5982
|
+ // The problem is that 'ch' should be set to 0 for the first
|
5977
|
5983
|
// execution cycle so that parameters may be set to the initial active channel
|
5978
|
5984
|
// during the first cycle. After the first cycle however parameters should be
|
5979
|
5985
|
// sent to the next channel which will be faded up. Setting
|
|
@@ -5986,7 +5992,7 @@ cmDspRC_t _cmDspAvailCh_Exec( cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt
|
5986
|
5992
|
// other processors had at least one chance to run.
|
5987
|
5993
|
if( p->audioCycleCnt == 2 )
|
5988
|
5994
|
{
|
5989
|
|
- _cmDspAvailCh_SetNextAvailCh(ctx,inst,true);
|
|
5995
|
+ _cmDspAvailCh_SetNextAvailCh(ctx,inst,true,"exec");
|
5990
|
5996
|
}
|
5991
|
5997
|
|
5992
|
5998
|
return rc;
|
|
@@ -6013,7 +6019,7 @@ cmDspRC_t _cmDspAvailCh_Recv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_
|
6013
|
6019
|
cmDspInstErr(ctx,inst,kInvalidStateDspRC,"There are no available channels to trigger.");
|
6014
|
6020
|
else
|
6015
|
6021
|
{
|
6016
|
|
- // indicate that the next channel is no longer available
|
|
6022
|
+ // indicate that ch[nexAvailChIdx] is no longer available
|
6017
|
6023
|
cmDspSetBool(ctx, inst, p->baseDisInAvId + p->nextAvailChIdx, true);
|
6018
|
6024
|
|
6019
|
6025
|
// raise the gate to start the xfade.
|
|
@@ -6027,10 +6033,11 @@ cmDspRC_t _cmDspAvailCh_Recv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_
|
6027
|
6033
|
cmDspSetBool(ctx,inst, p->baseGateOutAvId+i, false );
|
6028
|
6034
|
}
|
6029
|
6035
|
|
|
6036
|
+ // invalidate nextAvailChIdx
|
6030
|
6037
|
p->nextAvailChIdx = cmInvalidIdx;
|
6031
|
6038
|
|
6032
|
6039
|
// It may be possible to know the next avail ch so try to set it here.
|
6033
|
|
- _cmDspAvailCh_SetNextAvailCh(ctx, inst, false );
|
|
6040
|
+ _cmDspAvailCh_SetNextAvailCh(ctx, inst, false, "trig" );
|
6034
|
6041
|
|
6035
|
6042
|
}
|
6036
|
6043
|
|
|
@@ -6043,8 +6050,9 @@ cmDspRC_t _cmDspAvailCh_Recv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_
|
6043
|
6050
|
{
|
6044
|
6051
|
cmDspSetEvent(ctx,inst,evt);
|
6045
|
6052
|
|
6046
|
|
- // a channel was disabled so a new channel is available for selection
|
6047
|
|
- _cmDspAvailCh_SetNextAvailCh(ctx, inst, true );
|
|
6053
|
+ // a channel was disabled so a new channel should be available for selection
|
|
6054
|
+ if( p->audioCycleCnt > 0 )
|
|
6055
|
+ _cmDspAvailCh_SetNextAvailCh(ctx, inst, true, "dis" );
|
6048
|
6056
|
|
6049
|
6057
|
if( !exclModeFl )
|
6050
|
6058
|
cmDspSetBool(ctx, inst, p->baseGateOutAvId + (evt->dstVarId - p->baseDisInAvId), false);
|