Merge branch 'main' into glossing/ducking-click

This commit is contained in:
Aria 2025-08-26 12:08:58 -05:00
commit b3e25cfc52
8 changed files with 70 additions and 23 deletions

View file

@ -1,11 +1,11 @@
import { describe, bench } from 'vitest'; import { describe, bench } from 'vitest';
import { calculateTactus, sequence, stack } from '../index.mjs'; import { calculateSteps, sequence, stack } from '../index.mjs';
const pat64 = sequence(...Array(64).keys()); const pat64 = sequence(...Array(64).keys());
describe('steps', () => { describe('steps', () => {
calculateTactus(true); calculateSteps(true);
bench( bench(
'+tactus', '+tactus',
() => { () => {
@ -14,7 +14,7 @@ describe('steps', () => {
{ time: 1000 }, { time: 1000 },
); );
calculateTactus(false); calculateSteps(false);
bench( bench(
'-tactus', '-tactus',
() => { () => {
@ -25,7 +25,7 @@ describe('steps', () => {
}); });
describe('stack', () => { describe('stack', () => {
calculateTactus(true); calculateSteps(true);
bench( bench(
'+tactus', '+tactus',
() => { () => {
@ -34,7 +34,7 @@ describe('stack', () => {
{ time: 1000 }, { time: 1000 },
); );
calculateTactus(false); calculateSteps(false);
bench( bench(
'-tactus', '-tactus',
() => { () => {
@ -43,4 +43,4 @@ describe('stack', () => {
{ time: 1000 }, { time: 1000 },
); );
}); });
calculateTactus(true); calculateSteps(true);

View file

@ -1,10 +1,10 @@
import { describe, bench } from 'vitest'; import { describe, bench } from 'vitest';
import { calculateTactus } from '../../core/index.mjs'; import { calculateSteps } from '../../core/index.mjs';
import { mini } from '../index.mjs'; import { mini } from '../index.mjs';
describe('mini', () => { describe('mini', () => {
calculateTactus(true); calculateSteps(true);
bench( bench(
'+tactus', '+tactus',
() => { () => {
@ -13,7 +13,7 @@ describe('mini', () => {
{ time: 1000 }, { time: 1000 },
); );
calculateTactus(false); calculateSteps(false);
bench( bench(
'-tactus', '-tactus',
() => { () => {
@ -21,5 +21,5 @@ describe('mini', () => {
}, },
{ time: 1000 }, { time: 1000 },
); );
calculateTactus(true); calculateSteps(true);
}); });

View file

@ -20,3 +20,13 @@ samples('http://localhost:5432')
LOG=1 npx @strudel/sampler # adds logging LOG=1 npx @strudel/sampler # adds logging
PORT=5555 npx @strudel/sampler # changes port PORT=5555 npx @strudel/sampler # changes port
``` ```
## static json
when running with `--json`, you will simply get the json logged back:
```sh
npx --yes @strudel/sampler --json > strudel.json
```
this is useful if you want to create a sample pack from the current folder.

View file

@ -1,6 +1,6 @@
{ {
"name": "@strudel/sampler", "name": "@strudel/sampler",
"version": "0.2.0", "version": "0.2.2",
"description": "", "description": "",
"keywords": [ "keywords": [
"tidalcycles", "tidalcycles",

View file

@ -10,14 +10,6 @@ import os from 'os';
// eslint-disable-next-line // eslint-disable-next-line
const LOG = !!process.env.LOG || false; const LOG = !!process.env.LOG || false;
console.log(
cowsay.say({
text: 'welcome to @strudel/sampler',
e: 'oO',
T: 'U ',
}),
);
async function getFilesInDirectory(directory) { async function getFilesInDirectory(directory) {
let files = []; let files = [];
const dirents = await readdir(directory, { withFileTypes: true }); const dirents = await readdir(directory, { withFileTypes: true });
@ -60,8 +52,26 @@ async function getBanks(directory) {
return { banks, files }; return { banks, files };
} }
const args = process.argv.slice(2);
// eslint-disable-next-line // eslint-disable-next-line
const directory = process.cwd(); const directory = process.cwd();
if (args.includes('--json')) {
const { banks, files } = await getBanks(directory);
const json = JSON.stringify(banks);
console.log(json);
process.exit(0);
}
console.log(
cowsay.say({
text: 'welcome to @strudel/sampler',
e: 'oO',
T: 'U ',
}),
);
const server = http.createServer(async (req, res) => { const server = http.createServer(async (req, res) => {
res.setHeader('Access-Control-Allow-Origin', '*'); res.setHeader('Access-Control-Allow-Origin', '*');
const { banks, files } = await getBanks(directory); const { banks, files } = await getBanks(directory);

View file

@ -211,11 +211,29 @@ export function getVibratoOscillator(param, value, t) {
export function webAudioTimeout(audioContext, onComplete, startTime, stopTime) { export function webAudioTimeout(audioContext, onComplete, startTime, stopTime) {
const constantNode = new ConstantSourceNode(audioContext); const constantNode = new ConstantSourceNode(audioContext);
constantNode.start(startTime); // Certain browsers requires audio nodes to be connected in order for their onended events
constantNode.stop(stopTime); // to fire, so we _mute it_ and then connect it to the destination
const zeroGain = gainNode(0);
zeroGain.connect(audioContext.destination);
constantNode.connect(zeroGain);
// Schedule the `onComplete` callback to occur at `stopTime`
constantNode.onended = () => { constantNode.onended = () => {
// Ensure garbage collection
try {
zeroGain.disconnect();
} catch {
// pass
}
try {
constantNode.disconnect();
} catch {
// pass
}
onComplete(); onComplete();
}; };
constantNode.start(startTime);
constantNode.stop(stopTime);
return constantNode; return constantNode;
} }
const mod = (freq, range = 1, type = 'sine') => { const mod = (freq, range = 1, type = 'sine') => {

View file

@ -8,8 +8,7 @@
"start": "astro dev", "start": "astro dev",
"build": "astro build", "build": "astro build",
"preview": "astro preview --port 3009 --host 0.0.0.0", "preview": "astro preview --port 3009 --host 0.0.0.0",
"astro": "astro", "astro": "astro"
"postinstall": "cp node_modules/hs2js/dist/tree-sitter.wasm public && cp node_modules/hs2js/dist/tree-sitter-haskell.wasm public"
}, },
"dependencies": { "dependencies": {
"@algolia/client-search": "^5.20.0", "@algolia/client-search": "^5.20.0",

View file

@ -178,6 +178,16 @@ the version number).
It is also possible, of course, to just remove it from cache (deleting cache in browser Privacy settings, It is also possible, of course, to just remove it from cache (deleting cache in browser Privacy settings,
or from the dev console if you're technically minded, or by using a cache deleting extension). or from the dev console if you're technically minded, or by using a cache deleting extension).
## Generating strudel.json
You can use [@strudel/sampler](https://www.npmjs.com/package/@strudel/sampler) to generate a strudel.json file for you, by running:
```sh
npx --yes @strudel/sampler --json > strudel.json
```
See other uses of strudel/sampler further below, under "From Disk via @strudel/sampler".
## Github Shortcut ## Github Shortcut
Because loading samples from github is common, there is a shortcut: Because loading samples from github is common, there is a shortcut: