Updates to support sample-rate conversion in cmApBuf.h/cpp.

This commit is contained in:
kevin.larke 2020-02-29 12:31:01 -05:00
parent d5f072fb40
commit 0aee816083
14 changed files with 421 additions and 177 deletions

316
cmApBuf.c
View File

@ -41,9 +41,6 @@
The fn variable however is not thread-safe and therefore care must be taken as
to how it is read and updated.
*/
enum { kInApIdx=0, kOutApIdx=1, kIoApCnt=2 };
@ -61,21 +58,25 @@ typedef struct
cmApSample_t* m; // m[mn] meter sample sum
unsigned mn; // length of m[]
unsigned mi; // next ele of m[] to rcv sum
cmApSample_t s0; // buffered sample used for srate conversion
} cmApCh;
typedef struct
{
unsigned chCnt;
cmApCh* chArray;
unsigned chCnt; // Count of channels
cmApCh* chArray; // chArray[chCnt] channel record array
unsigned n; // length of b[] (multiple of dspFrameCnt) bufCnt*framesPerCycle
double srate; // device sample rate;
unsigned n; // Length of b[] (multiple of dspFrameCnt) bufCnt*framesPerCycle
double srate; // Device sample rate;
int srateMult; // Internal sample rate multiplier (negative values for dividing). This srateMult*srate is the sample rate of
// signals held in the chApCh[] input and output buffers. Sample rate conversion to/from this rate
// occurs in cmApBufUpdate() as signals go from/to the audio device.
unsigned faultCnt;
unsigned framesPerCycle;
unsigned dspFrameCnt;
cmTimeSpec_t timeStamp; // base (starting) time stamp for this device
unsigned ioFrameCnt; // count of frames input or output for this device
unsigned faultCnt; // error count since start
unsigned framesPerCycle; // expected count of frames per channel to/from the audio device on each call to cmApBufUpdate()
unsigned dspFrameCnt; // number of frames per channel in buffers returned by cmApBufGet().
cmTimeSpec_t timeStamp; // base (starting) time stamp for this device
unsigned ioFrameCnt; // count of frames input or output for this device
} cmApIO;
@ -93,11 +94,145 @@ typedef struct
cmApSample_t* zeroBuf; // buffer of zeros
unsigned zeroBufCnt; // max of all dspFrameCnt for all devices.
unsigned abufIdx;
cmApSample_t abuf[ 16384 ];
} cmApBuf;
cmApBuf _cmApBuf;
// Copy the source channel (srcChIdx) to the destination buffer and apply up-sampling.
// 'src' is an interleaved buffer with 'srcN' samples per channel and 'srcChN' channels (total size in samples = srcN*srcChN)
// 'dst' is a non-interleaved (single channel) circular buffer of length 'dstN' where 'dstIdx' is the index of the first dst slot to receive a sample..
// Return the index into dst[] of the next location to receive an incoming sample.
unsigned _cmApCopyInUpSample( const cmApSample_t* src, unsigned srcN, unsigned srcChN, unsigned srcChIdx, cmApSample_t* dst, unsigned dstN, unsigned dstIdx, unsigned mult, double gain, cmApSample_t* s0_Ref )
{
cmApSample_t s0 = *s0_Ref;
unsigned si,k,di=dstIdx;
for(si=0; si<srcN; ++si)
{
cmApSample_t s1 = src[si*srcChN+srcChIdx];
for(k=1; k<mult; ++k)
{
dst[di] = gain * (s0 + (s1 - s0) * k / mult );
di = (di+1) % dstN;
}
dst[di] = gain * s1;
di = (di+1) % dstN;
s0 = s1;
}
*s0_Ref = s0;
return di;
}
// Copy the source channel (srcChIdx) to the destination buffer and apply down-sampling.
// 'src' is an interleaved linear buffer with 'srcN' samples per channel and 'srcChN' channels,
// 'dst' is a non-interleaved circular buffer of length 'dstN' where 'dstIdx' is the index of the first dst slot to receive a sample..
// Return the index into dst[] of the next location to receive an incoming sample.
unsigned _cmApCopyInDnSample( const cmApSample_t* src, unsigned srcN, unsigned srcChN, unsigned srcChIdx, cmApSample_t* dst, unsigned dstN, unsigned dstIdx, unsigned div, double gain )
{
unsigned si,di=dstIdx;
for(si=0; si<srcN; si+=div)
{
dst[di] = gain * src[si*srcChN+srcChIdx];
di = (di+1) % dstN;
}
return di;
}
// Copy samples from an interleaved src buffer to a non-interleaved dst buffer with sample rate conversion
unsigned _cmApCopyInSamples( const cmApSample_t* src, unsigned srcN, unsigned srcChN, unsigned srcChIdx, cmApSample_t* dst, unsigned dstN, unsigned dstIdx, int srateMult, double gain, cmApSample_t* s0_Ref )
{
if( srateMult < 1 )
return _cmApCopyInDnSample( src, srcN, srcChN, srcChIdx, dst, dstN, dstIdx, -srateMult, gain );
return _cmApCopyInUpSample( src, srcN, srcChN, srcChIdx, dst, dstN, dstIdx, srateMult, gain, s0_Ref );
}
void printBuf( const cmApSample_t* src, unsigned srcN, unsigned bi, unsigned n )
{
unsigned i,j;
for(i=bi,j=0; j<n; ++i,++j)
{
i = i % srcN;
printf("(%i,%i,%f),\n",j,i,src[i]);
}
printf("-----\n");
}
// Copy
// 'src' is a non-interleaved circular buf of total length 'srcN', with the first sample coming at 'srcIdx'.
// 'dst' is an interleaved buffer of length 'dstN' with 'dstChN' channels
// Return the index of the next src sample.
unsigned _cmApCopyOutUpSample( const cmApSample_t* src, unsigned srcN, unsigned srcIdx, cmApSample_t* dst, unsigned dstN, unsigned dstChN, unsigned dstChIdx, int mult, double gain, cmApSample_t* s0_Ref )
{
unsigned di,si=srcIdx;
cmApSample_t s0 = *s0_Ref;
for(di=0; di<dstN; ++di)
{
cmApSample_t s1 = src[si];
unsigned k;
for(k=1; k<mult && di<dstN; ++di,++k)
{
dst[di*dstChN+dstChIdx] = gain * (s0 + (s1 - s0) * k / mult );
}
if( di < dstN )
{
dst[di*dstChN+dstChIdx] = gain * s1;
++di;
}
si = (si + 1) % srcN;
s0 = s1;
}
*s0_Ref = s0;
return si;
}
// 'src' is a non-interleaved (single channel) circular buf of total length 'srcN', with the first sample coming at 'srcIdx'.
// 'dst' is an interleaved buffer of length 'dstN' with 'dstChN' channels
// Return the index of the next src sample.
unsigned _cmApCopyOutDnSample( const cmApSample_t* src, unsigned srcN, unsigned srcIdx, cmApSample_t* dst, unsigned dstN, unsigned dstChN, unsigned dstChIdx, int div, double gain )
{
unsigned di,si;
// The total count of output samples is determined by 'dstN'
// Downsampling is acheived by advancing the src index by 'div' samples.
for(di=0,si=srcIdx; di<dstN; ++di)
{
dst[di*dstChN+dstChIdx] = gain * src[si];
si = (si + div) % srcN;
}
return si;
}
// Copy samples from a non-interleaved src buffer to an interleaved dst buffer with sample rate conversion
unsigned _cmApCopyOutSamples( const cmApSample_t* src, unsigned srcN, unsigned srcIdx, cmApSample_t* dst, unsigned dstN, unsigned dstChN, unsigned dstChIdx, int srateMult, double gain, cmApSample_t* s0_Ref )
{
if( srateMult > 0 )
return _cmApCopyOutDnSample(src, srcN, srcIdx, dst, dstN, dstChN, dstChIdx, srateMult, gain );
return _cmApCopyOutUpSample( src, srcN, srcIdx, dst, dstN, dstChN, dstChIdx, -srateMult, gain, s0_Ref );
}
cmApSample_t _cmApMeterValue( const cmApCh* cp )
{
double sum = 0;
@ -108,7 +243,7 @@ cmApSample_t _cmApMeterValue( const cmApCh* cp )
return cp->mn==0 ? 0 : (cmApSample_t)sqrt(sum/cp->mn);
}
void _cmApSine( cmApCh* cp, cmApSample_t* b0, unsigned n0, cmApSample_t* b1, unsigned n1, unsigned stride, float srate )
void _cmApSine0( cmApCh* cp, cmApSample_t* b0, unsigned n0, cmApSample_t* b1, unsigned n1, unsigned stride, float srate )
{
unsigned i;
@ -119,6 +254,23 @@ void _cmApSine( cmApCh* cp, cmApSample_t* b0, unsigned n0, cmApSample_t* b1, uns
b1[i*stride] = (float)(cp->gain * sin( 2.0 * M_PI * cp->hz * cp->phs / srate ));
}
// Synthesize a sine signal of length sigN*srateMult starting at dst[dstidx]
// Assume dst[dstN] is a circular buffer
unsigned _cmApSine( cmApCh* cp, cmApSample_t* dst, unsigned dstN, unsigned dstIdx, unsigned dstChCnt, unsigned sigN, unsigned srateMult, float srate, double gain )
{
unsigned i,di;
sigN = srateMult < 0 ? sigN/abs(srateMult) : sigN * srateMult;
for(i=0, di=dstIdx; i<sigN; ++i,++cp->phs)
{
dst[di] = (cmApSample_t)(gain * sin( 2.0 * M_PI * cp->hz * cp->phs / srate ));
di = (di+dstChCnt) % dstN;
}
return sigN;
}
cmApSample_t _cmApMeter( const cmApSample_t* b, unsigned bn, unsigned stride )
{
const cmApSample_t* ep = b + bn;
@ -151,6 +303,7 @@ void _cmApChInitialize( cmApCh* chPtr, unsigned n, unsigned mn )
chPtr->mn = mn;
chPtr->m = cmMemAllocZ(cmApSample_t,mn);
chPtr->mi = 0;
}
void _cmApIoFinalize( cmApIO* ioPtr )
@ -164,27 +317,31 @@ void _cmApIoFinalize( cmApIO* ioPtr )
ioPtr->n = 0;
}
void _cmApIoInitialize( cmApIO* ioPtr, double srate, unsigned framesPerCycle, unsigned chCnt, unsigned n, unsigned meterBufN, unsigned dspFrameCnt )
void _cmApIoInitialize( cmApIO* ioPtr, double srate, unsigned framesPerCycle, unsigned chCnt, unsigned n, unsigned meterBufN, unsigned dspFrameCnt, int srateMult )
{
unsigned i;
if( srateMult == 0 )
srateMult = 1;
_cmApIoFinalize(ioPtr);
n += (n % dspFrameCnt); // force buffer size to be a multiple of dspFrameCnt
ioPtr->chArray = chCnt==0 ? NULL : cmMemAllocZ( cmApCh, chCnt );
ioPtr->chCnt = chCnt;
ioPtr->n = n;
ioPtr->n = srateMult<0 ? n : n*srateMult;
ioPtr->faultCnt = 0;
ioPtr->framesPerCycle = framesPerCycle;
ioPtr->srate = srate;
ioPtr->srateMult = srateMult;
ioPtr->dspFrameCnt = dspFrameCnt;
ioPtr->timeStamp.tv_sec = 0;
ioPtr->timeStamp.tv_nsec = 0;
ioPtr->ioFrameCnt = 0;
for(i=0; i<chCnt; ++i )
_cmApChInitialize( ioPtr->chArray + i, n, meterBufN );
_cmApChInitialize( ioPtr->chArray + i, ioPtr->n, meterBufN );
}
@ -195,7 +352,7 @@ void _cmApDevFinalize( cmApDev* dp )
_cmApIoFinalize( dp->ioArray+i);
}
void _cmApDevInitialize( cmApDev* dp, double srate, unsigned iFpC, unsigned iChCnt, unsigned iBufN, unsigned oFpC, unsigned oChCnt, unsigned oBufN, unsigned meterBufN, unsigned dspFrameCnt )
void _cmApDevInitialize( cmApDev* dp, double srate, unsigned iFpC, unsigned iChCnt, unsigned iBufN, unsigned oFpC, unsigned oChCnt, unsigned oBufN, unsigned meterBufN, unsigned dspFrameCnt, int srateMult )
{
unsigned i;
@ -203,10 +360,10 @@ void _cmApDevInitialize( cmApDev* dp, double srate, unsigned iFpC, unsigned iChC
for(i=0; i<kIoApCnt; ++i)
{
unsigned chCnt = i==kInApIdx ? iChCnt : oChCnt;
unsigned bufN = i==kInApIdx ? iBufN : oBufN;
unsigned fpc = i==kInApIdx ? iFpC : oFpC;
_cmApIoInitialize( dp->ioArray+i, srate, fpc, chCnt, bufN, meterBufN, dspFrameCnt );
unsigned chCnt = i==kInApIdx ? iChCnt : oChCnt;
unsigned bufN = i==kInApIdx ? iBufN : oBufN;
unsigned fpc = i==kInApIdx ? iFpC : oFpC;
_cmApIoInitialize( dp->ioArray+i, srate, fpc, chCnt, bufN, meterBufN, dspFrameCnt, srateMult );
}
@ -222,6 +379,7 @@ cmAbRC_t cmApBufInitialize( unsigned devCnt, unsigned meterMs )
_cmApBuf.devArray = cmMemAllocZ( cmApDev, devCnt );
_cmApBuf.devCnt = devCnt;
cmApBufSetMeterMs(meterMs);
return kOkAbRC;
}
@ -236,6 +394,22 @@ cmAbRC_t cmApBufFinalize()
_cmApBuf.devCnt = 0;
FILE* fp;
if(_cmApBuf.abufIdx>0 )
{
if((fp = fopen("/home/kevin/temp/temp.csv","wt")) != NULL )
{
int i;
for(i=0; i<_cmApBuf.abufIdx; ++i)
{
fprintf(fp,"%f,\n",_cmApBuf.abuf[i]);
}
fclose(fp);
}
}
return kOkAbRC;
}
@ -247,14 +421,15 @@ cmAbRC_t cmApBufSetup(
unsigned inChCnt,
unsigned inFramesPerCycle,
unsigned outChCnt,
unsigned outFramesPerCycle)
unsigned outFramesPerCycle,
int srateMult)
{
cmApDev* devPtr = _cmApBuf.devArray + devIdx;
unsigned iBufN = bufCnt * inFramesPerCycle;
unsigned oBufN = bufCnt * outFramesPerCycle;
unsigned meterBufN = cmMax(1,floor(srate * _cmApBuf.meterMs / (1000.0 * outFramesPerCycle)));
_cmApDevInitialize( devPtr, srate, inFramesPerCycle, inChCnt, iBufN, outFramesPerCycle, outChCnt, oBufN, meterBufN, dspFrameCnt );
_cmApDevInitialize( devPtr, srate, inFramesPerCycle, inChCnt, iBufN, outFramesPerCycle, outChCnt, oBufN, meterBufN, dspFrameCnt, srateMult );
if( inFramesPerCycle > _cmApBuf.zeroBufCnt || outFramesPerCycle > _cmApBuf.zeroBufCnt )
{
@ -325,8 +500,6 @@ cmAbRC_t cmApBufUpdate(
for(j=0; j<pp->chCnt; ++j)
{
cmApCh* cp = ip->chArray + pp->begChIdx +j; // dest ch
unsigned n0 = ip->n - cp->ii; // first dest segment
unsigned n1 = 0; // second dest segment
assert(pp->begChIdx + j < ip->chCnt );
@ -339,16 +512,12 @@ cmAbRC_t cmApBufUpdate(
// if the incoming samples would go off the end of the buffer then
// copy in the samples in two segments (one at the end and another at begin of dest channel)
if( n0 < pp->audioFramesCnt )
n1 = pp->audioFramesCnt-n0;
else
n0 = pp->audioFramesCnt;
bool enaFl = cmIsFlag(cp->fl,kChApFl) && cmIsFlag(cp->fl,kMuteApFl)==false;
const cmApSample_t* sp = enaFl ? ((cmApSample_t*)pp->audioBytesPtr) + j : _cmApBuf.zeroBuf;
unsigned ssn = enaFl ? pp->chCnt : 1; // stride (packet samples are interleaved)
cmApSample_t* dp = cp->b + cp->ii;
const cmApSample_t* ep = dp + n0;
//unsigned ssn = enaFl ? pp->chCnt : 1; // stride (packet samples are interleaved)
//cmApSample_t* dp = cp->b + cp->ii;
//const cmApSample_t* ep = dp + n0;
// update the meter
@ -358,33 +527,41 @@ cmAbRC_t cmApBufUpdate(
cp->mi = (cp->mi + 1) % cp->mn;
}
unsigned incrSmpN = 0;
// if the test tone is enabled on this input channel
if( enaFl && cmIsFlag(cp->fl,kToneApFl) )
{
_cmApSine(cp, dp, n0, cp->b, n1, 1, ip->srate );
//_cmApSine(cp, dp, n0, cp->b, n1, 1, ip->srate );
incrSmpN = _cmApSine( cp, cp->b, ip->n, cp->ii, 1, pp->audioFramesCnt, ip->srateMult, ip->srate, cp->gain );
}
else // otherwise copy samples from the packet to the buffer
{
// copy the first segment
for(; dp < ep; sp += ssn )
*dp++ = cp->gain * *sp;
// if there is a second segment
if( n1 > 0 )
{
// copy the second segment
dp = cp->b;
ep = dp + n1;
for(; dp<ep; sp += ssn )
*dp++ = cp->gain * *sp;
}
unsigned pi = cp->ii;
cp->ii = _cmApCopyInSamples( (cmApSample_t*)pp->audioBytesPtr, pp->audioFramesCnt, pp->chCnt, j, cp->b, ip->n, cp->ii, ip->srateMult, cp->gain, &cp->s0 );
if( false )
if( j == 2 && _cmApBuf.abufIdx < 16384 )
{
int ii;
for(ii=pi; ii!=cp->ii && _cmApBuf.abufIdx<16384; _cmApBuf.abufIdx++)
{
_cmApBuf.abuf[ _cmApBuf.abufIdx ] = cp->b[ii];
ii = (ii + 1) % ip->n;
}
}
incrSmpN = cp->ii > pi ? cp->ii-pi : (ip->n-pi) + cp->ii;
}
// advance the input channel buffer
cp->ii = n1>0 ? n1 : cp->ii + n0;
//cp->fn += pp->audioFramesCnt;
cmThUIntIncr(&cp->fn,pp->audioFramesCnt);
cmThUIntIncr(&cp->fn,incrSmpN);
}
}
}
@ -423,7 +600,6 @@ cmAbRC_t cmApBufUpdate(
// ... otherwise decrease the count of returned samples
pp->audioFramesCnt = fn;
}
// if the outgong segments would go off the end of the buffer then
@ -433,19 +609,42 @@ cmAbRC_t cmApBufUpdate(
else
n0 = pp->audioFramesCnt;
cmApSample_t* dp = ((cmApSample_t*)pp->audioBytesPtr) + j;
cmApSample_t* bpp = ((cmApSample_t*)pp->audioBytesPtr) + j;
cmApSample_t* dp = bpp;
bool enaFl = cmIsFlag(cp->fl,kChApFl) && cmIsFlag(cp->fl,kMuteApFl)==false;
unsigned decrSmpN = 0;
// if the tone is enabled on this channel
if( enaFl && cmIsFlag(cp->fl,kToneApFl) )
{
_cmApSine(cp, dp, n0, dp + n0*pp->chCnt, n1, pp->chCnt, op->srate );
//_cmApSine(cp, dp, n0, dp + n0*pp->chCnt, n1, pp->chCnt, op->srate );
decrSmpN = _cmApSine( cp, (cmApSample_t*)pp->audioBytesPtr, pp->audioFramesCnt, 0, pp->chCnt, pp->audioFramesCnt, op->srateMult, op->srate, cp->gain );
}
else // otherwise copy samples from the output buffer to the packet
{
const cmApSample_t* sp = enaFl ? cp->b + cp->oi : _cmApBuf.zeroBuf;
const cmApSample_t* ep = sp + n0;
unsigned pi = cp->oi;
cp->oi = _cmApCopyOutSamples( enaFl ? cp->b : _cmApBuf.zeroBuf, op->n, cp->oi, (cmApSample_t*)pp->audioBytesPtr, pp->audioFramesCnt, pp->chCnt, j, op->srateMult, cp->gain, &cp->s0 );
decrSmpN = cp->oi>pi ? cp->oi-pi : (op->n-pi) + cp->oi;
if( true )
if( j == 2 && _cmApBuf.abufIdx < 16384 )
{
int ii;
for(ii=pi; ii!=cp->oi && _cmApBuf.abufIdx<16384; _cmApBuf.abufIdx++)
{
_cmApBuf.abuf[ _cmApBuf.abufIdx ] = cp->b[ii];
ii = (ii + 1) % op->n;
}
}
/*
// copy the first segment
for(; sp < ep; dp += pp->chCnt )
*dp = cp->gain * *sp++;
@ -460,6 +659,7 @@ cmAbRC_t cmApBufUpdate(
*dp = cp->gain * *sp++;
}
*/
}
// update the meter
@ -470,9 +670,13 @@ cmAbRC_t cmApBufUpdate(
}
// advance the output channel buffer
/*
cp->oi = n1>0 ? n1 : cp->oi + n0;
//cp->fn -= pp->audioFramesCnt;
cmThUIntDecr(&cp->fn,pp->audioFramesCnt);
*/
//cp->fn -= pp->audioFramesCnt;
cmThUIntDecr(&cp->fn,decrSmpN);
}
}
}
@ -657,7 +861,6 @@ void cmApBufGet( unsigned devIdx, unsigned flags, cmApSample_t* bufArray[], unsi
unsigned idx = flags & kInApFl ? kInApIdx : kOutApIdx;
const cmApIO* ioPtr = _cmApBuf.devArray[devIdx].ioArray + idx;
unsigned n = bufChCnt < ioPtr->chCnt ? bufChCnt : ioPtr->chCnt;
//unsigned offs = flags & kInApFl ? ioPtr->oi : ioPtr->ii;
cmApCh* cp = ioPtr->chArray;
for(i=0; i<n; ++i,++cp)
@ -881,6 +1084,7 @@ void cmApBufTest( cmRpt_t* rpt )
unsigned sigN = cycleCnt*framesPerCycle*inChCnt;
double srate = 44100.0;
unsigned meterMs = 50;
int srateMult = 1;
unsigned bufChCnt= inChCnt;
cmApSample_t* inBufArray[ bufChCnt ];
@ -910,7 +1114,7 @@ void cmApBufTest( cmRpt_t* rpt )
cmApBufInitialize(devCnt,meterMs);
// setup the buffer with the specific parameters to by used by the host audio ports
cmApBufSetup(devIdx,srate,dspFrameCnt,cycleCnt,inChCnt,framesPerCycle,outChCnt,framesPerCycle);
cmApBufSetup(devIdx,srate,dspFrameCnt,cycleCnt,inChCnt,framesPerCycle,outChCnt,framesPerCycle, srateMult);
// simulate cylcing through sigN buffer transactions
for(i=0; i<sigN; i+=framesPerCycle*inChCnt)

View File

@ -56,13 +56,13 @@ extern "C" {
cmAbRC_t cmApBufSetup(
unsigned devIdx, //< device to setup
double srate, //< device sample rate (only required for synthesizing the correct test-tone frequency)
unsigned dspFrameCnt, // dspFrameCnt - count of samples in channel buffers returned via cmApBufGet()
unsigned dspFrameCnt, //< dspFrameCnt - count of samples in channel buffers returned via cmApBufGet()
unsigned cycleCnt, //< number of audio port cycles to store
unsigned inChCnt, //< input channel count on this device
unsigned inFramesPerCycle, //< maximum number of incoming sample frames on an audio port cycle
unsigned outChCnt, //< output channel count on this device
unsigned outFramesPerCycle //< maximum number of outgoing sample frames in an audio port cycle
);
unsigned outFramesPerCycle, //< maximum number of outgoing sample frames in an audio port cycle
int srateMult ); //< sample rate cvt (positive for upsample, negative for downsample)
// Prime the buffer with 'audioCycleCnt' * outFramesPerCycle samples ready to be played
cmAbRC_t cmApBufPrimeOutput( unsigned devIdx, unsigned audioCycleCnt );

View File

@ -364,6 +364,7 @@ cmAdRC_t _cmAdParseSysJsonTree( cmAd_t* p )
"dspFramesPerCycle", kIntTId, &asap->dspFramesPerCycle,
"audioBufCnt", kIntTId, &asap->audioBufCnt,
"srate", kRealTId, &asap->srate,
"srateMult", kIntTId, &asap->srateMult,
NULL )) != kOkJsRC )
{
rc = _cmAdParseMemberErr(p, jsRC, errLabelPtr, cmStringNullGuard(p->asCfgArray[i].label));

View File

@ -738,6 +738,7 @@ int cmApAggTest( bool runFl, cmCtx_t* ctx, int argc, const char* argv[] )
cmApAggPortTestRecd r;
unsigned i;
cmRpt_t* rpt = &ctx->rpt;
int srateMult = 1;
if( _cmApAggGetOpt(argc,argv,"-h",0,true) )
_cmApAggPrintUsage(rpt);
@ -839,11 +840,11 @@ int cmApAggTest( bool runFl, cmCtx_t* ctx, int argc, const char* argv[] )
cmApBufInitialize( cmApDeviceCount(), r.meterMs );
// setup the buffer for the output device
cmApBufSetup( r.outDevIdx, r.srate, r.framesPerCycle, r.bufCnt, cmApDeviceChannelCount(r.outDevIdx,true), r.framesPerCycle, cmApDeviceChannelCount(r.outDevIdx,false), r.framesPerCycle );
cmApBufSetup( r.outDevIdx, r.srate, r.framesPerCycle, r.bufCnt, cmApDeviceChannelCount(r.outDevIdx,true), r.framesPerCycle, cmApDeviceChannelCount(r.outDevIdx,false), r.framesPerCycle, srateMult );
// setup the buffer for the input device
if( r.inDevIdx != r.outDevIdx )
cmApBufSetup( r.inDevIdx, r.srate, r.framesPerCycle, r.bufCnt, cmApDeviceChannelCount(r.inDevIdx,true), r.framesPerCycle, cmApDeviceChannelCount(r.inDevIdx,false), r.framesPerCycle );
cmApBufSetup( r.inDevIdx, r.srate, r.framesPerCycle, r.bufCnt, cmApDeviceChannelCount(r.inDevIdx,true), r.framesPerCycle, cmApDeviceChannelCount(r.inDevIdx,false), r.framesPerCycle, srateMult );
// setup an input device
if( cmApDeviceSetup(r.inDevIdx,r.srate,r.framesPerCycle,_cmApAggPortCb2,&r) != kOkApRC )

View File

@ -663,7 +663,8 @@ int cmApPortTest( bool runFl, cmRpt_t* rpt, int argc, const char* argv[] )
{
cmApPortTestRecd r;
unsigned i;
int result = 0;
int result = 0;
int srateMult = 1;
if( _cmApGetOpt(argc,argv,"-h",0,true) )
_cmApPrintUsage(rpt);
@ -698,6 +699,8 @@ int cmApPortTest( bool runFl, cmRpt_t* rpt, int argc, const char* argv[] )
r.ilog = ilog;
r.cbCnt = 0;
cmRptPrintf(rpt,"%s in:%i out:%i chidx:%i chs:%i bufs=%i frm=%i rate=%f\n",runFl?"exec":"rpt",r.inDevIdx,r.outDevIdx,r.chIdx,r.chCnt,r.bufCnt,r.framesPerCycle,r.srate);
if( cmApFileAllocate(rpt) != kOkApRC )
@ -737,11 +740,11 @@ int cmApPortTest( bool runFl, cmRpt_t* rpt, int argc, const char* argv[] )
cmApBufInitialize( cmApDeviceCount(), r.meterMs );
// setup the buffer for the output device
cmApBufSetup( r.outDevIdx, r.srate, r.framesPerCycle, r.bufCnt, cmApDeviceChannelCount(r.outDevIdx,true), r.framesPerCycle, cmApDeviceChannelCount(r.outDevIdx,false), r.framesPerCycle );
cmApBufSetup( r.outDevIdx, r.srate, r.framesPerCycle, r.bufCnt, cmApDeviceChannelCount(r.outDevIdx,true), r.framesPerCycle, cmApDeviceChannelCount(r.outDevIdx,false), r.framesPerCycle, srateMult );
// setup the buffer for the input device
if( r.inDevIdx != r.outDevIdx )
cmApBufSetup( r.inDevIdx, r.srate, r.framesPerCycle, r.bufCnt, cmApDeviceChannelCount(r.inDevIdx,true), r.framesPerCycle, cmApDeviceChannelCount(r.inDevIdx,false), r.framesPerCycle );
cmApBufSetup( r.inDevIdx, r.srate, r.framesPerCycle, r.bufCnt, cmApDeviceChannelCount(r.inDevIdx,true), r.framesPerCycle, cmApDeviceChannelCount(r.inDevIdx,false), r.framesPerCycle, srateMult );
cmApBufEnableMeter( r.inDevIdx, -1, kEnableApFl );

View File

@ -514,6 +514,14 @@ void _cmAudioSysSerialPortCallback( void* cbArg, const void* byteA, unsigned byt
//_cmAsCfg_t* p (_cmAsCfg_t*)cbArg;
// TODO: handle serial receive
/*
int i;
for(i=0; i<byteN; ++i)
{
printf("%02x ",((const uint8_t*)byteA)[i]);
fflush(stdout);
}
*/
}
cmAsRC_t cmAudioSysAllocate( cmAudioSysH_t* hp, cmRpt_t* rpt, const cmAudioSysCfg_t* cfg )
@ -800,7 +808,7 @@ cmAsRC_t cmAudioSysInitialize( cmAudioSysH_t h, const cmAudioSysCfg_t* cfg )
// setup the input device buffer
if( ss->args.inDevIdx != cmInvalidIdx )
if((rc = cmApBufSetup( ss->args.inDevIdx, ss->args.srate, ss->args.dspFramesPerCycle, ss->args.audioBufCnt, cmApDeviceChannelCount(ss->args.inDevIdx, true), ss->args.devFramesPerCycle, cmApDeviceChannelCount(ss->args.inDevIdx, false), ss->args.devFramesPerCycle )) != kOkAsRC )
if((rc = cmApBufSetup( ss->args.inDevIdx, ss->args.srate, ss->args.dspFramesPerCycle, ss->args.audioBufCnt, cmApDeviceChannelCount(ss->args.inDevIdx, true), ss->args.devFramesPerCycle, cmApDeviceChannelCount(ss->args.inDevIdx, false), ss->args.devFramesPerCycle, ss->args.srateMult )) != kOkAsRC )
{
rc = _cmAsError(p,kAudioBufSetupErrAsRC,"Audio buffer input setup failed.");
goto errLabel;
@ -815,7 +823,7 @@ cmAsRC_t cmAudioSysInitialize( cmAudioSysH_t h, const cmAudioSysCfg_t* cfg )
// setup the output device buffer
if( ss->args.outDevIdx != ss->args.inDevIdx )
if((rc = cmApBufSetup( ss->args.outDevIdx, ss->args.srate, ss->args.dspFramesPerCycle, ss->args.audioBufCnt, cmApDeviceChannelCount(ss->args.outDevIdx, true), ss->args.devFramesPerCycle, cmApDeviceChannelCount(ss->args.outDevIdx, false), ss->args.devFramesPerCycle )) != kOkAsRC )
if((rc = cmApBufSetup( ss->args.outDevIdx, ss->args.srate, ss->args.dspFramesPerCycle, ss->args.audioBufCnt, cmApDeviceChannelCount(ss->args.outDevIdx, true), ss->args.devFramesPerCycle, cmApDeviceChannelCount(ss->args.outDevIdx, false), ss->args.devFramesPerCycle, ss->args.srateMult )) != kOkAsRC )
return _cmAsError(p,kAudioBufSetupErrAsRC,"Audio buffer ouput device setup failed.");
// setup the output audio buffer ptr array - used to recv output audio from the DSP system in _cmAsDspExecCallback()

View File

@ -139,6 +139,7 @@ extern "C" {
unsigned dspFramesPerCycle; // (64) Audio samples per channel per DSP cycle.
unsigned audioBufCnt; // (3) Audio device buffers.
double srate; // Audio sample rate.
int srateMult; // Sample rate multiplication factor (negative for divide)
} cmAudioSysArgs_t;
// Audio sub-system configuration record.

View File

@ -887,7 +887,7 @@ cmRtRC_t cmRtSysCfg( cmRtSysH_t h, const cmRtSysSubSys_t* ss, unsigned rtSubIdx
// setup the input device buffer
if( ss->args.inDevIdx != cmInvalidIdx )
if((rc = cmApBufSetup( ss->args.inDevIdx, ss->args.srate, ss->args.dspFramesPerCycle, ss->args.audioBufCnt, cmApDeviceChannelCount(ss->args.inDevIdx, true), ss->args.devFramesPerCycle, cmApDeviceChannelCount(ss->args.inDevIdx, false), ss->args.devFramesPerCycle )) != kOkRtRC )
if((rc = cmApBufSetup( ss->args.inDevIdx, ss->args.srate, ss->args.dspFramesPerCycle, ss->args.audioBufCnt, cmApDeviceChannelCount(ss->args.inDevIdx, true), ss->args.devFramesPerCycle, cmApDeviceChannelCount(ss->args.inDevIdx, false), ss->args.devFramesPerCycle, ss->args.srateMult )) != kOkRtRC )
{
rc = _cmRtError(p,kAudioBufSetupErrRtRC,"Audio buffer input setup failed.");
goto errLabel;
@ -902,7 +902,7 @@ cmRtRC_t cmRtSysCfg( cmRtSysH_t h, const cmRtSysSubSys_t* ss, unsigned rtSubIdx
// setup the output device buffer
if( ss->args.outDevIdx != ss->args.inDevIdx )
if((rc = cmApBufSetup( ss->args.outDevIdx, ss->args.srate, ss->args.dspFramesPerCycle, ss->args.audioBufCnt, cmApDeviceChannelCount(ss->args.outDevIdx, true), ss->args.devFramesPerCycle, cmApDeviceChannelCount(ss->args.outDevIdx, false), ss->args.devFramesPerCycle )) != kOkRtRC )
if((rc = cmApBufSetup( ss->args.outDevIdx, ss->args.srate, ss->args.dspFramesPerCycle, ss->args.audioBufCnt, cmApDeviceChannelCount(ss->args.outDevIdx, true), ss->args.devFramesPerCycle, cmApDeviceChannelCount(ss->args.outDevIdx, false), ss->args.devFramesPerCycle, ss->args.srateMult )) != kOkRtRC )
return _cmRtError(p,kAudioBufSetupErrRtRC,"Audio buffer ouput device setup failed.");
// setup the output audio buffer ptr array - used to recv output audio from the DSP system in _cmRtDspExecCallback()

View File

@ -153,6 +153,7 @@ extern "C" {
unsigned dspFramesPerCycle; // (64) Audio samples per channel per DSP cycle.
unsigned audioBufCnt; // (3) Audio device buffers.
double srate; // Audio sample rate.
int srateMult;
} cmRtSysArgs_t;
// Audio sub-system configuration record.

View File

@ -667,7 +667,7 @@ cmDspRC_t cmDspVarPresetRdWr( cmDspCtx_t* ctx, cmDspInst_t* inst, unsigned
}
double cmDspSampleRate( cmDspCtx_t* ctx )
{ return ctx->ctx->ss->args.srate; }
{ return ctx->ctx->ss->args.srate * ctx->ctx->ss->args.srateMult; }
unsigned cmDspSamplesPerCycle( cmDspCtx_t * ctx )
{ return ctx->ctx->ss->args.dspFramesPerCycle; }

View File

@ -2812,6 +2812,7 @@ enum
kStatusPcId,
kD0PcId,
kD1PcId,
kAllOffPcId
};
cmDspClass_t _cmPicadaeDC;
@ -2933,95 +2934,95 @@ typedef struct
cmDspPicadaeDuty_t cmDspPicadaeDutyMap[] =
{
21, {{ -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
22, {{ -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
23, {{ 0, 70 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
24, {{ 0, 75 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
25, {{ 0, 70 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
26, {{ 0, 65 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
27, {{ 0, 70 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
28, {{ 0, 70 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
29, {{ 0, 65 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
30, {{ 0, 65 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
31, {{ 0, 65 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
32, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
33, {{ 0, 65 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
34, {{ 0, 65 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
35, {{ 0, 65 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
36, {{ 0, 65 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
37, {{ 0, 65 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
38, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
39, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
40, {{ 0, 55 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
41, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
42, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
43, {{ 0, 65 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
44, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
45, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
46, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
47, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
48, {{ 0, 70 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
49, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
50, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
51, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
52, {{ 0, 55 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
53, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
54, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
55, {{ 0, 50 }, { 22000, 55 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
56, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
57, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
58, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
59, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
60, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
61, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
62, {{ 0, 55 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
63, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
64, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
65, {{ 0, 50 }, { 17000, 65 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
66, {{ 0, 53 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
67, {{ 0, 55 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
68, {{ 0, 53 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
69, {{ 0, 55 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
70, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
71, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
72, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
73, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
74, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
75, {{ 0, 55 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
76, {{ 0, 70 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
77, {{ 0, 50 }, { 15000, 60 }, { 19000, 70 }, { -1, -1 }, { -1, -1 }, },
78, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
79, {{ 0, 50 }, { 15000, 60 }, { 19000, 70 }, { -1, -1 }, { -1, -1 }, },
80, {{ 0, 45 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
81, {{ 0, 50 }, { 15000, 70 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
82, {{ 0, 50 }, { 12500, 60 }, { 14000, 65 }, { 17000, 70 }, { -1, -1 }, },
83, {{ 0, 50 }, { 15000, 65 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
84, {{ 0, 50 }, { 12500, 60 }, { 14000, 65 }, { 17000, 70 }, { -1, -1 }, },
85, {{ 0, 50 }, { 12500, 60 }, { 14000, 65 }, { 17000, 70 }, { -1, -1 }, },
86, {{ 0, 50 }, { 12500, 60 }, { 14000, 65 }, { 17000, 70 }, { -1, -1 }, },
87, {{ 0, 50 }, { 14000, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
88, {{ 0, 50 }, { 12500, 60 }, { 14000, 65 }, { 17000, 70 }, { -1, -1 }, },
89, {{ 0, 50 }, { 12500, 60 }, { 14000, 65 }, { 17000, 70 }, { -1, -1 }, },
90, {{ -1, -1}, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
91, {{ 0, 40 }, { 12500, 50 }, { 14000, 60 }, { 17000, 65 }, { -1, -1 }, },
92, {{ 0, 40 }, { 14000, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
93, {{ 0, 40 }, { 12500, 50 }, { 14000, 60 }, { 17000, 65 }, { -1, -1 }, },
94, {{ 0, 40 }, { 14000, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
95, {{ 0, 40 }, { 12500, 50 }, { 14000, 60 }, { 17000, 65 }, { -1, -1 }, },
96, {{ 0, 40 }, { 12500, 50 }, { 14000, 60 }, { 17000, 65 }, { -1, -1 }, },
97, {{ 0, 40 }, { 14000, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
98, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
99, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
100, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
101, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
102, {{ -1, -1}, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
103, {{ -1, -1}, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
104, {{ -1, -1}, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
105, {{ -1, -1}, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
106, {{ -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
107, {{ -1, -1}, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
108, {{ -1, -1}, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
0, {{ -1, -1}, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
{21, {{ -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{22, {{ -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{23, {{ 0, 70 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{24, {{ 0, 75 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{25, {{ 0, 70 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{26, {{ 0, 65 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{27, {{ 0, 70 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{28, {{ 0, 70 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{29, {{ 0, 65 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{30, {{ 0, 65 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{31, {{ 0, 65 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{32, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{33, {{ 0, 65 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{34, {{ 0, 65 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{35, {{ 0, 65 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{36, {{ 0, 65 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{37, {{ 0, 65 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{38, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{39, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{40, {{ 0, 55 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{41, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{42, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{43, {{ 0, 65 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{44, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{45, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{46, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{47, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{48, {{ 0, 70 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{49, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{50, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{51, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{52, {{ 0, 55 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{53, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{54, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{55, {{ 0, 50 }, { 22000, 55 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{56, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{57, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{58, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{59, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{60, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{61, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{62, {{ 0, 55 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{63, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{64, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{65, {{ 0, 50 }, { 17000, 65 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{66, {{ 0, 53 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{67, {{ 0, 55 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{68, {{ 0, 53 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{69, {{ 0, 55 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{70, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{71, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{72, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{73, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{74, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{75, {{ 0, 55 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{76, {{ 0, 70 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{77, {{ 0, 50 }, { 15000, 60 }, { 19000, 70 }, { -1, -1 }, { -1, -1 }, }},
{78, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{79, {{ 0, 50 }, { 15000, 60 }, { 19000, 70 }, { -1, -1 }, { -1, -1 }, }},
{80, {{ 0, 45 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{81, {{ 0, 50 }, { 15000, 70 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{82, {{ 0, 50 }, { 12500, 60 }, { 14000, 65 }, { 17000, 70 }, { -1, -1 }, }},
{83, {{ 0, 50 }, { 15000, 65 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{84, {{ 0, 50 }, { 12500, 60 }, { 14000, 65 }, { 17000, 70 }, { -1, -1 }, }},
{85, {{ 0, 50 }, { 12500, 60 }, { 14000, 65 }, { 17000, 70 }, { -1, -1 }, }},
{86, {{ 0, 50 }, { 12500, 60 }, { 14000, 65 }, { 17000, 70 }, { -1, -1 }, }},
{87, {{ 0, 50 }, { 14000, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{88, {{ 0, 50 }, { 12500, 60 }, { 14000, 65 }, { 17000, 70 }, { -1, -1 }, }},
{89, {{ 0, 50 }, { 12500, 60 }, { 14000, 65 }, { 17000, 70 }, { -1, -1 }, }},
{90, {{ -1, -1}, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{91, {{ 0, 40 }, { 12500, 50 }, { 14000, 60 }, { 17000, 65 }, { -1, -1 }, }},
{92, {{ 0, 40 }, { 14000, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{93, {{ 0, 40 }, { 12500, 50 }, { 14000, 60 }, { 17000, 65 }, { -1, -1 }, }},
{94, {{ 0, 40 }, { 14000, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{95, {{ 0, 40 }, { 12500, 50 }, { 14000, 60 }, { 17000, 65 }, { -1, -1 }, }},
{96, {{ 0, 40 }, { 12500, 50 }, { 14000, 60 }, { 17000, 65 }, { -1, -1 }, }},
{97, {{ 0, 40 }, { 14000, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{98, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{99, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{100, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{101, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{102, {{ -1, -1}, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{103, {{ -1, -1}, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{104, {{ -1, -1}, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{105, {{ -1, -1}, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{106, {{ -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{107, {{ -1, -1}, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{108, {{ -1, -1}, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
{ 0, {{ -1, -1}, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
};
@ -3135,6 +3136,7 @@ cmDspInst_t* _cmDspPicadaeAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsign
{ "status", kStatusPcId, 0, 0, kOutDsvFl | kInDsvFl | kUIntDsvFl | kOptArgDsvFl, "MIDI status" },
{ "d0", kD0PcId, 0, 0, kOutDsvFl | kInDsvFl | kUIntDsvFl | kOptArgDsvFl, "MIDI channel message d0" },
{ "d1", kD1PcId, 0, 0, kOutDsvFl | kInDsvFl | kUIntDsvFl | kOptArgDsvFl, "MIDI channel message d1" },
{ "alloff", kAllOffPcId, 0, 0, kOutDsvFl | kInDsvFl | kSymDsvFl | kOptArgDsvFl, "All notes off."},
{ NULL, 0, 0, 0, 0 }
};
@ -3205,6 +3207,10 @@ cmDspRC_t _cmDspPicadaeRecv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t
}
break;
case kAllOffPcId:
printf("Picadae All Off\n");
_cmDspPicadaReset( ctx, inst );
break;
default:
// store

View File

@ -131,11 +131,11 @@ cmDspRC_t _cmDspSysPgm_MidiFilePlay( cmDspSysH_t h, void** userPtrPtr )
cmDspRC_t rc = kOkDspRC;
//const cmChar_t* deviceName = "Scarlett 18i20 USB";
//const cmChar_t* portName = "Scarlett 18i20 USB MIDI 1";
const cmChar_t* deviceName = "Scarlett 18i20 USB";
const cmChar_t* portName = "Scarlett 18i20 USB MIDI 1";
const cmChar_t* deviceName = "Fastlane";
const cmChar_t* portName = "Fastlane MIDI A";
//const cmChar_t* deviceName = "Fastlane";
//const cmChar_t* portName = "Fastlane MIDI A";
//const cmChar_t* deviceName = "DKV-M4";
//const cmChar_t* portName = "DKV-M4 MIDI 1";
@ -150,7 +150,8 @@ cmDspRC_t _cmDspSysPgm_MidiFilePlay( cmDspSysH_t h, void** userPtrPtr )
cmDspInst_t* ai1p = cmDspSysAllocInst(h,"AudioIn", NULL, 1, 3 );
cmDspInst_t* mfp = cmDspSysAllocInst(h,"MidiFilePlay",NULL, 0 );
cmDspInst_t* mop = cmDspSysAllocInst( h,"MidiOut", NULL, 2, deviceName, portName);
cmDspInst_t* pic = cmDspSysAllocInst(h,"Picadae", NULL, 0 );
cmDspInst_t* mop = cmDspSysAllocInst( h,"MidiOut", NULL, 2, deviceName, portName);
cmDspInst_t* start = cmDspSysAllocInst( h,"Button", "start", 2, kButtonDuiId, 0.0 );
cmDspInst_t* stop = cmDspSysAllocInst( h,"Button", "stop", 2, kButtonDuiId, 0.0 );
@ -159,10 +160,10 @@ cmDspRC_t _cmDspSysPgm_MidiFilePlay( cmDspSysH_t h, void** userPtrPtr )
cmDspInst_t* beg = cmDspSysAllocInst(h,"Scalar", "Beg Samp", 5, kNumberDuiId, 0.0, 1000000000.0, 1.0, 0.0 );
cmDspInst_t* end = cmDspSysAllocInst(h,"Scalar", "End Samp", 5, kNumberDuiId, 0.0, 1000000000.0, 1.0, 1000000000.0 );
cmDspInst_t* ao0p = cmDspSysAllocInst(h,"AudioOut",NULL, 1, 0 );
cmDspInst_t* ao1p = cmDspSysAllocInst(h,"AudioOut",NULL, 1, 1 );
cmDspInst_t* ao2p = cmDspSysAllocInst(h,"AudioOut",NULL, 1, 2 );
cmDspInst_t* ao3p = cmDspSysAllocInst(h,"AudioOut",NULL, 1, 3 );
cmDspInst_t* ao0p = cmDspSysAllocInst(h,"AudioOut",NULL, 1, 2 );
cmDspInst_t* ao1p = cmDspSysAllocInst(h,"AudioOut",NULL, 1, 3 );
cmDspInst_t* ao2p = cmDspSysAllocInst(h,"AudioOut",NULL, 1, 4 );
cmDspInst_t* ao3p = cmDspSysAllocInst(h,"AudioOut",NULL, 1, 5 );
cmDspInst_t* im0p = cmDspSysAllocInst(h,"AMeter","In 0", 0);
cmDspInst_t* im1p = cmDspSysAllocInst(h,"AMeter","In 1", 0);
@ -190,10 +191,24 @@ cmDspRC_t _cmDspSysPgm_MidiFilePlay( cmDspSysH_t h, void** userPtrPtr )
cmDspSysInstallCb( h, stop, "sym", mfp, "sel", NULL);
cmDspSysInstallCb( h, cont, "sym", mfp, "sel", NULL);
bool usePicadaeFl = false;
cmDspSysInstallCb( h, mfp, "d1", mop, "d1", NULL);
cmDspSysInstallCb( h, mfp, "d0", mop, "d0", NULL);
cmDspSysInstallCb( h, mfp, "status", mop, "status", NULL);
if( usePicadaeFl )
{
cmDspSysInstallCb( h, mfp, "d1", pic, "d1", NULL);
cmDspSysInstallCb( h, mfp, "d0", pic, "d0", NULL);
cmDspSysInstallCb( h, mfp, "status", pic, "status", NULL);
cmDspSysInstallCb( h, pic, "d1", mop, "d1", NULL);
cmDspSysInstallCb( h, pic, "d0", mop, "d0", NULL);
cmDspSysInstallCb( h, pic, "status", mop, "status", NULL);
}
else
{
cmDspSysInstallCb( h, mfp, "d1", mop, "d1", NULL);
cmDspSysInstallCb( h, mfp, "d0", mop, "d0", NULL);
cmDspSysInstallCb( h, mfp, "status", mop, "status", NULL);
}
//cmDspSysConnectAudio(h, ai0p, "out", ao0p, "in");
//cmDspSysConnectAudio(h, ai1p, "out", ao1p, "in");
@ -357,7 +372,7 @@ cmDspRC_t _cmDspSysPgm_Test_Pedals( cmDspSysH_t h, void** userPtrPtr )
cmDspRC_t _cmDspSysPgm_Stereo_Through( cmDspSysH_t h, void** userPtrPtr )
{
cmDspInst_t* ignp = cmDspSysAllocInst( h,"Scalar", "In Gain", 5, kNumberDuiId, 0.0, 4.0, 0.01, 1.0);
cmDspInst_t* ignp = cmDspSysAllocInst( h,"Scalar", "In Gain", 5, kNumberDuiId, 0.0, 4.0, 0.01, 0.0);
//cmDspInst_t* ognp = cmDspSysAllocInst( h,"Scalar", "Out Gain", 5, kNumberDuiId, 0.0, 4.0, 0.01, 1.0);
cmDspInst_t* hzp = cmDspSysAllocInst(h,"Scalar", "Hz", 5, kNumberDuiId, 0.0, 10.0, 0.001, 1.0);
@ -403,7 +418,9 @@ cmDspRC_t _cmDspSysPgm_Stereo_Through( cmDspSysH_t h, void** userPtrPtr )
return kOkDspRC;
}
//------------------------------------------------------------------------------
//)
//( { label:cmDspSysPgm_All_In_And_Out file_desc:"Meter all the input channels and pass two channels to the output." kw:[spgm] }
cmDspRC_t _cmDspSysPgm_All_In_And_Out( cmDspSysH_t h, void** userPtrPtr )
{
cmDspInst_t* ignp = cmDspSysAllocInst( h,"Scalar", "In Gain", 5, kNumberDuiId, 0.0, 4.0, 0.01, 1.0);

View File

@ -95,6 +95,7 @@ cmDspRC_t _cmDspSysPgm_TimeLineLite(cmDspSysH_t h, void** userPtrPtr )
cmDspInst_t* ao3 = cmDspSysAllocInst(h,"AudioOut", NULL, 1, 3 ); // 3 2
cmDspSysNewPage(h,"Main");
cmDspInst_t* notesOffb= cmDspSysAllocInst(h,"Button", "notesOff", 2, kButtonDuiId, 1.0 );
cmDspInst_t* onb = cmDspSysAllocInst(h,"Button", "start", 2, kButtonDuiId, 1.0 );
cmDspInst_t* offb = cmDspSysAllocInst(h,"Button", "stop", 2, kButtonDuiId, 1.0 );
cmDspInst_t* mod_sel = cmDspSysAllocMsgList(h, NULL, "mod_sel", 1 );
@ -233,6 +234,7 @@ cmDspRC_t _cmDspSysPgm_TimeLineLite(cmDspSysH_t h, void** userPtrPtr )
cmDspSysInstallCb(h, prePath, "out", tlp, "path", NULL );
cmDspSysInstallCb(h, notesOffb, "sym", pic, "alloff", NULL );
// start connections
cmDspSysInstallCb(h, onb, "sym", tlRt, "s-in", NULL );

View File

@ -1547,7 +1547,7 @@ cmDspRC_t cmDspSysInstallCb1NN1M2( cmDspSysH_t h, cmDspInst_t* srcInstPtr, cons
double cmDspSysSampleRate( cmDspSysH_t h )
{
cmDsp_t* p = _cmDspHandleToPtr(h);
return p->ctx.ctx->ss->args.srate;
return cmDspSampleRate( &p->ctx );
}
cmJsonH_t cmDspSysPgmRsrcHandle( cmDspSysH_t h )