Clean build

This commit is contained in:
Hayk Martiros 2022-11-27 16:59:00 -08:00
parent 5cf6c476ab
commit e51c7d3129
4 changed files with 25 additions and 16 deletions

View File

@ -132,6 +132,7 @@ export default function AudioPlayer({
resultCounter, resultCounter,
inferenceResults, inferenceResults,
paused, paused,
nowPlayingCallback,
tonePlayer, tonePlayer,
]); ]);

View File

@ -1,6 +1,5 @@
import { useRouter } from "next/router"; import { useRouter } from "next/router";
import { useCallback, useEffect, useState } from "react"; import { useCallback, useEffect, useState } from "react";
import { useInterval } from "usehooks-ts";
import { import {
AppState, AppState,
@ -18,7 +17,6 @@ interface ModelInferenceProps {
appState: AppState; appState: AppState;
promptInputs: PromptInput[]; promptInputs: PromptInput[];
nowPlayingResult: InferenceResult; nowPlayingResult: InferenceResult;
paused: boolean;
newResultCallback: (input: InferenceInput, result: InferenceResult) => void; newResultCallback: (input: InferenceInput, result: InferenceResult) => void;
} }
@ -33,7 +31,6 @@ export default function ModelInference({
appState, appState,
promptInputs, promptInputs,
nowPlayingResult, nowPlayingResult,
paused,
newResultCallback, newResultCallback,
}: ModelInferenceProps) { }: ModelInferenceProps) {
// Create parameters for the inference request // Create parameters for the inference request
@ -142,10 +139,12 @@ export default function ModelInference({
numInferenceSteps, numInferenceSteps,
seedImageId, seedImageId,
newResultCallback, newResultCallback,
numRequestsMade,
numResponsesReceived,
] ]
); );
// Kick off the first inference run when everything is ready. // Kick off inference requests
useEffect(() => { useEffect(() => {
// Make sure things are initialized properly // Make sure things are initialized properly
if ( if (
@ -157,8 +156,10 @@ export default function ModelInference({
} }
if (numRequestsMade == 0) { if (numRequestsMade == 0) {
// Kick off the first request
runInference(alpha, seed, appState, promptInputs); runInference(alpha, seed, appState, promptInputs);
} else if (numRequestsMade == numResponsesReceived) { } else if (numRequestsMade == numResponsesReceived) {
// Otherwise buffer ahead a few from where the audio player currently is
// TODO(hayk): Replace this with better buffer management // TODO(hayk): Replace this with better buffer management
const nowPlayingCounter = nowPlayingResult ? nowPlayingResult.counter : 0; const nowPlayingCounter = nowPlayingResult ? nowPlayingResult.counter : 0;
@ -170,12 +171,13 @@ export default function ModelInference({
} }
}, [ }, [
initializedUrlParams, initializedUrlParams,
numRequestsMade,
alpha, alpha,
seed, seed,
appState, appState,
promptInputs, promptInputs,
paused, nowPlayingResult,
numRequestsMade,
numResponsesReceived,
runInference, runInference,
]); ]);

14
components/PageHead.tsx Normal file
View File

@ -0,0 +1,14 @@
import Head from "next/head";
export default function PageHead() {
return (
<Head>
<title>Riffusion</title>
<meta
name="description"
content="My name is Riffusion, and I write music."
/>
<link rel="icon" href="/favicon.ico" />
</Head>
);
}

View File

@ -1,9 +1,9 @@
import Head from "next/head";
import { useRouter } from "next/router"; import { useRouter } from "next/router";
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import * as Tone from "tone"; import * as Tone from "tone";
import AudioPlayer from "../components/AudioPlayer"; import AudioPlayer from "../components/AudioPlayer";
import PageHead from "../components/PageHead";
import Info from "../components/Info"; import Info from "../components/Info";
import ModelInference from "../components/ModelInference"; import ModelInference from "../components/ModelInference";
import Pause from "../components/Pause"; import Pause from "../components/Pause";
@ -156,14 +156,7 @@ export default function Home() {
return ( return (
<> <>
<Head> <PageHead />
<title>Riffusion</title>
<meta
name="description"
content="My name is Riffusion, and I write music."
/>
<link rel="icon" href="/favicon.ico" />
</Head>
<div className="bg-[#0A2342] flex flex-row min-h-screen text-white"> <div className="bg-[#0A2342] flex flex-row min-h-screen text-white">
<div className="w-1/3 min-h-screen"> <div className="w-1/3 min-h-screen">
@ -179,7 +172,6 @@ export default function Home() {
seed={seed} seed={seed}
appState={appState} appState={appState}
promptInputs={promptInputs} promptInputs={promptInputs}
paused={paused}
nowPlayingResult={nowPlayingResult} nowPlayingResult={nowPlayingResult}
newResultCallback={newResultCallback} newResultCallback={newResultCallback}
/> />