Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/arkham/elm-chords

Parse chords sheets for guitar and ukulele in Elm
https://github.com/arkham/elm-chords

chord-diagram chords elm guitar hacktoberfest music

Last synced: about 1 month ago
JSON representation

Parse chords sheets for guitar and ukulele in Elm

Awesome Lists containing this project

README

        

# Elm Chords [![Build Status](https://travis-ci.com/Arkham/elm-chords.svg?branch=master)](https://travis-ci.com/Arkham/elm-chords)

Parse chords sheets for guitar and ukulele in Elm!

## Installation

`elm install Arkham/elm-chords`

## Example

Here's an example of what you could do:

```elm
import Html exposing (Html)
import Chords exposing (Chord, Voicing)
import Chords.Chart
import Instruments.Guitar as Guitar

chords : List String
chords =
[ "Am"
, "E"
, "C"
, "Dm7"
, "G"
, "F"
, "A#"
, "C#"
]

view : Html msg
view =
Html.div []
(chords
|> List.map
(\name ->
( name, Chords.parseChord name )
)
|> List.map
(\( name, result ) ->
case result of
Ok chord ->
viewChord chord

Err err ->
Html.span []
[ Html.text ("Could not parse " ++ name)
]
)
)

viewChord : Chord -> Html msg
viewChord chord =
let
config =
{ tuning = Guitar.defaultTuning
, numFrets = 10
}

name =
Chords.toString chord
in
case Guitar.voicings config chord of
[] ->
Html.span []
[ Html.text
("Could not find voicing for chord " ++ name)
]

first :: rest ->
Chords.Chart.view name first
```

This will parse the chords, generate some voicings and display the charts. You
should see something like this!

If you'd like to use Ukulele instead, import `Instruments.Ukulele` and use
it in the same way!

## Tests

Pull the repo and run `elm-test`