{"id":13861371,"url":"https://github.com/iammordaty/key-tools","last_synced_at":"2026-01-11T08:56:06.091Z","repository":{"id":56988095,"uuid":"151224188","full_name":"iammordaty/key-tools","owner":"iammordaty","description":":musical_note: KeyTools is a library that allows you to convert musical keys between notations. In addition, KeyTools allows you to calculate matching keys for harmonic mixing.","archived":false,"fork":false,"pushed_at":"2020-03-03T14:40:17.000Z","size":22,"stargazers_count":31,"open_issues_count":0,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-08T06:19:02.495Z","etag":null,"topics":["automation","beatport","camelot-wheel","dj","harmonic-mixing","music-library","rekordbox","traktor"],"latest_commit_sha":null,"homepage":"","language":"PHP","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/iammordaty.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":"2018-10-02T08:33:32.000Z","updated_at":"2024-11-06T23:32:27.000Z","dependencies_parsed_at":"2022-08-21T09:40:45.902Z","dependency_job_id":null,"html_url":"https://github.com/iammordaty/key-tools","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iammordaty%2Fkey-tools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iammordaty%2Fkey-tools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iammordaty%2Fkey-tools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iammordaty%2Fkey-tools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iammordaty","download_url":"https://codeload.github.com/iammordaty/key-tools/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225968812,"owners_count":17553142,"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":["automation","beatport","camelot-wheel","dj","harmonic-mixing","music-library","rekordbox","traktor"],"created_at":"2024-08-05T06:01:19.852Z","updated_at":"2026-01-11T08:56:06.085Z","avatar_url":"https://github.com/iammordaty.png","language":"PHP","funding_links":[],"categories":["PHP"],"sub_categories":[],"readme":"# iammordaty/key-tools\n\nKeyTools is a library that allows you to convert musical keys between notations. In addition, KeyTools allows you to calculate matching keys for harmonic mixing.\n\nSupported notations:\n* Camelot Key\n* Open Key\n* Musical\n* Musical used by Beatport\n* Musical used by Essentia streaming extractor\n\nKeyTools is based on the code written by [@mossspence](https://github.com/mossspence), which can be found \n[here](https://github.com/mossspence/trakofflive/blob/master/appsrc/moss/musicapp/finder/keyTools.php).\n\n## Table of Contents\n\n- [Installation](#installation)\n- [Requirements](#requirements)\n- [Usage](#usage)\n- [Tests](#tests)\n- [Further information](#further-information)\n- [License](#license)\n\n## Installation\n\nThe easiest way to install this library is via [composer](https://getcomposer.org):\n\n```bash\n$ composer require iammordaty/key-tools\n```\n\n## Requirements\n\n* PHP 7.1 and higher\n\n## Usage\n\nThe following example shows how to calculate a new key.\n\n```php\nuse KeyTools\\KeyTools;\n\n$keyTools = new KeyTools();\n\necho $keyTools-\u003ecalculateKey('3A'); // \"3A\"\necho $keyTools-\u003ecalculateKey('3A', 1); // \"4A\"\necho $keyTools-\u003ecalculateKey('3A', 2); // \"5A\"\necho $keyTools-\u003ecalculateKey('3A', -1); // \"2A\"\necho $keyTools-\u003ecalculateKey('3A', 0, true); // \"3B\"\n```\n\nKeyTools can return keys with a leading zero – just set the parameter `leading_zero` to `true`,\nas in the following example. Please note that, this setting applies only to Camelot Key and Open Key notations.\n\n```php\nuse KeyTools\\KeyTools;\n\n$keyTools = new KeyTools([ \n    'leading_zero' =\u003e true, \n    'notation' =\u003e KeyTools::NOTATION_CAMELOT_KEY, \n]);\n\necho $keyTools-\u003ecalculateKey('3A'); // \"03A\"\necho $keyTools-\u003ecalculateKey('3A', 1); // \"04A\"\necho $keyTools-\u003ecalculateKey('3A', 2); // \"05A\"\necho $keyTools-\u003ecalculateKey('3A', -1); // \"02A\"\necho $keyTools-\u003ecalculateKey('3A', 0, true); // \"03B\"\n```\n\nTo calculate new key, you can also use shorthand methods:\n\n```php\necho $keyTools-\u003enoChange('3A'); // \"3A\"\necho $keyTools-\u003eperfectFifth('3A'); // \"4A\"\necho $keyTools-\u003ewholeStep('3A'); // \"5A\"\necho $keyTools-\u003eperfectFourth('3A'); // \"2A\"\necho $keyTools-\u003erelativeMinorToMajor('3A'); // \"3B\"\n```\n\nAlso, conversion of keys between notations is easy:\n\n```php\necho $keyTools-\u003econvertKeyToNotation('Fmin', KeyTools::NOTATION_CAMELOT_KEY); // \"4A\"\necho $keyTools-\u003econvertKeyToNotation('Fmin', KeyTools::NOTATION_OPEN_KEY); // \"9M\"\necho $keyTools-\u003econvertKeyToNotation('Fmin', KeyTools::NOTATION_MUSICAL); // = \"Fm\"\n```\n\nKeyTools allows key and notation validation by suitable methods...\n\n```php\n$key = 'Fmin';\n$notation = KeyTools::NOTATION_CAMELOT_KEY;\n\n$keyTools = new KeyTools();\n\nif (!$keyTools-\u003eisValidKey($key)) {\n    exit('Invalid key');\n}\n\nif (!$keyTools-\u003eisSupportedNotation($notation)) {\n    exit('Unsupported notation');\n}\n\necho $keyTools-\u003econvertKeyToNotation($key, $notation); // \"4A\"\n```\n\n... or by throwing appropriate exceptions:\n\n```php\nuse KeyTools\\Exception\\InvalidKeyException;\nuse KeyTools\\Exception\\UnsupportedNotationException;\n\n$key = 'Fmin';\n$notation = KeyTools::NOTATION_CAMELOT_KEY;\n\ntry {\n    $keyTools = new KeyTools();\n\n    echo $keyTools-\u003econvertKeyToNotation($key, $notation); // \"4A\"\n} catch (InvalidKeyException | UnsupportedNotationException $e) {\n    echo $e-\u003egetMessage();\n}\n```\n\n## Tests\n\nCopy `phpunit.xml.dist` file to `phpunit.xml` and use [PHPUnit](https://phpunit.de) to run tests:\n\n```bash\n$ ./vendor/bin/phpunit\n```\n\n## Further information\n\n - [Harmonic mixing overview and how-to](http://www.harmonic-mixing.com/HowTo.aspx)\n - [\"What Is Harmonic Mixing?\" – tutorial by DJ Endo](http://blog.dubspot.com/harmonic-mixing-w-dj-endo-part-1/)\n - [\"Digital DJing: harmonic mixing\" – tutorial by Radley Marx](https://radleymarx.com/djs/digital-djing-harmonic-mixing/)\n - [Open Key notation](https://beatunes.com/en/open-key-notation.html)\n - [Camelot wheel (image)](https://forums.pioneerdj.com/hc/user_images/yBXP1v0OnnB8wIrg3_mbpw.jpeg)\n - [More possibilities for harmonic mixing (image)](https://imgur.com/KYw9IBE)\n - [Essentia – C++ library for audio and music analysis, description and synthesis](https://github.com/MTG/essentia)\n - [Essentia streaming extractor music command-line tool](https://essentia.upf.edu/streaming_extractor_music.html)\n\n## License\n\niammordaty/key-tools is licensed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiammordaty%2Fkey-tools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiammordaty%2Fkey-tools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiammordaty%2Fkey-tools/lists"}