Compare commits

..

No commits in common. "f66952ef5c88e05cef16398fea5f973f87349795" and "27c371e97ebecc02133f31f8f153e657f68a18aa" have entirely different histories.

3 changed files with 18 additions and 22 deletions

View File

@ -16,9 +16,7 @@ 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 OCTAVE_OFFSET = 48;
constexpr int MAX_GAMEPADS = 4;
constexpr int MAX_INSTRUMENT_TYPES = MAX_GAMEPADS;
constexpr float RECEPTOR_HEIGHT = 150.0f;
@ -28,7 +26,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.1f;
constexpr float MIN_GLYPH_DURATION_SEC = 0.05f;
const int GAMEPAD_BUTTONS[LANE_COUNT] = {
GAMEPAD_BUTTON_LEFT_FACE_LEFT, // Left
@ -89,8 +87,7 @@ const float INSTRUMENT_VOLUME[MAX_INSTRUMENT_TYPES] = {
0.7f
};
/* 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] {
const char* const INSTRUMENT_LANE_WAV[MAX_INSTRUMENT_TYPES][LANE_COUNT * OCTAVE_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",
@ -245,7 +242,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 >= MIDI_LANE_MIN && note.midi <= MIDI_LANE_MAX)
if (note.midi >= 0 && note.midi <= 127)
timed_notes.push_back({note.ticks, &note});
}
std::sort(timed_notes.begin(), timed_notes.end(),
@ -261,9 +258,11 @@ 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 wav_index = note.midi - MIDI_LANE_MIN;
int lane = wav_index % LANE_COUNT;
int octave = wav_index;
int lane = note.midi % LANE_COUNT;
int offset = 0;
if (note.midi >= OCTAVE_OFFSET)
offset = OCTAVE_OFFSET;
int octave = (note.midi - offset) % (LANE_COUNT * OCTAVE_COUNT);
int instrument_slot = note_index % MAX_INSTRUMENT_TYPES;
// Log original glyph timing (time is bottom, time + duration is top)
@ -357,8 +356,8 @@ public:
float lane_width = 0.0f;
float screen_width = 0.0f;
float screen_height = 0.0f;
Sound note_sounds[MAX_INSTRUMENT_TYPES][MIDI_LANE_COUNT] = {{0}};
bool note_sounds_loaded[MAX_INSTRUMENT_TYPES][MIDI_LANE_COUNT] = {{false}};
Sound note_sounds[MAX_INSTRUMENT_TYPES][LANE_COUNT * OCTAVE_COUNT] = {{0}};
bool note_sounds_loaded[MAX_INSTRUMENT_TYPES][LANE_COUNT * OCTAVE_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};
@ -425,7 +424,7 @@ public:
}
for (int slot = 0; slot < MAX_INSTRUMENT_TYPES; slot++)
{
for (int lane = 0; lane < MIDI_LANE_COUNT; lane++)
for (int lane = 0; lane < LANE_COUNT * OCTAVE_COUNT; lane++)
{
if (note_sounds_loaded[slot][lane])
{
@ -446,7 +445,7 @@ public:
update_layout();
for (int slot = 0; slot < MAX_INSTRUMENT_TYPES; slot++)
{
for (int lane = 0; lane < MIDI_LANE_COUNT; lane++)
for (int lane = 0; lane < LANE_COUNT * OCTAVE_COUNT; lane++)
{
const char* path = INSTRUMENT_LANE_WAV[slot][lane];
if (FileExists(path))

View File

@ -32,9 +32,9 @@ public:
static constexpr const char* INSTRUMENT_IMAGE_PATHS[MAX_INSTRUMENT_TYPES] = {
"assets/instruments/guitar.png",
"assets/instruments/sax.png",
"assets/instruments/violin.png",
"assets/instruments/piano.png",
"assets/instruments/violin.png",
"assets/instruments/sax.png",
};
std::array<int, MAX_INSTRUMENT_TYPES> instrument_owner = {-1, -1, -1, -1};

View File

@ -15,15 +15,12 @@ public:
void update(float delta_time) override
{
bool start = IsKeyPressed(KEY_ENTER);
for (int gp = 0; gp < 4; gp++)
// Trigger scene change on Enter key or gamepad start button.
if (IsKeyPressed(KEY_ENTER) || IsGamepadButtonPressed(0, GAMEPAD_BUTTON_MIDDLE_RIGHT))
{
if (IsGamepadAvailable(gp) && IsGamepadButtonPressed(gp, GAMEPAD_BUTTON_MIDDLE_RIGHT))
start = true;
}
if (start)
game->go_to_scene("song_select");
}
}
void draw() override
{