Be smart with readonly

This commit is contained in:
Travis Ralston 2021-07-12 14:11:24 -06:00
parent 79aa205a95
commit e045aa940e
2 changed files with 7 additions and 10 deletions

View file

@ -95,7 +95,7 @@ export default class VoiceRecordComposerTile extends React.PureComponent<IProps,
duration: Math.round(this.state.recorder.durationSeconds * 1000),
// https://github.com/matrix-org/matrix-doc/pull/3246
waveform: this.state.recorder.getPlayback().waveformThumbnail.map(v => Math.round(v * 1024)),
waveform: this.state.recorder.getPlayback().thumbnailWaveform.map(v => Math.round(v * 1024)),
},
"org.matrix.msc3245.voice": {}, // No content, this is a rendering hint
});

View file

@ -52,12 +52,17 @@ function makePlaybackWaveform(input: number[]): number[] {
}
export class Playback extends EventEmitter implements IDestroyable {
/**
* Stable waveform for representing a thumbnail of the media. Values are
* guaranteed to be between zero and one, inclusive.
*/
public readonly thumbnailWaveform: number[];
private readonly context: AudioContext;
private source: AudioBufferSourceNode;
private state = PlaybackState.Decoding;
private audioBuf: AudioBuffer;
private resampledWaveform: number[];
private thumbnailWaveform: number[];
private waveformObservable = new SimpleObservable<number[]>();
private readonly clock: PlaybackClock;
private readonly fileSize: number;
@ -95,14 +100,6 @@ export class Playback extends EventEmitter implements IDestroyable {
return this.resampledWaveform;
}
/**
* Stable waveform for representing a thumbnail of the media. Values are
* guaranteed to be between zero and one, inclusive.
*/
public get waveformThumbnail(): number[] {
return this.thumbnailWaveform;
}
public get waveformData(): SimpleObservable<number[]> {
return this.waveformObservable;
}