Skip to content

Commit

Permalink
add - doc - Added test device key combo
Browse files Browse the repository at this point in the history
---

We've added a new key combo that allows you to test your device and your driver.

---

Type: add
Breaking: False
Doc Required: True
Backport Required: False
Part: 1/1
  • Loading branch information
AptiviCEO committed Sep 19, 2024
1 parent 1e6e205 commit b66d79c
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 1 deletion.
7 changes: 6 additions & 1 deletion BassBoom.Cli/BassBoom.Cli.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0;net48</TargetFrameworks>
Expand All @@ -21,4 +21,9 @@
<Copy SourceFiles="@(Assets)" DestinationFolder="$(OutDir)" />
</Target>

<ItemGroup>
<None Remove="..\BassBoom\Assets\sample.mp3" />
<EmbeddedResource Include="..\BassBoom\Assets\sample.mp3" />
</ItemGroup>

</Project>
6 changes: 6 additions & 0 deletions BassBoom.Cli/CliBase/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ internal static class Player
new("Disco Mode!", ConsoleKey.L),
new("Enable volume boost", ConsoleKey.V),
new("Save to playlist", ConsoleKey.F1),
new("Play test sound (to test device and driver)", ConsoleKey.F2),
new("Open the equalizer", ConsoleKey.E),
new("Device and driver information", ConsoleKey.D),
new("Set device and driver", ConsoleKey.D, ConsoleModifiers.Control),
Expand Down Expand Up @@ -249,6 +250,11 @@ private static void HandleKeypressIdleMode(ConsoleKeyInfo keystroke, Screen play
else
Common.CurrentCachedInfo.RepeatCheckpoint = PlaybackPositioningTools.GetCurrentDurationSpan(BassBoomCli.basolia);
break;
case ConsoleKey.F2:
PlayerControls.PlayTest();
Common.redraw = true;
playerScreen.RequireRefresh();
break;
default:
Common.HandleKeypressCommon(keystroke, playerScreen, false);
break;
Expand Down
32 changes: 32 additions & 0 deletions BassBoom.Cli/CliBase/PlayerControls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
using BassBoom.Basolia.Playback.Playlists;
using BassBoom.Basolia.Playback.Playlists.Enumerations;
using BassBoom.Cli.Tools;
using SpecProbe.Software.Platform;
using System;
using System.IO;
using System.Linq;
Expand Down Expand Up @@ -429,6 +430,37 @@ internal static void PromptSeek()
}
}

internal static void PlayTest()
{
if (Common.CurrentCachedInfo is not null)
return;

// Ignore all settings while playing test sound, because it IS a test session.
InfoBoxColor.WriteInfoBox("Playing test sound...", false);

// Extract the test sound asset to a temporary file
string path = PlatformHelper.IsOnWindows() ? $"{Environment.GetEnvironmentVariable("TEMP")}" : $"{Environment.GetEnvironmentVariable("TEMP")}";
string fullPath = $"{path}/{DateTime.Now:ddMMyyyyHHmmssfff}.mp3";
var stream = typeof(PlayerControls).Assembly.GetManifestResourceStream("BassBoom.Cli.sample.mp3") ??
throw new Exception("Missing test sound data.");
var target = File.OpenWrite(fullPath);
stream.CopyTo(target);

// Now, close the file and play it
target.Close();
FileTools.OpenFile(BassBoomCli.basolia, fullPath);
PlaybackTools.Play(BassBoomCli.basolia);
FileTools.CloseFile(BassBoomCli.basolia);
File.Delete(fullPath);

// Ask the user if everything is OK.
int answer = InfoBoxButtonsColor.WriteInfoBoxButtons("Sound test", [new InputChoiceInfo("Yes", "Yes"), new InputChoiceInfo("No", "No")], "Is everything OK in this current configuration?");
if (answer == 0)
InfoBoxColor.WriteInfoBox("Congratulations! You've set up everything properly!");
else if (answer == 1)
InfoBoxColor.WriteInfoBox("Check your device and try again.");
}

internal static void ShowSongInfo()
{
if (Common.CurrentCachedInfo is null)
Expand Down
Binary file added BassBoom/Assets/sample.mp3
Binary file not shown.

0 comments on commit b66d79c

Please sign in to comment.