![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
A javascript api for generating frequencies for use with the web audio API
This package aims to:
What it doesn't do:
View the online demo on GitHub here
Or download/clone it and run npm install
which will install any dependencies, npm run build
to create the demo bundle and npm run start
which will start a new server at localhost:8080.
Then, be sure to navigate to the demo folder in order to see the page i.e. localhost:8080/demo
It is recommended you install via Yarn or NPM
using
yarn add freqi
or
npm install freqi
Freqi is configured to work with both AMD and CJS applications.
If you're using Webpack, Browserify or some other CJS module loader
import (ES6), like so
import freqi from 'freqi'
or for CommonJS use
var freqi = require('freqi');
Freqi provides a pure function, getFreqs
, which accepts a config object and returns an array of frequencies. There are two mandatory properties: startFreq
and intervals
.
startFreq
can be a frequency in Hz, such as 440
(for A) or a relative frequency such 1
which is useful for playing back audio files, such as MP3s or OGGs, where 1
is the original playback rate. intervals
is the set of notes you want to generate frequencies from. These intervals can be any integer, positive or negative e.g. [-5, 0, 7]
.
Optionally, you can pass in a custom number of semitones. The default is 12
, a western chromatic scale, but you could pass in 19 for a non-western scale - this can produce very interesting results!
If you are using Freqi to generate multiple sequences of notes you can offset the root note using the rootNote
property. A value of 2
for example will pitch the provided intervals up by two semitones.
Also, you can offset the intervals themselves to produce inversions e.g. {intervals: [0, 3, 5, 7, 10], inversionStartNote: 2}
is the equivalent of {intervals: [5, 7, 10, 12, 15], inversionStartNote: 2}
. Note that the intervals array is automatically extended to the next octave to ensure the same number of notes are created.
Following on from the above, a larger number of notes can be set than is provided by the intervals
property e.g. {intervals : [0, 3, 5], numNotes: 5}
. In this case Freqi will add the missing array items and extend them to the next octave. You can have Freqi add any value to these missing items - setting amountToAdd
to 0
will effectively add the same numbers again.
If, for any reason, you want an even longer set of frequencies back simply use the repeatMultiple
property, which will repeat the duplication process x number of times.
In a later version it will be possible to generate musical scales that use just intonation rather than equal temperament
Also, it will be possible to pass in note letters, such as C#
FAQs
A library that generates musical frequencies for use with the Web Audio API
The npm package freqi receives a total of 9 weekly downloads. As such, freqi popularity was classified as not popular.
We found that freqi demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.