| 25 | unitsEachPeak(): int {return 1 << this.shift} |
| 26 | |
| 27 | append(frames: ReadonlyArray<Float32Array>): void { |
| 28 | for (let channel = 0; channel < this.numChannels; ++channel) { |
| 29 | const channelFrames = frames[channel] |
| 30 | assert(channelFrames.length === RenderQuantum, "Invalid number of frames.") |
| 31 | let min = Number.POSITIVE_INFINITY |
| 32 | let max = Number.NEGATIVE_INFINITY |
| 33 | for (let i = 0; i < RenderQuantum; ++i) { |
| 34 | const frame = channelFrames[i] |
| 35 | min = Math.min(frame, min) |
| 36 | max = Math.max(frame, max) |
| 37 | } |
| 38 | const channelData = this.data[channel] |
| 39 | channelData[this.dataIndex[channel]++] = SamplePeakWorker.pack(min, max) |
| 40 | if (this.dataIndex[channel] === channelData.length) { |
| 41 | const newArray = new Int32Array(channelData.length << 1) |
| 42 | newArray.set(channelData, 0) |
| 43 | this.data[channel] = newArray |
| 44 | } |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | nearest(_unitsPerPixel: number): Nullable<Peaks.Stage> {return this.stages.at(0) ?? null} |
| 49 | } |