Update require, import and export syntax
This commit is contained in:
1 parent
08e3a56cdf
commit
6155ddfc2e
3 files changed
+33
-33
No files matched your search
@@ -1,15 +1,15 @@
|
||||
const PropTypes = require('prop-types');
|
||||
const React = require('react');
|
||||
const classNames = require('classnames');
|
||||
const Box = require('../box/box.jsx');
|
||||
const Waveform = require('../waveform/waveform.jsx');
|
||||
const BufferedInput = require('../buffered-input/buffered-input.jsx');
|
||||
import PropTypes from 'prop-types';
|
||||
import React from 'react';
|
||||
import classNames from 'classnames';
|
||||
import Box from '../box/box.jsx';
|
||||
import Waveform from '../waveform/waveform.jsx';
|
||||
import BufferedInput from '../buffered-input/buffered-input.jsx';
|
||||
|
||||
const styles = require('./sound-editor.css');
|
||||
const formStyles = require('../../css/forms.css');
|
||||
import styles from './sound-editor.css';
|
||||
import formStyles from '../../css/forms.css';
|
||||
|
||||
const playIcon = require('../record-modal/icon--play.svg');
|
||||
const stopIcon = require('../record-modal/icon--stop-playback.svg');
|
||||
import playIcon from '../record-modal/icon--play.svg';
|
||||
import stopIcon from '../record-modal/icon--stop-playback.svg';
|
||||
|
||||
const SoundEditor = props => (
|
||||
<Box className={styles.editorContainer}>
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
const bindAll = require('lodash.bindall');
|
||||
const PropTypes = require('prop-types');
|
||||
const React = require('react');
|
||||
import bindAll from 'lodash.bindall';
|
||||
import PropTypes from 'prop-types';
|
||||
import React from 'react';
|
||||
|
||||
const {connect} = require('react-redux');
|
||||
import {connect} from 'react-redux';
|
||||
|
||||
const {computeRMS} = require('../lib/audio/audio-util.js');
|
||||
import {computeRMS} from '../lib/audio/audio-util.js';
|
||||
|
||||
const SoundEditorComponent = require('../components/sound-editor/sound-editor.jsx');
|
||||
const AudioBufferPlayer = require('../lib/audio/audio-buffer-player.js');
|
||||
import SoundEditorComponent from '../components/sound-editor/sound-editor.jsx';
|
||||
import AudioBufferPlayer from '../lib/audio/audio-buffer-player.js';
|
||||
|
||||
const getChunkLevels = (samples, chunkSize = 1024) => {
|
||||
const sampleCount = samples.length;
|
||||
|
||||
+16
-16
@@ -1,18 +1,18 @@
|
||||
class AudioUtil {
|
||||
static computeRMS (samples) {
|
||||
// Calculate RMS, adapted from https://github.com/Tonejs/Tone.js/blob/master/Tone/component/Meter.js#L88
|
||||
let sum = 0;
|
||||
for (let i = 0; i < samples.length; i++) {
|
||||
const sample = samples[i];
|
||||
sum += Math.pow(sample, 2);
|
||||
}
|
||||
const rms = Math.sqrt(sum / samples.length);
|
||||
// Scale it
|
||||
const unity = 0.55;
|
||||
const val = rms / unity;
|
||||
// Scale the output curve
|
||||
return Math.sqrt(val);
|
||||
const computeRMS = function (samples) {
|
||||
// Calculate RMS, adapted from https://github.com/Tonejs/Tone.js/blob/master/Tone/component/Meter.js#L88
|
||||
let sum = 0;
|
||||
for (let i = 0; i < samples.length; i++) {
|
||||
const sample = samples[i];
|
||||
sum += Math.pow(sample, 2);
|
||||
}
|
||||
}
|
||||
const rms = Math.sqrt(sum / samples.length);
|
||||
// Scale it
|
||||
const unity = 0.55;
|
||||
const val = rms / unity;
|
||||
// Scale the output curve
|
||||
return Math.sqrt(val);
|
||||
};
|
||||
|
||||
module.exports = AudioUtil;
|
||||
export {
|
||||
computeRMS
|
||||
};
|
||||
Reference in new issue
Block a user