1.0.3 • Published 10 months ago

musical-note-frequency v1.0.3

Weekly downloads
-
License
MIT
Repository
-
Last release
10 months ago

Musical Note Frequency Calculator

A simple package to calculate the frequency of musical notes based on their name and octave.

Installation

Install the package via npm:

npm install musical-note-frequency

Usage

Here's how to use the package to calculate the frequency of notes:

import { getNoteFrequency } from 'musical-note-frequency';
import { calculateNoteFrequency } from 'musical-note-frequency/dist/music-theory';

// Get formatted frequency string
console.log(getNoteFrequency('A', 4)); // Outputs: "The frequency of A4 is 440.00 Hz"

// Get the exact frequency as a number
console.log(calculateNoteFrequency('C', 4)); // Outputs: 261.6255653005986

API

calculateNoteFrequency(note: NoteName, octave: Octave): number

Calculates the frequency of a given note and octave.

  • note: The note name (e.g., 'C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B', 'Cb', etc.)
  • octave: The octave number (0 to 8)

getNoteFrequency(note: NoteName, octave: Octave): string

Returns a formatted string with the note and its frequency.

  • note: The note name (e.g., 'C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B', 'Cb', etc.)
  • octave: The octave number (0 to 8)

Example Output

  • The frequency of A4 is 440.00 Hz
  • The frequency of C4 is 261.63 Hz

EASY

NOW GO, MAKE A GREAT MUSIC APP

1.0.3

10 months ago

1.0.2

10 months ago