Mapped notes to new .wav's and their midi ranges

This commit is contained in:
Gordon Weeks 2026-01-31 17:32:58 -08:00
parent 77610f6b06
commit aab7cbdafa

View File

@ -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<Glyph> chart_from_song(const Song& song, int track_override)
std::vector<std::pair<int, const Note*>> 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, &note});
}
std::sort(timed_notes.begin(), timed_notes.end(),
@ -257,8 +261,9 @@ std::vector<Glyph> 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<Sound> 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))