Code Monkey home page Code Monkey logo

elm-chords's Introduction

Elm Chords Build Status

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:

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

elm-chords's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

elm-chords's Issues

Expose modules mentioned in README

README mentions

import Chords.ChordParser as CP
import Chords.Instruments.Guitar as Guitar
import Chords.Instruments.Voicing exposing (Voicing)

and also Chords.Instruments.Diagram.view

There's only Chords module exposed though! ๐Ÿ™ƒ

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.