Skip to content

Commit

Permalink
vee one point three point seven
Browse files Browse the repository at this point in the history
  • Loading branch information
undefined06855 committed Jun 29, 2024
1 parent 0d95b80 commit ce46a49
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 14 deletions.
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
41 changes: 30 additions & 11 deletions src/AudioManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool>("unnamed-song-fallback")) songName = unloadedSong.path.filename().string();
else songName = Mod::get()->getSettingValue<std::string>("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]+");
Expand Down Expand Up @@ -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<bool>("unnamed-song-fallback")) songName = usong.path.filename().string();
else songName = Mod::get()->getSettingValue<std::string>("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");
Expand All @@ -148,11 +150,17 @@ void AudioManager::playSongID(int id) {
std::string songName;
const char* songNameAsChar = reinterpret_cast<const char*>(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<std::codecvt_utf8_utf16<char16_t>, char16_t> converter;
songName = converter.to_bytes(reinterpret_cast<const char16_t*>(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<std::codecvt_utf8_utf16<char16_t>, char16_t> converter;
Expand All @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/AudioManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ class AudioManager {

void updateLowPassFilter();

std::string figureOutFallbackName(UnloadedAudio unloadedSong);

void playNewSong();
void playSongID(int id);
void nextSong();
Expand Down
4 changes: 2 additions & 2 deletions src/Ease.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
}
};

0 comments on commit ce46a49

Please sign in to comment.