Skip to content

Commit

Permalink
docs: Add docs about fft() for hydra
Browse files Browse the repository at this point in the history
  • Loading branch information
munshkr committed Dec 30, 2024
1 parent 0466e5f commit 99bce8d
Showing 1 changed file with 42 additions and 5 deletions.
47 changes: 42 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ run Flok in secure mode by passing the `--secure` parameter:

```sh
npx flok-web@latest --secure
```
```

#### Note about remote users (not LAN)

Expand Down Expand Up @@ -159,7 +159,7 @@ object, like this:

#### Sardine

Use `flok-repl` with the `-t sardine` parameter. In order to make it work,
Use `flok-repl` with the `-t sardine` parameter. In order to make it work,
the `sardine` REPL must be included to your PATH. It should already be the
case if you followed a regular install.

Expand Down Expand Up @@ -217,14 +217,51 @@ installing and using it.

#### Hydra

[Hydra](https://hydra.ojack.xyz/) is a video synth and coding environment, inspired in
analog video synthesis, that runs directly in the browser and is already included in
[Hydra](https://hydra.ojack.xyz/) is a video synth and coding environment, inspired in
analog video synthesis, that runs directly in the browser and is already included in
the web App. You don't need to install anything as it runs on the browser. Just use
the `hydra` target to execute Hydra code.

You can also use [p5.js](https://p5js.org/) within a `hydra` target, like you would in
You can also use [p5.js](https://p5js.org/) within a `hydra` target, like you would in
the official Hydra editor.

##### `fft()` function

The `fft()` function is a special function that allows you to get the FFT data
from web targets. Note: Only Strudel is supported at the moment.

```ts
fft(index: number,
buckets: number = 8,
options?: { min?: number; max?: number, scale?: number, analyzerId?: string }): number
```

Parameters:
- `index: number` : The index of the bucket to return the value from.
- `buckets: number`: The number of buckets to combine the underlying FFT data
too. Defaults to 8.
- `options?: { min?: number; max?: number, scale?: number }`:
- `min?: number`: Minimum clamp value of the underlying data. Defaults to
-150.
- `max?: number`: Maximum clamp value of the underlying data. Defaults to 0.
- `scale?: number`: Scale of the output. Defaults to 1 (so the output is
from 0 to 1)
- `analyzerId?: string`: Which Strudel analyser to listen to. Defaults to
`flok-master`, which is also automatically added to all strudel patterns.
Can be used to route different patterns to different parts of the hydra
visualiser

Example:
```js
solid(() => fft(0,1), 0)
.mask(shape(5,.05))
.rotate(() => 50 * fft(0, 40)) // we need to supply a function for the parameter, for it to update automaticaly
```

**Caveat**: Because of how we setup the analyze node on Strudel, every Strudel pane
needs a re-eval after the Hydra code decides that we need to get the fft data.
This does not happen automatically, manual re-eval is necessary.

#### Mercury

[Mercury](https://github.com/tmhglnd/mercury) is a minimal and human readable
Expand Down

0 comments on commit 99bce8d

Please sign in to comment.