Merge pull request #128 from UniversityRadioYork/mstratford-audio-fixes

Audio Fixes Galore.
This commit is contained in:
Matthew Stratford 2020-05-23 00:42:52 +01:00 committed by GitHub
commit 8ed02dfc54
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 6 deletions

View file

@ -77,7 +77,7 @@ class Player extends ((PlayerEmitter as unknown) as { new (): EventEmitter }) {
_applyVolume() {
const level = this.volume + this.trim;
const linear = Math.pow(10, level / 10);
const linear = Math.pow(10, level / 20);
if (linear < 1) {
this.wavesurfer.setVolume(linear);
(this.wavesurfer as any).backend.gainNode.gain.value = 1;
@ -312,7 +312,7 @@ export class AudioEngine extends ((EngineEmitter as unknown) as {
setMicCalibrationGain(value: number) {
this.micCalibrationGain.gain.value =
value === 0 ? 1 : Math.pow(10, value / 10);
value === 0 ? 1 : Math.pow(10, value / 20);
}
setMicVolume(value: number) {

View file

@ -28,6 +28,8 @@ type VolumePresetEnum = "off" | "bed" | "full";
type MicVolumePresetEnum = "off" | "full";
export type MicErrorEnum = "NO_PERMISSION" | "NOT_SECURE_CONTEXT" | "UNKNOWN";
const defaultTrimDB = -6; // The default trim applied to channel players.
interface PlayerState {
loadedItem: PlanItem | Track | AuxItem | null;
loading: number;
@ -64,7 +66,7 @@ const BasePlayerState: PlayerState = {
state: "stopped",
volume: 1,
gain: 0,
trim: -3,
trim: defaultTrimDB,
timeCurrent: 0,
timeRemaining: 0,
timeLength: 0,
@ -105,7 +107,7 @@ const mixerState = createSlice({
state.players[action.payload.player].tracklistItemID = -1;
state.players[action.payload.player].loadError = false;
if (action.payload.resetTrim) {
state.players[action.payload.player].trim = -3;
state.players[action.payload.player].trim = defaultTrimDB;
}
},
itemLoadPercentage(

View file

@ -87,7 +87,8 @@ export function VUMeter(props: VUMeterProps) {
ctx.fillStyle = "#e8d120";
}
const valueOffset = Math.abs(peak - props.range[0]) / valueRange;
const valueOffset =
(Math.max(peak, props.range[0]) - props.range[0]) / valueRange;
ctx.fillRect(0, 0, valueOffset * width, height - 10);

View file

@ -145,7 +145,13 @@ function MicControl() {
</p>
)}
<div id="micMeter">
<VUMeter width={250} height={40} source="mic-final" range={[-70, 0]} />
<VUMeter
width={250}
height={40}
source="mic-final"
range={[-40, 3]}
greenRange={[-10, -5]}
/>
</div>
<div className={`mixer-buttons ${!state.open && "disabled"}`}>
<div