Merge branch 'main' into main

This commit is contained in:
froos 2025-11-04 18:55:34 +01:00
commit 3e636bd6f0
2 changed files with 15 additions and 15 deletions

View file

@ -1,8 +1,10 @@
import jsdoc from '../../doc.json'; import jsdoc from '../../doc.json';
import { autocompletion } from '@codemirror/autocomplete'; import { autocompletion } from '@codemirror/autocomplete';
import { h } from './html'; import { h } from './html';
import { Scale } from '@tonaljs/tonal'; //TODO: fix tonal scale import
import { soundMap } from 'superdough'; // import { Scale } from '@tonaljs/tonal';
// import { soundMap } from '@strudel/webaudio';
let soundMap = undefined;
import { complex } from '@strudel/tonal'; import { complex } from '@strudel/tonal';
const escapeHtml = (str) => { const escapeHtml = (str) => {
@ -79,7 +81,9 @@ const hasExcludedTags = (doc) =>
['superdirtOnly', 'noAutocomplete'].some((tag) => doc.tags?.find((t) => t.originalTitle === tag)); ['superdirtOnly', 'noAutocomplete'].some((tag) => doc.tags?.find((t) => t.originalTitle === tag));
export function bankCompletions() { export function bankCompletions() {
const soundDict = soundMap.get(); // TODO: FIX IMPORT
const soundDict = soundMap?.get() ?? {};
const banks = new Set(); const banks = new Set();
for (const key of Object.keys(soundDict)) { for (const key of Object.keys(soundDict)) {
const [bank, suffix] = key.split('_'); const [bank, suffix] = key.split('_');
@ -90,13 +94,13 @@ export function bankCompletions() {
.map((name) => ({ label: name, type: 'bank' })); .map((name) => ({ label: name, type: 'bank' }));
} }
// Attempt to get all scale names from Tonal // Attempt to get all scale names from Tonal TODO: FIX IMPORT
let scaleCompletions = []; let scaleCompletions = [];
try { // try {
scaleCompletions = (Scale.names ? Scale.names() : []).map((name) => ({ label: name, type: 'scale' })); // scaleCompletions = (Scale.names ? Scale.names() : []).map((name) => ({ label: name, type: 'scale' }));
} catch (e) { // } catch (e) {
console.warn('[autocomplete] Could not load scale names from Tonal:', e); // console.warn('[autocomplete] Could not load scale names from Tonal:', e);
} // }
// Valid mode values for voicing // Valid mode values for voicing
const modeCompletions = [ const modeCompletions = [
@ -268,7 +272,7 @@ function soundHandler(context) {
const inside = text.slice(quoteIdx + 1); const inside = text.slice(quoteIdx + 1);
const fragMatch = inside.match(SOUND_FRAGMENT_MATCH_REGEX); const fragMatch = inside.match(SOUND_FRAGMENT_MATCH_REGEX);
const fragment = fragMatch ? fragMatch[1] : inside; const fragment = fragMatch ? fragMatch[1] : inside;
const soundNames = Object.keys(soundMap.get()).sort(); const soundNames = Object.keys(soundMap?.get() ?? {}).sort();
const filteredSounds = soundNames.filter((name) => name.includes(fragment)); const filteredSounds = soundNames.filter((name) => name.includes(fragment));
let options = filteredSounds.map((name) => ({ label: name, type: 'sound' })); let options = filteredSounds.map((name) => ({ label: name, type: 'sound' }));
const from = soundContext.to - fragment.length; const from = soundContext.to - fragment.length;

View file

@ -92,11 +92,7 @@ export function registerSamplesFromDB(config = userSamplesDBConfig, onComplete =
async function blobToDataUrl(blob) { async function blobToDataUrl(blob) {
return new Promise((resolve) => { return new Promise((resolve) => {
var reader = new FileReader(); resolve(URL.createObjectURL(blob));
reader.onload = function (event) {
resolve(event.target.result);
};
reader.readAsDataURL(blob);
}); });
} }