Mercurial > hg > ugly-duckling
view src/app/visualisations/grid/grid.component.ts @ 472:9251232b689e
Bring through (but don't yet use) bin names from output descriptor
author | Chris Cannam <cannam@all-day-breakfast.com> |
---|---|
date | Fri, 30 Jun 2017 09:07:12 +0100 |
parents | b69a223166b5 |
children | de23ea6bcd0d |
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 {AugmentedMatrixFeature} from '../FeatureUtilities'; 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: WavesComponent, useExisting: GridComponent} ] }) export class GridComponent extends VerticallyBoundedWavesComponent<AugmentedMatrixFeature> { @Input() set grid(grid: AugmentedMatrixFeature) { 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] { const bins = this.feature.binNames; console.log("have " + bins.length + " bins"); return [0, this.feature.data.length > 0 ? this.feature.data[0].length : 0]; } }