Skip to content

AndrinoLabGit/PianoFromAbove

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PianoFromAbove

This is the software that drives some of the Impossible MIDI videos on youtube:

Synthesia is the main alternate with way more market share and much more active development, but appaerently PFA is more performant, so some prefer it. Yay.

The original inspiration:

And so I made it happen:

Binaries

https://github.com/brian-pantano/PianoFromAbove/releases

Viz branch

There's now a viz branch which will house graphics and performance updates going forward (if there is a forward).

How to build

This is unfortunately very tricky. Hopefully I will simplify this in the future.

  • clone this repo
  • Download and install VisualStudio 2010
  • Download and install Direct X SDK
  • Download and extract Google Protocol Buffers 2.5
    • Build libprotobuf-lite.vcproj
  • Download and extract Boost 1.55
  • Open the .sln and edit the VC++ Directories from the project properties so that the Include Directories and Library Directories point to the location of your boost and protocol buffers downloads
  • Cross fingers
  • Build! (Release, x64)

Once that's done, there should be a Release\PFA-1.1.0-x86_64.exe that you can run.

There's an optional .nsi script that you can run if you want to build an installer.

The code probably isn't the best, and it probably goes against all sorts of best practices but it is fairly snappy. I'm not very good at writing UI or UX, but I am fairly good at writing datastructures and writing minimal and fast code. Good luck reading it!

This Fork

8/30/20

Goal

  • I am learning how to program. I have zero/minimal C++ experience. My first goal is to complie PianoFromAbove using VS Community 2019. This might not work. My second goal is to allow note playback on a Nektar Midi Controller.

Steps During Testing

8/31/20

Tweeks to learn the program

  • Reduced opening sound to 3 seconds

Notes to try to figure out how to get playback on Nektar key press

  • Gamestate.cpp has text for button presses
const wchar_t *GameScore::MissedText = L"Missed!";
const wchar_t *GameScore::IncorrectText = L"Wrong!";
const wchar_t *GameScore::OkText = L"OK!";
const wchar_t *GameScore::GoodText = L"Good!";
const wchar_t *GameScore::GreatText = L"Great!";
  • Main logic code seems to be in Gamestate.cpp
GameState::GameError MainScreen::Logic( void )
  • Possible Sound Logic
        // Advance start position updating initial state as we pass stale events
        // Also PLAYS THE MUSIC
        while ( m_iStartPos < iEventCount && m_vEvents[m_iStartPos]->GetAbsMicroSec() <= m_llStartTime )
        {
            MIDIChannelEvent *pEvent = m_vEvents[m_iStartPos];
            if ( pEvent->GetChannelEventType() != MIDIChannelEvent::NoteOn )
                m_OutDevice.PlayEvent( pEvent->GetEventCode(), pEvent->GetParam1(), pEvent->GetParam2() );
            else if ( !m_bMute && !m_vTrackSettings[pEvent->GetTrack()].aChannels[pEvent->GetChannel()].bMuted &&
                      ( m_eGameMode != Learn || m_iLearnOrdinal >= 0 ) )
                m_OutDevice.PlayEvent( pEvent->GetEventCode(), pEvent->GetParam1(),
                                       static_cast< int >( pEvent->GetParam2() * dVolumeCorrect + 0.5 ) );
            UpdateState( m_iStartPos );
            m_iStartPos++;
        }
  • Possible Key Render on Key Press Logic (White Keys)
                bool bBadLearn = ( m_eGameMode == Learn && m_iLearnOrdinal >= 0 && ( iTrack != m_iLearnTrack || iChannel != m_iLearnChannel ) );
                ChannelSettings &csKBWhite = ( m_pInputState[i] == -2 || bBadLearn ||
                                               pEvent->GetInputQuality() == MIDIChannelEvent::Missed ? m_csKBBadNote :
                                               m_vTrackSettings[iTrack].aChannels[iChannel] );
                m_pRenderer->DrawRect( fCurX + fKeyGap1 , fCurY, m_fWhiteCX - fKeyGap, fTopCY + fNearCY - 2.0f,
                    csKBWhite.iDarkRGB | iAlpha, csKBWhite.iDarkRGB | iAlpha, csKBWhite.iPrimaryRGB | iAlpha, csKBWhite.iPrimaryRGB | iAlpha );
                m_pRenderer->DrawRect( fCurX + fKeyGap1 , fCurY + fTopCY + fNearCY - 2.0f, m_fWhiteCX - fKeyGap, 2.0f, csKBWhite.iDarkRGB | iAlpha );
  • Possible Key Render on Key Press Logic (Sharps)
