diff --git a/app/public/config/config.example.js b/app/public/config/config.example.js
index b591c16..9ee5e37 100644
--- a/app/public/config/config.example.js
+++ b/app/public/config/config.example.js
@@ -44,13 +44,14 @@ var config =
},
defaultAudio :
{
- sampleRate : 48000,
- channelCount : 1,
- volume : 1.0,
- autoGainControl : true,
- echoCancellation : true,
- noiseSuppression : true,
- sampleSize : 16
+ sampleRate : 48000,
+ channelCount : 1,
+ volume : 1.0,
+ autoGainControl : true,
+ echoCancellation : true,
+ noiseSuppression : true,
+ voiceActivityMute : false,
+ sampleSize : 16
},
background : 'images/background.jpg',
defaultLayout : 'democratic', // democratic, filmstrip
diff --git a/app/src/RoomClient.js b/app/src/RoomClient.js
index df276ae..9fece61 100644
--- a/app/src/RoomClient.js
+++ b/app/src/RoomClient.js
@@ -980,21 +980,11 @@ export default class RoomClient
if (!this._harkStream.getAudioTracks()[0])
throw new Error('getMicStream():something went wrong with hark');
- this._hark = hark(this._harkStream, { play: false });
+ this._hark = hark(this._harkStream, { play: false, interval: 5 });
// eslint-disable-next-line no-unused-vars
- this._hark.on('volume_change', (dBs, threshold) =>
+ this._hark.on('volume_change', (volume, threshold) =>
{
- // The exact formula to convert from dBs (-100..0) to linear (0..1) is:
- // Math.pow(10, dBs / 20)
- // However it does not produce a visually useful output, so let exagerate
- // it a bit. Also, let convert it from 0..1 to 0..10 and avoid value 1 to
- // minimize component renderings.
- let volume = Math.round(Math.pow(10, dBs / 85) * 10);
-
- if (volume === 1)
- volume = 0;
-
volume = Math.round(volume);
if (this._micProducer && volume !== this._micProducer.volume)
@@ -1004,13 +994,23 @@ export default class RoomClient
store.dispatch(peerVolumeActions.setPeerVolume(this._peerId, volume));
}
});
- this._hark.on('speaking', function()
+ this._hark.on('speaking', () =>
{
+ this._hark.setInterval(300);
store.dispatch(meActions.setIsSpeaking(true));
+ if (store.getState().settings.voiceActivatedUnmute && this._micProducer.paused)
+ {
+ this.unmuteMic();
+ }
});
- this._hark.on('stopped_speaking', function()
+ this._hark.on('stopped_speaking', () =>
{
store.dispatch(meActions.setIsSpeaking(false));
+ if (store.getState().settings.voiceActivatedUnmute && !this._micProducer.paused)
+ {
+ this.muteMic();
+ }
+ this._hark.setInterval(5);
});
}
@@ -1856,23 +1856,12 @@ export default class RoomClient
producerPaused
} = request.data;
- let codecOptions;
-
- if (kind === 'audio')
- {
- codecOptions =
- {
- opusStereo : 1
- };
- }
-
const consumer = await this._recvTransport.consume(
{
id,
producerId,
kind,
rtpParameters,
- codecOptions,
appData : { ...appData, peerId } // Trick.
});
@@ -3760,6 +3749,14 @@ export default class RoomClient
store.dispatch(meActions.setWebcamInProgress(false));
}
+ async _setNoiseThreshold(threshold)
+ {
+ logger.debug('_setNoiseThreshold:%s', threshold);
+ this._hark.setThreshold(threshold);
+ store.dispatch(
+ settingsActions.setNoiseThreshold(threshold));
+ }
+
async _updateAudioDevices()
{
logger.debug('_updateAudioDevices()');
diff --git a/app/src/actions/settingsActions.js b/app/src/actions/settingsActions.js
index 63c12bf..f168ac3 100644
--- a/app/src/actions/settingsActions.js
+++ b/app/src/actions/settingsActions.js
@@ -61,6 +61,18 @@ export const setNoiseSuppression = (noiseSuppression) =>
payload : { noiseSuppression }
});
+export const setVoiceActivatedUnmute = (voiceActivatedUnmute) =>
+ ({
+ type: 'SET_VOICE_ACTIVATED_UNMUTE',
+ payload: { voiceActivatedUnmute }
+ });
+
+export const setNoiseThreshold = (noiseThreshold) =>
+ ({
+ type: 'SET_NOISE_THRESHOLD',
+ payload: { noiseThreshold }
+ });
+
export const setDefaultAudio = (audio) =>
({
type : 'SET_DEFAULT_AUDIO',
diff --git a/app/src/components/Containers/Volume.js b/app/src/components/Containers/Volume.js
index 3c13a39..14d9d5d 100644
--- a/app/src/components/Containers/Volume.js
+++ b/app/src/components/Containers/Volume.js
@@ -149,9 +149,16 @@ const makeMapStateToProps = (initialState, props) =>
{
const mapStateToProps = (state) =>
{
+ if (state.peerVolumes[props.id]>state.settings.noiseThreshold)
+ {
return {
- volume : state.peerVolumes[props.id]
+ volume : Math.round((state.peerVolumes[props.id]+100) / 10)
};
+ }
+ else
+ {
+ return { volume: 0 };
+ }
};
return mapStateToProps;
diff --git a/app/src/components/Settings/MediaSettings.js b/app/src/components/Settings/MediaSettings.js
index d215181..334b93f 100644
--- a/app/src/components/Settings/MediaSettings.js
+++ b/app/src/components/Settings/MediaSettings.js
@@ -6,31 +6,66 @@ import { withRoomContext } from '../../RoomContext';
import * as settingsActions from '../../actions/settingsActions';
import PropTypes from 'prop-types';
import { useIntl, FormattedMessage } from 'react-intl';
+import classnames from 'classnames';
import MenuItem from '@material-ui/core/MenuItem';
import FormHelperText from '@material-ui/core/FormHelperText';
import FormControl from '@material-ui/core/FormControl';
import FormControlLabel from '@material-ui/core/FormControlLabel';
import Select from '@material-ui/core/Select';
import Checkbox from '@material-ui/core/Checkbox';
+import Slider from '@material-ui/core/Slider';
+import Typography from '@material-ui/core/Typography';
-const styles = (theme) =>
- ({
- setting :
+const NoiseSlider = withStyles(
+ {
+ root :
{
- padding : theme.spacing(2)
+ color : '#3880ff',
+ height : 2,
+ padding : '15px 0'
},
- formControl :
- {
- display : 'flex'
+ track : {
+ height : 2
+ },
+ rail : {
+ height : 2,
+ opacity : 0.2,
+ },
+ mark : {
+ backgroundColor : '#bfbfbf',
+ height : 10,
+ width : 3,
+ marginTop : -3
+ },
+ markActive : {
+ opacity : 1,
+ backgroundColor : 'currentColor'
}
- });
+ })(Slider);
+
+const styles = (theme) => ({
+ setting :
+ {
+ padding : theme.spacing(2)
+ },
+ margin :
+ {
+ height : theme.spacing(3),
+ },
+ formControl :
+ {
+ display : 'flex'
+ }
+});
const MediaSettings = ({
setEchoCancellation,
setAutoGainControl,
setNoiseSuppression,
+ setVoiceActivatedUnmute,
roomClient,
me,
+ volume,
settings,
classes
}) =>
@@ -135,6 +170,32 @@ const MediaSettings = ({
}
+