fix: mini repl punchcard + claviature flags

This commit is contained in:
Felix Roos 2024-06-02 10:49:07 +02:00
parent 3dc5fd0e7e
commit bf90867685
2 changed files with 22 additions and 11 deletions

View File

@ -29,13 +29,17 @@ export function MiniRepl({
claviatureLabels, claviatureLabels,
maxHeight, maxHeight,
autodraw, autodraw,
drawTime,
}) { }) {
const code = tunes ? tunes[0] : tune; const code = tunes ? tunes[0] : tune;
const id = useMemo(() => s4(), []); const id = useMemo(() => s4(), []);
const canvasId = useMemo(() => `canvas-${id}`, [id]); const canvasId = useMemo(() => `canvas-${id}`, [id]);
autodraw = !!punchcard || !!claviature || !!autodraw; autodraw = !!punchcard || !!claviature || !!autodraw;
const shouldShowCanvas = !!punchcard; const shouldShowCanvas = !!punchcard;
const drawTime = punchcard ? [0, 4] : [-2, 2]; drawTime = drawTime ?? punchcard ? [0, 4] : [-2, 2];
if (claviature) {
drawTime = [0, 0];
}
const [activeNotes, setActiveNotes] = useState([]); const [activeNotes, setActiveNotes] = useState([]);
const init = useCallback(({ code, autodraw }) => { const init = useCallback(({ code, autodraw }) => {
@ -57,7 +61,7 @@ export function MiniRepl({
pat = pat.onTrigger(onTrigger, false); pat = pat.onTrigger(onTrigger, false);
} }
if (claviature) { if (claviature) {
editor?.painters.push((ctx, time, haps, drawTime) => { pat = pat.onPaint((ctx, time, haps, drawTime) => {
const active = haps const active = haps
.map((hap) => hap.value.note) .map((hap) => hap.value.note)
.filter(Boolean) .filter(Boolean)
@ -66,7 +70,7 @@ export function MiniRepl({
}); });
} }
if (punchcard) { if (punchcard) {
editor?.painters.push(getPunchcardPainter({ labels: !!punchcardLabels })); pat = pat.punchcard({ labels: !!punchcardLabels });
} }
return pat; return pat;
}, },

View File

@ -38,8 +38,7 @@ You can change the color as well, even pattern it:
tune={`n("<0 2 1 3 2>*8") tune={`n("<0 2 1 3 2>*8")
.scale("<A1 D2>/4:minor:pentatonic") .scale("<A1 D2>/4:minor:pentatonic")
.s("supersaw").lpf(300).lpenv("<4 3 2>*4") .s("supersaw").lpf(300).lpenv("<4 3 2>*4")
._punchcard() ._punchcard()`}
`}
autodraw autodraw
/> />
@ -48,8 +47,7 @@ You can change the color as well, even pattern it:
tune={`n("<0 2 1 3 2>*8") tune={`n("<0 2 1 3 2>*8")
.scale("<A1 D2>/4:minor:pentatonic") .scale("<A1 D2>/4:minor:pentatonic")
.s("supersaw").lpf(300).lpenv("<4 3 2>\*4") .s("supersaw").lpf(300).lpenv("<4 3 2>\*4")
.\_pianoroll() .\_pianoroll()`}
`}
autodraw autodraw
/> />
@ -60,8 +58,8 @@ You can change the color as well, even pattern it:
tune={`n("<0 2 1 3 2>*8") tune={`n("<0 2 1 3 2>*8")
.scale("<A1 D2>/4:minor:pentatonic") .scale("<A1 D2>/4:minor:pentatonic")
.s("supersaw").lpf(300).lpenv("<4 3 2>*4") .s("supersaw").lpf(300).lpenv("<4 3 2>*4")
._spiral() ._spiral()`}
`} autodraw
/> />
## Scope ## Scope
@ -71,8 +69,17 @@ You can change the color as well, even pattern it:
tune={`n("<0 2 1 3 2>*8") tune={`n("<0 2 1 3 2>*8")
.scale("<A1 D2>/4:minor:pentatonic") .scale("<A1 D2>/4:minor:pentatonic")
.s("supersaw").lpf(300).lpenv("<4 3 2>*4") .s("supersaw").lpf(300).lpenv("<4 3 2>*4")
._scope() ._scope()`}
`} />
## Pitchwheel
<MiniRepl
client:idle
tune={`n("<0 2 1 3 2>*8")
.scale("<A1 D2>/4:minor:pentatonic")
.s("supersaw").lpf(300).lpenv("<4 3 2>*4")
._pitchwheel()`}
/> />
{/* <JsDoc client:idle name="pianoroll" h={0} /> */} {/* <JsDoc client:idle name="pianoroll" h={0} /> */}