From c61af9316f379004f25da1ae7207f2bc57676d3e Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Fri, 21 Oct 2022 23:06:07 -0700 Subject: [PATCH] Move to unused Chime class --- CHANGELIST.md | 1 + MPF.Core/Utilities/Chime.cs | 396 ++++++++++++++++++++++++++++++++++++ MPF.Core/Utilities/Tools.cs | 79 ------- 3 files changed, 397 insertions(+), 79 deletions(-) create mode 100644 MPF.Core/Utilities/Chime.cs diff --git a/CHANGELIST.md b/CHANGELIST.md index ddc625b6..1842bc30 100644 --- a/CHANGELIST.md +++ b/CHANGELIST.md @@ -173,6 +173,7 @@ - Fix layerbreak-based checks - Add PS4 serial finding (tjanas) - Add unused notification method +- Move to unused Chime class ### 2.3 (2022-02-05) - Start overhauling Redump information pulling, again diff --git a/MPF.Core/Utilities/Chime.cs b/MPF.Core/Utilities/Chime.cs new file mode 100644 index 00000000..c248ea80 --- /dev/null +++ b/MPF.Core/Utilities/Chime.cs @@ -0,0 +1,396 @@ +using System; + +namespace MPF.Core.Utilities +{ + /// + /// Methods to deal with outputting tones to the PC speaker + /// + public class Chime + { + /// + /// Standard duration to play a single tone + /// + private const int standardDurationMs = 200; + + #region Octave 0 + + /// + /// Frequency representing C(0) + /// + private const int noteC0 = 16; // 16.35 + + /// + /// Frequency representing D(0) + /// + private const int noteD0 = 18; // 18.35 + + /// + /// Frequency representing E(0) + /// + private const int noteE0 = 21; // 20.60 + + /// + /// Frequency representing F(0) + /// + private const int noteF0 = 22; // 21.83 + + /// + /// Frequency representing G(0) + /// + private const int noteG0 = 25; // 24.50 + + /// + /// Frequency representing A(0) + /// + private const int noteA0 = 28; // 27.50 + + /// + /// Frequency representing B(0) + /// + private const int noteB0 = 31; // 30.87 + + #endregion + + #region Octave 1 + + /// + /// Frequency representing C(1) + /// + private const int noteC1 = 33; // 32.70 + + /// + /// Frequency representing D(1) + /// + private const int noteD1 = 37; // 36.71 + + /// + /// Frequency representing E(1) + /// + private const int noteE1 = 41; // 41.20 + + /// + /// Frequency representing F(1) + /// + private const int noteF1 = 44; // 43.65 + + /// + /// Frequency representing G(1) + /// + private const int noteG1 = 49; // 49.00 + + /// + /// Frequency representing A(1) + /// + private const int noteA1 = 55; // 55.00 + + /// + /// Frequency representing B(1) + /// + private const int noteB1 = 62; // 61.74 + + #endregion + + #region Octave 2 + + /// + /// Frequency representing C(2) + /// + private const int noteC2 = 65; // 65.41 + + /// + /// Frequency representing D(2) + /// + private const int noteD2 = 73; // 73.42 + + /// + /// Frequency representing E(2) + /// + private const int noteE2 = 82; // 82.41 + + /// + /// Frequency representing F(2) + /// + private const int noteF2 = 87; // 87.31 + + /// + /// Frequency representing G(2) + /// + private const int noteG2 = 98; // 98.00 + + /// + /// Frequency representing A(2) + /// + private const int noteA2 = 110; // 110.00 + + /// + /// Frequency representing B(2) + /// + private const int noteB2 = 123; // 123.47 + + #endregion + + #region Octave 3 + + /// + /// Frequency representing C(3) + /// + private const int noteC3 = 131; // 130.81 + + /// + /// Frequency representing D(3) + /// + private const int noteD3 = 147; // 146.83 + + /// + /// Frequency representing E(3) + /// + private const int noteE3 = 165; // 164.81 + + /// + /// Frequency representing F(3) + /// + private const int noteF3 = 175; // 174.61 + + /// + /// Frequency representing G(3) + /// + private const int noteG3 = 196; // 196.00 + + /// + /// Frequency representing A(3) + /// + private const int noteA3 = 220; // 220.00 + + /// + /// Frequency representing B(3) + /// + private const int noteB3 = 247; // 246.94 + + #endregion + + #region Octave 4 + + /// + /// Frequency representing C(4) + /// + private const int noteC4 = 262; // 261.63 + + /// + /// Frequency representing D(4) + /// + private const int noteD4 = 294; // 293.66 + + /// + /// Frequency representing E(4) + /// + private const int noteE4 = 330; // 329.63 + + /// + /// Frequency representing F(4) + /// + private const int noteF4 = 349; // 349.23 + + /// + /// Frequency representing G(4) + /// + private const int noteG4 = 392; // 392.00 + + /// + /// Frequency representing A(4) + /// + private const int noteA4 = 440; // 440.00 + + /// + /// Frequency representing B(4) + /// + private const int noteB4 = 494; // 493.88 + + #endregion + + #region Octave 5 + + /// + /// Frequency representing C(5) + /// + private const int noteC5 = 523; // 523.25 + + /// + /// Frequency representing D(5) + /// + private const int noteD5 = 587; // 587.33 + + /// + /// Frequency representing E(5) + /// + private const int noteE5 = 659; // 659.25 + + /// + /// Frequency representing F(5) + /// + private const int noteF5 = 698; // 698.46 + + /// + /// Frequency representing G(5) + /// + private const int noteG5 = 783; // 783.99 + + /// + /// Frequency representing A(5) + /// + private const int noteA5 = 880; // 880.00 + + /// + /// Frequency representing B(5) + /// + private const int noteB5 = 988; // 987.77 + + #endregion + + #region Octave 6 + + /// + /// Frequency representing C(6) + /// + private const int noteC6 = 1047; // 1046.50 + + /// + /// Frequency representing D(6) + /// + private const int noteD6 = 1175; // 1174.66 + + /// + /// Frequency representing E(6) + /// + private const int noteE6 = 1319; // 1318.51 + + /// + /// Frequency representing F(6) + /// + private const int noteF6 = 1397; // 1396.91 + + /// + /// Frequency representing G(6) + /// + private const int noteG6 = 1568; // 1567.98 + + /// + /// Frequency representing A(6) + /// + private const int noteA6 = 1760; // 1760.00 + + /// + /// Frequency representing B(6) + /// + private const int noteB6 = 1976; // 1975.53 + + #endregion + + #region Octave 7 + + /// + /// Frequency representing C(7) + /// + private const int noteC7 = 2093; // 2093.00 + + /// + /// Frequency representing D(7) + /// + private const int noteD7 = 2349; // 2349.32 + + /// + /// Frequency representing E(7) + /// + private const int noteE7 = 2637; // 2637.02 + + /// + /// Frequency representing F(7) + /// + private const int noteF7 = 2794; // 2793.83 + + /// + /// Frequency representing G(7) + /// + private const int noteG7 = 3136; // 3135.96 + + /// + /// Frequency representing A(7) + /// + private const int noteA7 = 3520; // 3520.00 + + /// + /// Frequency representing B(7) + /// + private const int noteB7 = 3951; // 3951.07 + + #endregion + + #region Octave 8 + + /// + /// Frequency representing C(8) + /// + private const int noteC8 = 4186; // 4186.01 + + /// + /// Frequency representing D(8) + /// + private const int noteD8 = 4699; // 4698.63 + + /// + /// Frequency representing E(8) + /// + private const int noteE8 = 5274; // 5274.04 + + /// + /// Frequency representing F(8) + /// + private const int noteF8 = 5588; // 5587.65 + + /// + /// Frequency representing G(8) + /// + private const int noteG8 = 6272; // 6271.93 + + /// + /// Frequency representing A(8) + /// + private const int noteA8 = 7040; // 7040.00 + + /// + /// Frequency representing B(8) + /// + private const int noteB8 = 7902; // 7902.13 + + #endregion + + /// + /// Output a series of beeps for completion, similar to DiscImageCreator + /// + /// True if the upward series should play, false otherwise + public static void StandardCompletion(bool success) + { + if (success) + { + Console.Beep(noteC4, standardDurationMs); + Console.Beep(noteD4, standardDurationMs); + Console.Beep(noteE4, standardDurationMs); + Console.Beep(noteF4, standardDurationMs); + Console.Beep(noteG4, standardDurationMs); + Console.Beep(noteA4, standardDurationMs); + Console.Beep(noteB4, standardDurationMs); + Console.Beep(noteC5, standardDurationMs); + } + else + { + Console.Beep(noteC5, standardDurationMs); + Console.Beep(noteB4, standardDurationMs); + Console.Beep(noteA4, standardDurationMs); + Console.Beep(noteG4, standardDurationMs); + Console.Beep(noteF4, standardDurationMs); + Console.Beep(noteE4, standardDurationMs); + Console.Beep(noteD4, standardDurationMs); + Console.Beep(noteC4, standardDurationMs); + } + } + } +} diff --git a/MPF.Core/Utilities/Tools.cs b/MPF.Core/Utilities/Tools.cs index 78799dce..56d7799b 100644 --- a/MPF.Core/Utilities/Tools.cs +++ b/MPF.Core/Utilities/Tools.cs @@ -72,85 +72,6 @@ namespace MPF.Core.Utilities #endregion - #region Notification - - /// - /// Duration to play a single tone - /// - private const int durationMs = 200; - - /// - /// Frequency representing C(4) - /// - private const int noteC4 = 262; - - /// - /// Frequency representing D(4) - /// - private const int noteD4 = 294; - - /// - /// Frequency representing E(4) - /// - private const int noteE4 = 330; - - /// - /// Frequency representing F(4) - /// - private const int noteF4 = 349; - - /// - /// Frequency representing G(4) - /// - private const int noteG4 = 392; - - /// - /// Frequency representing A(5) - /// - private const int noteA5 = 440; - - /// - /// Frequency representing B(5) - /// - private const int noteB5 = 494; - - /// - /// Frequency representing C(5) - /// - private const int noteC5 = 523; - - /// - /// Output a series of beeps for success or failure, similar to DiscImageCreator - /// - /// True if the upward series should play, false otherwise - public static void SoundBeep(bool success) - { - if (success) - { - Console.Beep(noteC4, durationMs); - Console.Beep(noteD4, durationMs); - Console.Beep(noteE4, durationMs); - Console.Beep(noteF4, durationMs); - Console.Beep(noteG4, durationMs); - Console.Beep(noteA5, durationMs); - Console.Beep(noteB5, durationMs); - Console.Beep(noteC5, durationMs); - } - else - { - Console.Beep(noteC5, durationMs); - Console.Beep(noteB5, durationMs); - Console.Beep(noteA5, durationMs); - Console.Beep(noteG4, durationMs); - Console.Beep(noteF4, durationMs); - Console.Beep(noteE4, durationMs); - Console.Beep(noteD4, durationMs); - Console.Beep(noteC4, durationMs); - } - } - - #endregion - #region Support ///