Added dummy DSP time line ctl
This commit is contained in:
parent
4d4988c764
commit
d15a8fd963
293
src/kc/kcApp.cpp
293
src/kc/kcApp.cpp
@ -240,69 +240,6 @@ kcApp::kcKmRC_t kcApp::audioDspFinalize()
|
||||
}
|
||||
|
||||
|
||||
// this function is called whenever a audio configuration parameter
|
||||
// changes (e.g. device, sample rate )
|
||||
/*
|
||||
kcApp::kcKmRC_t kcApp::audioDspStart()
|
||||
{
|
||||
kcKmRC_t rc = kOkKmRC;
|
||||
|
||||
// initializing the engine will result in a new control ui being generated so delete the current on
|
||||
_clearCtlList();
|
||||
|
||||
// initialize the real-time system
|
||||
if( kcEngInitialize(h,cfg) != kOkKeRC )
|
||||
{
|
||||
rc = cmErrMsg(&ctx->err,kEngFailKmRC,"Engine initialization failed.");
|
||||
goto errLabel;
|
||||
}
|
||||
|
||||
_stopTimerFl = false;
|
||||
|
||||
// load the dsp program
|
||||
if( kcEngLoad(h) != kOkKeRC )
|
||||
{
|
||||
rc = cmErrMsg(&ctx->err,kEngFailKmRC,"Engine load failed.");
|
||||
goto errLabel;
|
||||
}
|
||||
|
||||
// start the real-time system
|
||||
if( kcEngEnable(h,true) != kOkKeRC )
|
||||
{
|
||||
rc = cmErrMsg(&ctx->err,kEngFailKmRC,"Engine enable failed.");
|
||||
goto errLabel;
|
||||
}
|
||||
|
||||
ena_chk->value(1);
|
||||
|
||||
errLabel:
|
||||
return rc;
|
||||
}
|
||||
|
||||
kcApp::kcKmRC_t kcApp::stopEngine( )
|
||||
{
|
||||
kcKmRC_t rc = kOkKmRC;
|
||||
|
||||
|
||||
if( kcEngIsValid(h))
|
||||
{
|
||||
// pause the real-time system
|
||||
if( kcEngEnable(h,false) != kOkKeRC )
|
||||
rc = cmErrMsg(&ctx->err,kEngFailKmRC,"Engine disable failed.");
|
||||
else
|
||||
ena_chk->value(0);
|
||||
|
||||
_stopTimerFl = true;
|
||||
|
||||
// finalize the real-time system
|
||||
if( kcEngFinalize(h) != kOkKeRC )
|
||||
rc = cmErrMsg(&ctx->err,kEngFailKmRC,"Engine finalize failed.");
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
void kcApp::resize(int x, int y, int w, int h)
|
||||
{
|
||||
Fl_Double_Window::resize(x, y, w, h);
|
||||
@ -381,7 +318,7 @@ void kcApp::_createMenu(int w, int h)
|
||||
{ 0 },
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
|
||||
menu = new Fl_Menu_Bar(0,0,w,h);
|
||||
menu->copy(items);
|
||||
}
|
||||
@ -1246,6 +1183,53 @@ void kcApp::_setLabelValue( ctl_t* cp, unsigned instVarId, const cmDspValue_t* v
|
||||
sp->redraw();
|
||||
}
|
||||
|
||||
|
||||
void kcApp::_createTmln( const cmDspUiHdr_t* m )
|
||||
{
|
||||
int x,y,w=0,h=0;
|
||||
ctl_t* cp = _createCtl(m, kTmlnTypeId, x,y,w,h );
|
||||
|
||||
cp->u.tmln.text = new Fl_Input(x,y,w,h);
|
||||
|
||||
_insertNewCtl(cp, m, cp->u.tmln.text, cp->u.tmln.varIdArray, kTmlnVarCnt );
|
||||
}
|
||||
|
||||
void kcApp::_setTmlnValue( ctl_t* cp, unsigned instVarId, const cmDspValue_t* vp )
|
||||
{
|
||||
unsigned i=0;
|
||||
Fl_Input* tp = cp->u.tmln.text;
|
||||
|
||||
for(i=0; i<kTmlnVarCnt; ++i)
|
||||
if( cp->u.tmln.varIdArray[i] == instVarId )
|
||||
{
|
||||
switch(i)
|
||||
{
|
||||
case kTmlnValArgIdx:
|
||||
tp->value( cmDsvStrcz(vp));
|
||||
break;
|
||||
|
||||
case kTmlnLblArgIdx:
|
||||
{
|
||||
const char* lbl = cmDsvStrcz(vp);
|
||||
if( lbl == NULL )
|
||||
tp->label(NULL);
|
||||
else
|
||||
tp->copy_label( lbl );
|
||||
|
||||
tp->align(FL_ALIGN_RIGHT);
|
||||
tp->resize( tp->x(), tp->y(), tp->w()/2, tp->h());
|
||||
tp->redraw();
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
{ assert(0); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void kcApp::_newColumn( const cmDspUiHdr_t* m )
|
||||
{
|
||||
_incrColW = cmDsvGetUInt(&m->value);
|
||||
@ -1642,6 +1626,10 @@ void kcApp::_onRecvValue( const cmDspUiHdr_t* m )
|
||||
_setMeterValue(cp, m->instVarId, &m->value);
|
||||
break;
|
||||
|
||||
case kTmlnTypeId:
|
||||
_setTmlnValue(cp, m->instVarId, &m->value);
|
||||
break;
|
||||
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
@ -1691,6 +1679,10 @@ void kcApp::_handleUiMsg( const cmDspUiHdr_t* m )
|
||||
_createMeter(m);
|
||||
break;
|
||||
|
||||
case kTimeLineDuiId:
|
||||
_createTmln(m);
|
||||
break;
|
||||
|
||||
case kValueDuiId:
|
||||
_onRecvValue(m);
|
||||
break;
|
||||
@ -1813,175 +1805,6 @@ kcApp* kcApp::_getApp( Fl_Widget* w )
|
||||
return (kcApp*)gp->user_data();
|
||||
}
|
||||
|
||||
/*
|
||||
kcApp::kcKmRC_t kcApp::_restartEngine()
|
||||
{
|
||||
kcKmRC_t rc;
|
||||
if((rc = stopEngine(&_ctx,_keH)) != kOkKmRC )
|
||||
goto errLabel;
|
||||
|
||||
if((rc = startEngine(&_ctx,_keH,&_cfg)) != kOkKmRC )
|
||||
goto errLabel;
|
||||
|
||||
errLabel:
|
||||
if( rc != kOkKmRC )
|
||||
cmErrMsg(&_ctx.err,kEngFailKmRC,"Engine restart failed.");
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
void kcApp::_selAudDev( Fl_Menu_Button* b, bool inputFl, const cmChar_t* devLbl )
|
||||
{
|
||||
unsigned* curDevIdxPtr = inputFl ? &_cfg.asArgs.inDevIdx : &_cfg.asArgs.outDevIdx;
|
||||
unsigned curDevIdx = *curDevIdxPtr;
|
||||
const Fl_Menu_Item* mip = b->mvalue();
|
||||
bool updateBtnFl = true;
|
||||
|
||||
if( mip == NULL )
|
||||
return;
|
||||
|
||||
// get the select device index
|
||||
unsigned newDevIdx = mip->argument();
|
||||
|
||||
// if the new dev idx is same as cur dev idx there is nothing to do
|
||||
if( newDevIdx != curDevIdx )
|
||||
{
|
||||
// assign the new dev idx to the audio setup cfg
|
||||
*curDevIdxPtr = newDevIdx;
|
||||
|
||||
// restart the engine with the new cfg
|
||||
if( _restartEngine() == kOkKmRC )
|
||||
{
|
||||
// if the audio engine restarted successfully then store the new dev idx to the preferences
|
||||
if( cmPrefsSetScalarUInt(_prH,devLbl,newDevIdx) != kOkPrRC )
|
||||
cmErrMsg(&_ctx.err,kPrefSetFailKmRC,"An error occurred while attempting to set the audio device preference '%s'.",devLbl);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// the new dev idx didn't work - restart the engine with the original dev idx
|
||||
*curDevIdxPtr = curDevIdx;
|
||||
_restartEngine();
|
||||
updateBtnFl = false;
|
||||
}
|
||||
}
|
||||
|
||||
// set the menu btn to show the current device
|
||||
if( updateBtnFl )
|
||||
b->copy_label( mip->label() );
|
||||
|
||||
}
|
||||
|
||||
void kcApp::_selectAudioDevice(Fl_Menu_Button* b, unsigned id)
|
||||
{
|
||||
switch(b->argument())
|
||||
{
|
||||
case kInAudDevBtnId:
|
||||
_selAudDev(b, true, "cfg/inAudDevIdx" );
|
||||
break;
|
||||
|
||||
case kOutAudDevBtnId:
|
||||
_selAudDev(b,false,"cfg/outAudDevIdx");
|
||||
break;
|
||||
|
||||
default:
|
||||
{ assert(0); }
|
||||
}
|
||||
}
|
||||
|
||||
void kcApp::_selectSampleRate(unsigned asSubIdx, unsigned id)
|
||||
{
|
||||
const Fl_Menu_Item* i = sr_btn->mvalue();
|
||||
double curSrate = _cfg.asArgs.srate;
|
||||
double newSrate = i->argument();
|
||||
bool updateBtnFl = true;
|
||||
|
||||
//cmAdIfSetSampleRate(_aiH,asSubIdx,newSrate);
|
||||
|
||||
if( curSrate != newSrate )
|
||||
{
|
||||
_cfg.asArgs.srate = newSrate;
|
||||
|
||||
if( _restartEngine() == kOkKmRC )
|
||||
{
|
||||
if( cmPrefsSetScalarReal(_prH,"cfg/srate",newSrate) != kOkPrRC )
|
||||
cmErrMsg(&_ctx.err,kPrefSetFailKmRC,"An error occurred while settig the audio sample rate preference.");
|
||||
}
|
||||
else
|
||||
{
|
||||
_cfg.asArgs.srate = curSrate;
|
||||
_restartEngine();
|
||||
updateBtnFl = false;
|
||||
}
|
||||
}
|
||||
|
||||
if( updateBtnFl)
|
||||
sr_btn->copy_label( sr_btn->mvalue()->label() );
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
void kcApp::_s_prefCbFunc( cmPrH_t prH, void* cbDataPtr, unsigned prefId )
|
||||
{ ((kcApp*)cbDataPtr)->_prefCbFunc(prH,prefId); }
|
||||
|
||||
void kcApp::_prefCbFunc( cmPrH_t prH, unsigned prefId )
|
||||
{
|
||||
}
|
||||
|
||||
kcApp::kcKmRC_t kcApp::_loadPrefs( cmCtx_t* ctx )
|
||||
{
|
||||
kcKmRC_t rc = kOkKmRC;
|
||||
const cmChar_t* prefDir = cmFsPrefsDir();
|
||||
const cmChar_t* rsrcDir = cmFsRsrcDir();
|
||||
const cmChar_t* fn = "org.larke.kc.txt";
|
||||
const cmChar_t* prefFn = cmFsMakeFn(prefDir,fn,NULL,NULL);
|
||||
const cmChar_t* rsrcFn = cmFsMakeFn(rsrcDir,fn,NULL,NULL);
|
||||
const cmChar_t* pfn = prefFn;
|
||||
|
||||
if( cmFsIsFile(pfn) == false )
|
||||
{
|
||||
pfn = rsrcFn;
|
||||
if( cmFsIsFile(pfn) == false )
|
||||
{
|
||||
rc = cmErrMsg(&ctx->err,kPrefsNotFoundKmRC,"The default preferences file '%s' was not found.",pfn);
|
||||
pfn = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if( pfn != NULL )
|
||||
if( cmPrefsInitialize(&_prH,pfn,_s_prefCbFunc,this,ctx) != kOkPrRC )
|
||||
rc = cmErrMsg(&ctx->err,kPrefLoadFailKmRC,"Preference load from '%s' failed.",pfn);
|
||||
|
||||
// Even if cmPrefsInitialize() fails we continue with _cfg setup using the hard coded default values.
|
||||
|
||||
_cfg.asArgs.rpt = &ctx->rpt;
|
||||
_cfg.asArgs.inDevIdx = cmPrefsUIntDef( _prH,"cfg/inAudDevIdx", 0);
|
||||
_cfg.asArgs.outDevIdx = cmPrefsUIntDef( _prH,"cfg/outAudDevIdx", 2);
|
||||
_cfg.asArgs.syncInputFl = cmPrefsBoolDef( _prH,"cfg/syncInputFl", true);
|
||||
_cfg.asArgs.midiPortBufByteCnt = cmPrefsUIntDef( _prH,"cfg/midiPortBufByteCnt", 8192);
|
||||
_cfg.asArgs.msgQueueByteCnt = cmPrefsUIntDef( _prH,"cfg/msgQueueByteCnt", 16384);
|
||||
_cfg.asArgs.devFramesPerCycle = cmPrefsUIntDef( _prH,"cfg/devFramesPerCycle", 128);
|
||||
_cfg.asArgs.dspFramesPerCycle = cmPrefsUIntDef( _prH,"cfg/dspFramesPerCycle", 64);
|
||||
_cfg.asArgs.audioBufCnt = cmPrefsUIntDef( _prH,"cfg/audioBufCnt", 2);
|
||||
_cfg.asArgs.srate = cmPrefsRealDef( _prH,"cfg/srate", 48000);
|
||||
const cmChar_t* audioDir = cmPrefsStringDef( _prH,"cfg/audioDir", cmFsUserDir());
|
||||
|
||||
_cfg.meterMs = 50;
|
||||
_cfg.prefH = _prH;
|
||||
|
||||
|
||||
_prefsFn = prefFn;
|
||||
|
||||
ad_btn->filename(audioDir);
|
||||
|
||||
|
||||
|
||||
//print("%s\n",prefFn);
|
||||
|
||||
return rc;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
void kcApp::_testStub()
|
||||
@ -2250,7 +2073,11 @@ void kcApp::_ctl_cb(ctl_t* cp)
|
||||
cmDsvSetUInt( &value, idx + 1);
|
||||
cp->u.mlst.mbtn->label( cp->u.mlst.mbtn->text(idx) );
|
||||
}
|
||||
break;
|
||||
|
||||
case kTmlnTypeId:
|
||||
instVarId = cp->u.text.varIdArray[ kTmlnValArgIdx ];
|
||||
cmDsvSetStrz(&value,(cmChar_t*)cp->u.tmln.text->value());
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -94,6 +94,7 @@ private:
|
||||
kFnamTypeId,
|
||||
kMlstTypeId,
|
||||
kMetrTypeId,
|
||||
kTmlnTypeId,
|
||||
|
||||
|
||||
kSldrMinArgIdx = 0,
|
||||
@ -133,7 +134,11 @@ private:
|
||||
kMetrMaxArgIdx = 1,
|
||||
kMetrValArgIdx = 2,
|
||||
kMetrLblArgIdx = 3,
|
||||
kMetrVarCnt = 4
|
||||
kMetrVarCnt = 4,
|
||||
|
||||
kTmlnValArgIdx = 0,
|
||||
kTmlnLblArgIdx = 1,
|
||||
kTmlnVarCnt = 2
|
||||
|
||||
};
|
||||
|
||||
@ -216,6 +221,14 @@ private:
|
||||
unsigned varIdArray[ kMetrVarCnt ];
|
||||
} metr_t;
|
||||
|
||||
typedef struct tmln_str
|
||||
{
|
||||
Fl_Input* text;
|
||||
char* val;
|
||||
unsigned varIdArray[ kTmlnVarCnt ];
|
||||
} tmln_t;
|
||||
|
||||
|
||||
typedef struct ctl_str
|
||||
{
|
||||
kcApp* thisPtr;
|
||||
@ -234,6 +247,7 @@ private:
|
||||
fnam_t fnam;
|
||||
mlst_t mlst;
|
||||
metr_t metr;
|
||||
tmln_t tmln;
|
||||
} u;
|
||||
struct ctl_str* linkPtr;
|
||||
} ctl_t;
|
||||
@ -317,6 +331,8 @@ private:
|
||||
void _setCheckValue( ctl_t* cp, unsigned instVarId, const cmDspValue_t* vp );
|
||||
void _createLabel( const cmDspUiHdr_t* m );
|
||||
void _setLabelValue( ctl_t* cp, unsigned instVarId, const cmDspValue_t* vp );
|
||||
void _createTmln( const cmDspUiHdr_t* m );
|
||||
void _setTmlnValue( ctl_t* cp, unsigned instVarId, const cmDspValue_t* vp );
|
||||
void _newColumn( const cmDspUiHdr_t* m );
|
||||
|
||||
void _insertAudioSysCfgLabel(unsigned long idx, const cmChar_t* label );
|
||||
|
Loading…
Reference in New Issue
Block a user