mirror of
https://codeberg.org/uzu/strudel
synced 2026-11-26 18:23:58 -05:00
fix old core imports to use pattern package
This commit is contained in:
+1
-1
@@ -80,4 +80,4 @@
|
||||
"engines": {
|
||||
"node": ">=18.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ Copyright (C) 2022 Strudel contributors - see <https://codeberg.org/uzu/strudel/
|
||||
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 { Pattern, pure, register, reify, logger } from './pattern.mjs';
|
||||
import { Pattern, pure, register, reify, logger } from '@strudel/pattern';
|
||||
|
||||
export function createParam(names) {
|
||||
let isMulti = Array.isArray(names);
|
||||
|
||||
+34
-1
@@ -6,10 +6,43 @@ This program is free software: you can redistribute it and/or modify it under th
|
||||
|
||||
import * as controls from './controls.mjs'; // legacy
|
||||
import createClock from './zyklus.mjs';
|
||||
export { Fraction, controls, createClock };
|
||||
import { Pattern } from '@strudel/pattern';
|
||||
export { controls, createClock };
|
||||
export * from '@strudel/pattern';
|
||||
export * from './controls.mjs';
|
||||
export * from './cyclist.mjs';
|
||||
export * from './repl.mjs';
|
||||
export * from './speak.mjs';
|
||||
export * from './schedulerState.mjs';
|
||||
export * from './ui.mjs';
|
||||
import { getClockTime } from './schedulerState.mjs';
|
||||
|
||||
// legacy:
|
||||
Pattern.prototype.onTrigger = function (onTrigger, dominant = true) {
|
||||
console.warn('onTrigger is deprecated.. use onSchedule(hap, time, cps) instead');
|
||||
return this.onSchedule((hap, t, cps) => {
|
||||
const currentTime = getClockTime();
|
||||
return onTrigger(hap, currentTime, cps, t);
|
||||
}, dominant);
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* make something happen on event time
|
||||
* uses browser timeout which is innacurate for audio tasks
|
||||
* @param {Function} func
|
||||
* @name onTriggerTime
|
||||
* @tags external_io
|
||||
* @memberof Pattern.prototype
|
||||
* @returns {Pattern}
|
||||
* @example
|
||||
* s("bd!8").onTriggerTime((hap) => {console.log(hap)})
|
||||
*/
|
||||
Pattern.prototype.onTriggerTime = function (func) {
|
||||
return this.onSchedule((hap, targetTime) => {
|
||||
const diff = targetTime - getClockTime();
|
||||
setTimeout(() => {
|
||||
func(hap);
|
||||
}, diff * 1000);
|
||||
}, false);
|
||||
};
|
||||
|
||||
@@ -4,8 +4,7 @@ Copyright (C) 2022 Strudel contributors - see <https://codeberg.org/uzu/strudel/
|
||||
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 { logger } from './logger.mjs';
|
||||
import { ClockCollator, cycleToSeconds } from './util.mjs';
|
||||
import { logger, ClockCollator, cycleToSeconds } from '@strudel/pattern';
|
||||
|
||||
export class NeoCyclist {
|
||||
constructor({ onSchedule, onToggle, getTime, onTrigger }) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { NeoCyclist } from './neocyclist.mjs';
|
||||
import { Cyclist } from './cyclist.mjs';
|
||||
import { evaluate as _evaluate } from './evaluate.mjs';
|
||||
import { errorLogger, logger } from './logger.mjs';
|
||||
import { evaluate as _evaluate, reset_state } from '@strudel/pattern';
|
||||
import { errorLogger, logger, evalScope, register, Pattern, isPattern, silence, stack } from '@strudel/pattern';
|
||||
import {
|
||||
setCpsFunc,
|
||||
setIsStarted,
|
||||
@@ -10,9 +10,6 @@ import {
|
||||
setScheduleFunc,
|
||||
setClockTime,
|
||||
} from './schedulerState.mjs';
|
||||
import { evalScope } from './evaluate.mjs';
|
||||
import { register, Pattern, isPattern, silence, stack } from './pattern.mjs';
|
||||
import { reset_state } from './impure.mjs';
|
||||
|
||||
export function repl({
|
||||
onSchedule,
|
||||
|
||||
@@ -7,7 +7,7 @@ This program is free software: you can redistribute it and/or modify it under th
|
||||
import { s, pan, getControlName } from '../controls.mjs';
|
||||
import { mini } from '../../mini/mini.mjs';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import Fraction from '../fraction.mjs';
|
||||
import { Fraction } from '@strudel/pattern';
|
||||
|
||||
describe('controls', () => {
|
||||
it('should support controls', () => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { listen } from '@tauri-apps/api/event';
|
||||
import { logger } from '../core/logger.mjs';
|
||||
import { logger } from '@strudel/core';
|
||||
|
||||
// listen for log events from the Tauri backend and log in the UI
|
||||
await listen('log-event', (e) => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, bench } from 'vitest';
|
||||
|
||||
import { calculateSteps } from '../../core/index.mjs';
|
||||
import { calculateSteps } from '@strudel/pattern';
|
||||
import { mini } from '../index.mjs';
|
||||
|
||||
describe('mini', () => {
|
||||
|
||||
@@ -5,8 +5,8 @@ This program is free software: you can redistribute it and/or modify it under th
|
||||
*/
|
||||
|
||||
import * as krill from './krill-parser.js';
|
||||
import * as strudel from '@strudel/core';
|
||||
import Fraction, { lcm } from '@strudel/core/fraction.mjs';
|
||||
import * as strudel from '@strudel/pattern';
|
||||
import { Fraction, lcm } from '@strudel/pattern';
|
||||
|
||||
const randOffset = 0.0003;
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
},
|
||||
"homepage": "https://codeberg.org/uzu/strudel#readme",
|
||||
"dependencies": {
|
||||
"@strudel/core": "workspace:*"
|
||||
"@strudel/pattern": "workspace:*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"peggy": "^4.2.0",
|
||||
|
||||
@@ -5,8 +5,8 @@ This program is free software: you can redistribute it and/or modify it under th
|
||||
*/
|
||||
|
||||
import { getLeafLocation, getLeafLocations, mini, mini2ast } from '../mini.mjs';
|
||||
import '@strudel/core/euclid.mjs';
|
||||
import { Fraction } from '@strudel/core/index.mjs';
|
||||
import '@strudel/pattern';
|
||||
import { Fraction } from '@strudel/pattern';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
describe('mini', () => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// motion.mjs
|
||||
|
||||
import { signal } from '../core/signal.mjs';
|
||||
import { signal } from '@strudel/core';
|
||||
|
||||
/**
|
||||
* The accelerometer's x-axis value ranges from 0 to 1.
|
||||
|
||||
@@ -5,9 +5,9 @@ This program is free software: you can redistribute it and/or modify it under th
|
||||
*/
|
||||
|
||||
export * from './euclid.mjs';
|
||||
import Fraction from './fraction.mjs';
|
||||
import Fraction, { lcm } from './fraction.mjs';
|
||||
import { logger } from './logger.mjs';
|
||||
export { Fraction };
|
||||
export { Fraction, lcm };
|
||||
export * from './evaluate.mjs';
|
||||
export * from './hap.mjs';
|
||||
export * from './impure.mjs';
|
||||
|
||||
@@ -5,7 +5,7 @@ let debounce = 1000,
|
||||
lastTime;
|
||||
|
||||
export function errorLogger(e, origin = 'cyclist') {
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
if (typeof process !== 'undefined' && process.env.NODE_ENV === 'development') {
|
||||
console.error(e);
|
||||
}
|
||||
logger(`[${origin}] error: ${e.message}`);
|
||||
|
||||
@@ -27,7 +27,6 @@ import {
|
||||
import drawLine from './drawLine.mjs';
|
||||
import { errorLogger, logger } from './logger.mjs';
|
||||
import { strudelScope } from './evaluate.mjs';
|
||||
import { getClockTime } from './schedulerState.mjs';
|
||||
|
||||
let stringParser;
|
||||
|
||||
@@ -959,15 +958,6 @@ export class Pattern {
|
||||
);
|
||||
}
|
||||
|
||||
// legacy:
|
||||
onTrigger(onTrigger, dominant = true) {
|
||||
console.warn('onTrigger is deprecated.. use onSchedule(hap, time, cps) instead');
|
||||
return this.onSchedule((hap, t, cps) => {
|
||||
const currentTime = getClockTime();
|
||||
return onTrigger(hap, currentTime, cps, t);
|
||||
}, dominant);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the content of the current event to the console (visible in the side menu).
|
||||
* @param {Function} [func]
|
||||
@@ -4057,27 +4047,6 @@ export const slice = register(
|
||||
false, // turns off auto-patternification
|
||||
);
|
||||
|
||||
/**
|
||||
*
|
||||
* make something happen on event time
|
||||
* uses browser timeout which is innacurate for audio tasks
|
||||
* @param {Function} func
|
||||
* @name onTriggerTime
|
||||
* @tags external_io
|
||||
* @memberof Pattern.prototype
|
||||
* @returns {Pattern}
|
||||
* @example
|
||||
* s("bd!8").onTriggerTime((hap) => {console.log(hap)})
|
||||
*/
|
||||
Pattern.prototype.onTriggerTime = function (func) {
|
||||
return this.onSchedule((hap, targetTime) => {
|
||||
const diff = targetTime - getClockTime();
|
||||
setTimeout(() => {
|
||||
func(hap);
|
||||
}, diff * 1000);
|
||||
}, false);
|
||||
};
|
||||
|
||||
/**
|
||||
* Works the same as slice, but changes the playback speed of each slice to match the duration of its step.
|
||||
* @name splice
|
||||
|
||||
@@ -58,11 +58,12 @@ import {
|
||||
arp,
|
||||
} from '../index.mjs';
|
||||
|
||||
import { log, logValues, stackCenter } from '../pattern.mjs';
|
||||
import { reify, stackCenter } from '../pattern.mjs';
|
||||
|
||||
import { steady } from '../signal.mjs';
|
||||
|
||||
import { n, s } from '../controls.mjs';
|
||||
let n = (value) => reify(value).fmap((v) => ({ n: v }));
|
||||
let s = (value) => reify(value).fmap((v) => ({ s: v }));
|
||||
|
||||
const st = (begin, end) => new State(ts(begin, end));
|
||||
const ts = (begin, end) => new TimeSpan(Fraction(begin), Fraction(end));
|
||||
@@ -1055,7 +1056,7 @@ describe('Pattern', () => {
|
||||
});
|
||||
describe('hurry', () => {
|
||||
it('Can speed up patterns and sounds', () => {
|
||||
sameFirst(s(sequence('a', 'b')).hurry(2), s(sequence('a', 'b')).fast(2).speed(2));
|
||||
sameFirst(s(sequence('a', 'b')).hurry(2), s(sequence('a', 'b')).fast(2).set({ speed: 2 }));
|
||||
});
|
||||
});
|
||||
/*describe('composable functions', () => {
|
||||
@@ -1405,7 +1406,7 @@ describe('Pattern', () => {
|
||||
describe('logValues', () => {
|
||||
it('logs values to console', () => {
|
||||
const mockConsoleLog = vi.spyOn(console, 'log').mockImplementation(() => {});
|
||||
const pattern = pure('a').note('c#').logValues();
|
||||
const pattern = pure({ s: 'bd', speed: 2 }).logValues();
|
||||
const haps = pattern.queryArc(0, 1);
|
||||
|
||||
// Force a trigger
|
||||
@@ -1414,7 +1415,7 @@ describe('Pattern', () => {
|
||||
});
|
||||
|
||||
expect(mockConsoleLog).toHaveBeenCalledWith(
|
||||
'%c[hap] value:a note:c#',
|
||||
'%c[hap] s:bd speed:2',
|
||||
'background-color: black;color:white;border-radius:15px',
|
||||
);
|
||||
mockConsoleLog.mockRestore();
|
||||
|
||||
Generated
+5
-2
@@ -41,6 +41,9 @@ importers:
|
||||
'@strudel/mini':
|
||||
specifier: workspace:*
|
||||
version: link:packages/mini
|
||||
'@strudel/pattern':
|
||||
specifier: workspace:*
|
||||
version: link:packages/pattern
|
||||
'@strudel/tonal':
|
||||
specifier: workspace:*
|
||||
version: link:packages/tonal
|
||||
@@ -413,9 +416,9 @@ importers:
|
||||
|
||||
packages/mini:
|
||||
dependencies:
|
||||
'@strudel/core':
|
||||
'@strudel/pattern':
|
||||
specifier: workspace:*
|
||||
version: link:../core
|
||||
version: link:../pattern
|
||||
devDependencies:
|
||||
peggy:
|
||||
specifier: ^4.2.0
|
||||
|
||||
+1
-2
@@ -1,6 +1,5 @@
|
||||
import { afterEach } from 'vitest';
|
||||
import { useRNG } from './packages/core/signal.mjs';
|
||||
import { setDefaultJoin } from './packages/core/pattern.mjs';
|
||||
import { useRNG, setDefaultJoin } from './packages/pattern/index.mjs';
|
||||
|
||||
afterEach(() => {
|
||||
// Avoid bleed between tests
|
||||
|
||||
Reference in New Issue
Block a user