Skip to content

Commit 886dbd8

Browse files
committed
Fix export for frequencies tool
1 parent a8e6161 commit 886dbd8

File tree

3 files changed

+37
-17
lines changed

3 files changed

+37
-17
lines changed

README.md

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
11
[![Build Status](https://travis-ci.org/peterkhayes/pitchfinder.svg?branch=master)](https://travis-ci.org/peterkhayes/pitchfinder)
2+
23
# pitchfinder
4+
35
A compilation of pitch detection algorithms for Javascript. Supports both the browser and node.
46

57
## Provided pitch-finding algorithms
6-
- **YIN** - The best balance of accuracy and speed, in my experience. Occasionally provides values that are wildly incorrect.
8+
9+
- **YIN** - The best balance of accuracy and speed, in my experience. Occasionally provides values that are wildly incorrect.
710
- **AMDF** - Slow and only accurate to around +/- 2%, but finds a frequency more consistenly than others.
811
- **Dynamic Wavelet** - Very fast, but struggles to identify lower frequencies.
9-
- **YIN w/ FFT** *(coming soon)*
10-
- **Goertzel** *(coming soon)*
11-
- **Mcleod** *(coming soon)*
12+
- **YIN w/ FFT** _(coming soon)_
13+
- **Goertzel** _(coming soon)_
14+
- **Mcleod** _(coming soon)_
1215

1316
## Installation
17+
1418
`npm install --save pitchfinder`
1519

1620
## Usage
1721

1822
### Finding the pitch of a wav file in node
23+
1924
All pitchfinding algorithms provided operate on `Float32Array`s. To find the pitch of a `wav` file, we can use the `wav-decoder` library to extract the data into such an array.
25+
2026
```javascript
2127
const fs = require("fs");
2228
const WavDecoder = require("wav-decoder");
@@ -32,17 +38,21 @@ const pitch = detectPitch(float32Array); // null if pitch cannot be identified
3238
```
3339

3440
### Finding the pitch of a WebAudio AudioBuffer in the browser
35-
This assumes you are using an npm-compatible build system, like Webpack or Browserify, and that your target browser supports WebAudio. Ample documentation on WebAudio is available online, especially on Mozilla's MDN.
41+
42+
This assumes you are using an npm-compatible build system, like Webpack or Browserify, and that your target browser supports WebAudio. Ample documentation on WebAudio is available online, especially on Mozilla's MDN.
43+
3644
```javascript
37-
const Pitchfinder = require("pitchfinder");
38-
const detectPitch = Pitchfinder.AMDF();
45+
import * as Pitchfinder from "pitchfinder";
3946

4047
const myAudioBuffer = getAudioBuffer(); // assume this returns a WebAudio AudioBuffer object
4148
const float32Array = myAudioBuffer.getChannelData(0); // get a single channel of sound
49+
50+
const detectPitch = Pitchfinder.AMDF();
4251
const pitch = detectPitch(float32Array); // null if pitch cannot be identified
4352
```
4453

4554
### Finding a series of pitches
55+
4656
Set a tempo and a quantization interval, and an array of pitches at each interval will be returned.
4757

4858
```javascript
@@ -56,41 +66,50 @@ const frequencies = Pitchfinder.frequencies(detectPitch, float32Array, {
5666

5767
// or use multiple detectors for better accuracy at the cost of speed.
5868
const detectors = [detectPitch, Pitchfinder.AMDF()];
59-
const moreAccurateFrequencies = Pitchfinder.frequencies(detectors, float32Array, {
60-
tempo: 130, // in BPM, defaults to 120
61-
quantization: 4, // samples per beat, defaults to 4 (i.e. 16th notes)
62-
});
69+
const moreAccurateFrequencies = Pitchfinder.frequencies(
70+
detectors,
71+
float32Array,
72+
{
73+
tempo: 130, // in BPM, defaults to 120
74+
quantization: 4, // samples per beat, defaults to 4 (i.e. 16th notes)
75+
}
76+
);
6377
```
6478

65-
6679
## Configuration
6780

6881
### All detectors
82+
6983
- `sampleRate` - defaults to 44100
7084

7185
### YIN
86+
7287
- `threshold` - used by the algorithm
7388
- `probabilityThreshold` - don't return a pitch if probability estimate is below this number.
7489

7590
### AMDF
91+
7692
- `minFrequency` - Lowest frequency detectable
7793
- `maxFrequency` - Highest frequency detectable
7894
- `sensitivity`
7995
- `ratio`
8096

8197
### Dynamic Wavelet
82-
*no special config*
98+
99+
_no special config_
83100

84101
## Note
85102

86103
If you'd like a version that uses compiled C++ code and runs much faster, check out [this repo](https://github.com/cristovao-trevisan/node-pitchfinder). However, it will not work in the browser.
87104

88105
## Todo
106+
89107
- Integrate with `teoria` or another music theory tool to add more intelligent parsing.
90-
- Note-onsite algorithms.
108+
- Note-onset algorithms.
91109
- Enable requiring of single detectors.
92110

93111
## Thanks
94-
Several of these algorithms were ported from Jonas Six's excellent TarsosDSP library (written in Java). If you're looking for a far deeper set of tools than this, check out his work [on his website](https://0110.be/tags/TarsosDSP) or [on Github](https://github.com/JorenSix/TarsosDSP).
112+
113+
Several of these algorithms were ported from Jonas Six's excellent TarsosDSP library (written in Java). If you're looking for a far deeper set of tools than this, check out his work [on his website](https://0110.be/tags/TarsosDSP) or [on Github](https://github.com/JorenSix/TarsosDSP).
95114

96115
Thanks to Aubio for his [YIN code](https://github.com/aubio/aubio/blob/master/src/pitch/pitchyin.c)

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "pitchfinder",
3-
"version": "2.3.1",
3+
"version": "2.3.2",
44
"description": "A pitch-detection library for node and the browser",
55
"main": "lib/index.js",
66
"types": "lib/index.d.ts",
@@ -50,4 +50,4 @@
5050
"wav": "^1.0.0",
5151
"wav-decoder": "^1.1.0"
5252
}
53-
}
53+
}

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export {
1717
DynamicWaveletConfig,
1818
Macleod,
1919
MacleodConfig,
20+
frequencies,
2021
};
2122

2223
export default {

0 commit comments

Comments
 (0)