mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-23 03:28:33 +00:00
add working claviature method
This commit is contained in:
parent
0a1da6f651
commit
f2e16f946c
@ -1,20 +1,23 @@
|
|||||||
import { createSignal, For } from 'solid-js';
|
import { For } from 'solid-js';
|
||||||
import { customElement } from 'solid-element';
|
import { customElement } from 'solid-element';
|
||||||
import { getClaviature } from 'claviature';
|
import { getClaviature } from 'claviature';
|
||||||
import { Dynamic } from 'solid-js/web';
|
import { Dynamic } from 'solid-js/web';
|
||||||
|
|
||||||
customElement('strudel-claviature', { someProp: 'one', otherProp: 'two' }, (props, { element }) => {
|
let defaultOptions = {
|
||||||
const svg = getClaviature({
|
range: ['A1', 'C6'],
|
||||||
options: {
|
};
|
||||||
range: ['A1', 'C4'],
|
|
||||||
colorize: [{ keys: ['C3', 'E3', 'G3'], color: 'yellow' }],
|
customElement('strudel-claviature', { options: JSON.stringify(defaultOptions) }, (props, { element }) => {
|
||||||
},
|
let svg = () => {
|
||||||
});
|
let c = getClaviature({
|
||||||
const [activeNotes, setActiveNotes] = createSignal([]);
|
options: JSON.parse(props.options),
|
||||||
|
});
|
||||||
|
return c;
|
||||||
|
};
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<svg {...svg.attributes}>
|
<svg {...svg().attributes}>
|
||||||
<For each={svg.children}>
|
<For each={svg().children}>
|
||||||
{(el) => {
|
{(el) => {
|
||||||
return (
|
return (
|
||||||
<Dynamic component={el.name} {...el.attributes}>
|
<Dynamic component={el.name} {...el.attributes}>
|
||||||
|
|||||||
@ -1 +1,24 @@
|
|||||||
export * from './Claviature.jsx';
|
export * from './Claviature.jsx';
|
||||||
|
import { Pattern } from '@strudel/core';
|
||||||
|
|
||||||
|
Pattern.prototype.claviature = function (options = {}) {
|
||||||
|
if (!window.claviature) {
|
||||||
|
window.claviature = document.createElement('strudel-claviature');
|
||||||
|
window.claviature.style.position = 'absolute';
|
||||||
|
window.claviature.style.bottom = 0;
|
||||||
|
window.claviature.style.left = 0;
|
||||||
|
document.body.append(window.claviature);
|
||||||
|
}
|
||||||
|
return this.onFrame((haps) => {
|
||||||
|
const keys = haps.map((h) => h.value.note);
|
||||||
|
// console.log('keys',keys);
|
||||||
|
window.claviature.setAttribute(
|
||||||
|
'options',
|
||||||
|
JSON.stringify({
|
||||||
|
...options,
|
||||||
|
range: options.range || ['A2', 'C6'],
|
||||||
|
colorize: [{ keys: keys, color: options.color || 'steelblue' }],
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user