diff --git a/server/classes/sound.js b/server/classes/sound.js index 6443fb55f..3e4227c11 100644 --- a/server/classes/sound.js +++ b/server/classes/sound.js @@ -10,5 +10,6 @@ export default class Sound { this.playbackRate = params.playbackRate || 1; this.channel = params.channel || [0, 1]; this.looping = params.looping || false; + this.preserveChannels = params.preserveChannels === false ? false : true; } } diff --git a/server/typeDefs/clients.ts b/server/typeDefs/clients.ts index b451a7e8e..3dd32bc55 100644 --- a/server/typeDefs/clients.ts +++ b/server/typeDefs/clients.ts @@ -77,6 +77,7 @@ const schema = gql` playbackRate: Float channel: [Int] looping: Boolean + preserveChannels: Boolean } input SoundInput { @@ -87,6 +88,7 @@ const schema = gql` playbackRate: Float channel: [Int] looping: Boolean + preserveChannels: Boolean } extend type Query { diff --git a/src/components/client/soundController.tsx b/src/components/client/soundController.tsx index 24f2efbe5..3f37938d0 100644 --- a/src/components/client/soundController.tsx +++ b/src/components/client/soundController.tsx @@ -13,6 +13,7 @@ const SOUND_SUB = gql` playbackRate channel looping + preserveChannels } } `; diff --git a/src/components/generic/SoundPlayer.tsx b/src/components/generic/SoundPlayer.tsx index ab7fcb15c..45c9be32e 100644 --- a/src/components/generic/SoundPlayer.tsx +++ b/src/components/generic/SoundPlayer.tsx @@ -94,6 +94,7 @@ interface Sound { channel?: number | number[]; source?: AudioBufferSourceNode; gain?: GainNode; + preserveChannels?: boolean; onFinishedPlaying?: () => void; } export function playSound(opts: Sound) { @@ -132,7 +133,7 @@ export function playSound(opts: Sound) { const sound = {...opts} || {}; //Create a new buffer and set it to the specified channel. sound.source = audioContext.createBufferSource(); - sound.source.buffer = downMixBuffer(buffer, channel); + sound.preserveChannels ? (sound.source.buffer = buffer) : (sound.source.buffer = downMixBuffer(buffer, channel)) sound.source.loop = opts.looping || false; sound.source.playbackRate.setValueAtTime(playbackRate, 0); sound.gain = audioContext.createGain(); diff --git a/src/components/macros/playSound.js b/src/components/macros/playSound.js index f7eacf1cf..588ff59ac 100644 --- a/src/components/macros/playSound.js +++ b/src/components/macros/playSound.js @@ -1,12 +1,17 @@ import React from "react"; -import {FormGroup, Label, Input, Button} from "helpers/reactstrap"; +import { FormGroup, Label, Input, Button, Popover, PopoverHeader, PopoverBody } from "helpers/reactstrap"; import SoundPicker from "helpers/soundPicker"; import playSoundHOC from "components/generic/SoundPlayer"; -function PlaySound({updateArgs, args, stations, clients, playSound}) { +function PlaySound({ updateArgs, args, stations, clients, playSound }) { + let [showChannelPopover, setShowChannelPopover] = React.useState(false); + let [showOverridesPopover, setShowOverridesPopover] = React.useState(false); + const toggleChannelPopover = () => setShowChannelPopover(!showChannelPopover); + const toggleOverridesPopover = () => setShowOverridesPopover(!showOverridesPopover); + const sound = args.sound || {}; const updateSound = (which, val) => { - updateArgs("sound", {...sound, [which]: val}); + updateArgs("sound", { ...sound, [which]: val }); }; React.useEffect(() => { if (!args.station) { @@ -66,9 +71,9 @@ function PlaySound({updateArgs, args, stations, clients, playSound}) { -