Skip to content

Commit

Permalink
Hide the use of MIDI behind velocity (#13258)
Browse files Browse the repository at this point in the history
* conhost requires an additional dependency in Windows, which might
  cause us trouble in WPG
* Terminal requires an additional *package* dependency, which *will*
  cause us trouble in WPG (since GmDls is about 3MB)

I chose to scope the feature checks to MidiOut directly, as I wanted to
keep the delay behavior in MidiAudio::PlayNote. This is negotiable.

References #13252
  • Loading branch information
DHowett authored Jun 9, 2022
1 parent 799b5d4 commit 205c09c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
17 changes: 13 additions & 4 deletions src/audio/midi/MidiAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,25 @@ namespace

MidiOut() noexcept
{
midiOutOpen(&handle, MIDI_MAPPER, NULL, NULL, CALLBACK_NULL);
OutputMessage(PROGRAM_CHANGE, SQUARE_WAVE_SYNTH);
if constexpr (Feature_DECPSViaMidiPlayer::IsEnabled())
{
midiOutOpen(&handle, MIDI_MAPPER, NULL, NULL, CALLBACK_NULL);
OutputMessage(PROGRAM_CHANGE, SQUARE_WAVE_SYNTH);
}
}
~MidiOut() noexcept
{
midiOutClose(handle);
if constexpr (Feature_DECPSViaMidiPlayer::IsEnabled())
{
midiOutClose(handle);
}
}
void OutputMessage(const int b1, const int b2, const int b3 = 0, const int b4 = 0) noexcept
{
midiOutShortMsg(handle, MAKELONG(MAKEWORD(b1, b2), MAKEWORD(b3, b4)));
if constexpr (Feature_DECPSViaMidiPlayer::IsEnabled())
{
midiOutShortMsg(handle, MAKELONG(MAKEWORD(b1, b2), MAKEWORD(b3, b4)));
}
}

MidiOut(const MidiOut&) = delete;
Expand Down
3 changes: 2 additions & 1 deletion src/cascadia/TerminalControl/TerminalControlLib.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@
<PRIResource Include="Resources\en-US\Resources.resw" />
<OCResourceDirectory Include="Resources" />
</ItemGroup>
<ItemGroup>
<ItemGroup Condition="'$(WindowsTerminalBranding)'=='' or '$(WindowsTerminalBranding)'=='Dev' or '$(WindowsTerminalBranding)'=='Preview'">
<!-- GH#13252 Only vend this dependency for Dev and Preview builds. -->
<SDKReference Include="Microsoft.Midi.GmDls, Version=10.0.22000.0" />
</ItemGroup>
<!-- ========================= Project References ======================== -->
Expand Down
12 changes: 12 additions & 0 deletions src/features.xml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,18 @@
</alwaysDisabledBrandingTokens>
</feature>

<feature>
<name>Feature_DECPSViaMidiPlayer</name>
<description>Enables playing sound via DECPS using the MIDI player.</description>
<stage>AlwaysDisabled</stage>
<!-- We're disabling this for WindowsInbox and Stable because it requires an additional
package dependency or library dependency. -->
<alwaysEnabledBrandingTokens>
<brandingToken>Dev</brandingToken>
<brandingToken>Preview</brandingToken>
</alwaysEnabledBrandingTokens>
</feature>

<feature>
<name>Feature_ScrollbarMarks</name>
<description>Enables the experimental scrollbar marks feature.</description>
Expand Down

0 comments on commit 205c09c

Please sign in to comment.