-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce re-imagined algorithm and updated tech stack (#14)
* Add initial changes required for the package. * Add Github action to deploy into Github pages. * Update the readme file with a detailed getting started section.
- Loading branch information
1 parent
a242ef5
commit c2885d0
Showing
18 changed files
with
5,087 additions
and
7,568 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: Deploy to Github pages | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node-version: [18.16.0] | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- name: Install Packages | ||
run: npm ci | ||
- name: Run Tests | ||
run: npm run test | ||
- name: Build page | ||
run: npm run ci && npm run copy | ||
- name: Deploy to gh-pages | ||
uses: peaceiris/actions-gh-pages@v3 | ||
with: | ||
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }} | ||
publish_dir: ./build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
/node_modules | ||
coverage | ||
.idea | ||
.idea | ||
/dist | ||
/build | ||
.DS_Store |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,86 @@ | ||
# Chords Transposer # | ||
# Chords Transposer | ||
|
||
Easily transpose chords from a one scale to another scale | ||
The Chord Transposer is a TypeScript/JavaScript library designed to manipulate and transpose chords within text-based songs. This library is intended for browser use and offers functionalities to parse song texts, identify chord positions, and apply transformations like transposing and highlighting chords. | ||
|
||
using chords.js file you can parse a raw text into chords and song lines, transpose song from this scale to given scale or from a required numbers of semitones. | ||
## Features | ||
|
||
use | ||
- **Chord Parsing:** Parses song texts to identify and extract chords. | ||
- **Chord Transposition:** Allows shifting chords up or down by a specified interval. | ||
- **HTML Tag Insertion:** Supports highlighting chords by inserting HTML tags around them. | ||
|
||
## Getting Started | ||
|
||
Once installed, import the `chords-transposer` library into your project, | ||
|
||
```js | ||
import Transposer from "chords-transposer"; | ||
``` | ||
|
||
### 1. Parsing Chord Progressions | ||
|
||
Create a Transposer object by passing the chord progression string: | ||
|
||
```js | ||
const song = "Gm F Gm Eb B F B Gm"; | ||
const songObj = new Transposer(song); | ||
``` | ||
<script src="lib/chords.js"></script> | ||
|
||
### 2. Getting Chords with Tags | ||
|
||
Retrieve the chord progression with HTML span tags for styling: | ||
|
||
```js | ||
const chordsWithTags = songObj.getWithTags(); | ||
console.log(chordsWithTags); | ||
``` | ||
to add chords.js file into html page | ||
|
||
## Exposed Functions | ||
```javascript | ||
shiftScale(src, from, to); | ||
shiftScaleBy(src, val); | ||
parse(src); | ||
The output will be: | ||
|
||
```html | ||
<span class="chords-highlighted">Gm</span> <span class="chords-highlighted">F</span> <span class="chords-highlighted">Gm</span> <span class="chords-highlighted">Eb</span> <span class="chords-highlighted">B</span> <span class="chords-highlighted">F</span> <span class="chords-highlighted">B</span> <span class="chords-highlighted">Gm</span> | ||
``` | ||
|
||
## Examples ## | ||
```javascript | ||
|
||
function shift(src_id, dst_id, from, to) { | ||
val = 0; | ||
var src = document.getElementById(src_id).value; | ||
var dst = document.getElementById(dst_id); | ||
dst.innerHTML = chords.shiftScale(src, from, to); //returns a string | ||
} | ||
|
||
function shiftPlus(src_id, dst_id) { | ||
val += 1; | ||
var src = document.getElementById(src_id).value; | ||
var dst = document.getElementById(dst_id); | ||
dst.innerHTML = chords.shiftScaleBy(src, val); //returns a string | ||
} | ||
|
||
function shiftMinus(src_id, dst_id) { | ||
val -= 1; | ||
var src = document.getElementById(src_id).value; | ||
var dst = document.getElementById(dst_id); | ||
dst.innerHTML = chords.shiftScaleBy(src, val); //returns a string | ||
} | ||
|
||
function parse(src_id, dst_id) { | ||
val = 0; | ||
var src = document.getElementById(src_id).value; | ||
var dst = document.getElementById(dst_id); | ||
dst.innerHTML = chords.parse(src); //returns a string | ||
} | ||
### 3. Shifting Scale | ||
|
||
Transpose the chord progression by shifting the scale: | ||
|
||
```js | ||
const shiftedChords = songObj.shiftScaleBy(1).getWithTags(); | ||
console.log(shiftedChords); | ||
``` | ||
|
||
Contributions are welcome! | ||
### 4. Shifting Scale From One Key to Another | ||
|
||
Transpose the chord progression by specifying the original and target keys: | ||
|
||
```js | ||
const transposedChords = songObj.shiftScaleFromTo("G", "A").getWithTags(); | ||
console.log(transposedChords); | ||
``` | ||
|
||
### 5. Complex Scale Shifting | ||
|
||
Combine multiple scale shifts for complex transpositions: | ||
|
||
```js | ||
const complexTransposition = songObj.shiftScaleBy(1).shiftScaleBy(1).shiftScaleBy(1).getWithTags(); | ||
console.log(complexTransposition); | ||
``` | ||
|
||
## API Reference | ||
|
||
The library exposes the following main methods: | ||
|
||
1. `constructor(song: string)`: Initializes the library with the song text. | ||
2. `shiftScaleBy(shiftBy: number)`: Shifts chords by the specified number of semitones. | ||
3. `shiftScaleFromTo(from: string, to: string)`: Shifts chords from a specific chord to another. | ||
4. `getWithTags()`: Returns the updated song text with HTML tags around chords. | ||
|
||
Refer to the library source code or documentation for more detailed API information. | ||
|
||
## Contributing | ||
|
||
Contributions to this library are welcome! If you encounter issues or have ideas for enhancements, feel free to create an issue or pull request on the GitHub repository. | ||
|
||
## License | ||
This library is licensed under the MIT License. |
Oops, something went wrong.