Skip to content

Commit

Permalink
Rewrite scripts/docs.js
Browse files Browse the repository at this point in the history
The funcs.md file had diverged quite a lot from what the script
generated. The new script means we can again autogenerate funcs.md
from the hydra-synth/src/composable-glsl-functions.js file.
  • Loading branch information
ssssam committed Dec 9, 2019
1 parent a3c4a96 commit 05b69b6
Show file tree
Hide file tree
Showing 2 changed files with 385 additions and 44 deletions.
264 changes: 264 additions & 0 deletions docs/funcs.md.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,264 @@
{{! This is a mustache template for the Hydra function documentation.
The funcs.md file is generated by `scripts/docs.js` using this template.
}}
# Functions

- [Categories of functions](#categories)
- [Complete contents of functions](#contents)

## Categories

- [Audio](#audio)
- [Color](#color)
- [Geometry](#geometry)
- [Global variables](#global-variables)
- [Modulators](#modulators)
- [Operators](#operators)
- [Sources](#sources)
- [Parameter sequences](#parameter-sequences)

## Contents

- [Audio](#audio)
- [hide](#hide)
- [setBins](#setbins)
- [setCutoff](#setcutoff)
- [setScale](#setScale)
- [setSmooth](#setSmooth)
- [show](#show)
- [Color](#color)
{{ category-toc-color }}
- [Geometry](#geometry)
{{ category-toc-geometry }}
- [Global variables](#global-variables)
- [mouse](#mouse)
- [time](#time)
- [Modulators](#modulators)
{{ category-toc-modulators }}
- [Operators](#operators)
{{ category-toc-operators }}
- [Sources](#sources)
{{ category-toc-sources }}
- [out](#out)
- [render](#render)
- [Parameter sequences](#parameter-sequences)
- [Lists as parameter sequences](#lists-as-parameter-sequences)
- [Functions on parameter sequences](#functions-on-parameter-sequences)
- [fast](#fast)

---

## Audio

Functions for manipulating audio signals.

- [hide](#hide)
- [setBins](#setbins)
- [setCutoff](#setcutoff)
- [setScale](#setScale)
- [setSmooth](#setSmooth)
- [show](#show)

### hide

`.hide()`

### setBins

`.setBins( bins )`

* `bins` :: integer (default `x`)

### setCutoff

`.setCutoff( frequency )`

* `frequency` :: float (default `x`)

### setScale

`.setScale( amount )`

* `amount` :: float (default `x`)

### setSmooth

`.setSmooth( amount )`

* `amount` :: float (default `x`)

### show

`.show()`

---

## Color

Functions for manipulating color.

{{ category-toc-color }}

{{& functions-color }}

---

## Geometry

Functions for manipulating geometry.

{{ category-toc-geometry }}

{{& functions-geometry }}

---

## Global variables

Useful variables that are defined globally, and can be used within functions as a parameter.

- [mouse](#mouse)
- [time](#time)

### mouse

`mouse`

* `.x` :: x position of mouse
* `.y` :: y position of mouse

#### Example

Control the oscillator frequency with the mouse position:

```javascript
osc(() => mouse.x).out(o0)
```

### time

`time`

* `time` :: the current time

#### Example

Control the oscillator using a sine wave based on the current time:

```javascript
osc( ({time}) => Math.sin(time) ).out(o0)
```

---

## Modulators

Functions for describing modulations of sources.

{{ category-toc-modulators }}

{{& functions-modulators }}

## Operators

Functions for performing operations on sources.

{{ category-toc-operators }}

{{& functions-operators }}

---

## Sources

Sources are elementary generators that output different types of visual content.

{{ category-toc-sources }}
- [out](#out)
- [render](#render)

{{& functions-sources }}

### out

`.out( buffer )`

* `buffer`
* `osc`: `o0`, `o1`, `o2`, `o3`
* `src`: `s0`, `s1`, `s2`, `s3`

#### Example

```javascript
// output four oscillators to different buffers
// and then modulate them together
osc( [1,10,50,100,250,500].fast(2) ).kaleid(20).out(o0) // frequency
osc( ({time}) => Math.sin(time/10) * 100 ).kaleid(19).out(o1) // frequency 2
osc( 10, [-10,-1,-0.1,0,0.1,1,10], 0 ).kaleid(21).out(o2) // sync
osc(10,0.1, ({time}) => Math.sin(time/10) * 1 ) // offset
.modulate(o1,0.05)
.modulate(o2,0.05)
.modulate(o3,0.05)
.kaleid(20)
.add(noise(3,10))
.out(o3)
render(o3)
```

### render

`render( buffer )`

* `buffer`: buffer (default `o0`)

#### Example

```javascript
osc( [1,10,50,100,250,500].fast(2) ).out(o0) // frequency
osc( ({time}) => Math.sin(time/10) * 100 ).out(o1) // frequency 2
osc( 10, [-10,-1,-0.1,0,0.1,1,10], 0 ).out(o2) // sync
osc(10,0.1, ({time}) => Math.sin(time/10) * 100 ).out(o3) // offset

render(o0) // change to o1, o2, or o3
```

```javascript
// see all four buffers at once
osc( [1,10,50,100,250,500].fast(2) ).out(o0) // frequency
osc( ({time}) => Math.sin(time/10) * 100 ).out(o1) // frequency 2
osc( 10, [-10,-1,-0.1,0,0.1,1,10], 0 ).out(o2) // sync
osc(10,0.1, ({time}) => Math.sin(time/10) * 100 ).out(o3) // offset
render()
```

---

## Parameter sequences

- [Lists as parameter sequences](#lists-as-parameter-sequences)
- [Functions on parameter sequences](#functions-on-parameter-sequences)
- [fast](#fast)

### Lists as parameter sequences

```
osc(
[80, 100, 200, 50], 1 )
)
.out(o0)
```

### Functions on parameter sequences

#### fast

`fast ( amount) `

* `amount` :: float (default `x`)

```
osc(
[80, 100, 200, 50].fast(0.2), 1 )
)
.out(o0)
```
Loading

0 comments on commit 05b69b6

Please sign in to comment.