Skip to content

Commit

Permalink
Music: Add new relative_speed option in the config layer (julianxhoka…
Browse files Browse the repository at this point in the history
  • Loading branch information
myst6re authored Mar 3, 2024
1 parent 4351599 commit 1e8b467
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
4 changes: 4 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

- Full commit list since last stable release: https://github.com/julianxhokaxhiu/FFNx/compare/1.18.1...master

## Common

- Music: Add new [relative_speed](https://github.com/julianxhokaxhiu/FFNx/blob/master/misc/FFNx.music.toml#L29-L31) option in the config layer ( https://github.com/julianxhokaxhiu/FFNx/pull/672 )

## FF8

- Graphics: Fix texture animations by copy only partially animated ( https://github.com/julianxhokaxhiu/FFNx/pull/670 )
Expand Down
4 changes: 4 additions & 0 deletions misc/FFNx.music.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
# -----------------------------------------------------------------------------
# disabled: Set this flag to true to never play this music and act like it was
# never triggered by the game.
# -----------------------------------------------------------------------------
# relative_speed: Set the music relative speed, with 1.0 is the normal speed,
# between 0.0 and 1.0 (not included) the music is slowed down, and above 1.0
# the music is sped up.
###############################################################################

# This entry will shuffle "battle" with "battle2", "bossbat1" and "bossbat2".
Expand Down
9 changes: 9 additions & 0 deletions src/audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,7 @@ void NxAudioEngine::overloadPlayArgumentsFromConfig(char* name, uint32_t* id, Mu
std::optional<SoLoud::time> offset_seconds_opt = config[name]["offset_seconds"].value<SoLoud::time>();
std::optional<std::string> no_intro_track_opt = config[name]["no_intro_track"].value<std::string>();
std::optional<SoLoud::time> intro_seconds_opt = config[name]["intro_seconds"].value<SoLoud::time>();
std::optional<float> relative_speed_opt = config[name]["relative_speed"].value<float>();

if (offset_seconds_opt.has_value()) {
musicOptions->offsetSeconds = *offset_seconds_opt;
Expand Down Expand Up @@ -653,6 +654,10 @@ void NxAudioEngine::overloadPlayArgumentsFromConfig(char* name, uint32_t* id, Mu
}
}

if (relative_speed_opt.has_value() && *relative_speed_opt > 0.0f) {
musicOptions->relativeSpeed = *relative_speed_opt;
}

// Shuffle Music playback, if any entry found for the current music name
toml::array* shuffleNames = config[name]["shuffle"].as_array();
if (shuffleNames && !shuffleNames->empty() && shuffleNames->is_homogeneous(toml::node_type::string)) {
Expand Down Expand Up @@ -722,6 +727,10 @@ bool NxAudioEngine::playMusic(const char* name, uint32_t id, int channel, MusicO
setMusicVolume(music.wantedMusicVolume, channel, options.fadetime);
}

if (options.relativeSpeed > 0.0f && options.relativeSpeed != 1.0f) {
setMusicSpeed(options.relativeSpeed, channel);
}

return true;
}

Expand Down
12 changes: 7 additions & 5 deletions src/audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,21 @@ class NxAudioEngine
{
MusicOptions() :
offsetSeconds(0.0),
fadetime(0.0),
targetVolume(-1.0f),
relativeSpeed(1.0f),
format(""),
noIntro(false),
sync(false),
useNameAsFullPath(false),
suppressOpeningSilence(false),
fadetime(0.0),
targetVolume(-1.0f),
format("")
suppressOpeningSilence(false)
{}
SoLoud::time offsetSeconds;
bool noIntro, sync, useNameAsFullPath, suppressOpeningSilence;
SoLoud::time fadetime;
float targetVolume;
float relativeSpeed;
char format[12];
bool noIntro, sync, useNameAsFullPath, suppressOpeningSilence;
};

struct NxAudioEngineSFX
Expand Down

0 comments on commit 1e8b467

Please sign in to comment.