const bool bBadLearn = ( m_eGameMode == Learn && m_iLearnOrdinal >= 0 && ( iTrack != m_iLearnTrack || iChannel != m_iLearnChannel ) );
                const ChannelSettings &csKBSharp = ( m_pInputState[i] == -2 || bBadLearn ||
                                                     pEvent->GetInputQuality() == MIDIChannelEvent::Missed ? m_csKBBadNote :
                                                     m_vTrackSettings[iTrack].aChannels[iChannel] );
                m_pRenderer->DrawSkew( fSharpTopX1, fCurY + fSharpCY - fNewNear,
                                       fSharpTopX2, fCurY + fSharpCY - fNewNear,
                                       x + cx, fCurY + fSharpCY, x, fCurY + fSharpCY,
                                       csKBSharp.iPrimaryRGB | iAlpha, csKBSharp.iPrimaryRGB | iAlpha, csKBSharp.iDarkRGB | iAlpha, csKBSharp.iDarkRGB | iAlpha );
                m_pRenderer->DrawSkew( fSharpTopX1, fCurY - fNewNear,
                                       fSharpTopX1, fCurY + fSharpCY - fNewNear,
                                       x, fCurY + fSharpCY, x, fCurY,
                                       csKBSharp.iPrimaryRGB | iAlpha, csKBSharp.iPrimaryRGB | iAlpha, csKBSharp.iDarkRGB | iAlpha, csKBSharp.iDarkRGB | iAlpha );
                m_pRenderer->DrawSkew( fSharpTopX2, fCurY + fSharpCY - fNewNear,
                                       fSharpTopX2, fCurY - fNewNear,
                                       x + cx, fCurY, x + cx, fCurY + fSharpCY,
                                       csKBSharp.iPrimaryRGB | iAlpha, csKBSharp.iPrimaryRGB | iAlpha, csKBSharp.iDarkRGB | iAlpha, csKBSharp.iDarkRGB | iAlpha );
                m_pRenderer->DrawRect( fSharpTopX1, fCurY - fNewNear, fSharpTopX2 - fSharpTopX1, fSharpCY, csKBSharp.iDarkRGB | iAlpha );
                m_pRenderer->DrawSkew( fSharpTopX1, fCurY - fNewNear,
                                       fSharpTopX2, fCurY - fNewNear,
                                       fSharpTopX2, fCurY - fNewNear + fSharpCY * 0.35f,
                                       fSharpTopX1, fCurY - fNewNear + fSharpCY * 0.25f,
                                       csKBSharp.iPrimaryRGB | iAlpha, csKBSharp.iPrimaryRGB | iAlpha, csKBSharp.iPrimaryRGB | iAlpha, csKBSharp.iPrimaryRGB | iAlpha );
                m_pRenderer->DrawSkew( fSharpTopX1, fCurY - fNewNear + fSharpCY * 0.25f,
                                       fSharpTopX2, fCurY - fNewNear + fSharpCY * 0.35f,
                                       fSharpTopX2, fCurY - fNewNear + fSharpCY * 0.75f,
                                       fSharpTopX1, fCurY - fNewNear + fSharpCY * 0.65f,
                                       csKBSharp.iPrimaryRGB | iAlpha, csKBSharp.iPrimaryRGB | iAlpha, csKBSharp.iDarkRGB | iAlpha, csKBSharp.iDarkRGB | iAlpha );

9/27/20

  • More attempts at figuring out C++
  • Code uses MIDIOutDevice m_OutDevice to play audio
  • MIDIOutDevice found in midi.h. How does PlayEvent work?
PlayEvent( unsigned char bStatus, unsigned char bParam1, unsigned char bParam2 = 0 );
  • MIDI Code in Midi.cpp
bool MIDIOutDevice::PlayEvent( unsigned char cStatus, unsigned char cParam1, unsigned char cParam2 )
{
    if ( !m_bIsOpen ) return false;
    return midiOutShortMsg( m_hMIDIOut, ( cParam2 << 16 ) + ( cParam1 << 8 ) + cStatus ) == MMSYSERR_NOERROR;
}
( cParam2 << 16 ) + ( cParam1 << 8 ) + cStatus
  • Commenting this code out only stops the intro music song
        MIDIChannelEvent *pEvent = m_vEvents[m_iStartPos];
        if (pEvent->GetChannelEventType() != MIDIChannelEvent::NoteOn) {
            m_OutDevice.PlayEvent(pEvent->GetEventCode(), pEvent->GetParam1(), pEvent->GetParam2());
        }
        else if (!m_bMute && !m_vTrackSettings[pEvent->GetTrack()].aChannels[pEvent->GetChannel()].bMuted) {
            m_OutDevice.PlayEvent(pEvent->GetEventCode(), pEvent->GetParam1(), static_cast<int>(pEvent->GetParam2() * dVolumeCorrect + 0.5));
        }
         UpdateState( m_iStartPos );
        m_iStartPos++;
  • I missed this code:
void MainScreen::ProcessInput()
{
    static const ControlsSettings &cControls = Config::GetConfig().GetControlsSettings();
    static PlaybackSettings &cPlayback = Config::GetConfig().GetPlaybackSettings();

    int iMilliSecs;
    unsigned char cStatus, cParam1, cParam2;
  • Can I juse use the PlayEvent here to play a sound??
  • Somewhat working with current complied code. Added the following code to the start of the input:
m_OutDevice.PlayEventAcrossChannels(cStatus, cParam1, static_cast<int>(cParam2 * dVolumeCorrect + 0.5));

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C++ 94.2%
  • C 3.5%
  • NSIS 2.3%