Add real-time note detection and NOTEDROP visualization

Implemented musical note detection in AudioAnalyzer, exposing dominant note and strength in AudioFeatures. Updated HUD to display detected note. Added "NOTEDROP" fractal preset that animates detected notes as colored glyphs. Extended bitmap font to support sharps. Increased fractal preset count and adjusted HUD layout.
This commit is contained in:
Michal Vrba
2026-02-13 20:43:29 +01:00
parent 8bf3978354
commit 6a1bdfb935
5 changed files with 221 additions and 5 deletions
+27 -5
View File
@@ -145,7 +145,7 @@ public class Game1 : Game
if (IsPressed(keyboard, Keys.Right))
{
_fractalPresetIndex = Math.Min(19, _fractalPresetIndex + 1);
_fractalPresetIndex = Math.Min(20, _fractalPresetIndex + 1);
}
if (IsPressed(keyboard, Keys.M))
@@ -194,10 +194,11 @@ public class Game1 : Game
_hudFont.DrawText(_spriteBatch, _pixel, "HIGH " + _latestFeatures.High.ToString("0.000"), 12, 110, 2, Color.White);
_hudFont.DrawText(_spriteBatch, _pixel, "BEAT " + _latestFeatures.Beat.ToString("0.000"), 12, 130, 2, Color.White);
_hudFont.DrawText(_spriteBatch, _pixel, "BPM " + _latestFeatures.Bpm.ToString("0.0"), 12, 150, 2, Color.White);
_hudFont.DrawText(_spriteBatch, _pixel, "PAUSED " + (_isPaused ? "YES" : "NO"), 12, 170, 2, Color.White);
_hudFont.DrawText(_spriteBatch, _pixel, "FPS " + _fps, 12, 190, 2, Color.White);
_hudFont.DrawText(_spriteBatch, _pixel, "QUALITY " + _renderQuality + " 1 2 3", 12, 210, 2, Color.White);
_hudFont.DrawText(_spriteBatch, _pixel, "F OR F11 FULLSCREEN R RESIZE", 12, 230, 2, Color.White);
_hudFont.DrawText(_spriteBatch, _pixel, "NOTE " + GetDetectedNoteName(_latestFeatures.DetectedNoteIndex), 12, 170, 2, Color.White);
_hudFont.DrawText(_spriteBatch, _pixel, "PAUSED " + (_isPaused ? "YES" : "NO"), 12, 190, 2, Color.White);
_hudFont.DrawText(_spriteBatch, _pixel, "FPS " + _fps, 12, 210, 2, Color.White);
_hudFont.DrawText(_spriteBatch, _pixel, "QUALITY " + _renderQuality + " 1 2 3", 12, 230, 2, Color.White);
_hudFont.DrawText(_spriteBatch, _pixel, "F OR F11 FULLSCREEN R RESIZE", 12, 250, 2, Color.White);
_spriteBatch.End();
}
@@ -247,10 +248,31 @@ public class Game1 : Game
17 => "MOSAIC",
18 => "RIBBON",
19 => "GRAINBARS",
20 => "NOTEDROP",
_ => "JULIA"
};
}
private static string GetDetectedNoteName(int noteIndex)
{
return noteIndex switch
{
0 => "C",
1 => "C#",
2 => "D",
3 => "D#",
4 => "E",
5 => "F",
6 => "F#",
7 => "G",
8 => "G#",
9 => "A",
10 => "A#",
11 => "B",
_ => "-"
};
}
private void ToggleFullScreen()
{
_graphics.ToggleFullScreen();