A transient shaper you can plug in: its state, a panel with a handle for the attack and the sustain and an engine that plays it. Play a loop through it and drag the handle: up for more click, left for a shorter ring
@audio-ui
block-transient.tsx
"use client";
import { useState } from "react";
import { PlayToggle } from "@/components/audio-ui/play-toggle";
import { TransientPanel } from "@/components/audio-ui/devices/transient/panel";
import { useDeviceLoop } from "@/hooks/use-device-loop";
import { useMasterBus } from "@/hooks/use-master-bus";
import {
type TransientState,
transientDevice,
} from "@/components/audio-ui/devices/transient/device";
import { createTransientEngine } from "@/components/audio-ui/devices/transient/engine";
const MASTER_VOLUME = 0.7;
/**
* A transient shaper you can plug in: its state, a panel with a handle for
* the attack and the sustain and an engine that plays it, each its own file
* and none knowing the others. Play the loop and drag the handle: up for more
* click, down to soften it, left to shorten what rings.
*/
export function BlockTransient() {
const [state, setState] = useState<TransientState>(() =>
transientDevice.defaults()
);
const master = useMasterBus(MASTER_VOLUME);
const { playing, toggle } = useDeviceLoop({
create: createTransientEngine,
destination: master,
state,
});
return (
<div className="rounded-xl h-full w-full min-w-0">
<TransientPanel onValueChange={setState} value={state}>
<PlayToggle
label="Play a loop through it"
onToggle={toggle}
playing={playing}
/>
</TransientPanel>
</div>
);
}




























