Browse Source

BasicAudioPlayer: add gain multiplier

sschmidTU 2 years ago
parent
commit
a46e354b5d
1 changed files with 4 additions and 1 deletions
  1. 4 1
      src/Playback/BasicAudioPlayer.ts

+ 4 - 1
src/Playback/BasicAudioPlayer.ts

@@ -20,6 +20,9 @@ export class BasicAudioPlayer implements IAudioPlayer<SoundfontPlayer.Player> {
   protected channelToSoundFont: Map<number, number> = new Map();
 
   public SoundfontInstrumentOptions = {}; // e.g. set { from: 'server.com/soundfonts/' } for soundfont fetching url
+  /** Multiplicator for gain (volume output). 1 represents the maximum volume in OSMD (100%),
+   *  but it looks like soundfont-player is louder with volumes > 1, e.g. 3 */
+  public GainMultiplier: number = 1;
 
   public async open(uniqueInstruments: number[], numberOfinstruments: number = 16): Promise<void> {
     if (this.piano === undefined) {
@@ -61,7 +64,7 @@ export class BasicAudioPlayer implements IAudioPlayer<SoundfontPlayer.Player> {
       this.channelToSoundFont.get(instrumentChannel)
     );
     soundFont.schedule(0, [
-      { note: key, duration: lengthInMs / 1000, gain: sampleVolume },
+      { note: key, duration: lengthInMs / 1000, gain: sampleVolume * this.GainMultiplier },
     ]);
   }