Skip to content

Commit

Permalink
Merge pull request #735 from dtinth/volume-regulation
Browse files Browse the repository at this point in the history
  • Loading branch information
release-train[bot] committed Oct 30, 2021
2 parents 574c01a + ca4e48c commit 0fdc54e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
6 changes: 5 additions & 1 deletion bemuse/src/app/game-launcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import createAutoVelocity from './interactors/createAutoVelocity'
import { StoredOptions } from './types'
import GenericErrorScene from './ui/GenericErrorScene'
import ResultScene from './ui/ResultScene'
import { getSoundVolume } from './query-flags'

const Log = BemuseLogger.forModule('game-launcher')

Expand Down Expand Up @@ -282,7 +283,10 @@ const DEFAULT_REPLAYGAIN = -12.2 // dB

function getVolume(song: Song) {
const gain = replayGainFor(song)
return Math.pow(10, ((gain == null ? DEFAULT_REPLAYGAIN : gain) + 8) / 20)
return (
Math.pow(10, ((gain == null ? DEFAULT_REPLAYGAIN : gain) + 4) / 20) *
getSoundVolume()
)
}

function replayGainFor(song: Song) {
Expand Down
9 changes: 9 additions & 0 deletions bemuse/src/app/query-flags.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ export function getMusicServer() {
return query.BEMUSE_MUSIC_SERVER || query.server
}

/**
* The `?volume` flag specifies the sound volume.
*
* @see https://bemuse.ninja/project/docs/music-server.html
*/
export function getSoundVolume() {
return +query.volume || 1
}

/**
* The `?archive` flag specifies a URL to a BMS archive file to be downloaded when the player enters the game.
*
Expand Down

0 comments on commit 0fdc54e

Please sign in to comment.