Added score control, cleaned up and removed dead code.

This commit is contained in:
kpl 2012-11-26 23:21:26 -08:00
parent e1593195ea
commit 662d12cc62
2 changed files with 218 additions and 146 deletions

View File

@ -63,11 +63,14 @@
kcApp::kcApp(cmCtx_t* ctx, cmTsMp1cH_t printqH, int w, int h, const cmChar_t* title, cmAiH_t aiH, int argc, char* argv[] ) kcApp::kcApp(cmCtx_t* ctx, cmTsMp1cH_t printqH, int w, int h, const cmChar_t* title, cmAiH_t aiH, int argc, char* argv[] )
: Fl_Double_Window(w, h,title), : Fl_Double_Window(w, h,title),
splt(NULL),_menu(NULL),_aiH(aiH), _ctx(ctx),_aiH(aiH),
_statIdx(0),_pageList(NULL),_ctlList(NULL), _menu(NULL),_splt(NULL),_con(NULL),_tabs(NULL),_mstr_grp(NULL),
_as_btn(NULL),_ai_btn(NULL),_ao_btn(NULL),_pgm_btn(NULL),
_ss_btn(NULL),_sr_btn(NULL),_ena_chk(NULL),
_pageList(NULL),_ctlList(NULL),
_stopTimerFl(false),_newPageFl(true), _stopTimerFl(false),_newPageFl(true),
_incrColW(0),_colW(0),_horzBordFl(false),_horzBord(0), _incrColW(0),_colW(0),_horzBordFl(false),_horzBord(0),
_closeCnt(0),_ssCnt(0),_ssArray(0),_ssPhase(0),_ssUpdateFl(false), _ssCnt(0),_ssArray(0),_ssPhase(0),_ssUpdateFl(false),
_printqH(printqH),_printFl(0), _printqH(printqH),_printFl(0),
_tlCtl(NULL) _tlCtl(NULL)
{ {
@ -79,48 +82,48 @@ kcApp::kcApp(cmCtx_t* ctx, cmTsMp1cH_t printqH, int w, int h, const cmChar_t* ti
// and a horizontal splitter on the bottom // and a horizontal splitter on the bottom
begin(); begin();
_createMenu(w,kMenuH); _createMenu(w,kMenuH);
splt = new Fl_HSplitter(0, kMenuH, w, h-kStatusH-kMenuH, h-kStatusH-kMenuH-100); _splt = new Fl_HSplitter(0, kMenuH, w, h-kStatusH-kMenuH, h-kStatusH-kMenuH-100);
end(); end();
// Create a text display object for console output andvadd it to the lower splitter area // Create a text display object for console output andvadd it to the lower splitter area
buf = new Fl_Text_Buffer(); Fl_Text_Buffer* buf = new Fl_Text_Buffer();
con = new Fl_Text_Display(splt->container2->x(),splt->container2->y(),splt->container2->w(),splt->container2->h()); _con = new Fl_Text_Display(_splt->container2->x(),_splt->container2->y(),_splt->container2->w(),_splt->container2->h());
con->buffer(buf); _con->buffer(buf);
splt->container2->add(con); _splt->container2->add(_con);
// Create a tab view and added it to the upper splitter area // Create a tab view and added it to the upper splitter area
tabs = new Fl_Tabs(splt->container1->x(),splt->container1->y(),splt->container1->w(),splt->container1->h()); _tabs = new Fl_Tabs(_splt->container1->x(),_splt->container1->y(),_splt->container1->w(),_splt->container1->h());
tabs->callback(_s_tab_cb,this); _tabs->callback(_s_tab_cb,this);
tabs->end(); _tabs->end();
splt->container1->add(tabs); _splt->container1->add(_tabs);
int tx,ty,th,tw; int tx,ty,th,tw;
tabs->client_area(tx,ty,tw,th); _tabs->client_area(tx,ty,tw,th);
// Create the 'Setup' tab group // Create the 'Setup' tab group
Fl_Group* setup_grp = new Fl_Group(tx,ty,tw,th,"Setup"); Fl_Group* setup_grp = new Fl_Group(tx,ty,tw,th,"Setup");
tabs->add(setup_grp); _tabs->add(setup_grp);
_createSetupDlg(setup_grp); _createSetupDlg(setup_grp);
// Create the master group // Create the master group
tabs->add(mstr_grp = new Fl_Group(tx,ty,tw,th,"Master")); _tabs->add(_mstr_grp = new Fl_Group(tx,ty,tw,th,"Master"));
// Create an empty tab group and make it resizable // Create an empty tab group and make it resizable
// to prevent the other tab groups from being resizable. // to prevent the other tab groups from being resizable.
Fl_Group* wdgt = new Fl_Group(tx,ty+30,1,1); Fl_Group* wdgt = new Fl_Group(tx,ty+30,1,1);
tabs->add(wdgt); _tabs->add(wdgt);
tabs->resizable(wdgt); // make other tabs non-resizable _tabs->resizable(wdgt); // make other tabs non-resizable
// make the splitter the resizable group element (thereby making the menu non-resizable). // make the splitter the resizable group element (thereby making the menu non-resizable).
// see:http://fltk.org/articles.php?L415+I0+T+M1000+P1 // see:http://fltk.org/articles.php?L415+I0+T+M1000+P1
resizable(splt); resizable(_splt);
show(argc, argv); show(argc, argv);
// direct all output to the console window // direct all output to the console window
cmRptSetup(&_ctx.rpt,_s_print,_s_print, this); cmRptSetup(&_ctx->rpt,_s_print,_s_print, this);
cmTsMp1cSetCbFunc(_printqH, _s_print_queue_cb, this ); cmTsMp1cSetCbFunc(_printqH, _s_print_queue_cb, this );
// install a timer to check for messages from the engine // install a timer to check for messages from the engine
@ -138,7 +141,7 @@ kcApp::~kcApp()
void kcApp::resize(int x, int y, int w, int h) void kcApp::resize(int x, int y, int w, int h)
{ {
Fl_Double_Window::resize(x, y, w, h); Fl_Double_Window::resize(x, y, w, h);
splt->resize(0, kMenuH, w, h-kStatusH); _splt->resize(0, kMenuH, w, h-kStatusH);
} }
void kcApp::tlCtlNewTimeLineFile( tlCtl* tlCtl, const cmChar_t* fn ) void kcApp::tlCtlNewTimeLineFile( tlCtl* tlCtl, const cmChar_t* fn )
@ -161,41 +164,41 @@ void kcApp::_createSetupDlg( Fl_Group* grp )
btn->callback( _s_btn_cb, kAudDevRptBtnId ); btn->callback( _s_btn_cb, kAudDevRptBtnId );
yy += btn->h() + vBord; yy += btn->h() + vBord;
as_btn = new Fl_Menu_Button(xx,yy,ctl_width,kMenuH,"Audio System Cfg"); _as_btn = new Fl_Menu_Button(xx,yy,ctl_width,kMenuH,"Audio System Cfg");
as_btn->callback( _s_btn_cb, kAudioSysCfgBtnId); _as_btn->callback( _s_btn_cb, kAudioSysCfgBtnId);
yy += as_btn->h() + vBord; yy += _as_btn->h() + vBord;
ai_btn = new Fl_Menu_Button(xx,yy,ctl_width,kMenuH,"Audio Input Devices"); _ai_btn = new Fl_Menu_Button(xx,yy,ctl_width,kMenuH,"Audio Input Devices");
ai_btn->callback( _s_btn_cb, kInAudDevBtnId); _ai_btn->callback( _s_btn_cb, kInAudDevBtnId);
yy += ai_btn->h() + vBord; yy += _ai_btn->h() + vBord;
ao_btn = new Fl_Menu_Button(xx,yy,ctl_width,kMenuH,"Audio Output Devices"); _ao_btn = new Fl_Menu_Button(xx,yy,ctl_width,kMenuH,"Audio Output Devices");
ao_btn->callback( _s_btn_cb, kOutAudDevBtnId); _ao_btn->callback( _s_btn_cb, kOutAudDevBtnId);
yy += ao_btn->h() + vBord; yy += _ao_btn->h() + vBord;
pgm_btn = new Fl_Menu_Button(xx,yy,ctl_width,kMenuH,"Programs"); _pgm_btn = new Fl_Menu_Button(xx,yy,ctl_width,kMenuH,"Programs");
pgm_btn->callback( _s_btn_cb, kPgmBtnId); _pgm_btn->callback( _s_btn_cb, kPgmBtnId);
yy += pgm_btn->h() + vBord; yy += _pgm_btn->h() + vBord;
ss_btn = new Fl_Menu_Button(xx,yy,ctl_width,kMenuH,"Sub-System"); _ss_btn = new Fl_Menu_Button(xx,yy,ctl_width,kMenuH,"Sub-System");
ss_btn->callback( _s_btn_cb, kSubSystemIdxBtnId); _ss_btn->callback( _s_btn_cb, kSubSystemIdxBtnId);
yy += ss_btn->h() + vBord; yy += _ss_btn->h() + vBord;
sr_btn = new Fl_Menu_Button(xx,yy,ctl_width,kMenuH,"Sample Rate"); _sr_btn = new Fl_Menu_Button(xx,yy,ctl_width,kMenuH,"Sample Rate");
sr_btn->callback( _s_btn_cb, kSrateBtnId); _sr_btn->callback( _s_btn_cb, kSrateBtnId);
sr_btn->add("44100",0,NULL,(void*)44100,0); _sr_btn->add("44100",0,NULL,(void*)44100,0);
sr_btn->add("48000",0,NULL,(void*)48000,0); _sr_btn->add("48000",0,NULL,(void*)48000,0);
sr_btn->add("96000",0,NULL,(void*)96000,0); _sr_btn->add("96000",0,NULL,(void*)96000,0);
yy += sr_btn->h() + vBord; yy += _sr_btn->h() + vBord;
btn = new Fl_Button(xx,yy,ctl_width,kMenuH,"Test"); btn = new Fl_Button(xx,yy,ctl_width,kMenuH,"Test");
btn->callback( _s_btn_cb, kTestBtnId ); btn->callback( _s_btn_cb, kTestBtnId );
yy += btn->h() + vBord; yy += btn->h() + vBord;
ena_chk = new Fl_Check_Button(xx,yy,ctl_width,kMenuH,"Enable Audio"); _ena_chk = new Fl_Check_Button(xx,yy,ctl_width,kMenuH,"Enable Audio");
ena_chk->callback( _s_btn_cb, kEnableBtnId ); _ena_chk->callback( _s_btn_cb, kEnableBtnId );
yy += ena_chk->h() + vBord; yy += _ena_chk->h() + vBord;
// place this ctrl in the lower left corner to prevent the other controls from resizing // place this ctrl in the lower left corner to prevent the other controls from resizing
Fl_Box* bx = new Fl_Box(FL_NO_BOX,xx+ctl_width,yy,10,10,NULL); Fl_Box* bx = new Fl_Box(FL_NO_BOX,xx+ctl_width,yy,10,10,NULL);
@ -222,7 +225,7 @@ void kcApp::_createMenu(int w, int h)
kcApp::page_t* kcApp::_createPage( const char* title ) kcApp::page_t* kcApp::_createPage( const char* title )
{ {
int tx,ty,th,tw; int tx,ty,th,tw;
tabs->client_area(tx,ty,tw,th); _tabs->client_area(tx,ty,tw,th);
page_t* page = new page_t; page_t* page = new page_t;
page->link = _pageList; page->link = _pageList;
@ -231,13 +234,13 @@ kcApp::page_t* kcApp::_createPage( const char* title )
_newPageFl = true; _newPageFl = true;
// Create the 'Controls' tab group // Create the 'Controls' tab group
tabs->begin(); _tabs->begin();
page->grp = new Fl_Group(tx,ty,tw,th,title); page->grp = new Fl_Group(tx,ty,tw,th,title);
page->grp->begin(); page->grp->begin();
Fl_Box* bx = new Fl_Box(FL_NO_BOX,page->grp->x()+page->grp->w(),page->grp->y()+page->grp->h(),1,1,NULL); Fl_Box* bx = new Fl_Box(FL_NO_BOX,page->grp->x()+page->grp->w(),page->grp->y()+page->grp->h(),1,1,NULL);
page->grp->resizable(bx); page->grp->resizable(bx);
page->grp->end(); page->grp->end();
tabs->end(); _tabs->end();
return page; return page;
} }
@ -293,7 +296,7 @@ void kcApp::_clearCtlList(bool mstrFl)
_ctlList = ncl; // make the new ctl list the current ctl list _ctlList = ncl; // make the new ctl list the current ctl list
if( mstrFl ) if( mstrFl )
mstr_grp->clear(); _mstr_grp->clear();
_tlCtl = NULL; _tlCtl = NULL;
} }
@ -484,7 +487,7 @@ void kcApp::_insertNewCtl( ctl_t* cp, const cmDspUiHdr_t* m, Fl_Widget* wdgt, un
// _genNewCtlPosn() should have been called before this - where a new page list would have been created. // _genNewCtlPosn() should have been called before this - where a new page list would have been created.
assert( cp->mstrFl || (cp->mstrFl==false && _pageList != NULL) ); assert( cp->mstrFl || (cp->mstrFl==false && _pageList != NULL) );
Fl_Group* grp = cp->mstrFl ? mstr_grp : _pageList->grp; Fl_Group* grp = cp->mstrFl ? _mstr_grp : _pageList->grp;
cp->wdgtPtr = wdgt; cp->wdgtPtr = wdgt;
cp->wdgtPtr->callback(_s_ctl_cb, cp ); cp->wdgtPtr->callback(_s_ctl_cb, cp );
@ -746,15 +749,15 @@ kcApp::kcKmRC_t kcApp::_loadMlist( ctl_t* cp, const cmJsonNode_t* np )
switch(jsRC) switch(jsRC)
{ {
case kBufTooSmallJsRC: case kBufTooSmallJsRC:
rc = cmErrMsg(&_ctx.err,kMlistLoadFailKmRC,"The msg list line character buffer is too small at JSON array element index %i.",ri); rc = cmErrMsg(&_ctx->err,kMlistLoadFailKmRC,"The msg list line character buffer is too small at JSON array element index %i.",ri);
break; break;
case kInvalidNodeTypeJsRC: case kInvalidNodeTypeJsRC:
rc = cmErrMsg(&_ctx.err,kMlistLoadFailKmRC,"The msg list array element at index %i is not a JSON leaf node.",ri); rc = cmErrMsg(&_ctx->err,kMlistLoadFailKmRC,"The msg list array element at index %i is not a JSON leaf node.",ri);
break; break;
default: default:
rc = cmErrMsg(&_ctx.err,kMlistLoadFailKmRC,"JSON to msg list text conversion failed on array element %i.",ri); rc = cmErrMsg(&_ctx->err,kMlistLoadFailKmRC,"JSON to msg list text conversion failed on array element %i.",ri);
break; break;
} }
break; break;
@ -768,7 +771,7 @@ kcApp::kcKmRC_t kcApp::_loadMlist( ctl_t* cp, const cmJsonNode_t* np )
if( j+1 < m ) if( j+1 < m )
{ {
if( bep - bbp < 1 ) if( bep - bbp < 1 )
rc = cmErrMsg(&_ctx.err,kMlistLoadFailKmRC,"The msg list line buffer is too small."); rc = cmErrMsg(&_ctx->err,kMlistLoadFailKmRC,"The msg list line buffer is too small.");
else else
{ {
*bbp++ = '\t'; *bbp++ = '\t';
@ -1088,18 +1091,22 @@ void kcApp::_createTmln( const cmDspUiHdr_t* m )
page_t* pg = _createPage("TimeLine"); page_t* pg = _createPage("TimeLine");
ctl_t* cp = _createCtl(m, kTmlnTypeId, x,y,w,h, true ); ctl_t* cp = _createCtl(m, kTmlnTypeId, x,y,w,h, true );
w = pg->grp->w(); w = pg->grp->w();
h = pg->grp->h(); h = pg->grp->h();
cp->u.tmln.tlctl = new tlCtl(&_ctx,this,_menu,this); // currently we only support one score control because
// currently we only support one time-line control because
// we have not yet implmenented a method of providing // we have not yet implmenented a method of providing
// timer callbacks to a list of UI controls // timer callbacks to a list of UI controls
assert( _tlCtl == NULL ); if( _tlCtl != NULL )
_tlCtl = cp->u.tmln.tlctl; cp->u.tmln.tlctl = _tlCtl;
else
{
_tlCtl = new tlCtl(_ctx,this,_menu,this);
cp->u.tmln.tlctl = _tlCtl;
}
Fl_Widget* wdgt = cp->u.tmln.tlctl->initTimeLineCtlr(x,y,w,h); Fl_Widget* wdgt = cp->u.tmln.tlctl->initTimeLineCtlr(x,y,w,h);
@ -1110,17 +1117,12 @@ void kcApp::_createTmln( const cmDspUiHdr_t* m )
void kcApp::_setTmlnValue( ctl_t* cp, unsigned instVarId, const cmDspValue_t* vp ) void kcApp::_setTmlnValue( ctl_t* cp, unsigned instVarId, const cmDspValue_t* vp )
{ {
unsigned i=0; unsigned i=0;
//tlCtl* tp = cp->u.tmln.tlctl;
for(i=0; i<kTmlnVarCnt; ++i) for(i=0; i<kTmlnVarCnt; ++i)
if( cp->u.tmln.varIdArray[i] == instVarId ) if( cp->u.tmln.varIdArray[i] == instVarId )
{ {
switch(i) switch(i)
{ {
case kTmlnSelArgIdx:
//tp->value( cmDsvStrcz(vp));
break;
case kTmlnFileArgIdx: case kTmlnFileArgIdx:
{ {
@ -1144,12 +1146,80 @@ void kcApp::_setTmlnValue( ctl_t* cp, unsigned instVarId, const cmDspValue_t* vp
} }
break; break;
case kTmlnSelArgIdx:
//tp->value( cmDsvStrcz(vp));
break;
case kTmlnCursArgIdx:
cp->u.tmln.tlctl->setAudioFileCursor(cmDsvUInt(vp));
break;
default: default:
{ assert(0); } { assert(0); }
} }
} }
} }
void kcApp::_createScor( const cmDspUiHdr_t* m )
{
int x,y,w=0,h=0;
page_t* pg = _createPage("Score");
ctl_t* cp = _createCtl(m, kScorTypeId, x,y,w,h, true );
w = pg->grp->w();
h = pg->grp->h();
// currently we only support one score control because
// we have not yet implmenented a method of providing
// timer callbacks to a list of UI controls
if( _tlCtl != NULL )
cp->u.scor.tlctl = _tlCtl;
else
{
_tlCtl = new tlCtl(_ctx,this,_menu,this);
cp->u.scor.tlctl = _tlCtl;
}
Fl_Widget* wdgt = cp->u.scor.tlctl->initScoreCtlr(x,y,w,h);
_insertNewCtl(cp,m,wdgt,cp->u.scor.varIdArray,kScorVarCnt);
}
void kcApp::_setScorValue( ctl_t* cp, unsigned instVarId, const cmDspValue_t* vp )
{
unsigned i=0;
//tlCtl* tp = cp->u.scor.tlctl;
for(i=0; i<kScorVarCnt; ++i)
if( cp->u.scor.varIdArray[i] == instVarId )
{
switch(i)
{
case kScorSelArgIdx:
//tp->value( cmDsvStrcz(vp));
break;
case kScorFileArgIdx:
{
const char* fn;
if((fn = cmDsvStrcz(vp)) != NULL )
{
cp->u.scor.tlctl->openScoreFile(fn);
//cp->u.scor.tlctl->redraw();
}
}
break;
default:
{ assert(0); }
}
}
}
void kcApp::_newColumn( const cmDspUiHdr_t* m ) void kcApp::_newColumn( const cmDspUiHdr_t* m )
{ {
@ -1162,14 +1232,14 @@ void kcApp::_newColumn( const cmDspUiHdr_t* m )
void kcApp::_insertAudioSysCfgLabel(unsigned long idx, const char* label) void kcApp::_insertAudioSysCfgLabel(unsigned long idx, const char* label)
{ {
if( idx == 0 ) if( idx == 0 )
as_btn->clear(); _as_btn->clear();
as_btn->add(label,0,NULL,(void*)idx,0); _as_btn->add(label,0,NULL,(void*)idx,0);
} }
void kcApp::_insertDeviceLabel( unsigned long devIdx, bool inputFl, const cmChar_t* label ) void kcApp::_insertDeviceLabel( unsigned long devIdx, bool inputFl, const cmChar_t* label )
{ {
Fl_Menu_Button* bp = inputFl ? ai_btn : ao_btn; Fl_Menu_Button* bp = inputFl ? _ai_btn : _ao_btn;
// ??? if( idx == 0 ) // ??? if( idx == 0 )
// bp->clear(); // bp->clear();
@ -1181,9 +1251,9 @@ void kcApp::_insertDeviceLabel( unsigned long devIdx, bool inputFl, const cmChar
void kcApp::_insertProgramLabel( unsigned long idx, const cmChar_t* label ) void kcApp::_insertProgramLabel( unsigned long idx, const cmChar_t* label )
{ {
if( idx == 0 ) if( idx == 0 )
pgm_btn->clear(); _pgm_btn->clear();
pgm_btn->add(label,0,NULL,(void*)idx,0); _pgm_btn->add(label,0,NULL,(void*)idx,0);
} }
void kcApp::_insertSubSysCnt( unsigned long subSysCnt ) void kcApp::_insertSubSysCnt( unsigned long subSysCnt )
@ -1209,11 +1279,11 @@ void kcApp::_insertSubSysCnt( unsigned long subSysCnt )
id = i-1; id = i-1;
} }
ss_btn->add(label,0,NULL,(void*)id); _ss_btn->add(label,0,NULL,(void*)id);
} }
ss_btn->value(0); _ss_btn->value(0);
ss_btn->copy_label( ss_btn->mvalue()->label() ); _ss_btn->copy_label( _ss_btn->mvalue()->label() );
} }
unsigned kcApp::_getCurAudioSubSysIdx() unsigned kcApp::_getCurAudioSubSysIdx()
@ -1221,7 +1291,7 @@ unsigned kcApp::_getCurAudioSubSysIdx()
const Fl_Menu_Item* mip; const Fl_Menu_Item* mip;
unsigned retVal = 0; unsigned retVal = 0;
if( (mip = ss_btn->mvalue()) != NULL) if( (mip = _ss_btn->mvalue()) != NULL)
retVal = mip->argument(); retVal = mip->argument();
return retVal; return retVal;
@ -1249,7 +1319,7 @@ void kcApp::_setDeviceMenuButton( unsigned asSubIdx, bool inputFl, unsigned devI
if( _getCurAudioSubSysIdx() != asSubIdx ) if( _getCurAudioSubSysIdx() != asSubIdx )
return; return;
Fl_Menu_Button* mbp = inputFl ? ai_btn : ao_btn; Fl_Menu_Button* mbp = inputFl ? _ai_btn : _ao_btn;
const Fl_Menu_Item* map = mbp->menu(); const Fl_Menu_Item* map = mbp->menu();
unsigned n = mbp->size(); unsigned n = mbp->size();
@ -1270,18 +1340,18 @@ void kcApp::_setDeviceMenuButton( unsigned asSubIdx, bool inputFl, unsigned devI
void kcApp::_setSampleRateBtn( unsigned value ) void kcApp::_setSampleRateBtn( unsigned value )
{ {
unsigned i; unsigned i;
unsigned n = sr_btn->size(); unsigned n = _sr_btn->size();
for(i=0; i<n-1; ++i) for(i=0; i<n-1; ++i)
{ {
if( sr_btn->menu()[i].argument() == value ) if( _sr_btn->menu()[i].argument() == value )
{ {
sr_btn->value(i); _sr_btn->value(i);
sr_btn->copy_label( sr_btn->mvalue()->label() ); _sr_btn->copy_label( _sr_btn->mvalue()->label() );
return; return;
} }
} }
sr_btn->copy_label("Sample Rate?"); _sr_btn->copy_label("Sample Rate?");
} }
@ -1454,7 +1524,7 @@ void kcApp::_handleSsInitMsg( const cmAudioSysSsInitMsg_t* m, const cmChar_t* in
prog->minimum(0); prog->minimum(0);
prog->maximum(1); prog->maximum(1);
prog->copy_label(lblArray[i]); prog->copy_label(lblArray[i]);
mstr_grp->add(prog); _mstr_grp->add(prog);
ss->cnt[i] = 0; ss->cnt[i] = 0;
ss->prog[i] = prog; ss->prog[i] = prog;
@ -1551,6 +1621,10 @@ void kcApp::_onRecvValue( const cmDspUiHdr_t* m )
_setTmlnValue(cp, m->instVarId, &m->value); _setTmlnValue(cp, m->instVarId, &m->value);
break; break;
case kScorTypeId:
_setScorValue(cp, m->instVarId, &m->value);
break;
default: default:
assert(0); assert(0);
} }
@ -1564,7 +1638,7 @@ void kcApp::_handleUiMsg( const cmDspUiHdr_t* m )
switch( m->selId ) switch( m->selId )
{ {
case kPrintDuiId: case kPrintDuiId:
cmDsvPrint(&m->value,NULL,&_ctx.rpt); cmDsvPrint(&m->value,NULL,&_ctx->rpt);
break; break;
case kNumberDuiId: case kNumberDuiId:
@ -1604,6 +1678,10 @@ void kcApp::_handleUiMsg( const cmDspUiHdr_t* m )
_createTmln(m); _createTmln(m);
break; break;
case kScoreDuiId:
_createScor(m);
break;
case kValueDuiId: case kValueDuiId:
_onRecvValue(m); _onRecvValue(m);
break; break;
@ -1640,7 +1718,7 @@ void kcApp::_handleUiMsg( const cmDspUiHdr_t* m )
break; break;
case kSetAudioCfgDuiId: case kSetAudioCfgDuiId:
_setMenuButton(as_btn,cmDsvUInt(&m->value),"Audio System Cfg"); _setMenuButton(_as_btn,cmDsvUInt(&m->value),"Audio System Cfg");
break; break;
case kSetAudioDevDuiId: case kSetAudioDevDuiId:
@ -1652,12 +1730,12 @@ void kcApp::_handleUiMsg( const cmDspUiHdr_t* m )
break; break;
case kSetPgmDuiId: case kSetPgmDuiId:
_setMenuButton(pgm_btn,cmDsvUInt(&m->value),"Program?"); _setMenuButton(_pgm_btn,cmDsvUInt(&m->value),"Program?");
_clearCtlList(false); _clearCtlList(false);
break; break;
case kEnableDuiId: case kEnableDuiId:
ena_chk->value(m->flags); _ena_chk->value(m->flags);
break; break;
} }
@ -1685,7 +1763,7 @@ void kcApp::_getEngMsg()
if( aiRC == kNoMsgAiRC ) if( aiRC == kNoMsgAiRC )
break; break;
cmErrMsg(&_ctx.err,kEngFailKmRC,"Audio DSP dispatch message request failed."); cmErrMsg(&_ctx->err,kEngFailKmRC,"Audio DSP dispatch message request failed.");
break; break;
} }
} }
@ -1712,7 +1790,7 @@ void kcApp::_testStub()
cmAudioFileTest( cmAudioFileTest(
// "/Users/kevin/media/audio/20100819-Kreisberg/fragments/Bass End_21a.wav", // "/Users/kevin/media/audio/20100819-Kreisberg/fragments/Bass End_21a.wav",
"/Users/kevin/media/audio/McGill-1/1 Audio Track.aiff", "/Users/kevin/media/audio/McGill-1/1 Audio Track.aiff",
"/Users/kevin/src/octave/cm_audio_file_test.m",_ctx.err.rpt ); "/Users/kevin/src/octave/cm_audio_file_test.m",_ctx->err.rpt );
*/ */
//cmSymTblTest(&_ctx); //cmSymTblTest(&_ctx);
@ -1741,32 +1819,10 @@ void kcApp::_callback(void* data)
{ {
if( Fl::event() == FL_CLOSE ) if( Fl::event() == FL_CLOSE )
{ {
//unsigned cc = _closeCnt; delete _tlCtl;
ctl_t* cp = _ctlList;
for(; cp!=NULL; cp=cp->linkPtr)
if( cp->typeId == kTmlnTypeId )
delete cp->u.tmln.tlctl;
_stopTimerFl = true; _stopTimerFl = true;
// attempt to shut down the pgm
//if( audioDspFinalize() != kOkKmRC )
// ++_closeCnt;
// the first time the pgm fails to shut down
// do not allow the pgm to close the main window
// this will give a chance for the error messages
// to be diplayed in the console - all successive
// times the return value from finalizePgm() is
// ignored and the program is terminated.
/*
if( _closeCnt == 1 && cc==0)
{
deactivate(); // send a strong hint that a problem occurred
return;
}
*/
// When all windows are windows are closed then the app. // When all windows are windows are closed then the app.
// will close - so hiding the application window // will close - so hiding the application window
@ -1832,13 +1888,13 @@ void kcApp::_s_tab_cb(Fl_Widget* w, void* data)
void kcApp::_tab_cb(Fl_Widget*) void kcApp::_tab_cb(Fl_Widget*)
{ {
Fl_Widget* w = tabs->value(); Fl_Widget* w = _tabs->value();
_ssUpdateFl = w == (Fl_Widget*)mstr_grp; _ssUpdateFl = w == (Fl_Widget*)_mstr_grp;
_ssPhase = kSsPhaseMax; _ssPhase = kSsPhaseMax;
if( cmAdIfIsValid(_aiH) ) if( cmAdIfIsValid(_aiH) )
{ {
if( cmAdIfEnableStatusNotify(_aiH, _ssUpdateFl ) != kOkAiRC ) if( cmAdIfEnableStatusNotify(_aiH, _ssUpdateFl ) != kOkAiRC )
cmErrMsg(&_ctx.err,kEngFailKmRC,"A request to enable/disable status notification failed."); cmErrMsg(&_ctx->err,kEngFailKmRC,"A request to enable/disable status notification failed.");
} }
} }
@ -1962,6 +2018,15 @@ void kcApp::_ctl_cb(ctl_t* cp)
} }
break; break;
case kScorTypeId:
{
instVarId = cp->u.text.varIdArray[ kScorSelArgIdx ];
unsigned selEleIdx = cp->u.scor.tlctl->scoreSelectedEleIndex();
cmDsvSetUInt(&value, selEleIdx );
}
break;
default: default:
{assert(0);} {assert(0);}
@ -1977,7 +2042,7 @@ void kcApp::_ctl_cb(ctl_t* cp)
instVarId, instVarId,
&value) != kOkAiRC) &value) != kOkAiRC)
{ {
cmErrMsg(&_ctx.err,kEngFailKmRC,"An attempt to send a UI message to the audio DSP interface failed."); cmErrMsg(&_ctx->err,kEngFailKmRC,"An attempt to send a UI message to the audio DSP interface failed.");
} }
} }
@ -2000,7 +2065,7 @@ void kcApp::vprint(const char* fmt, va_list vl )
{ {
// use _printFl to guard against recursion which would eventually overflow the stack. // use _printFl to guard against recursion which would eventually overflow the stack.
++_printFl; ++_printFl;
cmErrMsg(&_ctx.err,kQueueFailKmRC,"Print enqueue failed on msg:%s.",buf); cmErrMsg(&_ctx->err,kQueueFailKmRC,"Print enqueue failed on msg:%s.",buf);
--_printFl; --_printFl;
} }
@ -2035,15 +2100,15 @@ void kcApp::_checkPrintQueue()
if( cmTsMp1cDequeueMsg(_printqH, NULL, 0) != kOkThRC && _printFl==0 ) if( cmTsMp1cDequeueMsg(_printqH, NULL, 0) != kOkThRC && _printFl==0 )
{ {
++_printFl; ++_printFl;
cmErrMsg(&_ctx.err,kPrintQueFailKmRC,"Print dequeue failed."); cmErrMsg(&_ctx->err,kPrintQueFailKmRC,"Print dequeue failed.");
--_printFl; --_printFl;
} }
} }
void kcApp::_print( const char* text ) void kcApp::_print( const char* text )
{ {
if( con != NULL ) if( _con != NULL )
con->insert(text); _con->insert(text);
#ifndef NDEBUG #ifndef NDEBUG
fputs(text,stdout); fputs(text,stdout);
#endif #endif

View File

@ -44,9 +44,6 @@ class kcApp : public Fl_Double_Window, public tlCtlRspdr
public: public:
typedef unsigned kcKmRC_t; typedef unsigned kcKmRC_t;
kcApp(cmCtx_t* ctx, cmTsMp1cH_t printQH, int w, int h, const cmChar_t* title, cmAiH_t aiH, int argc, char* argv[] ); kcApp(cmCtx_t* ctx, cmTsMp1cH_t printQH, int w, int h, const cmChar_t* title, cmAiH_t aiH, int argc, char* argv[] );
virtual ~kcApp(); virtual ~kcApp();
@ -71,24 +68,6 @@ private:
kSsPhaseMax = 20 kSsPhaseMax = 20
}; };
//Fl_Menu_Bar* menu;
Fl_HSplitter* splt;
Fl_Box* ind[4];
Fl_Text_Buffer* buf;
Fl_Text_Display* con;
Fl_Tabs* tabs;
Fl_Check_Button* ena_chk;
//Fl_Group* ctl_grp;
Fl_Menu_Button* as_btn;
Fl_Menu_Button* ai_btn;
Fl_Menu_Button* ao_btn;
Fl_Menu_Button* pgm_btn;
Fl_Menu_Button* ss_btn;
Fl_Menu_Button* sr_btn;
Fl_Group* mstr_grp;
enum enum
{ {
@ -102,7 +81,7 @@ private:
kMlstTypeId, kMlstTypeId,
kMetrTypeId, kMetrTypeId,
kTmlnTypeId, kTmlnTypeId,
kScorTypeId,
kSldrMinArgIdx = 0, kSldrMinArgIdx = 0,
kSldrMaxArgIdx = 1, kSldrMaxArgIdx = 1,
@ -146,7 +125,12 @@ private:
kTmlnFileArgIdx= 0, kTmlnFileArgIdx= 0,
kTmlnPathArgIdx= 1, kTmlnPathArgIdx= 1,
kTmlnSelArgIdx = 2, kTmlnSelArgIdx = 2,
kTmlnVarCnt = 3 kTmlnCursArgIdx= 3,
kTmlnVarCnt = 4,
kScorFileArgIdx = 0,
kScorSelArgIdx = 1,
kScorVarCnt = 2
}; };
@ -236,6 +220,13 @@ private:
unsigned varIdArray[ kTmlnVarCnt ]; unsigned varIdArray[ kTmlnVarCnt ];
} tmln_t; } tmln_t;
typedef struct scor_str
{
tlCtl* tlctl;
char* val;
unsigned varIdArray[ kScorVarCnt ];
} scor_t;
typedef struct ctl_str typedef struct ctl_str
{ {
@ -256,6 +247,7 @@ private:
mlst_t mlst; mlst_t mlst;
metr_t metr; metr_t metr;
tmln_t tmln; tmln_t tmln;
scor_t scor;
} u; } u;
struct ctl_str* linkPtr; struct ctl_str* linkPtr;
} ctl_t; } ctl_t;
@ -285,10 +277,23 @@ private:
} ss_t; } ss_t;
cmCtx_t _ctx; cmCtx_t* _ctx;
Fl_Menu_Bar* _menu; cmAiH_t _aiH;
cmAiH_t _aiH;
unsigned _statIdx; Fl_Menu_Bar* _menu;
Fl_HSplitter* _splt;
Fl_Text_Display* _con;
Fl_Tabs* _tabs;
Fl_Group* _mstr_grp;
Fl_Menu_Button* _as_btn;
Fl_Menu_Button* _ai_btn;
Fl_Menu_Button* _ao_btn;
Fl_Menu_Button* _pgm_btn;
Fl_Menu_Button* _ss_btn;
Fl_Menu_Button* _sr_btn;
Fl_Check_Button* _ena_chk;
page_t* _pageList; page_t* _pageList;
ctl_t* _ctlList; ctl_t* _ctlList;
bool _stopTimerFl; bool _stopTimerFl;
@ -297,12 +302,11 @@ private:
unsigned _colW; unsigned _colW;
bool _horzBordFl; bool _horzBordFl;
unsigned _horzBord; unsigned _horzBord;
unsigned _closeCnt;
unsigned _ssCnt; // count of audio system sub-systems (set in _handleSsInitMsg()) unsigned _ssCnt; // count of audio system sub-systems (set in _handleSsInitMsg())
ss_t* _ssArray; ss_t* _ssArray;
int _ssPhase; int _ssPhase;
bool _ssUpdateFl; bool _ssUpdateFl;
cmTsMp1cH_t _printqH; // thread-safe queue for controlling access to the output console from multiple threads cmTsMp1cH_t _printqH; // thread-safe queue for controlling access to the output console from multiple threads
int _printFl; int _printFl;
tlCtl* _tlCtl; tlCtl* _tlCtl;
@ -337,6 +341,9 @@ private:
void _setLabelValue( ctl_t* cp, unsigned instVarId, const cmDspValue_t* vp ); void _setLabelValue( ctl_t* cp, unsigned instVarId, const cmDspValue_t* vp );
void _createTmln( const cmDspUiHdr_t* m ); void _createTmln( const cmDspUiHdr_t* m );
void _setTmlnValue( ctl_t* cp, unsigned instVarId, const cmDspValue_t* vp ); void _setTmlnValue( ctl_t* cp, unsigned instVarId, const cmDspValue_t* vp );
void _createScor( const cmDspUiHdr_t* m );
void _setScorValue( ctl_t* cp, unsigned instVarId, const cmDspValue_t* vp );
void _newColumn( const cmDspUiHdr_t* m ); void _newColumn( const cmDspUiHdr_t* m );
void _insertAudioSysCfgLabel(unsigned long idx, const cmChar_t* label ); void _insertAudioSysCfgLabel(unsigned long idx, const cmChar_t* label );