Mercurial > hg > ugly-duckling
view src/app/visualisations/grid/grid.component.ts @ 471:b69a223166b5
Add vertical scale to matrix, but just using matrix bin count to begin
with
author | Chris Cannam <cannam@all-day-breakfast.com> |
---|---|
date | Thu, 29 Jun 2017 15:06:16 +0100 |
parents | 3ace7672638b |
children | 9251232b689e |
line wrap: on
line source
/** * Created by lucast on 31/05/2017. */ import { InspectableVerticallyBoundedComponent, VerticallyBounded, VerticallyBoundedWavesComponent, VerticalScaleRenderer, VerticalValueInspectorRenderer, WavesComponent } from '../waves-base.component'; import { ChangeDetectionStrategy, Component, Input, } from '@angular/core'; import Waves from 'waves-ui-piper'; import {MatrixFeature} from 'piper/HigherLevelUtilities'; import {iceMapper} from '../../spectrogram/ColourMap'; import {estimatePercentile} from '../../spectrogram/MatrixUtils'; @Component({ selector: 'ugly-grid', templateUrl: '../waves-template.html', styleUrls: ['../waves-template.css'], changeDetection: ChangeDetectionStrategy.OnPush, providers: [ {provide: VerticallyBounded, useExisting: GridComponent }, {provide: VerticalScaleRenderer, useExisting: GridComponent }, {provide: VerticalValueInspectorRenderer, useExisting: GridComponent }, {provide: WavesComponent, useExisting: GridComponent} ] }) export class GridComponent extends VerticallyBoundedWavesComponent<MatrixFeature> { @Input() set grid(grid: MatrixFeature) { this.feature = grid; } protected get featureLayers(): Layer[] { const startTime = this.feature.startTime; const stepDuration = this.feature.stepDuration; const matrixData = this.feature.data; if (matrixData.length === 0) { return []; } const targetValue = estimatePercentile(matrixData, 95); const gain = (targetValue > 0.0 ? (1.0 / targetValue) : 1.0); const matrixEntity = new Waves.utils.PrefilledMatrixEntity( matrixData, startTime, stepDuration ); return [ new Waves.helpers.MatrixLayer( matrixEntity, { gain: gain, height: this.height, normalise: 'none', mapper: iceMapper() } ) ]; } get range(): [number, number] { return [0, this.feature.data.length > 0 ? this.feature.data[0].length : 0]; } }