From aab7cbdafaddc2293d78365856989f8c1339f86d Mon Sep 17 00:00:00 2001 From: Gordon Weeks <627684+gcweeks@users.noreply.github.com> Date: Sat, 31 Jan 2026 17:32:58 -0800 Subject: [PATCH 1/3] Mapped notes to new .wav's and their midi ranges --- src/samples/ghhb_game.h | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/samples/ghhb_game.h b/src/samples/ghhb_game.h index ea3d3b7..45030e0 100644 --- a/src/samples/ghhb_game.h +++ b/src/samples/ghhb_game.h @@ -16,6 +16,9 @@ namespace { constexpr int LANE_COUNT = 12; constexpr int OCTAVE_COUNT = 3; +constexpr int MIDI_LANE_MIN = 48; +constexpr int MIDI_LANE_MAX = 83; +constexpr int MIDI_LANE_COUNT = MIDI_LANE_MAX - MIDI_LANE_MIN + 1; constexpr int MAX_GAMEPADS = 4; constexpr int MAX_INSTRUMENT_TYPES = MAX_GAMEPADS; constexpr float RECEPTOR_HEIGHT = 150.0f; @@ -25,7 +28,7 @@ constexpr float SCROLL_PX_PER_SEC = 350.0f; constexpr float LEAD_OFFSET_SECONDS = 3.0f; constexpr float GLYPH_HEIGHT_FRACTION_OF_LANE = 0.5f; constexpr float MIN_SUSTAIN_FALLBACK_SEC = 0.05f; -constexpr float MIN_GLYPH_DURATION_SEC = 0.05f; +constexpr float MIN_GLYPH_DURATION_SEC = 0.1f; const int GAMEPAD_BUTTONS[LANE_COUNT] = { GAMEPAD_BUTTON_LEFT_FACE_LEFT, // Left @@ -86,7 +89,8 @@ const float INSTRUMENT_VOLUME[MAX_INSTRUMENT_TYPES] = { 0.7f }; -const char* const INSTRUMENT_LANE_WAV[MAX_INSTRUMENT_TYPES][LANE_COUNT * OCTAVE_COUNT] { +/* Index i = MIDI note (48 + i); notes outside [48, 83] are not rendered. */ +const char* const INSTRUMENT_LANE_WAV[MAX_INSTRUMENT_TYPES][MIDI_LANE_COUNT] { { // Instrument 0 - Synth "assets/sounds/snes_synth/snes_synth_048.wav", "assets/sounds/snes_synth/snes_synth_049.wav", "assets/sounds/snes_synth/snes_synth_050.wav", "assets/sounds/snes_synth/snes_synth_051.wav", @@ -241,7 +245,7 @@ std::vector chart_from_song(const Song& song, int track_override) std::vector> timed_notes; for (const Note& note : track.notes) { - if (note.midi >= 0 && note.midi <= 127) + if (note.midi >= MIDI_LANE_MIN && note.midi <= MIDI_LANE_MAX) timed_notes.push_back({note.ticks, ¬e}); } std::sort(timed_notes.begin(), timed_notes.end(), @@ -257,8 +261,9 @@ std::vector chart_from_song(const Song& song, int track_override) const Note& note = *pair.second; float time_sec = note.ticks / ticks_per_sec; // This is now the BOTTOM time float duration_sec = note.duration_ticks / ticks_per_sec; - int lane = note.midi % LANE_COUNT; - int octave = note.midi % (LANE_COUNT * OCTAVE_COUNT); + int wav_index = note.midi - MIDI_LANE_MIN; + int lane = wav_index % LANE_COUNT; + int octave = wav_index; int instrument_slot = note_index % MAX_INSTRUMENT_TYPES; // Log original glyph timing (time is bottom, time + duration is top) @@ -352,8 +357,8 @@ public: float lane_width = 0.0f; float screen_width = 0.0f; float screen_height = 0.0f; - Sound note_sounds[MAX_INSTRUMENT_TYPES][LANE_COUNT * OCTAVE_COUNT] = {{0}}; - bool note_sounds_loaded[MAX_INSTRUMENT_TYPES][LANE_COUNT * OCTAVE_COUNT] = {{false}}; + Sound note_sounds[MAX_INSTRUMENT_TYPES][MIDI_LANE_COUNT] = {{0}}; + bool note_sounds_loaded[MAX_INSTRUMENT_TYPES][MIDI_LANE_COUNT] = {{false}}; std::deque note_sounds_playing[LANE_COUNT][MAX_INSTRUMENT_TYPES]; static constexpr float PRESS_FLASH_DURATION = 0.12f; float press_flash_timer[LANE_COUNT] = {0}; @@ -420,7 +425,7 @@ public: } for (int slot = 0; slot < MAX_INSTRUMENT_TYPES; slot++) { - for (int lane = 0; lane < LANE_COUNT * OCTAVE_COUNT; lane++) + for (int lane = 0; lane < MIDI_LANE_COUNT; lane++) { if (note_sounds_loaded[slot][lane]) { @@ -441,7 +446,7 @@ public: update_layout(); for (int slot = 0; slot < MAX_INSTRUMENT_TYPES; slot++) { - for (int lane = 0; lane < LANE_COUNT * OCTAVE_COUNT; lane++) + for (int lane = 0; lane < MIDI_LANE_COUNT; lane++) { const char* path = INSTRUMENT_LANE_WAV[slot][lane]; if (FileExists(path)) From afdfb4ef20b97bc72fd93300ac992e43ac2d0a43 Mon Sep 17 00:00:00 2001 From: Gordon Weeks <627684+gcweeks@users.noreply.github.com> Date: Sat, 31 Jan 2026 17:33:15 -0800 Subject: [PATCH 2/3] Allow any player to start game --- src/samples/title_screen.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/samples/title_screen.h b/src/samples/title_screen.h index e69dd8e..8c9a9f0 100644 --- a/src/samples/title_screen.h +++ b/src/samples/title_screen.h @@ -15,11 +15,14 @@ public: void update(float delta_time) override { - // Trigger scene change on Enter key or gamepad start button. - if (IsKeyPressed(KEY_ENTER) || IsGamepadButtonPressed(0, GAMEPAD_BUTTON_MIDDLE_RIGHT)) + bool start = IsKeyPressed(KEY_ENTER); + for (int gp = 0; gp < 4; gp++) { - game->go_to_scene("song_select"); + if (IsGamepadAvailable(gp) && IsGamepadButtonPressed(gp, GAMEPAD_BUTTON_MIDDLE_RIGHT)) + start = true; } + if (start) + game->go_to_scene("song_select"); } void draw() override From b5a4cb07082eaa618d5d4a6c412aa8c9ef6ee1d5 Mon Sep 17 00:00:00 2001 From: Gordon Weeks <627684+gcweeks@users.noreply.github.com> Date: Sat, 31 Jan 2026 17:33:40 -0800 Subject: [PATCH 3/3] Rearranged instrument icons to match .wav's --- src/samples/instrument_select.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/samples/instrument_select.h b/src/samples/instrument_select.h index b270ce2..dd0a341 100644 --- a/src/samples/instrument_select.h +++ b/src/samples/instrument_select.h @@ -32,9 +32,9 @@ public: static constexpr const char* INSTRUMENT_IMAGE_PATHS[MAX_INSTRUMENT_TYPES] = { "assets/instruments/guitar.png", - "assets/instruments/piano.png", - "assets/instruments/violin.png", "assets/instruments/sax.png", + "assets/instruments/violin.png", + "assets/instruments/piano.png", }; std::array instrument_owner = {-1, -1, -1, -1};