Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
bkeepers committed Mar 24, 2024
1 parent 831cddd commit 3b09008
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 14 deletions.
35 changes: 29 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,28 @@ const tuner = createTuner({
console.log('Note:', note)
},

//// Here are some other settings you can fiddle with
//// Here are some other settings you can fiddle with and their default values.
//// (let us know if you find values that work better).

//
//// The frequency of middle A. Defaults to 440Hz.
// a4: 440,

//
//// The minimum clarity threshold. Anything below this will be ignored
// clarityThreshold: 0.95,

//
// The minimum volume threshold. -100 means 1/100th the volume of the loudest sound.
// minVolumeDecibels: -100,

//
//// The minimum and maximum frequencies to detect. To reduce noise, everything else is filtered
//// out using a lowpass and highpass filter.
// minFrequency: 73.42, // D2, drop D
// maxFrequency: 1084.0, // C6, highest note on the guitar in front of me

//
//// The size of buffer to use for frequency analysis, which maps to the `fftSize`:
//// https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/fftSize
// bufferSize: 2048,
//
//// https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/smoothingTimeConstant
// smoothingTimeConstant: 0.9,
})

Expand All @@ -55,6 +59,25 @@ tuner.start()
tuner.stop()
```

When a pitch is clearly detected, the `onNote` callback is called with an object containing the following properties:

```js
{
// The frequency of the detected note
"frequency": 612.2498364209699,
// The node name (e.g. "A", "C#")
"name": "D♯",
// The note number (0-89)
"value": 75,
// The number of cents the detected frequency is off from the nearest note
"cents": -29,
// The octave of the detected note
"octave": 5,
// The clarity of the detected note (0-1)
"clarity": 0.9656978357299373
}
```

## Contributing

Contributions are welcome!
Expand Down
8 changes: 0 additions & 8 deletions demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,3 @@ function visualize() {
}

visualize();


// const oscillator = tuner.context.createOscillator();

// oscillator.type = "square";
// oscillator.frequency.setValueAtTime(440, tuner.context.currentTime); // value in hertz
// oscillator.connect(tuner.context.destination);
// oscillator.start();

0 comments on commit 3b09008

Please sign in to comment.