{"id":27314690,"url":"https://github.com/sambego/frequency-calculator","last_synced_at":"2025-04-12T07:59:40.658Z","repository":{"id":57241708,"uuid":"51263418","full_name":"Sambego/frequency-calculator","owner":"Sambego","description":"Calculate the frequency of a music note","archived":false,"fork":false,"pushed_at":"2023-05-18T22:15:10.000Z","size":32,"stargazers_count":5,"open_issues_count":1,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-12T07:59:33.876Z","etag":null,"topics":["frequency","frequency-calculator","web-audio-api"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Sambego.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-02-07T19:59:17.000Z","updated_at":"2023-05-20T02:36:36.000Z","dependencies_parsed_at":"2022-09-08T00:40:44.003Z","dependency_job_id":null,"html_url":"https://github.com/Sambego/frequency-calculator","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sambego%2Ffrequency-calculator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sambego%2Ffrequency-calculator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sambego%2Ffrequency-calculator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sambego%2Ffrequency-calculator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Sambego","download_url":"https://codeload.github.com/Sambego/frequency-calculator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248537119,"owners_count":21120705,"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":["frequency","frequency-calculator","web-audio-api"],"created_at":"2025-04-12T07:59:40.458Z","updated_at":"2025-04-12T07:59:40.652Z","avatar_url":"https://github.com/Sambego.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Frequency calculator\n\nThis is a small library to convert frequencies to steps, notes and octaves.\n\nTo use this library, get the files with NPM or bower:\n```\nnpm install frequency-calculator\n```\nor\n```\nbower install frequency-calculator\n```\n\nOnce installed you can import the the library:\n```javascript\nimport FrequencyCalculator from 'frequency-calculator';\n```\n\n## calculateSteps\nYou can calculate the number of half steps between the base note (A4) and a given note:\n```javascript\nFrequencyCalculator.calculateSteps('G', 4) // -\u003e -2;\n```\n\n## calculateFrequencyByNote\nOnce imported you can calculate the frequency of a note by supplying the note name and octave:\n```javascript\nFrequencyCalculator.calculateFrequencyByNote('C', 0) // -\u003e 16.35Hz;\n```\n\n## calculateFrequencyByStep\nIf you know the number of half steps, you can also calculate the frequency based on these steps, this can be a negative number if the note is below the base note (A4):\n```javascript\nFrequencyCalculator.calculateFrequencyByStep(-12) // -\u003e 220.00Hz;\n```\n\n## calculateStepsFromFrequency\nYou calculate the amount of half steps between a frequency and A4 (440Hz). If you want to round the steps, you can add `true` as the second parameter:\n```javascript\nFrequencyCalculator.calculateStepsFromFrequency(415.30) // -\u003e -1.0001958238467235;\n```\n\nor\n\n```javascript\nFrequencyCalculator.calculateStepsFromFrequency(415.30, true) // -\u003e -1;\n```\n\n## calculateNoteBySteps\nYou can calculate a note based on the the distance in half steps of A4:\n```javascript\nFrequencyCalculator.calculateNoteBySteps(-12) // -\u003e A;\n```\n\n## calculateOctaveBySteps\nYou can calculate an octave based on the the distance in half steps of A4, if you don't want the octave to be relative to A4, add `false` as the second parameter:\n```javascript\nFrequencyCalculator.calculateOctaveBySteps(-12); // -\u003e -1\n```\n\nor\n\n```javascript\nFrequencyCalculator.calculateOctaveBySteps(-12, false); // -\u003e -3\n```\n\n## calculateNoteByFrequency\nYou can calculate the note of a frequency:\n```javascript\nFrequencyCalculator.calculateNoteByFrequency(440); // -\u003e A\n```\n\n## calculateOctaveByFrequency\nYou can calculate the octave of a frequency. If you don't want the octave to be relative to A4, add `false` as the second parameter:\n```javascript\nFrequencyCalculator.calculateOctaveByFrequency(440); // -\u003e 0\n```\n\nor\n\n```javascript\nFrequencyCalculator.calculateOctaveByFrequency(440, false); // -\u003e 4\n```\n\n## TODO\n- [ ] Write tests\n- [ ] Create a demo\n\n## The MIT License (MIT)\nCopyright © 2016 Sam Bellen\n\nPermission is hereby granted, free of charge, to any person\nobtaining a copy of this software and associated documentation\nfiles (the “Software”), to deal in the Software without\nrestriction, including without limitation the rights to use,\ncopy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the\nSoftware is furnished to do so, subject to the following\nconditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\nOF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\nHOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\nWHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\nFROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\nOTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsambego%2Ffrequency-calculator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsambego%2Ffrequency-calculator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsambego%2Ffrequency-calculator/lists"}