From: <sag...@us...> - 2014-03-08 18:24:00
|
Revision: 3848 http://sourceforge.net/p/modplug/code/3848 Author: saga-games Date: 2014-03-08 18:23:52 +0000 (Sat, 08 Mar 2014) Log Message: ----------- [New] General tab: Added a tempo tap buton. [Mod] OpenMPT: Version is now 1.22.07.28 Modified Paths: -------------- trunk/OpenMPT/common/versionNumber.h trunk/OpenMPT/mptrack/Ctrl_gen.cpp trunk/OpenMPT/mptrack/Ctrl_gen.h trunk/OpenMPT/mptrack/mptrack.rc Modified: trunk/OpenMPT/common/versionNumber.h =================================================================== --- trunk/OpenMPT/common/versionNumber.h 2014-03-08 00:19:39 UTC (rev 3847) +++ trunk/OpenMPT/common/versionNumber.h 2014-03-08 18:23:52 UTC (rev 3848) @@ -17,7 +17,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 22 #define VER_MINOR 07 -#define VER_MINORMINOR 27 +#define VER_MINORMINOR 28 //Version string. For example "1.17.02.28" #define MPT_VERSION_STR VER_STRINGIZE(VER_MAJORMAJOR) "." VER_STRINGIZE(VER_MAJOR) "." VER_STRINGIZE(VER_MINOR) "." VER_STRINGIZE(VER_MINORMINOR) Modified: trunk/OpenMPT/mptrack/Ctrl_gen.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_gen.cpp 2014-03-08 00:19:39 UTC (rev 3847) +++ trunk/OpenMPT/mptrack/Ctrl_gen.cpp 2014-03-08 18:23:52 UTC (rev 3848) @@ -29,6 +29,7 @@ BEGIN_MESSAGE_MAP(CCtrlGeneral, CModControlDlg) //{{AFX_MSG_MAP(CCtrlGeneral) ON_WM_VSCROLL() + ON_COMMAND(IDC_BUTTON1, OnTapTempo) ON_COMMAND(IDC_BUTTON_MODTYPE, OnSongProperties) ON_COMMAND(IDC_BUTTON_PLAYERPROPS, OnPlayerProperties) ON_COMMAND(IDC_CHECK_LOOPSONG, OnLoopSongChanged) @@ -160,6 +161,47 @@ } +void CCtrlGeneral::OnTapTempo() +//----------------------------- +{ + static uint32 tapLength[16], lastTap = 0; + // Shift back the previously recorded tap history + for(size_t i = CountOf(tapLength) - 1; i >= 1; i--) + { + tapLength[i] = tapLength[i - 1]; + } + const uint32 now = timeGetTime(); + tapLength[0] = now - lastTap; + lastTap = now; + + // Now average over complete tap history + uint32 numSamples = 0, delay = 0; + for(uint32 i = 0; i < CountOf(tapLength); i++) + { + if(tapLength[i] < 2000) + { + numSamples++; + delay += tapLength[i]; + } else + { + break; + } + } + if(delay) + { + CModSpecifications specs = m_sndFile.GetModSpecifications(); + uint32 newTempo = 60000 * numSamples; + if(m_sndFile.m_nTempoMode != tempo_mode_modern) + { + newTempo = (newTempo * m_sndFile.m_nDefaultSpeed * m_sndFile.m_nDefaultRowsPerBeat) / 24; + } + newTempo /= delay; + Limit(newTempo, specs.tempoMin, specs.tempoMax); + SetDlgItemInt(IDC_EDIT_TEMPO, newTempo, FALSE); + } +} + + void CCtrlGeneral::UpdateView(DWORD dwHint, CObject *pHint) //--------------------------------------------------------- { @@ -208,6 +250,7 @@ const BOOL bIsNotMOD_XM = ((bIsNotMOD) && (m_sndFile.GetType() != MOD_TYPE_XM)); 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); @@ -354,7 +397,7 @@ m_sndFile.m_PlayState.m_nMusicTempo = n; m_modDoc.SetModified(); m_modDoc.UpdateAllViews(NULL, HINT_MODGENERAL, this); - UpdateView(HINT_MODGENERAL, NULL); + UpdateView(HINT_MODGENERAL, NULL); m_bEditsLocked=false; } } Modified: trunk/OpenMPT/mptrack/Ctrl_gen.h =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_gen.h 2014-03-08 00:19:39 UTC (rev 3847) +++ trunk/OpenMPT/mptrack/Ctrl_gen.h 2014-03-08 18:23:52 UTC (rev 3848) @@ -84,6 +84,7 @@ //{{AFX_MSG(CCtrlGeneral) afx_msg LRESULT OnUpdatePosition(WPARAM, LPARAM); afx_msg void OnVScroll(UINT, UINT, CScrollBar *); + afx_msg void OnTapTempo(); afx_msg void OnTitleChanged(); afx_msg void OnTempoChanged(); afx_msg void OnSpeedChanged(); Modified: trunk/OpenMPT/mptrack/mptrack.rc =================================================================== --- trunk/OpenMPT/mptrack/mptrack.rc 2014-03-08 00:19:39 UTC (rev 3847) +++ trunk/OpenMPT/mptrack/mptrack.rc 2014-03-08 18:23:52 UTC (rev 3848) @@ -716,6 +716,7 @@ CONTROL "",IDC_SLIDER_SONGTEMPO,"msctls_trackbar32",TBS_VERT | TBS_BOTH | TBS_NOTICKS,11,28,15,50 EDITTEXT IDC_EDIT_TEMPO,5,78,29,12,ES_AUTOHSCROLL | ES_NUMBER CONTROL "",IDC_SPIN_TEMPO,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,27,76,11,14 + PUSHBUTTON "Tap",IDC_BUTTON1,54,24,24,12 LTEXT "Ticks/row:",IDC_STATIC,44,40,35,8 EDITTEXT IDC_EDIT_SPEED,44,51,30,12,ES_AUTOHSCROLL | ES_NUMBER CONTROL "Spin1",IDC_SPIN_SPEED,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,67,50,11,14 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |