refactor: remove now redundant controls imports

This commit is contained in:
Felix Roos 2024-02-28 00:36:44 +01:00
parent 8efadd2547
commit 664a19a5c4
12 changed files with 20 additions and 41 deletions

View File

@ -1,6 +1,6 @@
import { StrudelMirror } from '@strudel/codemirror'; import { StrudelMirror } from '@strudel/codemirror';
import { funk42 } from './tunes'; import { funk42 } from './tunes';
import { drawPianoroll, evalScope, controls } from '@strudel/core'; import { drawPianoroll, evalScope } from '@strudel/core';
import './style.css'; import './style.css';
import { initAudioOnFirstClick } from '@strudel/webaudio'; import { initAudioOnFirstClick } from '@strudel/webaudio';
import { transpiler } from '@strudel/transpiler'; import { transpiler } from '@strudel/transpiler';
@ -25,7 +25,6 @@ const editor = new StrudelMirror({
prebake: async () => { prebake: async () => {
initAudioOnFirstClick(); // needed to make the browser happy (don't await this here..) initAudioOnFirstClick(); // needed to make the browser happy (don't await this here..)
const loadModules = evalScope( const loadModules = evalScope(
controls,
import('@strudel/core'), import('@strudel/core'),
import('@strudel/mini'), import('@strudel/mini'),
import('@strudel/tonal'), import('@strudel/tonal'),

View File

@ -1,5 +1,5 @@
import { controls, repl, evalScope } from '@strudel/core'; import { repl, evalScope } from '@strudel/core';
import { getAudioContext, webaudioOutput, initAudioOnFirstClick } from '@strudel/webaudio'; import { getAudioContext, webaudioOutput, initAudioOnFirstClick, registerSynthSounds } from '@strudel/webaudio';
import { transpiler } from '@strudel/transpiler'; import { transpiler } from '@strudel/transpiler';
import tune from './tune.mjs'; import tune from './tune.mjs';
@ -7,14 +7,9 @@ const ctx = getAudioContext();
const input = document.getElementById('text'); const input = document.getElementById('text');
input.innerHTML = tune; input.innerHTML = tune;
initAudioOnFirstClick(); initAudioOnFirstClick();
registerSynthSounds();
evalScope( evalScope(import('@strudel/core'), import('@strudel/mini'), import('@strudel/webaudio'), import('@strudel/tonal'));
controls,
import('@strudel/core'),
import('@strudel/mini'),
import('@strudel/webaudio'),
import('@strudel/tonal'),
);
const { evaluate } = repl({ const { evaluate } = repl({
defaultOutput: webaudioOutput, defaultOutput: webaudioOutput,

View File

@ -1,6 +1,4 @@
import { Pattern, getDrawContext, silence, register, pure } from './index.mjs'; import { Pattern, getDrawContext, silence, register, pure, createParams } from './index.mjs';
import controls from './controls.mjs'; // do not import from index.mjs as it breaks for some reason..
const { createParams } = controls;
let clearColor = '#22222210'; let clearColor = '#22222210';

View File

@ -4,23 +4,23 @@ Copyright (C) 2023 Strudel contributors - see <https://github.com/tidalcycles/st
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import controls from '../controls.mjs'; import { s } from '../controls.mjs';
import { mini } from '../../mini/mini.mjs'; import { mini } from '../../mini/mini.mjs';
import { describe, it, expect } from 'vitest'; import { describe, it, expect } from 'vitest';
describe('controls', () => { describe('controls', () => {
it('should support controls', () => { it('should support controls', () => {
expect(controls.s('bd').firstCycleValues).toEqual([{ s: 'bd' }]); expect(s('bd').firstCycleValues).toEqual([{ s: 'bd' }]);
}); });
it('should support compound controls', () => { it('should support compound controls', () => {
expect(controls.s(mini('bd:3')).firstCycleValues).toEqual([{ s: 'bd', n: 3 }]); expect(s(mini('bd:3')).firstCycleValues).toEqual([{ s: 'bd', n: 3 }]);
expect(controls.s(mini('bd:3 sd:4:1.4')).firstCycleValues).toEqual([ expect(s(mini('bd:3 sd:4:1.4')).firstCycleValues).toEqual([
{ s: 'bd', n: 3 }, { s: 'bd', n: 3 },
{ s: 'sd', n: 4, gain: 1.4 }, { s: 'sd', n: 4, gain: 1.4 },
]); ]);
}); });
it('should support ignore extra elements in compound controls', () => { it('should support ignore extra elements in compound controls', () => {
expect(controls.s(mini('bd:3:0.4 sd:4:0.5:3:17')).firstCycleValues).toEqual([ expect(s(mini('bd:3:0.4 sd:4:0.5:3:17')).firstCycleValues).toEqual([
{ s: 'bd', n: 3, gain: 0.4 }, { s: 'bd', n: 3, gain: 0.4 },
{ s: 'sd', n: 4, gain: 0.5 }, { s: 'sd', n: 4, gain: 0.5 },
]); ]);

View File

@ -51,9 +51,8 @@ import {
import { steady } from '../signal.mjs'; import { steady } from '../signal.mjs';
import controls from '../controls.mjs'; import { n, s } from '../controls.mjs';
const { n, s } = controls;
const st = (begin, end) => new State(ts(begin, end)); const st = (begin, end) => new State(ts(begin, end));
const ts = (begin, end) => new TimeSpan(Fraction(begin), Fraction(end)); const ts = (begin, end) => new TimeSpan(Fraction(begin), Fraction(end));
const hap = (whole, part, value, context = {}) => new Hap(whole, part, value, context); const hap = (whole, part, value, context = {}) => new Hap(whole, part, value, context);

View File

@ -6,8 +6,7 @@ This program is free software: you can redistribute it and/or modify it under th
import { describe, it, expect } from 'vitest'; import { describe, it, expect } from 'vitest';
import { map, valued, mul } from '../value.mjs'; import { map, valued, mul } from '../value.mjs';
import controls from '../controls.mjs'; import { n } from '../controls.mjs';
const { n } = controls;
describe('Value', () => { describe('Value', () => {
it('unionWith', () => { it('unionWith', () => {

View File

@ -1,4 +1,4 @@
import { controls, noteToMidi, valueToMidi, Pattern, evalScope } from '@strudel/core'; import { noteToMidi, valueToMidi, Pattern, evalScope } from '@strudel/core';
import { registerSynthSounds, registerZZFXSounds, samples } from '@strudel/webaudio'; import { registerSynthSounds, registerZZFXSounds, samples } from '@strudel/webaudio';
import * as core from '@strudel/core'; import * as core from '@strudel/core';
@ -17,7 +17,6 @@ export async function prebake() {
// import('@strudel/serial'), // import('@strudel/serial'),
// import('@strudel/csound'), // import('@strudel/csound'),
// import('@strudel/osc'), // import('@strudel/osc'),
controls, // sadly, this cannot be exported from core directly (yet)
); );
// load samples // load samples
const ds = 'https://raw.githubusercontent.com/felixroos/dough-samples/main/'; const ds = 'https://raw.githubusercontent.com/felixroos/dough-samples/main/';

View File

@ -7,10 +7,9 @@ This program is free software: you can redistribute it and/or modify it under th
// import { strict as assert } from 'assert'; // import { strict as assert } from 'assert';
import '../tonal.mjs'; // need to import this to add prototypes import '../tonal.mjs'; // need to import this to add prototypes
import { pure, controls, seq } from '@strudel/core'; import { pure, n, seq } from '@strudel/core';
import { describe, it, expect } from 'vitest'; import { describe, it, expect } from 'vitest';
import { mini } from '../../mini/mini.mjs'; import { mini } from '../../mini/mini.mjs';
const { n } = controls;
describe('tonal', () => { describe('tonal', () => {
it('Should run tonal functions ', () => { it('Should run tonal functions ', () => {

View File

@ -5,7 +5,7 @@ export * from '@strudel/transpiler';
export * from '@strudel/mini'; export * from '@strudel/mini';
export * from '@strudel/tonal'; export * from '@strudel/tonal';
export * from '@strudel/webaudio'; export * from '@strudel/webaudio';
import { Pattern, evalScope, controls } from '@strudel/core'; import { Pattern, evalScope } from '@strudel/core';
import { initAudioOnFirstClick, registerSynthSounds, webaudioScheduler } from '@strudel/webaudio'; import { initAudioOnFirstClick, registerSynthSounds, webaudioScheduler } from '@strudel/webaudio';
// import { registerSoundfonts } from '@strudel/soundfonts'; // import { registerSoundfonts } from '@strudel/soundfonts';
import { evaluate as _evaluate } from '@strudel/transpiler'; import { evaluate as _evaluate } from '@strudel/transpiler';
@ -15,7 +15,6 @@ import { miniAllStrings } from '@strudel/mini';
export async function defaultPrebake() { export async function defaultPrebake() {
const loadModules = evalScope( const loadModules = evalScope(
evalScope, evalScope,
controls,
import('@strudel/core'), import('@strudel/core'),
import('@strudel/mini'), import('@strudel/mini'),
import('@strudel/tonal'), import('@strudel/tonal'),

View File

@ -12,9 +12,8 @@ npm i @strudel/webaudio --save
## Example ## Example
```js ```js
import { repl, controls } from "@strudel/core"; import { repl, note } from "@strudel/core";
import { initAudioOnFirstClick, getAudioContext, webaudioOutput } from "@strudel/webaudio"; import { initAudioOnFirstClick, getAudioContext, webaudioOutput } from "@strudel/webaudio";
const { note } = controls;
initAudioOnFirstClick(); initAudioOnFirstClick();
const ctx = getAudioContext(); const ctx = getAudioContext();

View File

@ -7,7 +7,6 @@ import { evaluate } from '@strudel/transpiler';
import { evalScope } from '@strudel/core'; import { evalScope } from '@strudel/core';
import * as strudel from '@strudel/core'; import * as strudel from '@strudel/core';
import * as webaudio from '@strudel/webaudio'; import * as webaudio from '@strudel/webaudio';
import controls from '@strudel/core/controls.mjs';
// import gist from '@strudel/core/gist.js'; // import gist from '@strudel/core/gist.js';
import { mini, m } from '@strudel/mini/mini.mjs'; import { mini, m } from '@strudel/mini/mini.mjs';
// import * as voicingHelpers from '@strudel/tonal/voicings.mjs'; // import * as voicingHelpers from '@strudel/tonal/voicings.mjs';
@ -21,7 +20,6 @@ import '@strudel/xen/xen.mjs';
// import '@strudel/osc/osc.mjs'; // import '@strudel/osc/osc.mjs';
// import '@strudel/webaudio/webaudio.mjs'; // import '@strudel/webaudio/webaudio.mjs';
// import '@strudel/serial/serial.mjs'; // import '@strudel/serial/serial.mjs';
// import controls from '@strudel/core/controls.mjs';
import '../website/src/repl/piano'; import '../website/src/repl/piano';
class MockedNode { class MockedNode {
@ -153,10 +151,9 @@ evalScope(
strudel, strudel,
toneHelpersMocked, toneHelpersMocked,
uiHelpersMocked, uiHelpersMocked,
controls,
webaudio, webaudio,
tonalHelpers, tonalHelpers,
/* controls, /*
toneHelpers, toneHelpers,
voicingHelpers, voicingHelpers,
drawHelpers, drawHelpers,

View File

@ -1,4 +1,4 @@
import { controls, evalScope, hash2code, logger } from '@strudel/core'; import { evalScope, hash2code, logger } from '@strudel/core';
import { settingPatterns, defaultAudioDeviceName } from '../settings.mjs'; import { settingPatterns, defaultAudioDeviceName } from '../settings.mjs';
import { getAudioContext, initializeAudioOutput, setDefaultAudioContext } from '@strudel/webaudio'; import { getAudioContext, initializeAudioOutput, setDefaultAudioContext } from '@strudel/webaudio';
@ -92,11 +92,7 @@ export function loadModules() {
modules = modules.concat([import('@strudel/midi'), import('@strudel/osc')]); modules = modules.concat([import('@strudel/midi'), import('@strudel/osc')]);
} }
return evalScope( return evalScope(settingPatterns, ...modules);
controls, // sadly, this cannot be exported from core direclty
settingPatterns,
...modules,
);
} }
let lastShared; let lastShared;