void CommandTimer (COMMAND_T* ct, int val /*= 0*/, int valhw /*= 0*/, int relmode /*= 0*/, HWND hwnd /*= NULL*/, bool commandHook2 /*= false*/) { #ifdef WIN32 LARGE_INTEGER ticks, start, end; QueryPerformanceFrequency(&ticks); QueryPerformanceCounter(&start); #else timeval start, end; gettimeofday(&start, NULL); #endif if (commandHook2) ct->onAction(ct, val, valhw, relmode, hwnd); else ct->doCommand(ct); #ifdef WIN32 QueryPerformanceCounter(&end); int msTime = (int)((double)(end.QuadPart - start.QuadPart) * 1000 / (double)ticks.QuadPart + 0.5); #else gettimeofday(&end, NULL); int msTime = (int)((double)(end.tv_sec - start.tv_sec) * 1000 + (double)(end.tv_usec - start.tv_usec) / 1000 + 0.5); #endif WDL_FastString string; string.AppendFormatted(256, "%d ms to execute: %s\n", msTime, ct->accel.desc); ShowConsoleMsg(string.Get()); }
void BR_Timer::Progress (const char* message /*= NULL*/) { #ifdef WIN32 LARGE_INTEGER end, ticks; QueryPerformanceCounter(&end); QueryPerformanceFrequency(&ticks); LARGE_INTEGER start = m_start; if (m_paused) // in case timer is still paused start.QuadPart += end.QuadPart - m_pause.QuadPart; double msTime = (double)(end.QuadPart - start.QuadPart) * 1000 / (double)ticks.QuadPart; #else timeval end; gettimeofday(&end, NULL); timeval start = m_start; if (m_paused) // in case timer is still paused { timeval temp; timersub(&end, &m_pause, &temp); timeradd(&m_start, &temp, &start); } double msTime = (double)(end.tv_sec - start.tv_sec) * 1000 + (double)(end.tv_usec - start.tv_usec) / 1000; #endif bool paused = m_paused; this->Pause(); // ShowConsoleMsg wastes time and Progress can be called at any time during measurement WDL_FastString string; string.AppendFormatted(256, "%.3f ms to execute: %s\n", msTime, message ? message : m_message.Get()); ShowConsoleMsg(string.Get()); if (!paused) // resume only if time was not paused in the first place this->Resume(); }
int PromptClearProjectStartupAction(bool _clear) { int r=0, cmdId=SNM_NamedCommandLookup(g_prjActions.Get()->Get()); if (cmdId) { WDL_FastString msg; msg.AppendFormatted(256, _clear ? __LOCALIZE_VERFMT("Are you sure you want to clear the current startup action: '%s'?","sws_mbox") : __LOCALIZE_VERFMT("Are you sure you want to replace the current startup action: '%s'?","sws_mbox"), kbd_getTextFromCmd(cmdId, NULL)); r = MessageBox(GetMainHwnd(), msg.Get(), __LOCALIZE("S&M - Confirmation","sws_mbox"), MB_YESNO); } return r; }
int PromptClearStartupAction(int _type, bool _clear) { int r=0, cmdId=SNM_NamedCommandLookup(_type ? g_globalAction.Get() : g_prjActions.Get()->Get()); if (cmdId) { WDL_FastString msg; if (!_type) { msg.AppendFormatted(512, _clear ? __LOCALIZE_VERFMT("Are you sure you want to clear the project startup action: '%s'?","sws_startup_action") : __LOCALIZE_VERFMT("Are you sure you want to replace the project startup action: '%s'?","sws_startup_action"), kbd_getTextFromCmd(cmdId, NULL)); } else { msg.AppendFormatted(512, _clear ? __LOCALIZE_VERFMT("Are you sure you want to clear the global startup action: '%s'?","sws_startup_action") : __LOCALIZE_VERFMT("Are you sure you want to replace the global startup action: '%s'?","sws_startup_action"), kbd_getTextFromCmd(cmdId, NULL)); } r = MessageBox(GetMainHwnd(), msg.Get(), __LOCALIZE("S&M - Confirmation","sws_mbox"), MB_YESNO); } return r; }
void SetProjectStartupAction(COMMAND_T* _ct) { if (PromptClearProjectStartupAction(false) == IDNO) return; char idstr[SNM_MAX_ACTION_CUSTID_LEN]; lstrcpyn(idstr, __LOCALIZE("Paste command ID or identifier string here","sws_mbox"), sizeof(idstr)); if (PromptUserForString(GetMainHwnd(), SWS_CMD_SHORTNAME(_ct), idstr, sizeof(idstr), true)) { WDL_FastString msg; if (int cmdId = SNM_NamedCommandLookup(idstr)) { // more checks: http://forum.cockos.com/showpost.php?p=1252206&postcount=1618 if (int tstNum = CheckSwsMacroScriptNumCustomId(idstr)) { msg.SetFormatted(256, __LOCALIZE_VERFMT("%s failed: unreliable command ID '%s'!","sws_DLG_161"), SWS_CMD_SHORTNAME(_ct), idstr); msg.Append("\n"); // localization note: msgs shared with the CA editor if (tstNum==-1) msg.Append(__LOCALIZE("For SWS/S&M actions, you must use identifier strings (e.g. _SWS_ABOUT), not command IDs (e.g. 47145).\nTip: to copy such identifiers, right-click the action in the Actions window > Copy selected action cmdID/identifier string.","sws_mbox")); else if (tstNum==-2) msg.Append(__LOCALIZE("For macros/scripts, you must use identifier strings (e.g. _f506bc780a0ab34b8fdedb67ed5d3649), not command IDs (e.g. 47145).\nTip: to copy such identifiers, right-click the macro/script in the Actions window > Copy selected action cmdID/identifier string.","sws_mbox")); MessageBox(GetMainHwnd(), msg.Get(), __LOCALIZE("S&M - Error","sws_DLG_161"), MB_OK); } else { g_prjActions.Get()->Set(idstr); Undo_OnStateChangeEx2(NULL, SWS_CMD_SHORTNAME(_ct), UNDO_STATE_MISCCFG, -1); msg.SetFormatted(256, __LOCALIZE_VERFMT("'%s' is defined as project startup action","sws_mbox"), kbd_getTextFromCmd(cmdId, NULL)); char prjFn[SNM_MAX_PATH] = ""; EnumProjects(-1, prjFn, sizeof(prjFn)); if (*prjFn) { msg.Append("\n"); msg.AppendFormatted(SNM_MAX_PATH, __LOCALIZE_VERFMT("for %s","sws_mbox"), prjFn); } msg.Append("."); MessageBox(GetMainHwnd(), msg.Get(), SWS_CMD_SHORTNAME(_ct), MB_OK); } } else { msg.SetFormatted(256, __LOCALIZE_VERFMT("%s failed: command ID or identifier string '%s' not found in the 'Main' section of the action list!","sws_DLG_161"), SWS_CMD_SHORTNAME(_ct), idstr); MessageBox(GetMainHwnd(), msg.Get(), __LOCALIZE("S&M - Error","sws_DLG_161"), MB_OK); } } }
// _type: 0=Post-Fader (Post-Pan), 1=Pre-FX, 2=deprecated, 3=Pre-Fader (Post-FX) // _undoMsg: NULL=no undo bool CueBuss(const char* _undoMsg, const char* _busName, int _type, bool _showRouting, int _soloDefeat, char* _trTemplatePath, bool _sendToMaster, int* _hwOuts) { if (!SNM_CountSelectedTracks(NULL, false)) return false; WDL_FastString tmplt; if (_trTemplatePath && (!FileOrDirExists(_trTemplatePath) || !LoadChunk(_trTemplatePath, &tmplt) || !tmplt.GetLength())) { char msg[SNM_MAX_PATH] = ""; lstrcpyn(msg, __LOCALIZE("Cue buss not created!\nNo track template file defined","sws_DLG_149"), sizeof(msg)); if (*_trTemplatePath) _snprintfSafe(msg, sizeof(msg), __LOCALIZE_VERFMT("Cue buss not created!\nTrack template not found (or empty): %s","sws_DLG_149"), _trTemplatePath); MessageBox(GetMainHwnd(), msg, __LOCALIZE("S&M - Error","sws_DLG_149"), MB_OK); return false; } bool updated = false; MediaTrack * cueTr = NULL; SNM_SendPatcher* p = NULL; for (int i=1; i <= GetNumTracks(); i++) // skip master { MediaTrack* tr = CSurf_TrackFromID(i, false); if (tr && *(int*)GetSetMediaTrackInfo(tr, "I_SELECTED", NULL)) { GetSetMediaTrackInfo(tr, "I_SELECTED", &g_i0); // add the buss track, done once! if (!cueTr) { InsertTrackAtIndex(GetNumTracks(), false); TrackList_AdjustWindows(false); cueTr = CSurf_TrackFromID(GetNumTracks(), false); GetSetMediaTrackInfo(cueTr, "P_NAME", (void*)_busName); p = new SNM_SendPatcher(cueTr); if (tmplt.GetLength()) { WDL_FastString chunk; MakeSingleTrackTemplateChunk(&tmplt, &chunk, true, true, false); ApplyTrackTemplate(cueTr, &chunk, false, false, p); } updated = true; } // add a send if (cueTr && p && tr != cueTr) AddReceiveWithVolPan(tr, cueTr, _type, p); } } if (cueTr && p) { // send to master/parent init if (!tmplt.GetLength()) { // solo defeat if (_soloDefeat) { char one[2] = "1"; updated |= (p->ParsePatch(SNM_SET_CHUNK_CHAR, 1, "TRACK", "MUTESOLO", 0, 3, one) > 0); } // master/parend send WDL_FastString mainSend; mainSend.SetFormatted(SNM_MAX_CHUNK_LINE_LENGTH, "MAINSEND %d 0", _sendToMaster?1:0); // adds hw outputs if (_hwOuts) { int monoHWCount=0; while (GetOutputChannelName(monoHWCount)) monoHWCount++; bool cr = false; for(int i=0; i<SNM_MAX_HW_OUTS; i++) { if (_hwOuts[i]) { if (!cr) { mainSend.Append("\n"); cr = true; } if (_hwOuts[i] >= monoHWCount) mainSend.AppendFormatted(32, "HWOUT %d ", (_hwOuts[i]-monoHWCount) | 1024); else mainSend.AppendFormatted(32, "HWOUT %d ", _hwOuts[i]-1); mainSend.Append("0 "); mainSend.AppendFormatted(20, "%.14f ", *(double*)GetConfigVar("defhwvol")); mainSend.Append("0.00000000000000 0 0 0 -1.00000000000000 -1\n"); } } if (!cr) mainSend.Append("\n"); // hot } // patch both updates (no break keyword here: new empty track) updated |= p->ReplaceLine("TRACK", "MAINSEND", 1, 0, mainSend.Get()); } p->Commit(); delete p; if (updated) { GetSetMediaTrackInfo(cueTr, "I_SELECTED", &g_i1); UpdateTimeline(); ScrollSelTrack(true, true); if (_showRouting) Main_OnCommand(40293, 0); if (_undoMsg) Undo_OnStateChangeEx2(NULL, _undoMsg, UNDO_STATE_ALL, -1); } } return updated; }