Przeglądaj źródła

feat(Metronome): Add metronome.PreCountVolume (#31), an alternate volume while precounting

fix #31
sschmidTU 3 lat temu
rodzic
commit
4e242acffd

+ 10 - 0
src/Playback/MetronomeInstrument.ts

@@ -14,6 +14,16 @@ export class MetronomeInstrument implements ISettableInstrument {
     public PitchMonitor: boolean;
     public Highlight: boolean;
     public Volume: number;
+    private preCountVolume: number;
+    public get PreCountVolume(): number {
+        if (this.preCountVolume >= 0) {
+            return this.preCountVolume;
+        }
+        return this.Volume; // if preCountVolume is undefined, use the main volume
+    }
+    public set PreCountVolume(value: number) {
+        this.preCountVolume = value;
+    }
     public MidiInstrumentId: MidiInstrument;
     public get Audible(): boolean {
         return this.audible;

+ 1 - 1
src/Playback/PlaybackManager.ts

@@ -1069,7 +1069,7 @@ export class PlaybackManager implements IPlaybackParametersListener {
             if (this.metronome.Audible ||
                 this.metronome.Solo ||
                 this.isPreCounting) {
-                let volume: number = this.metronome.Volume;
+                let volume: number = this.isPreCounting ? this.metronome.PreCountVolume : this.metronome.Volume;
                 if (!this.isPreCounting && this.SoloActive && !this.metronome.Solo) {
                     volume *= this.SoloAttenuationValue;
                 }