File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -265,6 +265,7 @@ const SoundEditor = props => (
265
265
onClick = { props . onSlower }
266
266
/>
267
267
< IconButton
268
+ disabled = { props . tooLoud }
268
269
className = { classNames ( styles . effectButton , styles . flipInRtl ) }
269
270
img = { louderIcon }
270
271
title = { < FormattedMessage { ...messages . louder } /> }
@@ -340,6 +341,7 @@ SoundEditor.propTypes = {
340
341
onUndo : PropTypes . func . isRequired ,
341
342
playhead : PropTypes . number ,
342
343
setRef : PropTypes . func ,
344
+ tooLoud : PropTypes . bool . isRequired ,
343
345
trimEnd : PropTypes . number ,
344
346
trimStart : PropTypes . number
345
347
} ;
Original file line number Diff line number Diff line change @@ -14,6 +14,8 @@ import log from '../lib/log.js';
14
14
15
15
const UNDO_STACK_SIZE = 99 ;
16
16
17
+ const MAX_RMS = 1.2 ;
18
+
17
19
class SoundEditor extends React . Component {
18
20
constructor ( props ) {
19
21
super ( props ) ;
@@ -265,6 +267,15 @@ class SoundEditor extends React.Component {
265
267
}
266
268
} ) ;
267
269
}
270
+ tooLoud ( ) {
271
+ const numChunks = this . state . chunkLevels . length ;
272
+ const startIndex = this . state . trimStart === null ?
273
+ 0 : Math . floor ( this . state . trimStart * numChunks ) ;
274
+ const endIndex = this . state . trimEnd === null ?
275
+ numChunks - 1 : Math . ceil ( this . state . trimEnd * numChunks ) ;
276
+ const trimChunks = this . state . chunkLevels . slice ( startIndex , endIndex ) ;
277
+ return Math . max ( ...trimChunks ) > MAX_RMS ;
278
+ }
268
279
getUndoItem ( ) {
269
280
return {
270
281
...this . copyCurrentBuffer ( ) ,
@@ -399,6 +410,7 @@ class SoundEditor extends React.Component {
399
410
name = { this . props . name }
400
411
playhead = { this . state . playhead }
401
412
setRef = { this . setRef }
413
+ tooLoud = { this . tooLoud ( ) }
402
414
trimEnd = { this . state . trimEnd }
403
415
trimStart = { this . state . trimStart }
404
416
onChangeName = { this . handleChangeName }
You can’t perform that action at this time.
0 commit comments