📄 xltwavplay.c
字号:
if ( msg->u.toclnt_settings.DataBits != 0 ) { /* Ignore bits if zero.. */ curBits = msg->u.toclnt_settings.DataBits; /* Current server bit setting */ BitsShow(); /* Reflect in controls */ } XtVaSetValues(wStereoCB,XmNset, msg->u.toclnt_settings.Channels == Stereo ? True : False, NULL); /* Show stereo setting */ /* * Update label text: */ XmSprintfLabel(wSamplingRateLbl1,"%lu Hz%s", (unsigned long)msg->u.toclnt_settings.SamplingRate, msg->u.toclnt_settings.bOvrSampling ? "*" : ""); if ( msg->u.toclnt_settings.bOvrSampling != 0 ) { SampleRateChg_Show((int)msg->u.toclnt_settings.SamplingRate); XtVaSetValues(wRateScrollBar,XmNvalue,msg->u.toclnt_settings.SamplingRate,NULL); } else { SampleRateChg_Show(0); XtVaSetValues(wRateScrollBar,XmNvalue,0,NULL); } /* Store this for the time display */ time_display.sampling_rate = (int)msg->u.toclnt_settings.SamplingRate; /* * Currently, this value should be "PCM" (wav file type) */ msg->u.toclnt_settings.WavType[sizeof msg->u.toclnt_settings.WavType - 1] = 0; XmSprintfLabel(wTypeLbl1,"%s",msg->u.toclnt_settings.WavType); /* * Update samples, bits and channels: */ sprintf(time_display.sample_info_str,"%u-bit%s %s%s", (unsigned)msg->u.toclnt_settings.DataBits, msg->u.toclnt_settings.bOvrBits ? "*" : "", msg->u.toclnt_settings.Channels == Stereo ? "stereo" : "mono", msg->u.toclnt_settings.bOvrMode ? "*" : ""); XmSprintfLabel(wSamplesLbl1,"%lu %s", (unsigned long)msg->u.toclnt_settings.Samples, time_display.sample_info_str); /* * Update duration time: */ XmSprintfLabel(wTimeLbl1,"%.2lf seconds", (double)msg->u.toclnt_settings.Samples / (double)msg->u.toclnt_settings.SamplingRate); /* Update time display if required */ seconds = time_display.sample_num / (double)time_display.sampling_rate; XmSprintfLabel(wTimeDisplayLbl1,"%02d:%02d:%02d.%02d", (int)seconds/3600,((int)seconds/60)%60, (int)seconds%60, (int)((seconds-(int)seconds)*SMPTE_FPS)); XtVaSetValues(wTimeScrollBar,XmNincrement, time_display.sampling_rate/SMPTE_FPS, XmNpageIncrement,time_display.sampling_rate,NULL); } else if ( msg->msg_type == ToClnt_WavInfo ) { if ( msg->u.toclnt_wavinfo.Errno != 0 ) { /* * Format an error message where the pathname should go: */ XmSprintfLabel(wFileLbl1,"<%s>",sys_errlist[msg->u.toclnt_wavinfo.Errno]); XmSprintfLabel(wDateLbl1,""); XmSprintfLabel(wSizeLbl1,""); XmSprintfLabel(wSamplesLbl1,""); XmSprintfLabel(wTimeLbl1,""); } else { if ( msg->u.toclnt_wavinfo.wavinfo.DataBits != 0 ) { curBits = msg->u.toclnt_wavinfo.wavinfo.DataBits; /* Current server bit setting */ BitsShow(); /* Reflect in controls */ } XtVaSetValues(wStereoCB,XmNset, msg->u.toclnt_wavinfo.wavinfo.Channels == Stereo ? True : False, NULL); /* Show stereo setting */ /* * Update label text: */ XmSprintfLabel(wSamplingRateLbl1,"%lu Hz", (unsigned long)msg->u.toclnt_wavinfo.wavinfo.SamplingRate); XmSprintfLabel(wTypeLbl1,"%s","PCM"); /* For now... */ XmSprintfLabel(wSamplesLbl1,"%lu %u-bit %s", (unsigned long)msg->u.toclnt_wavinfo.wavinfo.Samples, (unsigned)msg->u.toclnt_wavinfo.wavinfo.DataBits, msg->u.toclnt_wavinfo.wavinfo.Channels == Stereo ? "stereo" : "mono"); XmSprintfLabel(wTimeLbl1,"%.2lf seconds", (double)msg->u.toclnt_wavinfo.wavinfo.Samples / (double)msg->u.toclnt_wavinfo.wavinfo.SamplingRate); /* * Update time slider details: */ time_display.sample_num = 0; time_display.sampling_rate = msg->u.toclnt_wavinfo.wavinfo.SamplingRate; XmSprintfLabel(wTimeDisplayLbl1,"00:00:00.00"); { Arg al[5]; int size = msg->u.toclnt_wavinfo.wavinfo.Samples; XtSetArg(al[0],XmNmaximum,size + (size/10)); XtSetArg(al[1],XmNsliderSize,size/10); XtSetArg(al[2],XmNincrement,time_display.sampling_rate/SMPTE_FPS); XtSetArg(al[3],XmNpageIncrement,time_display.sampling_rate); XtSetArg(al[4],XmNvalue,0); XtSetValues(wTimeScrollBar,al,5); } } } else if ( msg->msg_type == ToClnt_Stat ) { /* * Update stat() info: */ if ( msg->u.toclnt_stat.Errno > 0 ) { /* * Show stat() error: */ XmSprintfLabel(wFileLbl1,"<%s>",sys_errlist[msg->u.toclnt_stat.Errno]); XmSprintfLabel(wDateLbl1,""); XmSprintfLabel(wSizeLbl1,""); XmSprintfLabel(wSamplesLbl1,""); XmSprintfLabel(wTimeLbl1,""); } else { /* * Show stat() info: */ XmSprintfLabel(wDateLbl1,"%s",StrDate(msg->u.toclnt_stat.sbuf.st_mtime)); XmSprintfLabel(wSizeLbl1,"%lu bytes",(unsigned long)msg->u.toclnt_stat.sbuf.st_size); } } else if ( msg->msg_type == ToClnt_Path ) { /* * Update pathname in panel display */ msg->u.toclnt_path.path[msg->bytes] = 0; XmSprintfLabel(wFileLbl1,"%s",msg->u.toclnt_path.path); /* * Highlight the pathname in the list box if we can (it should already be there) */ s = XmStringCreate(msg->u.toclnt_path.path,XmSTRING_DEFAULT_CHARSET); XmListSelectItem(wSelectionsListBox,s,False); XmStringFree(s); if ( !bRecorded && !strcmp(msg->u.toclnt_path.path,RECORD_PATH) ) { s = XmStringCreateLtoR(RECORD_PATH,XmSTRING_DEFAULT_CHARSET); PutFileSelection(s); XmStringFree(s); bRecorded = 1; } } else if ( msg->msg_type == ToClnt_PlayState ) { /* * Update time, duration and samples left during playback. */ XmSprintfLabel(wSamplesLbl1,"%lu %s", (unsigned long)msg->u.toclnt_playstate.SamplesLeft, time_display.sample_info_str); XmSprintfLabel(wTimeLbl1,"%.2lf seconds", (double)msg->u.toclnt_playstate.SamplesLeft / (double)time_display.sampling_rate); time_display.sample_num = msg->u.toclnt_playstate.CurrentSample; seconds = time_display.sample_num / (double)time_display.sampling_rate; XmSprintfLabel(wTimeDisplayLbl1,"%02d:%02d:%02d.%02d", (int)seconds/3600,((int)seconds/60)%60, (int)seconds%60, (int)((seconds-(int)seconds)*SMPTE_FPS)); XtVaSetValues(wTimeScrollBar,XmNvalue,time_display.sample_num); } else if ( msg->msg_type == ToClnt_RecState ) { /* * Update size, number of samples and duration during record. */ XmSprintfLabel(wSizeLbl1,"%lu bytes",(unsigned long)msg->u.toclnt_recstate.bytes_written); XmSprintfLabel(wSamplesLbl1,"%lu %s", (unsigned long)msg->u.toclnt_recstate.num_samples, time_display.sample_info_str); XmSprintfLabel(wTimeLbl1,"%.2lf seconds", (double)msg->u.toclnt_recstate.num_samples / (double)time_display.sampling_rate); } else if ( msg->msg_type == ToClnt_ErrMsg ) ReportError(msg->u.toclnt_errmsg.msg);}/* * This timed procedure just looks for incoming messages from the server: */static voidTimerProc1(XtPointer client_data,XtIntervalId *timer_id) { SVRMSG msg; int z; /* * Process messages until we run out of messages: */rpt: while ( (z = MsgFromServer(svrIPC,&msg,IPC_NOWAIT)) == 0 ) DispatchMsg(&msg); /* Act upon the server message */ if ( z != 0 && errno != ENOMSG ) { ReportErrorf("%s: Internal error from MsgFromServer()",sys_errlist[errno]); goto rpt; /* There may be more messages */ } XtAppAddTimeOut(aContext,TIMER1_MS,TimerProc1,NULL);}/* * The main program needs no introduction: */intmain(int argc,char **argv) { Arg al[20]; /* Arg list */ Cardinal ac; /* Args count */ char *cp; /* * Set environmental values: */ if ( (cp = getenv("WAVPLAYPATH")) != NULL ) env_WAVPLAYPATH = cp; /* Environment overrides compiled in default for WAVPLAYPATH */ if ( (cp = getenv("AUDIODEV")) != NULL ) env_AUDIODEV = cp; /* Environment overrides compiled in default for AUDIODEV */ if ( (cp = getenv("AUDIOLCK")) == NULL || sscanf(cp,"%lX",&env_AUDIOLCK) != 1 ) env_AUDIOLCK = AUDIOLCK; /* Use compiled in default, if no environment, or its bad */ /* * CreateApplication Context: */ ac = 0; XtSetArg(al[ac],XmNtitle,"X LessTif WAV Play version " WAVPLAY_VERSION); ++ac; wParent = XtAppInitialize(&aContext, "xltwavplay", /* app. class */ (XrmOptionDescList) NULL, 0, /* options */ &argc, argv, /* cmd line */ fallback_resources, /* fallback resources */ al,ac); /* hard coded resources */ /* * Create XmString() version of RECORD_PATH for list box processing: */ sRecorded_wav = XmStringCreate(RECORD_PATH,XmSTRING_DEFAULT_CHARSET); /* * Create Main widget: */ ac = 0; wMain = XmCreateMainWindow(wParent,"main",al,ac); XtManageChild(wMain); RegisterShellWidget(wMain); /* This is for Editres */ /* * Create the menu bar at the top of the main window: */ ac = 0; wMenuBar = XmCreateMenuBar(wMain,"menubar",al,ac); XtManageChild(wMenuBar); /* * Create the FILE menu in the menu bar: */ CreateMenu(wMenuBar,&wFileMenu,"filemenu",&wFileMenuCascade,"filemenucascade", "select_files",'M',PopupSelectFilesCB,&wSelect, /* File->Select */ "save_as",'M',PopupSaveAsCB,&wSaveAs, /* File->Save As.. */ "exit",'M',ExitCB,&wExit, /* File->Exit */ NULL); /* * Create the OPTIONS menu in the menu bar: */ CreateMenu(wMenuBar,&wOptionsMenu,"optsmenu",&wOptionsMenuCascade,"optsmenucascade", "debug",'T',OptionsDebugCB,&wOptions_DebugTgl, /* Options->Debug (toggle) */ "sem_reset",'M',OptionsSemResetCB,&wOptions_SemReset, /* Options->Semaphore Reset */ NULL); /* * Create the HELP menu in the menu bar: */ CreateMenu(wMenuBar,&wHelpMenu,"helpmenu",&wHelpMenuCascade,"helpmenucascade", "about",'M',AboutCB,&wAbout, /* Help->About */ NULL); /* * Create the error message dialog: */ sErrDlgTitle = XmStringCreate("X LessTif WAV Play : Error Message",XmSTRING_DEFAULT_CHARSET); ac = 0; XtSetArg(al[ac],XmNdefaultPosition,FALSE); ac++; XtSetArg(al[ac],XmNdialogStyle,XmDIALOG_APPLICATION_MODAL); ac++; XtSetArg(al[ac],XmNtitle,"Error Report"); ac++; XtSetArg(al[ac],XmNdefaultButtonType,XmDIALOG_OK_BUTTON); ++ac; XtSetArg(al[ac],XmNmessageAlignment,XmALIGNMENT_CENTER); ++ac; XtSetArg(al[ac],XmNdialogTitle,sErrDlgTitle); ++ac; XtSetArg(al[ac],XmNallowResize,FALSE); ++ac; wErrDlg = XmCreateErrorDialog(wParent,"ErrDlg",al,ac); XtAddCallback(wErrDlg,XmNokCallback,ExitDlgCB,NULL); XtUnmanageChild(XmMessageBoxGetChild(wErrDlg,XmDIALOG_CANCEL_BUTTON)); XtUnmanageChild(XmMessageBoxGetChild(wErrDlg,XmDIALOG_HELP_BUTTON)); RegisterShellWidget(wErrDlg); /* * Create About Dialog Message String: */ sAboutDlgTitle = XmStringCreate("About X LessTif WAV Play "WAVPLAY_VERSION,XmSTRING_DEFAULT_CHARSET); sAboutDlgMessage = XmStringCreateLtoR( "xltwavplay version " WAVPLAY_VERSION "\n" "was written by and is\n" "Copyright (C) 1997 by Warren W. Gay VE3WWG\n" "---\n" "Special thanks to Erik de Castro Lopo (erikd@zip.com.au)\n" "for his contributed WAV header code\n" "(files wavfile.c and wavfile.h)\n" "---\n" "Thanks also go to Andre Fuechsel for his original\n" "wavplay that inspired the current work (though\n" "this version does not contain his code)\n" "---\n" "Many thanks to the LINUX folks,\n" "the XFree86 folks,\n" "and the LessTif group\n" "for making this application possible.\n" "---\n" "This program comes with\n" "ABSOLUTELY NO WARRANTY.", XmSTRING_DEFAULT_CHARSET); /* * Create the About Dialog box: */ ac = 0; XtSetArg(al[ac],XmNdefaultPosition,FALSE); ac++; XtSetArg(al[ac],XmNtitle,"Error Report"); ac++; XtSetArg(al[ac],XmNdefaultButtonType,XmDIALOG_OK_BUTTON); ++ac; XtSetArg(al[ac],XmNmessageAlignment,XmALIGNMENT_CENTER); ++ac; XtSetArg(al[ac],XmNdialogTitle,sAboutDlgTitle); ++ac; XtSetArg(al[ac],XmNallowResize,FALSE); ++ac; wAboutDlg = XmCreateMessageDialog(wParent,"AboutDlg",al,ac); XtAddCallback(wAboutDlg,XmNokCallback,AboutDlgOkCB,NULL); XtUnmanageChild(XmMessageBoxGetChild(wAboutDlg,XmDIALOG_CANCEL_BUTTON)); XtUnmanageChild(XmMessageBoxGetChild(wAboutDlg,XmDIALOG_HELP_BUTTON)); RegisterShellWidget(wAboutDlg); /* * Create Files Selection Dialog: */ ac = 0; XtSetArg(al[ac],XmNfileTypeMask,XmFILE_REGULAR); ++ac; wFilesDlg = XmCreateFileSelectionDialog(wParent,"FilesDlg",al,ac); XtAddCallback(wFilesDlg,XmNokCallback,FilesDlgOKCB,NULL); XtAddCallback(wFilesDlg,XmNcancelCallback,DialogCancelCB,(XtPointer)wFilesDlg); XtUnmanageChild(XmFileSelectionBoxGetChild(wFilesDlg,XmDIALOG_HELP_BUTTON)); RegisterShellWidget(wFilesDlg); /* * Create "Save As..." Dialog */ ac = 0; XtSetArg(al[ac],XmNfileTypeMask,XmFILE_REGULAR); ++ac; wSaveAsDlg = XmCreateFileSelectionDialog(wParent,"SaveAsDlg",al,ac); XtAddCallback(wSaveAsDlg,XmNokCallback,SaveAsDlgOKCB,NULL); XtAddCallback(wSaveAsDlg,XmNcancelCallback,DialogCancelCB,(XtPointer)wSaveAsDlg); XtUnmanageChild(XmFileSelectionBoxGetChild(wSaveAsDlg,XmDIALOG_HELP_BUTTON)); RegisterShellWidget(wSaveAsDlg); /* * Create the main form widget: */ ac = 0; wMainForm = XmCreateForm(wMain,"main_form",al,ac); XtManageChild(wMainForm); ac = 0; XtSetArg(al[ac],XmNmarginHeight,6); ++ac; XtSetArg(al[ac],XmNmarginWidth,6); ++ac; wLeftRC = XmCreateRowColumn(wMainForm,"LeftRC",al,ac); XtManageChild(wLeftRC);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -