Opus input: Support switching gain modes based on player settings, since the Opus tag reader doesn't support Opus gain tags yet

CQTexperiment
Christopher Snowhill 2022-01-22 21:03:52 -08:00
parent 8e5c62f185
commit 6b8d300384
1 changed files with 11 additions and 0 deletions

View File

@ -89,6 +89,17 @@ opus_int64 sourceTell(void *_stream)
seekable = op_seekable(opusRef);
totalFrames = op_pcm_total(opusRef, -1);
NSString * gainMode = [[NSUserDefaults standardUserDefaults] stringForKey:@"volumeScaling"];
BOOL isAlbum = [gainMode hasPrefix:@"albumGain"];
BOOL isTrack = [gainMode hasPrefix:@"trackGain"];
if (isAlbum || isTrack) {
op_set_gain_offset(opusRef, isAlbum ? OP_HEADER_GAIN : OP_TRACK_GAIN, 0);
}
else {
op_set_gain_offset(opusRef, OP_ABSOLUTE_GAIN, 0);
}
[self willChangeValueForKey:@"properties"];
[self didChangeValueForKey:@"properties"];