Compare commits

..

7 Commits

6 changed files with 49 additions and 19 deletions
+6 -6
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);
+4 -4
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);
}); });
+10
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.
+1 -1
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",
+18 -8
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);
+10
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: