Skip to content

Commit

Permalink
Merge pull request #759 from tidalcycles/hydra-integration
Browse files Browse the repository at this point in the history
Hydra integration
  • Loading branch information
felixroos authored Oct 26, 2023
2 parents 5958c69 + 3ce50d8 commit 4761e25
Show file tree
Hide file tree
Showing 11 changed files with 350 additions and 45 deletions.
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ vite.config.js
**/dev-dist
**/dist
/src-tauri/target/**/*
reverbGen.mjs
reverbGen.mjs
hydra.mjs
29 changes: 29 additions & 0 deletions packages/hydra/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# @strudel/hydra

This package integrates [hydra-synth](https://www.npmjs.com/package/hydra-synth) into strudel.

## Usage in Strudel

This package is imported into strudel by default. To activate Hydra, place this code at the top of your code:

```js
await initHydra();
```

Then you can use hydra below!

## Usage via npm

```sh
npm i @strudel/hydra
```

Then add the import to your evalScope:

```js
import { evalScope } from '@strudel.cycles/core';

evalScope(
import('@strudel/hydra')
)
```
15 changes: 15 additions & 0 deletions packages/hydra/hydra.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { getDrawContext } from '@strudel.cycles/core';

export async function initHydra() {
if (!document.getElementById('hydra-canvas')) {
const { canvas: testCanvas } = getDrawContext();
await import('https://unpkg.com/hydra-synth');
const hydraCanvas = testCanvas.cloneNode(true);
hydraCanvas.id = 'hydra-canvas';
testCanvas.after(hydraCanvas);
new Hydra({ canvas: hydraCanvas, detectAudio: false });
s0.init({ src: testCanvas });
}
}

export const H = (p) => () => p.queryArc(getTime(), getTime())[0].value;
43 changes: 43 additions & 0 deletions packages/hydra/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"name": "@strudel/hydra",
"version": "0.9.0",
"description": "Hydra integration for strudel",
"main": "hydra.mjs",
"publishConfig": {
"main": "dist/index.js",
"module": "dist/index.mjs"
},
"scripts": {
"server": "node server.js",
"tidal-sniffer": "node tidal-sniffer.js",
"client": "npx serve -p 4321",
"build-bin": "npx pkg server.js --targets node16-macos-x64,node16-win-x64,node16-linux-x64 --out-path bin",
"build": "vite build",
"prepublishOnly": "npm run build"
},
"repository": {
"type": "git",
"url": "git+https://github.com/tidalcycles/strudel.git"
},
"keywords": [
"tidalcycles",
"strudel",
"pattern",
"livecoding",
"algorave"
],
"author": "Felix Roos <[email protected]>",
"license": "AGPL-3.0-or-later",
"bugs": {
"url": "https://github.com/tidalcycles/strudel/issues"
},
"homepage": "https://github.com/tidalcycles/strudel#readme",
"dependencies": {
"@strudel.cycles/core": "workspace:*",
"hydra-synth": "^1.3.29"
},
"devDependencies": {
"pkg": "^5.8.1",
"vite": "^4.3.3"
}
}
19 changes: 19 additions & 0 deletions packages/hydra/vite.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { defineConfig } from 'vite';
import { dependencies } from './package.json';
import { resolve } from 'path';

// https://vitejs.dev/config/
export default defineConfig({
plugins: [],
build: {
lib: {
entry: resolve(__dirname, 'hydra.mjs'),
formats: ['es', 'cjs'],
fileName: (ext) => ({ es: 'index.mjs', cjs: 'index.js' }[ext]),
},
rollupOptions: {
external: [...Object.keys(dependencies)],
},
target: 'esnext',
},
});
Loading

0 comments on commit 4761e25

Please sign in to comment.