Skip to content

Commit

Permalink
feat: Gain reduction meter & preparing Behringer XR protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
olzzon authored and olzzon committed Apr 18, 2020
1 parent 20d813f commit 17510ab
Show file tree
Hide file tree
Showing 24 changed files with 338 additions and 12 deletions.
36 changes: 36 additions & 0 deletions client/assets/css/ReductionMeter.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
.reductionmeter-body {
position: relative;
top: 15px;
width: 24px;
margin-top: 15px;
margin-left: 5px;
background-color: black;
border-radius: 7px;
}

.reductionmeter-canvas {
position: absolute;
width: 10px;
margin-left: -5px;
bottom: 0;
height: 100%;
}

.reductionmeter-lower-part {
position: absolute;
width: 10px;
margin-left: 10px;
background-color: rgb(0, 122, 37);
}
.reductionmeter-middle-part {
position: absolute;
width: 10px;
margin-left: 10px;
background-color: rgb(53, 167, 0);
}
.reductionmeter-upper-part {
position: absolute;
width: 10px;
margin-left: 10px;
background-color: rgb(206, 0, 0);
}
10 changes: 10 additions & 0 deletions client/components/ChanStrip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
SOCKET_SET_AUX_LEVEL
} from '../../server/constants/SOCKET_IO_DISPATCHERS';
import CcgChannelInputSettings from './CcgChannelSettings';
import ReductionMeter from './ReductionMeter';

interface IChanStripInjectProps {
label: string,
Expand Down Expand Up @@ -195,6 +196,14 @@ class ChanStrip extends React.PureComponent<IChanStripProps & IChanStripInjectPr
)
}

