{"id":16372541,"url":"https://github.com/dimadeveatii/octave-bands","last_synced_at":"2026-03-13T20:30:19.796Z","repository":{"id":41828958,"uuid":"485838398","full_name":"dimadeveatii/octave-bands","owner":"dimadeveatii","description":"Frequency limits for fractional Octave Bands","archived":false,"fork":false,"pushed_at":"2022-04-27T18:02:19.000Z","size":123,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-31T19:39:26.534Z","etag":null,"topics":["audio","audio-spectrum","equalization","equalizer","frequency","octave-bands"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dimadeveatii.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-04-26T15:12:26.000Z","updated_at":"2022-11-01T18:45:54.000Z","dependencies_parsed_at":"2022-08-11T18:41:06.204Z","dependency_job_id":null,"html_url":"https://github.com/dimadeveatii/octave-bands","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimadeveatii%2Foctave-bands","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimadeveatii%2Foctave-bands/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimadeveatii%2Foctave-bands/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimadeveatii%2Foctave-bands/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dimadeveatii","download_url":"https://codeload.github.com/dimadeveatii/octave-bands/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239921877,"owners_count":19718842,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["audio","audio-spectrum","equalization","equalizer","frequency","octave-bands"],"created_at":"2024-10-11T03:11:41.849Z","updated_at":"2026-03-13T20:30:19.705Z","avatar_url":"https://github.com/dimadeveatii.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# octave-bands\n\n[![Build status](https://github.com/dimadeveatii/octave-bands/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/dimadeveatii/octave-bands/actions/workflows/ci.yml?query=branch%3Amain++)\n[![NPM Version](https://img.shields.io/npm/v/octave-bands.svg)](https://npmjs.org/package/octave-bands)\n[![License](https://img.shields.io/npm/l/octave-bands)](https://github.com/dimadeveatii/octave-bands/blob/main/LICENSE)\n\nFrequency limits for fractional _Octave Bands_.\n\nA small, lightweight package for calculating the frequency bounds for fractional octave bands.  \nCalculate the frequency bounds for `1/2`, `1/3`, ... `1/N` octave bands.\n\n## Install\n\n```sh\nnpm install octave-bands\n```\n\n```ts\nimport { octaves, bandwidth, equalizer } from 'octave-bands';\n```\n\n## Usage\n\nGet frequency limits for 11 octave bands:\n\n```ts\nimport { octaves } from 'octave-bands';\n\nconst bands = octaves(); // or `octaves(1)`\nconsole.table(bands);\n\n/*\n┌─────────┬───────────┬────────┬───────────┐\n│ (index) │     0     │   1    │     2     │\n├─────────┼───────────┼────────┼───────────┤\n│    0    │  11.049   │ 15.625 │  22.097   │\n│    1    │  22.097   │ 31.25  │  44.194   │\n│    2    │  44.194   │  62.5  │  88.388   │\n│    3    │  88.388   │  125   │  176.777  │\n│    4    │  176.777  │  250   │  353.553  │\n│    5    │  353.553  │  500   │  707.107  │\n│    6    │  707.107  │  1000  │ 1414.214  │\n│    7    │ 1414.214  │  2000  │ 2828.427  │\n│    8    │ 2828.427  │  4000  │ 5656.854  │\n│    9    │ 5656.854  │  8000  │ 11313.708 │\n│   10    │ 11313.708 │ 16000  │ 22627.417 │\n└─────────┴───────────┴────────┴───────────┘\n*/\n```\n\nThe `octaves` function returns an array of band frequencies, where each band is a tuple of its _low_, _center_ and _high_ frequency in the form of `[low, center, high]`.\n\nTo get only the center frequencies:\n\n```ts\nimport { octaves } from 'octave-bands';\n\nconst bands = octaves();\nconsole.table(bands.map(([low, center, high]) =\u003e center));\n\n/*\n┌─────────┬────────┐\n│ (index) │ Values │\n├─────────┼────────┤\n│    0    │ 15.625 │\n│    1    │ 31.25  │\n│    2    │  62.5  │\n│    3    │  125   │\n│    4    │  250   │\n│    5    │  500   │\n│    6    │  1000  │\n│    7    │  2000  │\n│    8    │  4000  │\n│    9    │  8000  │\n│   10    │ 16000  │\n└─────────┴────────┘\n*/\n```\n\nGet _one-third-octave_ bands:\n\n```ts\nimport { octaves } from 'octave-bands';\n\nconst bands = octaves(1 / 3);\nconsole.table(bands);\n\n/*\n┌─────────┬───────────┬───────────┬───────────┐\n│ (index) │     0     │     1     │     2     │\n├─────────┼───────────┼───────────┼───────────┤\n│    0    │   13.92   │  15.625   │  17.538   │\n│    1    │  17.538   │  19.686   │  22.097   │\n...............................................\n│   18    │  890.899  │   1000    │ 1122.462  │\n...............................................\n│   31    │ 17959.393 │ 20158.737 │ 22627.417 │\n└─────────┴───────────┴───────────┴───────────┘\n*/\n```\n\nGet the frequency limits for a 21-band equalizer covering an audio spectrum\nfrom 20Hz to 20kHz\n\n```ts\nimport { equalizer } from 'octave-bands';\n\nconst bands = equalizer(21, { spectrum: [20, 20000] });\nconsole.table(bands);\n\n/*\n┌─────────┬───────────┬───────────┬───────────┐\n│ (index) │     0     │     1     │     2     │\n├─────────┼───────────┼───────────┼───────────┤\n│    0    │  16.828   │    20     │   23.77   │\n│    1    │   23.77   │  28.251   │  33.576   │\n│    2    │  33.576   │  39.905   │  47.427   │\n│    3    │  47.427   │  56.368   │  66.993   │\n...............................................\n│   19    │ 11913.243 │ 14158.916 │ 16827.903 │\n│   20    │ 16827.903 │   20000   │ 23770.045 │\n└─────────┴───────────┴───────────┴───────────┘\n*/\n```\n\nTo get the fractional bandwidth constant:\n\n```ts\nimport { bandwidth } from 'octave-bands';\n\nconsole.log('octave bandwidth', bandwidth()); // ~0.707\nconsole.log('1/2 octave bandwidth', bandwidth(1 / 2)); // ~0.348\nconsole.log('1/3 octave bandwidth', bandwidth(1 / 3)); // ~0.232\n```\n\n## API\n\n\u003e `octaves(fraction: number = 1, options?: Options): [number, number, number][]`\n\nCalculates the frequencies for fractional octave bands.\n\nArguments:\n\n- `fraction` - octave fraction _(defaults to `1`)_\n- `options` - additional options:\n\n```ts\ntype Options: {\n    center?: number,\n    spectrum?: [number, number]\n}\n```\n\n- `center` the center frequency of the band that will be used as a starting point to calculate other bands (defaults to `1000`).\n- `spectrum` - a two-numbers array representing the _min_ and _max_ values to include for center frequencies (defaults to `[15, 21000]`)\n\nReturns:\n\n- `[number, number, number][]` returns an array where each element represents the frequency bounds of a band `[low, center, high]`\n\n\u003e `equalizer(bands: number, options?: Options): [number, number, number][]`\n\nCalculates the frequency bounds for a given number of bands that should cover an audio spectrum.  \nThis is similar to `octaves` function, but instead of using octave's _fraction_ to calculate the frequencies, it uses the\nnumber of bands to output.\n\nArguments:\n\n- `bands` - the number of bands to output\n\n- `options` - additional options:\n\n```ts\ntype Options: {\n    spectrum?: [number, number]\n}\n```\n\n- `spectrum` - a two-numbers array representing the _min_ and _max_ values to include for center frequencies (defaults to `[15, 21000]`)\n\nReturns:\n\n- `[number, number, number][]` returns an array where each element represents the frequency bounds of a band `[low, center, high]`\n\n\u003e `bandwidth(fraction: number): number`\n\nCalculates the constant bandwidth per 1/N-octave.\n\nArguments:\n\n- `fraction` - octave fraction _(defaults to `1`)_\n\nReturns:\n\n- `number` the bandwidth constant\n\n## Formula\n\nThe following formula for calculating `1/N` octave bands in a given audio spectrum (ex. `~20Hz` to `~20KHz`) is used:\n\n```js\n// 1/N: one-Nth-octave\n\nf_center_0 = 1000\n\n// Center frequency of i-th band\nf_center(i) = f_center(i-1) * 2^(1 / N) = f_center(i+1) * 1 / 2^(1 / N)\n\n// Lower center frequency of n-th band\nf_low(i) = f_center(i) * 1 / 2^(1 / 2*N)\n\n// Higher center frequency of n-th band\nf_high(i) = f_center(i) * 2^(1 / 2*N)\n\n// And for every i-th band holds:\nspectrum[0] \u003c= f_center(i) \u003c= spectrum[1]\n\n// Fractional band width per 1/N-octave band (constant):\nBW = (f_high - f_low) / f_center // for every one-Nth-octave band\n```\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdimadeveatii%2Foctave-bands","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdimadeveatii%2Foctave-bands","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdimadeveatii%2Foctave-bands/lists"}