UNPKG

3.99 kBMarkdownView Raw
1# TwelveTetFretboard
2
3> TwelveTetFretboard is a small fretboard utility library for Javascript. It helps you manipulate pitches on a fretboard.
4
5Please, refer to the [Installation](#installation), [Usage](#usage) and [API](#api) sections for more information.
6
7## Installation <a name="installation"></a>
8
9Install the latest stable version of TwelveTetFretboard using [npm](https://www.npmjs.com/):
10
11```bash
12npm install twelvetet-fretboard twelvetet
13```
14
15You can also [access the files on unpkg.com](https://unpkg.com/twelvetet-fretboard/).
16
17You can use TwelveTetFretboard with module bundlers.
18
19The [npm package](https://www.npmjs.com/package/twelvetet-fretboard) includes precompiled production and development [UMD](https://github.com/umdjs/umd) builds in the `dist/` folder. They can be used without a bundler.
20
21The UMD builds make TwelveTetFretboard available as `window.TwelveTetFretboard` global variable.
22
23TwelveTetFretboard works in [any modern browser](http://caniuse.com/#feat=es5) and Node.js.
24
25## Usage <a name="usage"></a>
26
27```Javascript
28import Fretboard from 'twelvetet-fretboard'
29
30const tuning = ['E2', 'A2', 'D3', 'G3', 'B3', 'E4'] // standard guitar tuning
31const numFrets = 12
32const fretboard = new Fretboard(tuning, numFrets)
33
34console.log(fretboard.at(0, 0).toString()) // E4
35```
36
37## API <a name="api"></a>
38
39## Classes
40
41<dl>
42<dt><a href="#TwelveTetFretboard">TwelveTetFretboard</a></dt>
43<dd></dd>
44</dl>
45
46## Typedefs
47
48<dl>
49<dt><a href="#Position">Position</a></dt>
50<dd></dd>
51</dl>
52
53<a name="TwelveTetFretboard"></a>
54
55## TwelveTetFretboard
56**Kind**: global class
57
58* [TwelveTetFretboard](#TwelveTetFretboard)
59 * [new TwelveTetFretboard(tuning, numFrets, [tuningFrequency])](#new_TwelveTetFretboard_new)
60 * [.positions](#TwelveTetFretboard+positions)
61 * [.at(aStringIndex, aFretIndex)](#TwelveTetFretboard+at) ⇒ [<code>Pitch</code>](https://github.com/adriano-di-giovanni/twelvetet#Pitch)
62
63<a name="new_TwelveTetFretboard_new"></a>
64
65### new TwelveTetFretboard(tuning, numFrets, [tuningFrequency])
66
67| Param | Type | Description |
68| --- | --- | --- |
69| tuning | <code>Array</code> | An array of values representing fretboard tuning. |
70| numFrets | <code>Number</code> | A positive integer indicating the number of frets. |
71| [tuningFrequency] | <code>Number</code> | An optional positive number indicating the tuning frequency. |
72
73**Example**
74```js
75import Fretboard from 'twelvetet-fretboard'
76
77const tuning = ['E2', 'A2', 'D3', 'G3', 'B3', 'E4'] // standard guitar tuning
78const numFrets = 12
79const fretboard = new Fretboard(tuning, numFrets)
80
81console.log(fretboard.at(0, 0).toString()) // E4
82```
83<a name="TwelveTetFretboard+positions"></a>
84
85### twelveTetFretboard.positions
86**Kind**: instance property of [<code>TwelveTetFretboard</code>](#TwelveTetFretboard)
87**Properties**
88
89| Name | Type | Description |
90| --- | --- | --- |
91| positions | [<code>Array.&lt;Position&gt;</code>](#Position) | An array of all the positions on the fretboard |
92
93<a name="TwelveTetFretboard+at"></a>
94
95### twelveTetFretboard.at(aStringIndex, aFretIndex) ⇒ [<code>Pitch</code>](https://github.com/adriano-di-giovanni/twelvetet#Pitch)
96Returns the pitch at `(stringIndex, fretIndex)`
97
98**Kind**: instance method of [<code>TwelveTetFretboard</code>](#TwelveTetFretboard)
99
100| Param | Type | Description |
101| --- | --- | --- |
102| aStringIndex | <code>Number</code> | A zero-based integer indicating the string |
103| aFretIndex | <code>Number</code> | A zero-based integer indicating the fret |
104
105<a name="Position"></a>
106
107## Position
108**Kind**: global typedef
109**Properties**
110
111| Name | Type | Description |
112| --- | --- | --- |
113| pitch | [<code>Pitch</code>](https://github.com/adriano-di-giovanni/twelvetet#Pitch) | The pitch at `(stringIndex, fretIndex)`. |
114| stringIndex | <code>Number</code> | A zero-based integer indicating the string |
115| fretIndex | <code>Number</code> | A zero-based integer indicating the fret |
116
117
118## License
119
120This project is [MIT-licensed](LICENSE)