From 86c36d97be5b3110632a2a81c945bec5eb66925b Mon Sep 17 00:00:00 2001 From: Khang Date: Thu, 1 Apr 2021 13:37:40 -0400 Subject: [PATCH] config items for pitch bend visualization and framedump --- PianoFromAbove/Config.cpp | 8 ++++++++ PianoFromAbove/Config.h | 2 ++ PianoFromAbove/ConfigProcs.cpp | 4 ++++ PianoFromAbove/GameState.cpp | 17 +++++++++++------ PianoFromAbove/GameState.h | 1 + PianoFromAbove/PianoFromAbove.rc | Bin 36836 -> 37278 bytes PianoFromAbove/resource.h | 3 +++ 7 files changed, 29 insertions(+), 6 deletions(-) diff --git a/PianoFromAbove/Config.cpp b/PianoFromAbove/Config.cpp index 73cb636..b57f714 100644 --- a/PianoFromAbove/Config.cpp +++ b/PianoFromAbove/Config.cpp @@ -216,6 +216,8 @@ void VizSettings::LoadDefaultValues() { this->eMarkerEncoding = MarkerEncoding::CP1252; this->bNerdStats = false; this->sSplashMIDI = L""; + this->bVisualizePitchBends = false; + this->bDumpFrames = false; } void AudioSettings::LoadMIDIDevices() @@ -363,6 +365,10 @@ void VizSettings::LoadConfigValues(TiXmlElement* txRoot) { bShowMarkers = (iAttrVal != 0); if (txView->QueryIntAttribute("NerdStats", &iAttrVal) == TIXML_SUCCESS) bNerdStats = (iAttrVal != 0); + if (txView->QueryIntAttribute("VisualizePitchBends", &iAttrVal) == TIXML_SUCCESS) + bVisualizePitchBends = (iAttrVal != 0); + if (txView->QueryIntAttribute("DumpFrames", &iAttrVal) == TIXML_SUCCESS) + bDumpFrames = (iAttrVal != 0); std::string sTempStr; txView->QueryStringAttribute("SplashMIDI", &sTempStr); sSplashMIDI = Util::StringToWstring(sTempStr); @@ -471,5 +477,7 @@ bool VizSettings::SaveConfigValues(TiXmlElement* txRoot) { txViz->SetAttribute("MarkerEncoding", eMarkerEncoding); txViz->SetAttribute("NerdStats", bNerdStats); txViz->SetAttribute("SplashMIDI", Util::WstringToString(sSplashMIDI)); + txViz->SetAttribute("VisualizePitchBends", bVisualizePitchBends); + txViz->SetAttribute("DumpFrames", bDumpFrames); return true; } \ No newline at end of file diff --git a/PianoFromAbove/Config.h b/PianoFromAbove/Config.h index ab7eaac..8027269 100644 --- a/PianoFromAbove/Config.h +++ b/PianoFromAbove/Config.h @@ -177,6 +177,8 @@ struct VizSettings : public ISettings { enum MarkerEncoding { CP1252, CP932, UTF8 } eMarkerEncoding; bool bNerdStats; std::wstring sSplashMIDI; + bool bVisualizePitchBends; + bool bDumpFrames; }; class Config : public ISettings diff --git a/PianoFromAbove/ConfigProcs.cpp b/PianoFromAbove/ConfigProcs.cpp index 536b4c6..99a57b6 100644 --- a/PianoFromAbove/ConfigProcs.cpp +++ b/PianoFromAbove/ConfigProcs.cpp @@ -439,6 +439,8 @@ INT_PTR WINAPI VizProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { CheckDlgButton(hWnd, IDC_TICKBASED, viz.bTickBased); CheckDlgButton(hWnd, IDC_MARKERS, viz.bShowMarkers); CheckDlgButton(hWnd, IDC_STATS, viz.bNerdStats); + CheckDlgButton(hWnd, IDC_PITCHBENDS, viz.bVisualizePitchBends); + CheckDlgButton(hWnd, IDC_FFMPEG, viz.bDumpFrames); const wchar_t* codepages[] = { L"CP-1252 (Western)", L"CP-932 (Japanese)", L"UTF-8" }; for (int i = 0; i < sizeof(codepages) / sizeof(const wchar_t*); i++) @@ -488,6 +490,8 @@ INT_PTR WINAPI VizProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { viz.bNerdStats = IsDlgButtonChecked(hWnd, IDC_STATS); GetWindowTextW(GetDlgItem(hWnd, IDC_SPLASHMIDI), splash, 1024); viz.sSplashMIDI = splash; + viz.bVisualizePitchBends = IsDlgButtonChecked(hWnd, IDC_PITCHBENDS); + viz.bDumpFrames = IsDlgButtonChecked(hWnd, IDC_FFMPEG); config.SetVizSettings(viz); SetWindowLongPtr(hWnd, DWLP_MSGRESULT, PSNRET_NOERROR); diff --git a/PianoFromAbove/GameState.cpp b/PianoFromAbove/GameState.cpp index 7b2dcb5..867917c 100644 --- a/PianoFromAbove/GameState.cpp +++ b/PianoFromAbove/GameState.cpp @@ -609,6 +609,7 @@ void MainScreen::InitState() static const PlaybackSettings &cPlayback = config.GetPlaybackSettings(); static const ViewSettings &cView = config.GetViewSettings(); static const VisualSettings &cVisual = config.GetVisualSettings(); + static const VizSettings& cViz = config.GetVizSettings(); m_eGameMode = Practice; m_iStartPos = 0; @@ -633,6 +634,7 @@ void MainScreen::InitState() // m_Timer will be initialized *later* m_RealTimer.Init(false); + m_bDumpFrames = cViz.bDumpFrames; if (m_bDumpFrames) { m_hVideoPipe = CreateNamedPipe(TEXT("\\\\.\\pipe\\pfadump"), PIPE_ACCESS_OUTBOUND, @@ -1757,12 +1759,14 @@ void MainScreen::RenderNotes() size_t queue_pos = batch_vertices.size(); + bool visualize_bends = Config::GetConfig().GetVizSettings().bVisualizePitchBends; + for (int i = m_iEndPos; i >= m_iStartPos; i--) { MIDIChannelEvent* pEvent = m_vEvents[i]; if (pEvent->GetChannelEventType() == MIDIChannelEvent::NoteOn && pEvent->GetParam2() > 0 && pEvent->GetSister() && MIDI::IsSharp(pEvent->GetParam1())) { - const thread_work_t work{ queue_pos, pEvent }; + const thread_work_t work{ queue_pos, pEvent, visualize_bends }; m_vThreadWork.push_back(work); queue_pos += 12; } @@ -1770,7 +1774,7 @@ void MainScreen::RenderNotes() for (int i = 0; i < 128; i++) { if (MIDI::IsSharp(i)) { for (vector< int >::reverse_iterator it = (m_vState[i]).rbegin(); it != (m_vState[i]).rend();) { - const thread_work_t work{ queue_pos, m_vEvents[*it] }; + const thread_work_t work{ queue_pos, m_vEvents[*it], visualize_bends }; m_vThreadWork.push_back(work); queue_pos += 12; ++it; @@ -1784,7 +1788,7 @@ void MainScreen::RenderNotes() pEvent->GetParam2() > 0 && pEvent->GetSister()) { if (!MIDI::IsSharp(pEvent->GetParam1())) { - const thread_work_t work{ queue_pos, pEvent }; + const thread_work_t work{ queue_pos, pEvent, visualize_bends }; m_vThreadWork.push_back(work); queue_pos += 12; } @@ -1793,7 +1797,7 @@ void MainScreen::RenderNotes() for (int i = 0; i < 128; i++) { if (!MIDI::IsSharp(i)) { for (vector< int >::reverse_iterator it = (m_vState[i]).rbegin(); it != (m_vState[i]).rend();) { - const thread_work_t work{ queue_pos, m_vEvents[*it] }; + const thread_work_t work{ queue_pos, m_vEvents[*it], visualize_bends }; m_vThreadWork.push_back(work); queue_pos += 12; ++it; @@ -1832,8 +1836,9 @@ void MainScreen::RenderNote( thread_work_t& work ) if ( m_vTrackSettings[iTrack].aChannels[iChannel].bHidden ) return; // Compute true positions - float gap = notex_table[1] - notex_table[0]; - float x = GetNoteX( iNote ) + gap * (m_pBends[iChannel] / (8192.0f / 12.0f)); + float x = GetNoteX( iNote ); + if (work.visualize_bends) + x += (notex_table[1] - notex_table[0]) * (m_pBends[iChannel] / (8192.0f / 12.0f)); float y = m_fNotesY + m_fNotesCY * ( 1.0f - ( fNoteStart - m_fRndStartTime) / m_llTimeSpan ); float cx = MIDI::IsSharp( iNote ) ? m_fWhiteCX * SharpRatio : m_fWhiteCX; float cy = m_fNotesCY * ( ( fNoteEnd - fNoteStart ) / m_llTimeSpan); diff --git a/PianoFromAbove/GameState.h b/PianoFromAbove/GameState.h index 29adc42..f3ffac9 100644 --- a/PianoFromAbove/GameState.h +++ b/PianoFromAbove/GameState.h @@ -154,6 +154,7 @@ class CustomKeyEqualFunc { typedef struct { size_t queue_pos; // where to write the generated vertex data const MIDIChannelEvent* note; + bool visualize_bends; } thread_work_t; class MainScreen : public GameState diff --git a/PianoFromAbove/PianoFromAbove.rc b/PianoFromAbove/PianoFromAbove.rc index 899c16537dbe950a9bb4d38c99157a7dbab20aca..396ff095b75c0ef0f65d79e6d6b39373a86c2f42 100644 GIT binary patch delta 213 zcmaDdpK0D=rVU}r%q9%RlOOV0Zl0uE!#a5vAJ60k=5p>~44DkY45bW-3^_nn6+T0Y&l{Qh;id7<3ps8C)2g8R8iNfUFQ8%Y(s*!Ii;}!DaG!)o@Nj z215p8pel>WfB7-K1i6E7}KyzIg m+$UdD4HYzGFk&zRnq|mf0AvB_$p^b-C#QK!ZMM@~mIeT&MJ{3h delta 27 jcmbQYnCZ!UrVU}r%!Ul+lOOV0Zl0uE!@Bu|*0nSMlsXFG diff --git a/PianoFromAbove/resource.h b/PianoFromAbove/resource.h index 7da9587..522ed14 100644 --- a/PianoFromAbove/resource.h +++ b/PianoFromAbove/resource.h @@ -99,7 +99,10 @@ #define IDC_BUTTON2 1105 #define IDC_SPLASHRESET 1105 #define IDC_MEMUSAGE 1106 +#define IDC_PITCHBENDS 1106 #define IDC_TICKBASED 1107 +#define IDC_PITCHBENDS2 1108 +#define IDC_FFMPEG 1108 #define ID_FILE_PLAYFILE 40001 #define ID_FILE_ADDFILE 40002 #define ID_FILE_ADDFOLDER 40003