{"id":18645220,"url":"https://github.com/danigb/pitch-transpose","last_synced_at":"2025-11-05T03:30:26.890Z","repository":{"id":66458362,"uuid":"44236694","full_name":"danigb/pitch-transpose","owner":"danigb","description":"Simple and fast pitch transposition","archived":false,"fork":false,"pushed_at":"2015-10-21T19:35:39.000Z","size":132,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-12-27T11:34:49.036Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/danigb.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","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":"2015-10-14T09:10:26.000Z","updated_at":"2015-10-22T14:30:50.000Z","dependencies_parsed_at":"2023-02-20T20:45:14.828Z","dependency_job_id":null,"html_url":"https://github.com/danigb/pitch-transpose","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danigb%2Fpitch-transpose","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danigb%2Fpitch-transpose/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danigb%2Fpitch-transpose/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danigb%2Fpitch-transpose/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danigb","download_url":"https://codeload.github.com/danigb/pitch-transpose/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239449552,"owners_count":19640532,"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":[],"created_at":"2024-11-07T06:15:07.089Z","updated_at":"2025-11-05T03:30:26.833Z","avatar_url":"https://github.com/danigb.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pitch-transpose\n\n[![Build Status](https://travis-ci.org/danigb/pitch-transpose.svg?branch=master)](https://travis-ci.org/danigb/pitch-transpose)\n[![Test Coverage](https://codeclimate.com/github/danigb/pitch-transpose/badges/coverage.svg)](https://codeclimate.com/github/danigb/pitch-transpose/coverage)\n[![Code Climate](https://codeclimate.com/github/danigb/pitch-transpose/badges/gpa.svg)](https://codeclimate.com/github/danigb/pitch-transpose)\n[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://github.com/feross/standard)\n[![npm](https://img.shields.io/npm/v/pitch-transpose.svg)](https://www.npmjs.com/package/pitch-transpose)\n[![array-notation](https://img.shields.io/badge/array--notation-compatible-yellow.svg)](https://github.com/danigb/pitch-array)\n\n\nSimple and fast pitch transposition:\n\n```js\ntranspose('E2', '2M') // =\u003e 'F#2'\ntranspose('F4', '3m') // =\u003e 'Ab4'\n```\n\nThis is piece of a complete music manipulation library called [tonal](https://github.com/danigb/tonal)\n\n## Installation\n\nInstall the npm module: `npm i --save pitch-transpose` and use it:\n\n```js\nvar transpose = require('pitch-transpose')\ntranspose('3m', 'G') // =\u003e 'Bb'\n```\n\nFor browser environments you need browserify, webpack or a similar tool (or use [tonal](https://github.com/danigb/tonal))\n\n## Usage\n\n#### Pitch transposition\n\nThe simplest usage is with a pitch and interval (the order doesn't matter):\n\n```js\ntranspose('C2', '4A') // =\u003e 'F#2'\ntranspose('4A', 'C2') // =\u003e 'F#2'\n```\n\n#### Pitch class transposition\n\nYou can transpose pitch classes (pitches without octaves), and the returned value will be a pitch class:\n\n```js\ntranpose('A', '3M') // =\u003e 'C#'\ntranpose('A5', '3M') // =\u003e 'C#5'\n```\n\n#### Transposers\n\nAlso, you can partially apply to get a transposer:\n\n```js\nvar major3th = transpose('3M')\nmajor3th('D') // =\u003e 'F#'\n```\n\n#### Work with pitch or interval arrays\n\nPartially applied transposers allows to work with arrays seamlessly:\n\n```\n['C', 'D', 'E', 'F', 'G'].map(transpose('3M')) // =\u003e ['E', 'F#', 'G#', 'A', 'B']\n['1P', '3m', '5P'].map(transpose('C')) // =\u003e ['C', 'Eb', 'G']\n```\n\n#### Using different interval or pitch representations\n\nThis library can work with [pitches or intervals expressed as arrays](https://github.com/danigb/a-pitch):\n\n```js\ntranspose([0, 1, 3], [2, 0, 0]) // =\u003e [3, 1, 3]\n// is the same as: transpose('C#3', '3M') =\u003e 'E#3'\n```\n\nIt should be quite easy to write a custom parser/builder. TODO: write an example.\n\n## API\n\n\u003c!-- START docme generated API please keep comment here to allow auto update --\u003e\n\u003c!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN docme TO UPDATE --\u003e\n\n\u003cdiv\u003e\n\u003cdiv class=\"jsdoc-githubify\"\u003e\n\u003csection\u003e\n\u003carticle\u003e\n\u003cdiv class=\"container-overview\"\u003e\n\u003cdl class=\"details\"\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cdl\u003e\n\u003cdt\u003e\n\u003ch4 class=\"name\" id=\"transpose\"\u003e\u003cspan class=\"type-signature\"\u003e\u003c/span\u003etranspose\u003cspan class=\"signature\"\u003e(a, b)\u003c/span\u003e\u003cspan class=\"type-signature\"\u003e \u0026rarr; {String|Array}\u003c/span\u003e\u003c/h4\u003e\n\u003c/dt\u003e\n\u003cdd\u003e\n\u003cdiv class=\"description\"\u003e\n\u003cp\u003eTransposes pitch by an interval\u003c/p\u003e\n\u003c/div\u003e\n\u003ch5\u003eParameters:\u003c/h5\u003e\n\u003ctable class=\"params\"\u003e\n\u003cthead\u003e\n\u003ctr\u003e\n\u003cth\u003eName\u003c/th\u003e\n\u003cth\u003eType\u003c/th\u003e\n\u003cth class=\"last\"\u003eDescription\u003c/th\u003e\n\u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n\u003ctr\u003e\n\u003ctd class=\"name\"\u003e\u003ccode\u003ea\u003c/code\u003e\u003c/td\u003e\n\u003ctd class=\"type\"\u003e\n\u003cspan class=\"param-type\"\u003eString\u003c/span\u003e\n|\n\u003cspan class=\"param-type\"\u003eArray\u003c/span\u003e\n\u003c/td\u003e\n\u003ctd class=\"description last\"\u003e\u003cp\u003ea pitch or interval in string or array notation\u003c/p\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"name\"\u003e\u003ccode\u003eb\u003c/code\u003e\u003c/td\u003e\n\u003ctd class=\"type\"\u003e\n\u003cspan class=\"param-type\"\u003eString\u003c/span\u003e\n|\n\u003cspan class=\"param-type\"\u003eArray\u003c/span\u003e\n\u003c/td\u003e\n\u003ctd class=\"description last\"\u003e\u003cp\u003ea pitch or interval in string or array notation\u003c/p\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003cdl class=\"details\"\u003e\n\u003cdt class=\"tag-source\"\u003eSource:\u003c/dt\u003e\n\u003cdd class=\"tag-source\"\u003e\u003cul class=\"dummy\"\u003e\n\u003cli\u003e\n\u003ca href=\"https://github.com/danigb/pitch-transpose/blob/master/index.js\"\u003eindex.js\u003c/a\u003e\n\u003cspan\u003e, \u003c/span\u003e\n\u003ca href=\"https://github.com/danigb/pitch-transpose/blob/master/index.js#L19\"\u003elineno 19\u003c/a\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\u003c/dd\u003e\n\u003c/dl\u003e\n\u003ch5\u003eReturns:\u003c/h5\u003e\n\u003cdiv class=\"param-desc\"\u003e\n\u003cp\u003ethe transposed pitch\u003c/p\u003e\n\u003c/div\u003e\n\u003cdl\u003e\n\u003cdt\u003e\nType\n\u003c/dt\u003e\n\u003cdd\u003e\n\u003cspan class=\"param-type\"\u003eString\u003c/span\u003e\n|\n\u003cspan class=\"param-type\"\u003eArray\u003c/span\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003ch5\u003eExample\u003c/h5\u003e\n\u003cpre class=\"prettyprint\"\u003e\u003ccode\u003etranspose('3m', 'C4') // =\u003e 'Eb4'\ntranspose('C4', '3m') // =\u003e 'Eb4'\ntranpose([1, 0, 2], [3, -1, 0]) // =\u003e [3, 0, 2]\u003c/code\u003e\u003c/pre\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/article\u003e\n\u003c/section\u003e\n\u003c/div\u003e\n\n*generated with [docme](https://github.com/thlorenz/docme)*\n\u003c/div\u003e\n\u003c!-- END docme generated API please keep comment here to allow auto update --\u003e\n\n## License\n\nMIT License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanigb%2Fpitch-transpose","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanigb%2Fpitch-transpose","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanigb%2Fpitch-transpose/lists"}