An overdrive you can plug in: its state, a panel that draws the band that reaches the clip and an engine that plays it. Play a loop through it, drag the handle and turn the drive
@audio-ui
block-overdrive.tsx
"use client";
import { useState } from "react";
import { PlayToggle } from "@/components/audio-ui/play-toggle";
import { OverdrivePanel } from "@/components/audio-ui/devices/overdrive/panel";
import { useDeviceLoop } from "@/hooks/use-device-loop";
import { useMasterBus } from "@/hooks/use-master-bus";
import {
type OverdriveState,
overdriveDevice,
} from "@/components/audio-ui/devices/overdrive/device";
import { createOverdriveEngine } from "@/components/audio-ui/devices/overdrive/engine";
const MASTER_VOLUME = 0.7;
/**
* An overdrive you can plug in: its state, a panel that draws the band that
* reaches the clip and an engine that plays it, each its own file and none
* knowing the others. Play the loop, drag the handle and turn the drive.
*/
export function BlockOverdrive() {
const [state, setState] = useState<OverdriveState>(() =>
overdriveDevice.defaults()
);
const master = useMasterBus(MASTER_VOLUME);
const { playing, toggle } = useDeviceLoop({
create: createOverdriveEngine,
destination: master,
state,
});
return (
<div className="rounded-xl h-full w-full min-w-0">
<OverdrivePanel onValueChange={setState} value={state}>
<PlayToggle
label="Play a loop through it"
onToggle={toggle}
playing={playing}
/>
</OverdrivePanel>
</div>
);
}



























