feat: add audio channel test, av sync test
This commit is contained in:
parent
2d44469d0e
commit
76e81c1f60
17 changed files with 334 additions and 26 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1,3 +1,6 @@
|
|||
assets/generated/*
|
||||
!assets/generated/.gitkeep
|
||||
|
||||
.DS_Store
|
||||
node_modules
|
||||
/build
|
||||
|
|
52
Earthfile
52
Earthfile
|
@ -1,6 +1,30 @@
|
|||
VERSION 0.7
|
||||
FROM node:lts
|
||||
|
||||
site:
|
||||
RUN npm install -g pnpm
|
||||
COPY package.json pnpm-lock.yaml /site
|
||||
WORKDIR /site
|
||||
CACHE --id=pnpm $HOME/.local/share/pnpm
|
||||
RUN pnpm install --frozen-lockfile --prod
|
||||
COPY . /site
|
||||
COPY +assets-generated/* /site/assets/generated
|
||||
RUN pnpm build
|
||||
SAVE ARTIFACT build AS LOCAL build
|
||||
|
||||
deploy:
|
||||
FROM alpine
|
||||
RUN apk add openssh-client rsync
|
||||
RUN --secret SSH_CONFIG --secret SSH_UPLOAD_KEY --secret SSH_KNOWN_HOSTS \
|
||||
mkdir -p $HOME/.ssh && \
|
||||
echo "$SSH_CONFIG" > $HOME/.ssh/config && \
|
||||
echo "$SSH_UPLOAD_KEY" > $HOME/.ssh/id_rsa && \
|
||||
echo "$SSH_KNOWN_HOSTS" > $HOME/.ssh/known_hosts && \
|
||||
chmod 600 $HOME/.ssh/*
|
||||
COPY +site/build /build
|
||||
RUN --secret SSH_TARGET --push rsync -cvrz --delete /build/ $SSH_TARGET
|
||||
|
||||
|
||||
avsync-video-components:
|
||||
# https://pptr.dev/troubleshooting
|
||||
RUN apt-get update && apt-get -y install libgtk-3-dev libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 && rm -rf /var/lib/apt/lists/*
|
||||
|
@ -16,8 +40,8 @@ avsync-video-components:
|
|||
ARG CYCLES=16
|
||||
ARG SIZE=1200
|
||||
RUN pnpm av:render:video --fps $FPS --cycles 1 --size $SIZE --output /var/tmp/frames
|
||||
RUN pnpm av:render:audio -i beep.wav -o /var/tmp/track.wav --repeats $CYCLES
|
||||
SAVE ARTIFACT /var/tmp/frames
|
||||
RUN pnpm av:render:audio -i beep.wav -o /var/tmp/track.wav --repeats $CYCLES
|
||||
SAVE ARTIFACT /var/tmp/track.wav
|
||||
|
||||
avsync-video:
|
||||
|
@ -76,25 +100,7 @@ audio-channel-tracks-mp3:
|
|||
for file in /output/wav/7.1/*.wav; do ffmpeg -i $file -c:a libmp3lame /output/mp3/7.1/$(basename $file .wav).mp3 -hide_banner -loglevel error; done
|
||||
SAVE ARTIFACT /output/mp3
|
||||
|
||||
site:
|
||||
RUN npm install -g pnpm
|
||||
COPY package.json pnpm-lock.yaml /site
|
||||
WORKDIR /site
|
||||
CACHE --id=pnpm $HOME/.local/share/pnpm
|
||||
RUN pnpm install --frozen-lockfile --prod
|
||||
COPY . /site
|
||||
RUN pnpm build
|
||||
SAVE ARTIFACT build AS LOCAL build
|
||||
|
||||
deploy:
|
||||
FROM alpine
|
||||
RUN apk add openssh-client rsync
|
||||
RUN --secret SSH_CONFIG --secret SSH_UPLOAD_KEY --secret SSH_KNOWN_HOSTS \
|
||||
mkdir -p $HOME/.ssh && \
|
||||
echo "$SSH_CONFIG" > $HOME/.ssh/config && \
|
||||
echo "$SSH_UPLOAD_KEY" > $HOME/.ssh/id_rsa && \
|
||||
echo "$SSH_KNOWN_HOSTS" > $HOME/.ssh/known_hosts && \
|
||||
chmod 600 $HOME/.ssh/*
|
||||
COPY +site/build /build
|
||||
RUN --secret SSH_TARGET --push rsync -cvrz --delete /build/ $SSH_TARGET
|
||||
|
||||
assets-generated:
|
||||
COPY +avsync-video/avsync.webm /assets/avsync.webm
|
||||
COPY +audio-channel-tracks-mp3/mp3 /assets/audio/
|
||||
SAVE ARTIFACT /assets/* AS LOCAL assets/generated/
|
||||
|
|
0
assets/generated/.gitkeep
Normal file
0
assets/generated/.gitkeep
Normal file
|
@ -10,6 +10,7 @@
|
|||
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
||||
"lint": "prettier --check . && eslint .",
|
||||
"format": "prettier --write .",
|
||||
"generate-assets": "earthly +assets-generated",
|
||||
"av:dev": "cd av-sync && vite",
|
||||
"av:render:video": "cd av-sync && concurrently -P -k -s command-1 \"vite --port 8626\" \"wait-on http://localhost:8626 && node render-video.js --url http://localhost:8626 {@}\" --",
|
||||
"av:render:audio": "cd av-sync && node render-audio.js"
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
<TestCard full={onlyCard} on:focus={() => goto('/card')} />
|
||||
<main class:content={!onlyCard} class:sub={$page.url.pathname !== '/' && !onlyCard}>
|
||||
<a href="/" class="button button-back"><i class="ti ti-arrow-back" />Back</a>
|
||||
<a href=".." class="button button-back"><i class="ti ti-arrow-back" />Back</a>
|
||||
<slot />
|
||||
</main>
|
||||
|
||||
|
|
|
@ -9,10 +9,14 @@
|
|||
<i class="ti ti-device-desktop"></i>
|
||||
Screen
|
||||
</a>
|
||||
<a href="audio" class="disabled">
|
||||
<a href="audio">
|
||||
<i class="ti ti-volume"></i>
|
||||
Audio
|
||||
</a>
|
||||
<a href="av-sync" class="disabled">
|
||||
<i class="ti ti-time-duration-off"></i>
|
||||
AV Sync
|
||||
</a>
|
||||
<a href="keyboard">
|
||||
<i class="ti ti-keyboard"></i>
|
||||
Keyboard
|
||||
|
|
5
src/routes/audio/+layout.svelte
Normal file
5
src/routes/audio/+layout.svelte
Normal file
|
@ -0,0 +1,5 @@
|
|||
<script lang="ts">
|
||||
</script>
|
||||
|
||||
<h2><i class="ti ti-volume"></i> Audio test</h2>
|
||||
<slot />
|
1
src/routes/audio/+layout.ts
Normal file
1
src/routes/audio/+layout.ts
Normal file
|
@ -0,0 +1 @@
|
|||
export const trailingSlash = 'always';
|
|
@ -0,0 +1,20 @@
|
|||
<h3>Channel tests</h3>
|
||||
<ul>
|
||||
<li><a href="channels/stereo">Stereo</a></li>
|
||||
<li><a href="channels/5.1">5.1 Surround</a></li>
|
||||
<li><a href="channels/7.1">7.1 Surround</a></li>
|
||||
</ul>
|
||||
|
||||
<style>
|
||||
ul {
|
||||
list-style-type: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
}
|
||||
li {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
</style>
|
82
src/routes/audio/channels/+layout.svelte
Normal file
82
src/routes/audio/channels/+layout.svelte
Normal file
|
@ -0,0 +1,82 @@
|
|||
<script lang="ts">
|
||||
import { onDestroy } from 'svelte';
|
||||
|
||||
let channelsEl: HTMLDivElement;
|
||||
|
||||
let cycling = false;
|
||||
async function cycleChannels() {
|
||||
cycling = true;
|
||||
const buttons = channelsEl.querySelectorAll('button');
|
||||
buttons.forEach((button) => (button.disabled = true));
|
||||
const channels = channelsEl.querySelectorAll('audio');
|
||||
while (cycling) {
|
||||
for (const channel of channels) {
|
||||
await channel.play();
|
||||
await new Promise((resolve) => {
|
||||
channel.onended = resolve;
|
||||
});
|
||||
if (!cycling) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
buttons.forEach((button) => (button.disabled = false));
|
||||
}
|
||||
|
||||
function startCycle() {
|
||||
cycling = !cycling;
|
||||
if (cycling) {
|
||||
cycleChannels();
|
||||
}
|
||||
}
|
||||
|
||||
onDestroy(() => {
|
||||
cycling = false;
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class="channels" bind:this={channelsEl}>
|
||||
<slot />
|
||||
</div>
|
||||
<div class="controls">
|
||||
<button on:click={startCycle}>Cycle all</button>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.channels {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-evenly;
|
||||
font-size: 2rem;
|
||||
flex-grow: 1;
|
||||
|
||||
position: relative;
|
||||
}
|
||||
|
||||
:global(.channels .row) {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.controls {
|
||||
text-align: center;
|
||||
margin: 2rem 0;
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
|
||||
:global(.channels .center) {
|
||||
font-size: 0.9em;
|
||||
}
|
||||
|
||||
:global(.channels .label) {
|
||||
opacity: 0.33;
|
||||
font-size: 6rem;
|
||||
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
|
||||
pointer-events: none;
|
||||
}
|
||||
</style>
|
8
src/routes/audio/channels/+page.svelte
Normal file
8
src/routes/audio/channels/+page.svelte
Normal file
|
@ -0,0 +1,8 @@
|
|||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
import { goto } from '$app/navigation';
|
||||
|
||||
onMount(() => {
|
||||
goto('..');
|
||||
});
|
||||
</script>
|
24
src/routes/audio/channels/5.1/+page.svelte
Normal file
24
src/routes/audio/channels/5.1/+page.svelte
Normal file
|
@ -0,0 +1,24 @@
|
|||
<script lang="ts">
|
||||
import Speaker from '../speaker.svelte';
|
||||
import frontLeftUrl from '@assets/audio/5.1/Front_Left.mp3';
|
||||
import frontCenterUrl from '@assets/audio/5.1/Front_Center.mp3';
|
||||
import frontRightUrl from '@assets/audio/5.1/Front_Right.mp3';
|
||||
import rearLeftUrl from '@assets/audio/5.1/Rear_Left.mp3';
|
||||
import rearRightUrl from '@assets/audio/5.1/Rear_Right.mp3';
|
||||
import LfeUrl from '@assets/audio/5.1/LFE_Noise.mp3';
|
||||
</script>
|
||||
|
||||
<div class="row">
|
||||
<Speaker src={frontLeftUrl} left>Front Left</Speaker>
|
||||
<div class="center">
|
||||
<Speaker src={frontCenterUrl} center>Front Center</Speaker>
|
||||
</div>
|
||||
<Speaker src={frontRightUrl} right>Front Right</Speaker>
|
||||
</div>
|
||||
<div class="row">
|
||||
<Speaker src={rearLeftUrl} left>Rear Left</Speaker>
|
||||
<Speaker src={rearRightUrl} right>Rear Right</Speaker>
|
||||
</div>
|
||||
<Speaker src={LfeUrl} lfe>LFE</Speaker>
|
||||
|
||||
<div class="label">5.1</div>
|
31
src/routes/audio/channels/7.1/+page.svelte
Normal file
31
src/routes/audio/channels/7.1/+page.svelte
Normal file
|
@ -0,0 +1,31 @@
|
|||
<script lang="ts">
|
||||
import Speaker from '../speaker.svelte';
|
||||
import frontLeftUrl from '@assets/audio/7.1/Front_Left.mp3';
|
||||
import frontCenterUrl from '@assets/audio/7.1/Front_Center.mp3';
|
||||
import frontRightUrl from '@assets/audio/7.1/Front_Right.mp3';
|
||||
import sideLeftUrl from '@assets/audio/7.1/Side_Left.mp3';
|
||||
import sideRightUrl from '@assets/audio/7.1/Side_Right.mp3';
|
||||
import rearLeftUrl from '@assets/audio/7.1/Rear_Left.mp3';
|
||||
import rearRightUrl from '@assets/audio/7.1/Rear_Right.mp3';
|
||||
import LfeUrl from '@assets/audio/7.1/LFE_Noise.mp3';
|
||||
</script>
|
||||
|
||||
<div class="row">
|
||||
<Speaker src={frontLeftUrl} left>Front Left</Speaker>
|
||||
<div class="center">
|
||||
<Speaker src={frontCenterUrl} center>Front Center</Speaker>
|
||||
</div>
|
||||
<Speaker src={frontRightUrl} right>Front Right</Speaker>
|
||||
</div>
|
||||
<div class="row">
|
||||
<Speaker src={sideLeftUrl} left>Side Left</Speaker>
|
||||
<Speaker src={sideRightUrl} right>Side Right</Speaker>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<Speaker src={rearLeftUrl} left>Rear Left</Speaker>
|
||||
<Speaker src={rearRightUrl} right>Rear Right</Speaker>
|
||||
</div>
|
||||
<Speaker src={LfeUrl} lfe>LFE</Speaker>
|
||||
|
||||
<div class="label">7.1</div>
|
68
src/routes/audio/channels/speaker.svelte
Normal file
68
src/routes/audio/channels/speaker.svelte
Normal file
|
@ -0,0 +1,68 @@
|
|||
<script lang="ts">
|
||||
import { createEventDispatcher, onMount } from 'svelte';
|
||||
const dispatch = createEventDispatcher<{ end: void }>();
|
||||
|
||||
export let src: string;
|
||||
export let left = false;
|
||||
export let center = false;
|
||||
export let right = false;
|
||||
export let lfe = false;
|
||||
|
||||
let currentTime = 0;
|
||||
let paused = true;
|
||||
function play() {
|
||||
currentTime = 0;
|
||||
paused = false;
|
||||
}
|
||||
</script>
|
||||
|
||||
<button
|
||||
class="speaker"
|
||||
class:left
|
||||
class:right
|
||||
class:center
|
||||
class:lfe
|
||||
class:playing={!paused}
|
||||
on:click={play}
|
||||
>
|
||||
{#if !lfe}
|
||||
<i class="ti ti-volume"></i>
|
||||
{:else}
|
||||
<i class="ti ti-wave-sine"></i>
|
||||
{/if}
|
||||
<label><slot /></label>
|
||||
<audio bind:currentTime bind:paused {src}></audio>
|
||||
</button>
|
||||
|
||||
<style>
|
||||
.speaker {
|
||||
border: none;
|
||||
background: transparent;
|
||||
|
||||
display: inline-flex;
|
||||
flex-direction: column;
|
||||
text-align: center;
|
||||
|
||||
& .ti {
|
||||
font-size: 3em;
|
||||
}
|
||||
|
||||
&.right .ti {
|
||||
display: block;
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
|
||||
&.center .ti {
|
||||
display: block;
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
opacity: 0.33;
|
||||
}
|
||||
|
||||
&.playing {
|
||||
opacity: 0.66;
|
||||
}
|
||||
}
|
||||
</style>
|
14
src/routes/audio/channels/stereo/+page.svelte
Normal file
14
src/routes/audio/channels/stereo/+page.svelte
Normal file
|
@ -0,0 +1,14 @@
|
|||
<script lang="ts">
|
||||
import Speaker from '../speaker.svelte';
|
||||
import leftUrl from '@assets/audio/stereo/Left.mp3';
|
||||
import centerUrl from '@assets/audio/stereo/Center.mp3';
|
||||
import rightUrl from '@assets/audio/stereo/Right.mp3';
|
||||
</script>
|
||||
|
||||
<div class="row">
|
||||
<Speaker src={leftUrl} left>Left</Speaker>
|
||||
<div class="center">
|
||||
<Speaker src={centerUrl} center>Center</Speaker>
|
||||
</div>
|
||||
<Speaker src={rightUrl} right>Right</Speaker>
|
||||
</div>
|
30
src/routes/av-sync/+page.svelte
Normal file
30
src/routes/av-sync/+page.svelte
Normal file
|
@ -0,0 +1,30 @@
|
|||
<script lang="ts">
|
||||
import videoUrl from '@assets/avsync.webm';
|
||||
let paused = true;
|
||||
</script>
|
||||
|
||||
<h2><i class="ti ti-time-duration-off"></i> Audio/Video Synchronization</h2>
|
||||
<!-- svelte-ignore a11y-media-has-caption -->
|
||||
<video
|
||||
class:playing={!paused}
|
||||
autoplay
|
||||
loop
|
||||
bind:paused
|
||||
src={videoUrl}
|
||||
on:click={() => (paused = false)}
|
||||
></video>
|
||||
|
||||
<style>
|
||||
video {
|
||||
flex-grow: 1;
|
||||
|
||||
&:not(.playing) {
|
||||
opacity: 0.5;
|
||||
filter: grayscale(0.8);
|
||||
}
|
||||
|
||||
transition:
|
||||
opacity 0.3s,
|
||||
filter 0.3s;
|
||||
}
|
||||
</style>
|
|
@ -1,6 +1,17 @@
|
|||
import { sveltekit } from '@sveltejs/kit/vite';
|
||||
import { defineConfig } from 'vite';
|
||||
import * as path from 'path';
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [sveltekit()]
|
||||
plugins: [sveltekit()],
|
||||
resolve: {
|
||||
alias: {
|
||||
'@assets': path.join(__dirname, 'assets/generated')
|
||||
}
|
||||
},
|
||||
server: {
|
||||
fs: {
|
||||
allow: [path.join(__dirname, 'assets/generated')]
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue