mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-24 03:58:53 +00:00
move scope to webaudio package
This commit is contained in:
parent
2e31c8695a
commit
43efe6921d
@ -22,7 +22,6 @@ export * from './cyclist.mjs';
|
|||||||
export * from './logger.mjs';
|
export * from './logger.mjs';
|
||||||
export * from './time.mjs';
|
export * from './time.mjs';
|
||||||
export * from './draw.mjs';
|
export * from './draw.mjs';
|
||||||
export * from './scope.mjs';
|
|
||||||
export * from './animate.mjs';
|
export * from './animate.mjs';
|
||||||
export * from './pianoroll.mjs';
|
export * from './pianoroll.mjs';
|
||||||
export * from './spiral.mjs';
|
export * from './spiral.mjs';
|
||||||
|
|||||||
@ -5,4 +5,5 @@ This program is free software: you can redistribute it and/or modify it under th
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
export * from './webaudio.mjs';
|
export * from './webaudio.mjs';
|
||||||
|
export * from './scope.mjs';
|
||||||
export * from 'superdough';
|
export * from 'superdough';
|
||||||
|
|||||||
@ -1,11 +1,9 @@
|
|||||||
import { Pattern } from './pattern.mjs';
|
import { Pattern, getDrawContext, clamp } from '@strudel.cycles/core';
|
||||||
import { getDrawContext } from './draw.mjs';
|
import { analyser } from 'superdough';
|
||||||
import { analyser } from '@strudel.cycles/webaudio';
|
|
||||||
import { clamp } from './util.mjs';
|
|
||||||
|
|
||||||
export function drawTimeScope(
|
export function drawTimeScope(
|
||||||
analyser,
|
analyser,
|
||||||
{ align = true, color = 'white', thickness = 3, scale = 0.25, pos = 0.75, next = 1 } = {},
|
{ align = true, color = 'white', thickness = 3, scale = 0.25, pos = 0.75, next = 1, trigger = 0 } = {},
|
||||||
) {
|
) {
|
||||||
const ctx = getDrawContext();
|
const ctx = getDrawContext();
|
||||||
const dataArray = getAnalyzerData('time');
|
const dataArray = getAnalyzerData('time');
|
||||||
@ -17,9 +15,8 @@ export function drawTimeScope(
|
|||||||
let canvas = ctx.canvas;
|
let canvas = ctx.canvas;
|
||||||
|
|
||||||
const bufferSize = analyser.frequencyBinCount;
|
const bufferSize = analyser.frequencyBinCount;
|
||||||
const triggerValue = 0;
|
|
||||||
let triggerIndex = align
|
let triggerIndex = align
|
||||||
? Array.from(dataArray).findIndex((v, i, arr) => i && arr[i - 1] < triggerValue && v >= triggerValue)
|
? Array.from(dataArray).findIndex((v, i, arr) => i && arr[i - 1] > -trigger && v <= -trigger)
|
||||||
: 0;
|
: 0;
|
||||||
triggerIndex = Math.max(triggerIndex, 0); // fallback to 0 when no trigger is found
|
triggerIndex = Math.max(triggerIndex, 0); // fallback to 0 when no trigger is found
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user