diff --git a/components/ImagePlane.tsx b/components/ImagePlane.tsx index acd99e5..bcf684e 100644 --- a/components/ImagePlane.tsx +++ b/components/ImagePlane.tsx @@ -5,6 +5,7 @@ import { useLoader } from "@react-three/fiber"; interface ImagePlaneProps { url: string; height: number; + duration: number; } /** @@ -16,7 +17,7 @@ export default function ImagePlane(props: ImagePlaneProps) { return ( - + diff --git a/components/SpectrogramViewer.tsx b/components/SpectrogramViewer.tsx index 7ac5dc8..a357a39 100644 --- a/components/SpectrogramViewer.tsx +++ b/components/SpectrogramViewer.tsx @@ -1,6 +1,6 @@ import { useRef } from "react"; import { useFrame, useThree } from "@react-three/fiber"; -import { QuadraticBezierLine, Plane } from "@react-three/drei"; +import { Box } from "@react-three/drei"; import { InferenceResult } from "../types"; import HeightMapImage from "./HeightMapImage"; @@ -54,28 +54,26 @@ export default function SpectrogramViewer({ /> ); } else { - return ; + return ( + + ); } })} {/* TODO make into playhead component */} - - - - - {/* */} + + ); diff --git a/components/ThreeCanvas.tsx b/components/ThreeCanvas.tsx index 471ec99..54c54f9 100644 --- a/components/ThreeCanvas.tsx +++ b/components/ThreeCanvas.tsx @@ -20,7 +20,7 @@ export default function ThreeCanvas({ audioLength, }: CanvasProps) { return ( - + { }); }; +function getRandomInt(max: number) { + return Math.floor(Math.random() * max); +} + // TODO(hayk): Do this as soon as sample comes back const timeout = 5000; const maxLength = 10; @@ -66,7 +70,7 @@ export default function Home() { const [resultCounter, setResultCounter] = useState(0); const [alpha, setAlpha] = useState(0.0); - const [seed, setSeed] = useState(0); + const [seed, setSeed] = useState(getRandomInt(1000000)); const [appState, setAppState] = useState(AppState.SamePrompt); @@ -134,7 +138,8 @@ export default function Home() { Tone.Transport.scheduleRepeat((time) => { console.log( "Edge of clip, t = ", - Tone.Transport.getSecondsAtTime(time) + Tone.Transport.getSecondsAtTime(time), + bufferLength ); setNumClipsPlayed((n) => n + 1); }, bufferLength); @@ -346,14 +351,14 @@ export default function Home() {
- Tone.Transport.seconds} - audioLength={ - tonePlayer ? tonePlayer.sampleTime * tonePlayer.buffer.length : 5 - } - inferenceResults={inferenceResults} - /> + {tonePlayer && ( + Tone.Transport.seconds} + audioLength={tonePlayer.sampleTime * tonePlayer.buffer.length} + inferenceResults={inferenceResults} + /> + )}