gainReduction() {
return (
<div className="parameter-text">
Gain Red.
<ReductionMeter faderIndex = {this.props.faderIndex}/>
</div>
)
}
delay() {
return (
<React.Fragment>
Expand Down Expand Up @@ -383,6 +392,7 @@ class ChanStrip extends React.PureComponent<IChanStripProps & IChanStripInjectPr
<p className="zero-comp">______</p>
{this.ratio()}
<p className="zero-comp">______</p>
{this.gainReduction()}
<p className="horizontal-space"></p>
{this.delay()}

Expand Down
170 changes: 170 additions & 0 deletions client/components/ReductionMeter.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
import * as React from 'react'
import { connect } from "react-redux"

//assets:
import '../assets/css/ReductionMeter.css'
//Utils:

export interface IReductionMeterInjectedProps {
reductionVal: number
}

interface IVuMeterProps {
faderIndex: number
}

export class ReductionMeter extends React.Component<IReductionMeterInjectedProps> {
canvas: HTMLCanvasElement | undefined

totalPeak: number = 0
windowPeak: number = 0
windowLast: number = 0
WINDOW: number = 2000

constructor(props: any) {
super(props)
}

public shouldComponentUpdate(nextProps: IReductionMeterInjectedProps) {
return (
nextProps.reductionVal != this.props.reductionVal
)
}

totalHeight = () => {
return 170 / (window.mixerProtocol.meter.max - window.mixerProtocol.meter.min)
}

getTotalPeak = () => {
if (this.props.reductionVal > this.totalPeak) {
this.totalPeak = this.props.reductionVal
}
return this.totalHeight()*this.totalPeak
}

getWindowPeak = () => {
if (this.props.reductionVal > this.windowPeak || (Date.now() - this.windowLast) > this.WINDOW) {
this.windowPeak = this.props.reductionVal
this.windowLast = Date.now()
}
return this.totalHeight()*this.windowPeak
}

calcLower = () => {
let val = this.props.reductionVal
if (val >= window.mixerProtocol.meter.test) {
val = window.mixerProtocol.meter.test
}
return val
}

calcMiddle = () => {
let val = this.props.reductionVal
if (val < window.mixerProtocol.meter.test) {
val = window.mixerProtocol.meter.test
} else if (val >= window.mixerProtocol.meter.zero) {
val = window.mixerProtocol.meter.zero
}
return val+1
}

calcUpper = () => {
let val = this.props.reductionVal
if (val < window.mixerProtocol.meter.zero) {
val = window.mixerProtocol.meter.zero
}
return val+1
}

setRef = (element: HTMLCanvasElement) => {
this.canvas = element

this.paintVuMeter()
}

resetTotalPeak = () => {
this.totalPeak = 0
}

paintVuMeter = () => {
if (!this.canvas) return

const context = this.canvas.getContext("2d", {
antialias: false,
stencil: false,
preserveDrawingBuffer: true
}) as CanvasRenderingContext2D

if (!context) return

context.clearRect(0, 0, this.canvas.clientWidth, this.canvas.clientHeight)

// lower part
context.fillStyle = 'rgb(0, 122, 37)'
context.fillRect(0, 0, this.canvas.clientWidth, this.calcLower()) //(this.totalHeight() - this.calcLower()), this.canvas.clientWidth, this.calcLower())

// middle part
let middle = this.calcMiddle()
let middleRef = this.totalHeight() * window.mixerProtocol.meter.test
context.fillStyle = 'rgb(53, 167, 0)'
context.fillRect(0, middleRef, this.canvas.clientWidth, middle)// (this.totalHeight() * (range - window.mixerProtocol.meter.test) - this.calcMiddle()), this.canvas.clientWidth, this.calcMiddle())

// upper part (too high/clip)
let upper = this.calcUpper()
let upperRef = this.totalHeight() * window.mixerProtocol.meter.zero
context.fillStyle = 'rgb(206, 0, 0)'
context.fillRect(0, upperRef, this.canvas.clientWidth, upper)

// windowed peak
const windowPeak = this.getWindowPeak()
if (this.windowPeak < window.mixerProtocol.meter.zero) {
context.fillStyle = 'rgb(16, 56, 0)'
} else {
context.fillStyle = 'rgb(100, 100, 100)'
}
context.fillRect(0, (this.totalHeight() - windowPeak), this.canvas.clientWidth, 2)

// absolute peak
if (this.totalPeak < window.mixerProtocol.meter.zero) {
context.fillStyle = 'rgb(64, 64, 64)'
} else {
context.fillStyle = 'rgb(255, 0, 0)'
}
context.fillRect(0, (this.totalHeight() - this.getTotalPeak()), this.canvas.clientWidth, 2)
}

render() {
this.paintVuMeter()

return (
<div className="reductionmeter-body"
style={{
"height" : this.totalHeight() + 30
}}
onClick={this.resetTotalPeak}
>
<canvas
className="reductionmeter-canvas"
style={
{
"height": this.totalHeight(),
"top": "10px"
}
}
height={this.totalHeight()}
width={10}
ref={this.setRef}
></canvas>

</div>
)
}
}

const mapStateToProps = (state: any, props: any): IReductionMeterInjectedProps => {
return {
reductionVal: state.faders[0].vuMeters[props.faderIndex].reductionVal
}
}

export default connect<IReductionMeterInjectedProps, any, any>(mapStateToProps)(ReductionMeter)
13 changes: 11 additions & 2 deletions client/utils/SocketClientHandlers.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { SET_COMPLETE_FADER_STATE, SET_VU_LEVEL, SET_SINGLE_FADER_STATE } from "../../server/reducers/faderActions";
import { SET_COMPLETE_FADER_STATE, SET_VU_LEVEL, SET_SINGLE_FADER_STATE, SET_VU_REDUCTION_LEVEL } from "../../server/reducers/faderActions";
import { SET_COMPLETE_CH_STATE, SET_SINGLE_CH_STATE } from "../../server/reducers/channelActions";
import { UPDATE_SETTINGS, SET_MIXER_ONLINE, SET_SERVER_ONLINE } from "../../server/reducers/settingsActions";
import { SOCKET_SET_VU, SOCKET_RETURN_SNAPSHOT_LIST, SOCKET_SET_FULL_STORE, SOCKET_SET_STORE_FADER, SOCKET_SET_STORE_CHANNEL, SOCKET_RETURN_CCG_LIST } from "../../server/constants/SOCKET_IO_DISPATCHERS";
import { SOCKET_SET_VU, SOCKET_RETURN_SNAPSHOT_LIST, SOCKET_SET_FULL_STORE, SOCKET_SET_STORE_FADER, SOCKET_SET_STORE_CHANNEL, SOCKET_RETURN_CCG_LIST, SOCKET_SET_VU_REDUCTION } from "../../server/constants/SOCKET_IO_DISPATCHERS";

export const socketClientHandlers = () => {
window.socketIoClient
Expand Down Expand Up @@ -98,6 +98,15 @@ export const socketClientHandlers = () => {
});
})
)
.on(SOCKET_SET_VU_REDUCTION, (
(payload: any) => {
window.storeRedux.dispatch({
type:SET_VU_REDUCTION_LEVEL,
channel: payload.faderIndex,
level: payload.level
});
})
)
.on(SOCKET_RETURN_SNAPSHOT_LIST, (
(payload: any) => {
window.snapshotFileList = payload
Expand Down
1 change: 1 addition & 0 deletions server/constants/MixerProtocolInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export interface IChannelTypes {
fromMixer: {
CHANNEL_OUT_GAIN: Array<IMixerMessageProtocol>,
CHANNEL_VU: Array<IMixerMessageProtocol>,
CHANNEL_VU_REDUCTION: Array<IMixerMessageProtocol>,
CHANNEL_NAME: Array<IMixerMessageProtocol>
PFL: Array<IMixerMessageProtocol>
NEXT_SEND: Array<IMixerMessageProtocol>
Expand Down
1 change: 1 addition & 0 deletions server/constants/SOCKET_IO_DISPATCHERS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const SOCKET_CLEAR_PST = 'clearPst'
export const SOCKET_SAVE_SETTINGS = 'saveSettings'
export const SOCKET_RESTART_SERVER = 'restartServer'
export const SOCKET_SET_VU = 'setVu'
export const SOCKET_SET_VU_REDUCTION = 'setVuReduction'
export const SOCKET_GET_SNAPSHOT_LIST = 'getSnapshotList'
export const SOCKET_RETURN_SNAPSHOT_LIST = 'returnSnapshotList'
export const SOCKET_GET_CCG_LIST = 'getCcgList'
Expand Down
1 change: 1 addition & 0 deletions server/constants/mixerProtocols/DmxIs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const DMXIS: IMixerProtocol = {
fromMixer: {
CHANNEL_OUT_GAIN: [{ mixerMessage: '/dmxis/ch/{channel}', value: 0, type: 'f', min: 0, max: 1, zero: 0.75}],
CHANNEL_VU: [emptyMixerMessage()],
CHANNEL_VU_REDUCTION: [emptyMixerMessage()],
CHANNEL_NAME: [emptyMixerMessage()],
PFL: [emptyMixerMessage()],
NEXT_SEND: [emptyMixerMessage()],
Expand Down
1 change: 1 addition & 0 deletions server/constants/mixerProtocols/LawoMC2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const LawoMC2: IMixerProtocol = {
zero: 0
}],
CHANNEL_VU: [emptyMixerMessage()],
CHANNEL_VU_REDUCTION: [emptyMixerMessage()],
CHANNEL_NAME: [{
mixerMessage: '',
value: 0,
Expand Down
1 change: 1 addition & 0 deletions server/constants/mixerProtocols/LawoRelayVrx4.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const LawoRelayVrx4: IMixerProtocol = {
zero: 75
}],
CHANNEL_VU: [emptyMixerMessage()],
CHANNEL_VU_REDUCTION: [emptyMixerMessage()],
CHANNEL_NAME: [{
mixerMessage: '',
value: 0,
Expand Down
1 change: 1 addition & 0 deletions server/constants/mixerProtocols/LawoRuby.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const LawoRuby: IMixerProtocol = {
zero: 0
}],
CHANNEL_VU: [emptyMixerMessage()],
CHANNEL_VU_REDUCTION: [emptyMixerMessage()],
CHANNEL_NAME: [{
mixerMessage: '',
value: 0,
Expand Down
1 change: 1 addition & 0 deletions server/constants/mixerProtocols/SSLsystemT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const SSLSystemT: IMixerProtocol = {
fromMixer: {
CHANNEL_OUT_GAIN: [emptyMixerMessage()], // Handled by SSLMixerconnection
CHANNEL_VU: [emptyMixerMessage()], // Not implemented in SSL Automation protocol yet
CHANNEL_VU_REDUCTION: [emptyMixerMessage()],
CHANNEL_NAME: [emptyMixerMessage()],
PFL: [emptyMixerMessage()],
NEXT_SEND: [emptyMixerMessage()],
Expand Down
1 change: 1 addition & 0 deletions server/constants/mixerProtocols/StuderOnAirEmber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const StuderOnAirMaster: IMixerProtocol = {
zero: 0
}],
CHANNEL_VU: [emptyMixerMessage()],
CHANNEL_VU_REDUCTION: [emptyMixerMessage()],
CHANNEL_NAME: [{
mixerMessage: 'System/Mixer/Channels/Inp Mono/Inp Mono #{channel}/Functions/Channel Attribute/User Label',
value: 0,
Expand Down
3 changes: 3 additions & 0 deletions server/constants/mixerProtocols/StuderVistaEmber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const StuderVistaMaster: IMixerProtocol = {
fromMixer: {
CHANNEL_OUT_GAIN: [emptyMixerMessage()],
CHANNEL_VU: [emptyMixerMessage()],
CHANNEL_VU_REDUCTION: [emptyMixerMessage()],
CHANNEL_NAME: [emptyMixerMessage()],
PFL: [emptyMixerMessage()],
NEXT_SEND: [emptyMixerMessage()],
Expand Down Expand Up @@ -76,6 +77,7 @@ export const StuderVistaMaster: IMixerProtocol = {
zero: 750
}],
CHANNEL_VU: [emptyMixerMessage()],
CHANNEL_VU_REDUCTION: [emptyMixerMessage()],
CHANNEL_NAME: [{
mixerMessage: 'System/Mixer/Channels/Inp Stereo/Inp Stereo #{channel}/Functions/Channel Attribute/User Label',
value: 0,
Expand Down Expand Up @@ -143,6 +145,7 @@ export const StuderVistaMaster: IMixerProtocol = {
zero: 750
}],
CHANNEL_VU: [emptyMixerMessage()],
CHANNEL_VU_REDUCTION: [emptyMixerMessage()],
CHANNEL_NAME: [{
mixerMessage: 'System/Mixer/Channels/Inp 5_1/Inp 5_1 #{channel}/Functions/Channel Attribute/User Label',
value: 0,
Expand Down
1 change: 1 addition & 0 deletions server/constants/mixerProtocols/ardourMaster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export const ArdourMaster: IMixerProtocol = {
fromMixer: {
CHANNEL_OUT_GAIN: [{ mixerMessage: '/strip/fader/{channel}', value: 0, type: 'f', min: 0, max: 1, zero: 0.75}],
CHANNEL_VU: [{ mixerMessage: '/strip/meter/{channel}', value: 0, type: 'f', min: 0, max: 1, zero: 0.75}],
CHANNEL_VU_REDUCTION: [emptyMixerMessage()],
CHANNEL_NAME: [{ mixerMessage: '/strip/name/{channel}', value: 0, type: 'f', min: 0, max: 1, zero: 0.75}],
PFL: [emptyMixerMessage()],
NEXT_SEND: [emptyMixerMessage()],
Expand Down
1 change: 1 addition & 0 deletions server/constants/mixerProtocols/behringerXrMaster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export const BehringerXrMaster: IMixerProtocol = {
fromMixer: {
CHANNEL_OUT_GAIN: [{ mixerMessage: '/ch/{channel}/mix/fader', value: 0, type: 'f', min: 0, max: 1, zero: 0.75}],
CHANNEL_VU: [{ mixerMessage: '/meters/1', value: 0, type: 'f', min: 0, max: 1, zero: 0.75}],
CHANNEL_VU_REDUCTION: [{ mixerMessage: '/meters/1', value: 0, type: 'f', min: 0, max: 1, zero: 0.75}],
CHANNEL_NAME: [{ mixerMessage: '/ch/{channel}/config/name', value: 0, type: 'f', min: 0, max: 1, zero: 0.75}],
PFL: [emptyMixerMessage()],
NEXT_SEND: [emptyMixerMessage()],
Expand Down
3 changes: 2 additions & 1 deletion server/constants/mixerProtocols/casparCGMaster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ let CasparCGMasterObject: ICasparCGMixerGeometry = {
channelTypeColor: '#2f2f2f',
fromMixer: {
CHANNEL_OUT_GAIN: [{ mixerMessage: 'none', value: 0, type: 'f', min: 0, max: 1.5, zero: 1}],
CHANNEL_VU: [emptyMixerMessage()],
CHANNEL_VU: [emptyMixerMessage()],
CHANNEL_VU_REDUCTION: [emptyMixerMessage()],
CHANNEL_NAME: [emptyMixerMessage()],
PFL: [emptyMixerMessage()],
NEXT_SEND: [emptyMixerMessage()],
Expand Down
1 change: 1 addition & 0 deletions server/constants/mixerProtocols/genericMidi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const GenericMidi: IMixerProtocol = {
fromMixer: {
CHANNEL_OUT_GAIN: [{ mixerMessage: "0", value: 0, type: 'f', min: 0, max: 1, zero: 0.75}], //PgmChange 0 - ignores this command
CHANNEL_VU: [{ mixerMessage: "0", value: 0, type: 'f', min: 0, max: 1, zero: 0.75}], //PgmChange 0 - ignores this command
CHANNEL_VU_REDUCTION: [emptyMixerMessage()],
CHANNEL_NAME: [emptyMixerMessage()],
PFL: [emptyMixerMessage()],
NEXT_SEND: [emptyMixerMessage()],
Expand Down
1 change: 1 addition & 0 deletions server/constants/mixerProtocols/midasMaster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export const MidasMaster: IMixerProtocol = {
fromMixer: {
CHANNEL_OUT_GAIN: [{ mixerMessage: '/ch/{channel}/mix/fader', value: 0, type: 'f', min: 0, max: 1, zero: 0.75}],
CHANNEL_VU: [{ mixerMessage: '/meters/1', value: 0, type: 'f', min: 0, max: 1, zero: 0.75}],
CHANNEL_VU_REDUCTION: [emptyMixerMessage()],
CHANNEL_NAME: [emptyMixerMessage()], //[{ mixerMessage: '/ch/{channel}/config/name', value: 0, type: 'f', min: 0, max: 1, zero: 0.75}],
PFL: [emptyMixerMessage()],
NEXT_SEND: [emptyMixerMessage()],
Expand Down
Loading

0 comments on commit 17510ab

Please sign in to comment.