Skip to content

Commit

Permalink
config items for pitch bend visualization and framedump
Browse files Browse the repository at this point in the history
  • Loading branch information
khang06 committed Apr 1, 2021
1 parent 11dc067 commit 86c36d9
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 6 deletions.
8 changes: 8 additions & 0 deletions PianoFromAbove/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
2 changes: 2 additions & 0 deletions PianoFromAbove/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions PianoFromAbove/ConfigProcs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
Expand Down Expand Up @@ -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);
Expand Down
17 changes: 11 additions & 6 deletions PianoFromAbove/GameState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand Down Expand Up @@ -1757,20 +1759,22 @@ 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;
}
}
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;
Expand All @@ -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;
}
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions PianoFromAbove/GameState.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Binary file modified PianoFromAbove/PianoFromAbove.rc
Binary file not shown.
3 changes: 3 additions & 0 deletions PianoFromAbove/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 86c36d9

Please sign in to comment.