<commit_before>## Waveform visualiser

> Waveform drawing utility

Use this module to visualise waveform data over a shared timeline.  
The module relies on the [timeline](https://github.com/Ircam-RnD/timeLine) object.

### Demo

A working demo for this module can be found [here](https://github.com/Ircam-RnD/waveform-vis)

### Public API

##### `params(parameters)`

> @param `parameters` {object}  
> inherited from LayerVis, allow to customize the waveform from a layer perspective. 

_example:_ 

```javascript
var waveform = waveform()
  .params({
    // the y domain of the data - default to [-1, 1] 
    // according to the domain of an audio buffer 
    yDomain: [-1, 1],
    // rendering strategy `canvas` or `svg`, 
    // defaults to svg
    renderingStrategy: 'svg',
    // zoom delta before updating underlaying data
    triggerUpdateZoomDelta: 0.01
  });
```

##### `data(data)`

> @param `data` {ArrayBuffer|Array}  
> an ArrayBuffer to display

##### `duration(duration)`

> @param `duration` {int}  
> duration of the ArrayBuffer to display (in second)  

##### `sampleRate(sampleRate)`

> @param `sampleRate` {int}    
> the sample rate of the ArrayBuffer to display (default 441000)

##### `color(color)`

> @param `color` {string}  
> color of the waveform


#### Example use

```javascript
var d3 = require('d3');
var timeline = require('timeline');
var waveform = require('waveform');
var buffer = someAudioBuffer;

// create the graph
var graph = timeline()
  .xDomain([0, buffer.duration])
  .width(1000)
  .height(150)
  
// create the waveform layer
var waveformLayer = waveform()
  .params({ name: 'my-waveform' })
  // pass the raw ArrayBuffer from audio buffer
  .data(buffer.getChannelData(0).buffer)
  .sampleRate(buffer.sampleRate)
  .duration(buffer.duration)
  .color('steelblue');

// add the waveform layer to the timeline
graph.layer(waveformLayer);

// draw the timeline
d3.select('#timeline').call(graph.draw);
```

### Status

This library is under heavy development and subject to change.  
Evert new API breaking change we will be adding snapshots to the repository so you can always fetch a working copy.

For an in depth  explanation on the philosophy and usage of this library please refer to [this blog post](http://wave.ircam.fr/publications/visual-tools/).
## License
This module is released under the [BSD-3-Clause license](http://opensource.org/licenses/BSD-3-Clause).
## Acknowledgments
This code is part of the [WAVE project](http://wave.ircam.fr),  
funded by ANR (The French National Research Agency),  
_ContInt_ program,  
2012-2015.<commit_msg>readme doc work in progress<commit_after># Waveform visualiser

Use this module to visualise waveform data over a shared timeline.  
The module relies on the [timeline](https://github.com/Ircam-RnD/timeLine) object.

_A working demo for this module can be found [here](#)_

## Example usage

```javascript
var d3 = require('d3');
var timeline = require('timeline');
var waveform = require('waveform');
var buffer = someAudioBuffer;

// create the graph
var graph = timeline()
  .xDomain([0, buffer.duration])
  .width(1000)
  .height(150)
  
// create the waveform layer
var waveformLayer = waveform()
  .params({ name: 'my-waveform' })
  // pass the raw ArrayBuffer from our audio buffer
  .data(buffer.getChannelData(0).buffer)
  .sampleRate(buffer.sampleRate)
  .duration(buffer.duration)
  .color('steelblue');

// add the waveform layer to the timeline
graph.layer(waveformLayer);

// draw the timeline
d3.select('#timeline').call(graph.draw);
```


## Public API

### params
`.params({ yDomain, renderingStrategy, triggerUpdateZoomDelta triggerUpdateDragDelta, [name] })`   

> Sets the state on the layer level.

> * @key `yDomain`, @value `[int, int]`  
> Sets the layer's scale's domain to the specified array of numbers. The array must contain two or more numbers.

> * @key `renderingStrategy`, @value `'svg|canvas'`, @defaults `'svg'`  
> Sets the layer's rendering strategy.

> * @key `triggerUpdateZoomDelta`, @value `float`, @defaults `0.02`  
> Sets the minimum zoom delta level that will trigger an update call.

> * @key `triggerUpdateDragDelta`, @value `float`, @defaults `0.02`  
> Sets the minimum dragged delta (in pixels) dragged that will trigger an update call.


### data 
`.data(data)`

> Sets the data to be rendered
> * @param `data`, @value `array|ArrayBuffer`, @defaults `0.02`  

##### `duration(duration)`

> @param `duration` {int}  
> duration of the ArrayBuffer to display (in second)  

##### `sampleRate(sampleRate)`

> @param `sampleRate` {int}    
> the sample rate of the ArrayBuffer to display (default 441000)

##### `color(color)`

> @param `color` {string}  
> color of the waveform



### Status

This library is under heavy development and subject to change.  
Evert new API breaking change we will be adding snapshots to the repository so you can always fetch a working copy.

For an in depth  explanation on the philosophy and usage of this library please refer to [this blog post](http://wave.ircam.fr/publications/visual-tools/).
## License
This module is released under the [BSD-3-Clause license](http://opensource.org/licenses/BSD-3-Clause).
## Acknowledgments
This code is part of the [WAVE project](http://wave.ircam.fr),  
funded by ANR (The French National Research Agency),  
_ContInt_ program,  
2012-2015.
{'fraction_non_alphanumeric': 0.1257685858021241, 'fraction_numerical': 0.013415315818893237, 'mean_word_length': 4.181467181467181, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 31, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6375110', 'n_tokens_mistral': 1699, 'n_tokens_neox': 1592, 'n_words': 588}