diff --git a/changelog.md b/changelog.md index 4c50018..ba6da49 100644 --- a/changelog.md +++ b/changelog.md @@ -1,4 +1,7 @@ # EditorMusic +## v1.3.7 +- Small fixes on how metadata is read (see #16) +- I should've really made v1.3.6 and v1.3.4 major changes but whatever ## v1.3.6 - Change the text for how to get to mod config folder - Add fading for volume as well as low-pass filter to prevent popping (and make it sound nice) diff --git a/mod.json b/mod.json index 4a29099..08abdc4 100644 --- a/mod.json +++ b/mod.json @@ -4,7 +4,7 @@ "win": "2.206", "android": "2.206" }, - "version": "v1.3.6", + "version": "v1.3.7", "id": "undefined0.editormusic", "name": "EditorMusic", "developer": "undefined0", diff --git a/src/AudioManager.cpp b/src/AudioManager.cpp index 88dabcd..234da13 100644 --- a/src/AudioManager.cpp +++ b/src/AudioManager.cpp @@ -99,7 +99,13 @@ void AudioManager::tick(float dt) { } } -// FAKE IMPOSTOR FUNCTION for fading +std::string AudioManager::figureOutFallbackName(UnloadedAudio unloadedSong) { + std::string songName; + if (Mod::get()->getSettingValue("unnamed-song-fallback")) songName = unloadedSong.path.filename().string(); + else songName = Mod::get()->getSettingValue("unnamed-song-fallback-custom"); + return songName; +} + void AudioManager::playSongID(int id) { // filter for stuff like the BOM or whatever goofy unicode characters artists put in the song titles (WHY DOES MDK PUT A MUSIC NOTE?? IT'S NOT NEEDED) std::regex charsInBigFont("[^\u0020\u0021\u0022\u0023\u0024\u0025\u0026\u0027\u0028\u0029\u002a\u002b\u002c\u002d\u002e\u002f\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037\u0038\u0039\u003a\u003b\u003c\u003d\u003e\u003f\u0040\u0041\u0042\u0043\u0044\u0045\u0046\u0047\u0048\u0049\u004a\u004b\u004c\u004d\u004e\u004f\u0050\u0051\u0052\u0053\u0054\u0055\u0056\u0057\u0058\u0059\u005a\u005b\u005c\u005d\u005e\u005f\u0060\u0061\u0062\u0063\u0064\u0065\u0066\u0067\u0068\u0069\u006a\u006b\u006c\u006d\u006e\u006f\u0070\u0071\u0072\u0073\u0074\u0075\u0076\u0077\u0078\u0079\u007a\u007b\u007c\u007d\u007e\u2022]+"); @@ -133,13 +139,9 @@ void AudioManager::playSongID(int id) { log::info("checking existence..."); if (res == FMOD_ERR_TAGNOTFOUND) { log::warn("Name tag not found for song, using fallback"); - std::string songName; - if (Mod::get()->getSettingValue("unnamed-song-fallback")) songName = usong.path.filename().string(); - else songName = Mod::get()->getSettingValue("unnamed-song-fallback-custom"); - - this->song.name = songName; - log::info("Loaded song {}!", songName); + this->song.name = this->figureOutFallbackName(usong); + log::info("Loaded song {}!", this->song.name); } log::debug("Song has a name in metadata"); @@ -148,11 +150,17 @@ void AudioManager::playSongID(int id) { std::string songName; const char* songNameAsChar = reinterpret_cast(tag.data); - if (tag.datatype == FMOD_TAGDATATYPE_STRING_UTF16) { + switch (tag.datatype) { + case FMOD_TAGDATATYPE_STRING_UTF16: + { log::debug("Song name is in utf16"); std::wstring_convert, char16_t> converter; songName = converter.to_bytes(reinterpret_cast(songNameAsChar)); - } else if (tag.datatype == FMOD_TAGDATATYPE_STRING_UTF16BE) { + break; + } + + case FMOD_TAGDATATYPE_STRING_UTF16BE: + { log::debug("Song name is in utf16 but big endian (very silly)"); // silly big endian std::wstring_convert, char16_t> converter; @@ -161,9 +169,20 @@ void AudioManager::playSongID(int id) { utf16String[i] = (utf16String[i] << 8) | (utf16String[i] >> 8); } songName = converter.to_bytes(utf16String); - } else { - log::debug("Song name is in utf8 (nice)"); + break; + } + + case FMOD_TAGDATATYPE_STRING: + log::debug("uhh i think this is in utf8"); + case FMOD_TAGDATATYPE_STRING_UTF8: + log::debug("Song name is in utf8 (thanks)"); + log::debug("raw: {}, length: (datalen:{}, strlen:{})", songNameAsChar, tag.datalen, strlen(songNameAsChar)); songName = std::string(songNameAsChar, tag.datalen); + break; + default: + // uhhhh + log::info("wtf the song name isnt a string (using fallback)"); + songName = this->figureOutFallbackName(usong); } this->song.name = songName; diff --git a/src/AudioManager.hpp b/src/AudioManager.hpp index 6ffae77..daaef32 100644 --- a/src/AudioManager.hpp +++ b/src/AudioManager.hpp @@ -53,6 +53,8 @@ class AudioManager { void updateLowPassFilter(); + std::string figureOutFallbackName(UnloadedAudio unloadedSong); + void playNewSong(); void playSongID(int id); void nextSong(); diff --git a/src/Ease.cpp b/src/Ease.cpp index 9ea840f..9d70d5c 100644 --- a/src/Ease.cpp +++ b/src/Ease.cpp @@ -27,7 +27,7 @@ Ease::Ease(float start, float end, double duration, float* target, const std::fu } void Ease::tick(float dt) { - log::info("Tick from {} to {}", this->step, this->step + dt); + log::debug("Tick from {} to {}", this->step, this->step + dt); this->step += dt; @@ -55,9 +55,9 @@ void Ease::tick(float dt) { class $modify(CCScheduler) { void update(float dt) { + CCScheduler::update(dt); for (auto ease : eases) { ease->tick(dt); } - CCScheduler::update(dt); } };