Files
@ af83aeef8b0a
Branch filter:
Location: light9/web/ascoltami/Light9AscoltamiTimeline.ts - annotation
af83aeef8b0a
3.5 KiB
video/MP2T
fancier spectrograms
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe 06da5db2fafe | import { css, html, LitElement, PropertyValueMap } from "lit";
import { customElement, property, state } from "lit/decorators.js";
import Sylvester from "sylvester";
import { Zoom } from "../light9-timeline-audio";
import { PlainViewState } from "../Light9CursorCanvas";
import { getTopGraph } from "../RdfdbSyncedGraph";
import { show } from "../show_specific";
import { SyncedGraph } from "../SyncedGraph";
import { PlayerState } from "./PlayerState";
export { Light9TimelineAudio } from "../light9-timeline-audio";
export { Light9CursorCanvas } from "../Light9CursorCanvas";
export { RdfdbSyncedGraph } from "../RdfdbSyncedGraph";
export { ResourceDisplay } from "../ResourceDisplay";
const $V = Sylvester.Vector.create;
async function postJson(url: string, jsBody: Object) {
return fetch(url, {
method: "POST",
headers: { "Content-Type": "applcation/json" },
body: JSON.stringify(jsBody),
});
}
@customElement("light9-ascoltami-timeline")
export class Light9AscoltamiTimeline extends LitElement {
static styles = [
css`
.timeRow {
margin: 14px;
position: relative;
}
#overview {
height: 60px;
}
#zoomed {
margin-top: 40px;
height: 80px;
}
#cursor {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
}
`,
];
graph!: SyncedGraph;
@property() playerState: PlayerState = {
duration: null,
endOfSong: null,
pausedSongTime: null,
playing: null,
song: null,
wallStartTime: null,
};
@property() playerTime: number = 0;
@state() zoom: Zoom;
@state() overviewZoom: Zoom;
@state() viewState: PlainViewState | null = null;
constructor() {
super();
getTopGraph().then((g) => {
this.graph = g;
});
this.zoom = this.overviewZoom = { duration: null, t1: 0, t2: 1 };
}
protected willUpdate(_changedProperties: PropertyValueMap<this>): void {
super.willUpdate(_changedProperties);
if ((_changedProperties.has("playerState") || _changedProperties.has("playerTime")) && this.playerState !== null) {
const duration = this.playerState.duration;
const t = this.playerTime;
if (duration !== null) {
const timeRow = this.shadowRoot!.querySelector(".timeRow") as HTMLDivElement;
if (timeRow != null) {
this.updateZooms(duration, t, timeRow);
}
}
}
}
updateZooms(duration: number, t: number, timeRow: HTMLDivElement) {
this.overviewZoom = { duration: duration, t1: 0, t2: duration };
const t1 = t - 2;
const t2 = t + 20;
this.zoom = { duration: duration, t1, t2 };
const w = timeRow.offsetWidth;
this.viewState = {
zoomSpec: { t1: () => t1, t2: () => t2 },
cursor: { t: () => t },
audioY: () => 0,
audioH: () => 60,
zoomedTimeY: () => 60,
zoomedTimeH: () => 40,
fullZoomX: (sec: number) => (sec / duration) * w,
zoomInX: (sec: number) => ((sec - t1) / (t2 - t1)) * w,
mouse: { pos: () => $V([0, 0]) },
};
}
render() {
const song = this.playerState?.song;
if (!song) return html`(spectrogram)`;
return html`
<div class="timeRow">
<div id="timeSlider"></div>
<light9-timeline-audio id="overview" .show=${show} .song=${song} .zoom=${this.overviewZoom}> </light9-timeline-audio>
<light9-timeline-audio id="zoomed" .show=${show} .song=${song} .zoom=${this.zoom}></light9-timeline-audio>
<light9-cursor-canvas id="cursor" .viewState=${this.viewState}></light9-cursor-canvas>
</div>
`;
}
}
|