-
-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #759 from tidalcycles/hydra-integration
Hydra integration
- Loading branch information
Showing
11 changed files
with
350 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,4 +19,5 @@ vite.config.js | |
**/dev-dist | ||
**/dist | ||
/src-tauri/target/**/* | ||
reverbGen.mjs | ||
reverbGen.mjs | ||
hydra.mjs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') | ||
) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
}, | ||
}); |
Oops, something went wrong.