Waveform recording complete

pull/1102/head
Vincent 6 years ago
parent 92fa697f90
commit 8d8abf1e43

@ -262,10 +262,11 @@ $composition-container-height: 60px;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
/*max-width: 850px;*/
canvas { canvas {
width: auto; width: 100%;
padding: 0px $session-margin-lg;
max-width: 700px;
} }
} }

@ -196,7 +196,7 @@ export class SessionRecording extends React.Component<Props, State> {
const audioContext = new window.AudioContext(); const audioContext = new window.AudioContext();
const input = audioContext.createMediaStreamSource(stream); const input = audioContext.createMediaStreamSource(stream);
const bufferSize = 8192; const bufferSize = 1024;
const analyser = audioContext.createAnalyser(); const analyser = audioContext.createAnalyser();
analyser.smoothingTimeConstant = 0.3; analyser.smoothingTimeConstant = 0.3;
analyser.fftSize = 512; analyser.fftSize = 512;
@ -224,7 +224,7 @@ export class SessionRecording extends React.Component<Props, State> {
const barPadding = 3; const barPadding = 3;
const barWidth = 4; const barWidth = 4;
const numBars = Math.floor(CANVAS_WIDTH / (barPadding + barWidth)); const numBars = CANVAS_WIDTH / (barPadding + barWidth);
let volumeArray = freqArray.map(n => { let volumeArray = freqArray.map(n => {
const maxVal = Math.max(...freqArray); const maxVal = Math.max(...freqArray);
@ -238,22 +238,20 @@ export class SessionRecording extends React.Component<Props, State> {
// Create initial fake bars to improve appearance. // Create initial fake bars to improve appearance.
// Gradually increasing wave rather than a wall at the beginning // Gradually increasing wave rather than a wall at the beginning
// const frontLoadLen = Math.ceil(volumeArray.length / 10); const frontLoadLen = Math.ceil(volumeArray.length / 10);
// const frontLoad = volumeArray.slice(0, frontLoadLen - 1).reverse().map(n => n * 0.80); const frontLoad = volumeArray.slice(0, frontLoadLen - 1).reverse().map(n => n * 0.80);
// volumeArray = [...frontLoad, ...volumeArray]; volumeArray = [...frontLoad, ...volumeArray];
// Chop off values which exceed the bouinds of the container // Chop off values which exceed the bouinds of the container
//volumeArray = volumeArray.slice(0, numBars); volumeArray = volumeArray.slice(0, numBars);
console.log(`[vince][mic] Width: `, VISUALISATION_WIDTH); console.log(`[vince][mic] Width: `, VISUALISATION_WIDTH);
console.log(`[vince][mic] Nmbars:`, numBars);
console.log(`[vince][mic] volumeArray`, volumeArray);
canvas && (canvas.height = CANVAS_HEIGHT); canvas && (canvas.height = CANVAS_HEIGHT);
//canvas && (canvas.width = CANVAS_WIDTH); canvas && (canvas.width = CANVAS_WIDTH);
const canvasContext = canvas && (canvas.getContext(`2d`)); const canvasContext = canvas && (canvas.getContext(`2d`));
for (let i = 0; i < volumeArray.length; i++) { for (var i = 0; i < freqArray.length; i++) {
const barHeight = Math.ceil(volumeArray[i]); const barHeight = Math.ceil(volumeArray[i]);
const offset_x = Math.ceil(i * (barWidth + barPadding)); const offset_x = Math.ceil(i * (barWidth + barPadding));
const offset_y = Math.ceil((CANVAS_HEIGHT / 2 ) - (barHeight / 2 )); const offset_y = Math.ceil((CANVAS_HEIGHT / 2 ) - (barHeight / 2 ));

Loading…
Cancel
Save