int func_b(int pb) { // *** 50 int rv=0; TEMPO(16, 200*TIMEBASE, pb, rv); // 52 rv += func_a(0); TEMPO(18, 150*TIMEBASE, pb, rv); // 54 return rv; }
int main() { int rv = 0; TEMPO(7, 250*TIMEBASE, rv, rv); // 61 rv += func_a(1); TEMPO(12, 150*TIMEBASE, rv, rv); // 63 rv += func_b(0); TEMPO(9, 150*TIMEBASE, rv, rv); // 65 return rv; }
int func_a(int pa) { // *** 36 int rv=0; TEMPO(7, 500*TIMEBASE, pa, rv); // 38 if (pa==1) { rv += func_f(1); TEMPO(8, 500*TIMEBASE, pa, rv); // 42 rv += func_f(1); } TEMPO(6, 500*TIMEBASE, pa, rv); // 45 return rv; }
TEMPO CNumberEdit::GetTempoValue() //-------------------------------- { double d; GetDecimalValue(d); return TEMPO(d); }
namespace ModSpecs { // Force built-in integer operations. // C++11 constexpr operations on the enum value_type would also solve this. #define SongFlag FlagSet<SongFlags>::store_type const CModSpecifications mptm = { /* TODO: Proper, less arbitrarily chosen values here. NOTE: If changing limits, see whether: -savefile format and GUI methods can handle new values(might not be a small task :). */ MOD_TYPE_MPT, // Internal MODTYPE value "mptm", // File extension NOTE_MIN, // Minimum note index NOTE_MAX, // Maximum note index 4000, // Pattern max. 4000, // Order max. MAX_SEQUENCES, // Sequences max 1, // Channel min 127, // Channel max TEMPO(32, 0), // Min tempo TEMPO(512, 0), // Max tempo 1, // Min Speed 255, // Max Speed 1, // Min pattern rows 1024, // Max pattern rows 25, // Max mod name length 25, // Max sample name length 12, // Max sample filename length 25, // Max instrument name length 12, // Max instrument filename length 3999, // SamplesMax 255, // instrumentMax mixLevels1_17RC3, // defaultMixLevels SongFlag(0) | SONG_LINEARSLIDES | SONG_EXFILTERRANGE | SONG_ITOLDEFFECTS | SONG_ITCOMPATGXX | SONG_EMBEDMIDICFG, // Supported song flags 200, // Max MIDI mapping directives MAX_ENVPOINTS, // Envelope point count true, // Has notecut. true, // Has noteoff. true, // Has notefade. true, // Has envelope release node true, // Has song comments true, // Has "+++" pattern true, // Has "---" pattern true, // Has restart position (order) true, // Supports plugins true, // Custom pattern time signatures true, // Pattern names true, // Has artist name true, // Has default resampling true, // Fixed point tempo " JFEGHLKRXODB?CQATI?SMNVW?UY?P?Z\\:#??????", // Supported Effects " vpcdabuhlrgfe?o", // Supported Volume Column commands }; const CModSpecifications mod = { MOD_TYPE_MOD, // Internal MODTYPE value "mod", // File extension 37, // Minimum note index 108, // Maximum note index 128, // Pattern max. 128, // Order max. 1, // Only one order list 4, // Channel min 99, // Channel max TEMPO(32, 0), // Min tempo TEMPO(255, 0), // Max tempo 1, // Min Speed 31, // Max Speed 64, // Min pattern rows 64, // Max pattern rows 20, // Max mod name length 22, // Max sample name length 0, // Max sample filename length 0, // Max instrument name length 0, // Max instrument filename length 31, // SamplesMax 0, // instrumentMax mixLevelsCompatible, // defaultMixLevels SongFlag(0) | SONG_PT_MODE | SONG_AMIGALIMITS, // Supported song flags 0, // Max MIDI mapping directives 0, // No instrument envelopes false, // No notecut. false, // No noteoff. false, // No notefade. false, // No envelope release node false, // No song comments false, // Doesn't have "+++" pattern false, // Doesn't have "---" pattern true, // Has restart position (order) false, // Doesn't support plugins false, // No custom pattern time signatures false, // No pattern names false, // Doesn't have artist name false, // Doesn't have default resampling false, // Integer tempo " 0123456789ABCD?FF?E?????????????????????", // Supported Effects " ???????????????", // Supported Volume Column commands }; const CModSpecifications xm = { MOD_TYPE_XM, // Internal MODTYPE value "xm", // File extension 13, // Minimum note index 108, // Maximum note index 256, // Pattern max. 255, // Order max. 1, // Only one order list 1, // Channel min 32, // Channel max TEMPO(32, 0), // Min tempo TEMPO(512, 0), // Max tempo 1, // Min Speed 31, // Max Speed 1, // Min pattern rows 256, // Max pattern rows 20, // Max mod name length 22, // Max sample name length 0, // Max sample filename length 22, // Max instrument name length 0, // Max instrument filename length 128 * 16, // SamplesMax (actually 16 per instrument) 128, // instrumentMax mixLevelsCompatibleFT2, // defaultMixLevels SongFlag(0) | SONG_LINEARSLIDES, // Supported song flags 0, // Max MIDI mapping directives 12, // Envelope point count false, // No notecut. true, // Has noteoff. false, // No notefade. false, // No envelope release node false, // No song comments false, // Doesn't have "+++" pattern false, // Doesn't have "---" pattern true, // Has restart position (order) false, // Doesn't support plugins false, // No custom pattern time signatures false, // No pattern names false, // Doesn't have artist name false, // Doesn't have default resampling false, // Integer tempo " 0123456789ABCDRFFTE???GHK??XPL??????????", // Supported Effects " vpcdabuhlrg????", // Supported Volume Column commands }; // XM with MPT extensions const CModSpecifications xmEx = { MOD_TYPE_XM, // Internal MODTYPE value "xm", // File extension 13, // Minimum note index 108, // Maximum note index 256, // Pattern max. 255, // Order max. 1, // Only one order list 1, // Channel min 127, // Channel max TEMPO(32, 0), // Min tempo TEMPO(512, 0), // Max tempo 1, // Min Speed 31, // Max Speed 1, // Min pattern rows 1024, // Max pattern rows 20, // Max mod name length 22, // Max sample name length 0, // Max sample filename length 22, // Max instrument name length 0, // Max instrument filename length MAX_SAMPLES - 1, // SamplesMax (actually 32 per instrument(256 * 32 = 8192), but limited to MAX_SAMPLES = 4000) 255, // instrumentMax mixLevelsCompatibleFT2, // defaultMixLevels SongFlag(0) | SONG_LINEARSLIDES | SONG_EXFILTERRANGE | SONG_EMBEDMIDICFG, // Supported song flags 200, // Max MIDI mapping directives 12, // Envelope point count false, // No notecut. true, // Has noteoff. false, // No notefade. false, // No envelope release node true, // Has song comments false, // Doesn't have "+++" pattern false, // Doesn't have "---" pattern true, // Has restart position (order) true, // Supports plugins false, // No custom pattern time signatures true, // Pattern names true, // Has artist name false, // Doesn't have default resampling false, // Integer tempo " 0123456789ABCDRFFTE???GHK?YXPLZ\\?#??????", // Supported Effects " vpcdabuhlrgfe??", // Supported Volume Column commands }; const CModSpecifications s3m = { MOD_TYPE_S3M, // Internal MODTYPE value "s3m", // File extension 13, // Minimum note index 108, // Maximum note index 100, // Pattern max. 255, // Order max. 1, // Only one order list 1, // Channel min 32, // Channel max TEMPO(33, 0), // Min tempo TEMPO(255, 0), // Max tempo 1, // Min Speed 255, // Max Speed 64, // Min pattern rows 64, // Max pattern rows 27, // Max mod name length 27, // Max sample name length 12, // Max sample filename length 0, // Max instrument name length 0, // Max instrument filename length 99, // SamplesMax 0, // instrumentMax mixLevelsCompatible, // defaultMixLevels SongFlag(0) | SONG_FASTVOLSLIDES | SONG_AMIGALIMITS | SONG_S3MOLDVIBRATO, // Supported song flags 0, // Max MIDI mapping directives 0, // No instrument envelopes true, // Has notecut. false, // No noteoff. false, // No notefade. false, // No envelope release node false, // No song comments true, // Has "+++" pattern true, // Has "---" pattern false, // Doesn't have restart position (order) false, // Doesn't support plugins false, // No custom pattern time signatures false, // No pattern names false, // Doesn't have artist name false, // Doesn't have default resampling false, // Integer tempo " JFEGHLKRXODB?CQATI?SMNVW?U??????????????", // Supported Effects " vp?????????????", // Supported Volume Column commands }; // S3M with MPT extensions const CModSpecifications s3mEx = { MOD_TYPE_S3M, // Internal MODTYPE value "s3m", // File extension 13, // Minimum note index 108, // Maximum note index 100, // Pattern max. 255, // Order max. 1, // Only one order list 1, // Channel min 32, // Channel max TEMPO(33, 0), // Min tempo TEMPO(255, 0), // Max tempo 1, // Min Speed 255, // Max Speed 64, // Min pattern rows 64, // Max pattern rows 27, // Max mod name length 27, // Max sample name length 12, // Max sample filename length 0, // Max instrument name length 0, // Max instrument filename length 99, // SamplesMax 0, // instrumentMax mixLevelsCompatible, // defaultMixLevels SongFlag(0) | SONG_FASTVOLSLIDES | SONG_AMIGALIMITS, // Supported song flags 0, // Max MIDI mapping directives 0, // No instrument envelopes true, // Has notecut. false, // No noteoff. false, // No notefade. false, // No envelope release node false, // No song comments true, // Has "+++" pattern true, // Has "---" pattern false, // Doesn't have restart position (order) false, // Doesn't support plugins false, // No custom pattern time signatures false, // No pattern names false, // Doesn't have artist name false, // Doesn't have default resampling false, // Integer tempo " JFEGHLKRXODB?CQATI?SMNVW?UY?P?Z?????????", // Supported Effects " vp?????????????", // Supported Volume Column commands }; const CModSpecifications it = { MOD_TYPE_IT, // Internal MODTYPE value "it", // File extension 1, // Minimum note index 120, // Maximum note index 200, // Pattern max. 256, // Order max. 1, // Only one order list 1, // Channel min 64, // Channel max TEMPO(32, 0), // Min tempo TEMPO(255, 0), // Max tempo 1, // Min Speed 255, // Max Speed 1, // Min pattern rows 200, // Max pattern rows 25, // Max mod name length 25, // Max sample name length 12, // Max sample filename length 25, // Max instrument name length 12, // Max instrument filename length 99, // SamplesMax 99, // instrumentMax mixLevelsCompatible, // defaultMixLevels SongFlag(0) | SONG_LINEARSLIDES | SONG_ITOLDEFFECTS | SONG_ITCOMPATGXX | SONG_EMBEDMIDICFG, // Supported song flags 0, // Max MIDI mapping directives 25, // Envelope point count true, // Has notecut. true, // Has noteoff. true, // Has notefade. false, // No envelope release node true, // Has song comments true, // Has "+++" pattern true, // Has "--" pattern false, // Doesn't have restart position (order) false, // Doesn't support plugins false, // No custom pattern time signatures false, // No pattern names false, // Doesn't have artist name false, // Doesn't have default resampling false, // Integer tempo " JFEGHLKRXODB?CQATI?SMNVW?UY?P?Z?????????", // Supported Effects " vpcdab?h??gfe??", // Supported Volume Column commands }; const CModSpecifications itEx = { MOD_TYPE_IT, // Internal MODTYPE value "it", // File extension 1, // Minimum note index 120, // Maximum note index 240, // Pattern max. 256, // Order max. 1, // Only one order list 1, // Channel min 127, // Channel max TEMPO(32, 0), // Min tempo TEMPO(512, 0), // Max tempo 1, // Min Speed 255, // Max Speed 1, // Min pattern rows 1024, // Max pattern rows 25, // Max mod name length 25, // Max sample name length 12, // Max sample filename length 25, // Max instrument name length 12, // Max instrument filename length 3999, // SamplesMax 255, // instrumentMax mixLevelsCompatible, // defaultMixLevels SongFlag(0) | SONG_LINEARSLIDES | SONG_EXFILTERRANGE | SONG_ITOLDEFFECTS | SONG_ITCOMPATGXX | SONG_EMBEDMIDICFG, // Supported song flags 200, // Max MIDI mapping directives 25, // Envelope point count true, // Has notecut. true, // Has noteoff. true, // Has notefade. false, // No envelope release node true, // Has song comments true, // Has "+++" pattern true, // Has "---" pattern false, // Doesn't have restart position (order) true, // Supports plugins false, // No custom pattern time signatures true, // Pattern names true, // Has artist name false, // Doesn't have default resampling false, // Integer tempo " JFEGHLKRXODB?CQATI?SMNVW?UY?P?Z\\?#??????", // Supported Effects " vpcdab?h??gfe??", // Supported Volume Column commands }; const CModSpecifications *Collection[] = { &mptm, &mod, &s3m, &s3mEx, &xm, &xmEx, &it, &itEx }; } // namespace ModSpecs
void CCtrlGeneral::OnVScroll(UINT code, UINT pos, CScrollBar *pscroll) //-------------------------------------------------------------------- { CDialog::OnVScroll(code, pos, pscroll); if (m_bInitialized) { CSliderCtrl* pSlider = (CSliderCtrl*) pscroll; if (pSlider == &m_SliderTempo) { const TEMPO tempo = tempoMax - TEMPO(m_SliderTempo.GetPos(), 0); if ((tempo >= m_sndFile.GetModSpecifications().GetTempoMin()) && (tempo <= m_sndFile.GetModSpecifications().GetTempoMax()) && (tempo != m_sndFile.m_nDefaultTempo)) { m_sndFile.m_nDefaultTempo = m_sndFile.m_PlayState.m_nMusicTempo = tempo; m_modDoc.SetModified(); m_modDoc.UpdateAllViews(nullptr, GeneralHint().General(), this); } } else if (pSlider == &m_SliderGlobalVol) { const UINT gv = MAX_SLIDER_GLOBAL_VOL - m_SliderGlobalVol.GetPos(); if ((gv >= 0) && (gv <= MAX_SLIDER_GLOBAL_VOL) && (gv != m_sndFile.m_nDefaultGlobalVolume)) { m_sndFile.m_PlayState.m_nGlobalVolume = gv; m_sndFile.m_nDefaultGlobalVolume = gv; m_modDoc.SetModified(); m_modDoc.UpdateAllViews(nullptr, GeneralHint().General(), this); } } else if (pSlider == &m_SliderSamplePreAmp) { const UINT spa = MAX_SLIDER_SAMPLE_VOL - m_SliderSamplePreAmp.GetPos(); if ((spa >= 0) && (spa <= MAX_SLIDER_SAMPLE_VOL) && (spa != m_sndFile.m_nSamplePreAmp)) { m_sndFile.m_nSamplePreAmp = spa; if(m_sndFile.GetType() != MOD_TYPE_MOD) m_modDoc.SetModified(); m_modDoc.UpdateAllViews(nullptr, GeneralHint().General(), this); } } else if (pSlider == &m_SliderVSTiVol) { const UINT vv = MAX_SLIDER_VSTI_VOL - m_SliderVSTiVol.GetPos(); if ((vv >= 0) && (vv <= MAX_SLIDER_VSTI_VOL) && (vv != m_sndFile.m_nVSTiVolume)) { m_sndFile.m_nVSTiVolume = vv; m_sndFile.RecalculateGainForAllPlugs(); m_modDoc.SetModified(); m_modDoc.UpdateAllViews(nullptr, GeneralHint().General(), this); } } else if(pSlider == (CSliderCtrl*)&m_SpinTempo) { int pos32 = m_SpinTempo.GetPos32(); if(pos32 != 0) { TEMPO newTempo; if(m_sndFile.GetModSpecifications().hasFractionalTempo) { pos32 *= TEMPO::fractFact; if(CMainFrame::GetMainFrame()->GetInputHandler()->CtrlPressed()) pos32 /= 100; else pos32 /= 10; newTempo.SetRaw(pos32); } else { newTempo = TEMPO(pos32, 0); } newTempo += m_sndFile.m_nDefaultTempo; Limit(newTempo, tempoMin, tempoMax); m_sndFile.m_nDefaultTempo = m_sndFile.m_PlayState.m_nMusicTempo = newTempo; m_modDoc.SetModified(); LockControls(); m_modDoc.UpdateAllViews(nullptr, GeneralHint().General(), this); UnlockControls(); } m_SpinTempo.SetPos(0); } UpdateView(GeneralHint().General()); } }
void CCtrlGeneral::UpdateView(UpdateHint hint, CObject *pHint) //------------------------------------------------------------ { if (pHint == this) return; FlagSet<HintType> hintType = hint.GetType(); const bool updateAll = hintType[HINT_MODTYPE]; const ResamplingMode resamplingModes[] = { SRCMODE_NEAREST, SRCMODE_LINEAR, SRCMODE_SPLINE, SRCMODE_POLYPHASE, SRCMODE_FIRFILTER }; if (hintType == HINT_MPTOPTIONS || updateAll) { m_CbnResampling.ResetContent(); m_CbnResampling.SetItemData(m_CbnResampling.AddString(_T("Default (") + CString(CTrackApp::GetResamplingModeName(TrackerSettings::Instance().ResamplerMode, false)) + _T(")")), SRCMODE_DEFAULT); for(auto mode : resamplingModes) { m_CbnResampling.SetItemData(m_CbnResampling.AddString(CTrackApp::GetResamplingModeName(mode, false)), mode); } m_CbnResampling.Invalidate(FALSE); } if(updateAll) { CModSpecifications specs = m_sndFile.GetModSpecifications(); // S3M HACK: ST3 will ignore speed 255, even though it can be used with Axx. if(m_sndFile.GetType() == MOD_TYPE_S3M) m_SpinSpeed.SetRange32(1, 254); else m_SpinSpeed.SetRange32(specs.speedMin, specs.speedMax); tempoMin = specs.GetTempoMin(); tempoMax = specs.GetTempoMax(); // IT Hack: There are legacy OpenMPT-made ITs out there which use a higher default speed than 255. // Changing the upper tempo limit in the mod specs would break them, so do it here instead. if(m_sndFile.GetType() == MOD_TYPE_IT && m_sndFile.m_nDefaultTempo <= TEMPO(255, 0)) tempoMax.Set(255); m_SliderTempo.SetRange(0, tempoMax.GetInt() - tempoMin.GetInt()); m_EditTempo.AllowFractions(specs.hasFractionalTempo); const BOOL bIsNotMOD = (m_sndFile.GetType() != MOD_TYPE_MOD); const BOOL bIsNotMOD_S3M = ((bIsNotMOD) && (m_sndFile.GetType() != MOD_TYPE_S3M)); const BOOL bIsNotMOD_XM = ((bIsNotMOD) && (m_sndFile.GetType() != MOD_TYPE_XM)); m_EditArtist.EnableWindow(specs.hasArtistName); m_EditTempo.EnableWindow(bIsNotMOD); m_SpinTempo.EnableWindow(bIsNotMOD); GetDlgItem(IDC_BUTTON1)->EnableWindow(bIsNotMOD); m_SliderTempo.EnableWindow(bIsNotMOD); m_EditSpeed.EnableWindow(bIsNotMOD); m_SpinSpeed.EnableWindow(bIsNotMOD); const BOOL globalVol = bIsNotMOD_XM || m_sndFile.m_nDefaultGlobalVolume != MAX_GLOBAL_VOLUME; m_SliderGlobalVol.EnableWindow(globalVol); m_EditGlobalVol.EnableWindow(globalVol); m_SpinGlobalVol.EnableWindow(globalVol); m_EditSamplePA.EnableWindow(bIsNotMOD); m_SpinSamplePA.EnableWindow(bIsNotMOD); //m_SliderSamplePreAmp.EnableWindow(bIsNotMOD); m_SliderVSTiVol.EnableWindow(bIsNotMOD_S3M); m_EditVSTiVol.EnableWindow(bIsNotMOD_S3M); m_SpinVSTiVol.EnableWindow(bIsNotMOD_S3M); m_EditRestartPos.EnableWindow((specs.hasRestartPos || m_sndFile.Order.GetRestartPos() != 0)); m_SpinRestartPos.EnableWindow(m_EditRestartPos.IsWindowEnabled()); //Note: Sample volume slider is not disabled for MOD //on purpose(can be used to control play volume) } if(updateAll || (hint.GetCategory() == HINTCAT_GLOBAL && hintType[HINT_MODCHANNELS])) { // MOD Type const TCHAR *modType = _T(""); switch(m_sndFile.GetType()) { case MOD_TYPE_MOD: modType = _T("MOD (ProTracker)"); break; case MOD_TYPE_S3M: modType = _T("S3M (ScreamTracker)"); break; case MOD_TYPE_XM: modType = _T("XM (FastTracker 2)"); break; case MOD_TYPE_IT: modType = _T("IT (Impulse Tracker)"); break; case MOD_TYPE_MPT: modType = _T("MPTM (OpenMPT)"); break; default: modType = CSoundFile::ModTypeToString(m_sndFile.GetType()); break; } TCHAR s[256]; wsprintf(s, _T("%s, %u channel%s"), modType, m_sndFile.GetNumChannels(), (m_sndFile.GetNumChannels() != 1) ? _T("s") : _T("")); m_BtnModType.SetWindowText(s); } if (updateAll || (hint.GetCategory() == HINTCAT_SEQUENCE && hintType[HINT_MODSEQUENCE | HINT_RESTARTPOS])) { // Set max valid restart position m_SpinRestartPos.SetRange32(0, m_sndFile.Order.GetLengthTailTrimmed() - 1); SetDlgItemInt(IDC_EDIT_RESTARTPOS, m_sndFile.Order.GetRestartPos(), FALSE); } if (updateAll || (hint.GetCategory() == HINTCAT_GENERAL && hintType[HINT_MODGENERAL])) { if (!m_bEditsLocked) { m_EditTitle.SetWindowText(m_sndFile.GetTitle().c_str()); ::SetWindowTextW(m_EditArtist.m_hWnd, mpt::ToWide(m_sndFile.m_songArtist).c_str()); m_EditTempo.SetTempoValue(m_sndFile.m_nDefaultTempo); SetDlgItemInt(IDC_EDIT_SPEED, m_sndFile.m_nDefaultSpeed, FALSE); SetDlgItemInt(IDC_EDIT_GLOBALVOL, m_sndFile.m_nDefaultGlobalVolume / GetGlobalVolumeFactor(), FALSE); SetDlgItemInt(IDC_EDIT_VSTIVOL, m_sndFile.m_nVSTiVolume, FALSE); SetDlgItemInt(IDC_EDIT_SAMPLEPA, m_sndFile.m_nSamplePreAmp, FALSE); } m_SliderGlobalVol.SetPos(MAX_SLIDER_GLOBAL_VOL - m_sndFile.m_nDefaultGlobalVolume); m_SliderVSTiVol.SetPos(MAX_SLIDER_VSTI_VOL - m_sndFile.m_nVSTiVolume); m_SliderSamplePreAmp.SetPos(MAX_SLIDER_SAMPLE_VOL - m_sndFile.m_nSamplePreAmp); m_SliderTempo.SetPos((tempoMax - m_sndFile.m_nDefaultTempo).GetInt()); } if(updateAll || hintType == HINT_MPTOPTIONS || (hint.GetCategory() == HINTCAT_GENERAL && hintType[HINT_MODGENERAL])) { int srcMode = 0; for(int i = 0; i < CountOf(resamplingModes); i++) { if(m_sndFile.m_nResampling == resamplingModes[i]) srcMode = i + 1; } m_CbnResampling.SetCurSel(srcMode); } CheckDlgButton(IDC_CHECK_LOOPSONG, (TrackerSettings::Instance().gbLoopSong) ? TRUE : FALSE); if (hintType[HINT_MPTOPTIONS]) { m_VuMeterLeft.InvalidateRect(NULL, FALSE); m_VuMeterRight.InvalidateRect(NULL, FALSE); } }
int func_f(int pf) { // *** 29 int rv=0; TEMPO(12, 350*TIMEBASE, pf, rv); // 31 return rv; }
int dead_func(int pf) { int rv=0; TEMPO(10, 350*TIMEBASE, pf, rv); return rv; }