Need help with chordy?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

darth10
131 Stars 13 Forks MIT License 58 Commits 6 Opened issues

Description

A Ruby DSL for printing guitar chords

Services available

!
?

Need anything else?

Contributors list

= chordy
{Gem Version}[http://badge.fury.io/rb/chordy] {}[https://travis-ci.org/darth10/chordy] {}[https://app.fossa.io/projects/git%2Bgithub.com%2Fdarth10%2Fchordy?ref=badge_shield]

chordy is a DSL written in Ruby for printing guitar chord diagrams. A chordy script produces output that looks like a song with various chords, sections and arbitrary text.

It supports all chord families and most chord types. Variations in a note, such as a palm-mute or a trill, are also supported.
Formatting options are also provided.

== Installation

Ruby Gems is required. Run gem install chordy to install the gem.

== Usage

After installing the chordy gem, you can start chordy in an interactive mode through irb. You can declare chords to play using the play function.

=== Basic chords

The play function takes one required arugment, which can be a chord family like C or F#. There are a handful of notations to specify a chord family. For example, the C chord family can be represented as C, :C or "C". Similarly, F sharp is FSharp, :F! or "F!". A ! suffix denotes a sharp, and _ denotes a flat.

$ irb -r chordy 1.9.3p327 :001 > play C e [--0-] b [--1-] G [--0-] D [--2-] A [--3-] E [--3-]

=> #<:c:0x9288e54>

1.9.3p327 :002 > play :F! e [--0---2-] b [--1---2-] G [--0---3-] D [--2---4-] A [--3---4-] E [--3---2-]

=> #<:fsharp:0x92673f8>

1.9.3p327 :003 > play :E_ e [--0---2---3-] b [--1---2---4-] G [--0---3---3-] D [--2---4---1-] A [--3---4---1-] E [--3---2-----]

=> #<:dsharp:0x9258e70>

1.9.3p327 :004 >

To specify a chord type such a minor or a suspended chord, specify a second parameter such as :minor or :suspended_4. The chord type can also specified in a shorter way like :m or :sus4. Note that the default for this parameter is :major, which is shortened to :M. This {wiki page}[http://darth10.github.com/chordy/chords.html] contains a complete listing of all chord families and types.

1.9.3p327 :001 > play C, :minor e [--3-] b [--4-] G [--0-] D [--1-] A [--3-] E [----]

=> #<:c:0xa1d0650>

1.9.3p327 :002 > play :E_, :sus4 e [--3---4-] b [--4---4-] G [--0---1-] D [--1---1-] A [--3---1-] E [--------]

=> #<:dsharp:0xa1ae668>

1.9.3p327 :003 >

Chords are printed in high-to-low string order by default. To switch to low-to-high and high-to-string orders for printing, use the dolowtohigh and dohightolow functions respectively. Note that chords are always internally represented in low-to-high string order.

1.9.3p327 :001 > play C e [--0-] b [--1-] G [--0-] D [--2-] A [--3-] E [--3-]

=> #<:c:0x940be84>

1.9.3p327 :002 > play D e [--0---2-] b [--1---3-] G [--0---2-] D [--2---0-] A [--3---0-] E [--3-----]

=> #<:d:0x93ea658>

1.9.3p327 :003 > dolowto_high E [--3-----] A [--3---0-] D [--2---0-] G [--0---2-] b [--1---3-] e [--0---2-]

=> nil

1.9.3p327 :004 > dohighto_low e [--0---2-] b [--1---3-] G [--0---2-] D [--2---0-] A [--3---0-] E [--3-----]

=> nil

1.9.3p327 :005 >

A chord can also be described in terms of it's strings, by just passing an array of integers to the play function. The array represents the individual strings of chord in high-to-low string order. You can specify low-to-high string order for playing a chord by adding a :lowtohigh argument.

1.9.3-p327 :001 > play [5] e [--5-] b [----] G [----] D [----] A [----] E [----]

=> #<:chord:0x9602440>

1.9.3-p327 :002 > play [5], :lowtohigh e [--5-----] b [--------] G [--------] D [--------] A [--------] E [------5-]

=> #<:chord:0x95f8af8>

1.9.3-p327 :003 > play [2, 4, 4] e [--5-------2-] b [----------4-] G [----------4-] D [------------] A [------------] E [------5-----]

=> #<:chord:0x95a9bd8>

1.9.3-p327 :004 > play [2, 4, 4], :lowtohigh e [--5-------2-----] b [----------4-----] G [----------4-----] D [--------------4-] A [--------------4-] E [------5-------2-]

=> #<:chord:0x958d99c>

1.9.3-p327 :005 >

=== Variations

You can also play variations in chords, such as a muted chord or a harmonic. To play a variation, use the playvar function, where var is the variation name to play. Alternatively, you could use the name of the variation itself as a function, which takes a block of chords to be played. For example, the playmute function plays a muted chord, and the slide_down function plays multiple chords with a slide down. This {wiki page}[http://darth10.github.com/chordy/chords.html] contains a complete listing of all supported varations.

An interesting consequence is that variations can overlap. It's possible that a chord can have a mute as well as a slide_down variation. Of course, all such combinations are not possible. You won't get an error, but the printing will appear unaffected. For example, it's not possible to print both variations in a chord with both mute and harmonic variations.

1.9.3-p327 :001 > play_mute A e [--0-] b [--2-] G [--2-] D [--2-] A [--0-] E [--0-] M

=> #<:a:0x9f95fac>

1.9.3-p327 :002 > slidedown { 1.9.3-p327 :003 > play [2, 4, 4], :lowtohigh 1.9.3-p327 :004?> play [4, 6, 6], :lowto_high 1.9.3-p327 :005?> } e [--0---------] b [--2---------] G [--2---------] D [--2---4--6] A [--0---4--6] E [--0---2--4] M

=> #<:chord:0x9d36914>

1.9.3-p327 :006 > mute { slide_down { play [6] } } e [--0-----------6] b [--2-------------] G [--2-------------] D [--2---4--6----] A [--0---4--6----] E [--0---2--4----] M M

=> #<:chord:0x9fbbf7c>

1.9.3-p327 :007 > harmonic { mute { play [6] } } e [--0-----------6-|--6-] b [--2--------------|----] G [--2--------------|----] D [--2---4--6-----|----] A [--0---4--6-----|----] E [--0---2--4-----|----] M M M

=> #<:chord:0x9faed40>

1.9.3-p327 :008 >

=== Tuning

Chordy also supports different tunings. The tune function can be used to change the tuning, and has to be supplied with a tuning parameter. A tuning is represented as tuningxy, where x is the number of strings in the tuning and y is the name of the tuning. You must also prefix the Chordy module name. For example, Chordy.tuning7a represents A-tuning on a 7-string instrument. This {wiki page}[http://darth10.github.com/chordy/tuning.html] contains a complete listing of all supported tunings.

1.9.3-p327 :001 > play :C e [--0-] b [--1-] G [--0-] D [--2-] A [--3-] E [--3-]

=> #<:c:0x98f60e8>

1.9.3-p327 :002 > Chordy.tuning7a => ["a", "d", "g", "c", "f", "a", "d"]

1.9.3-p327 :003 > tune Chordy.tuning7a d [--0-] a [--1-] f [--0-] C [--2-] G [--3-] D [--3-] A [----]

=> nil

1.9.3-p327 :004 > play D d [--0---2-] a [--1---3-] f [--0---2-] C [--2---0-] G [--3---0-] D [--3-----] A [--------]

=> #<:d:0x989dc04>

1.9.3-p327 :005 >

=== Scripting

You could also script the chords to play by using require 'chordyscript'. Just be sure to call printchords. Here's a sample chordy script.

# 'sample.rb' require 'chordy_script'

play :C play "E" play :C, :m play "E", "minor"

play [-1, 3, 3, 2, 0, 1, -1] play [-1, 0, 2, 2]

print_chords

Here's what the output of the script looks like.

$ ruby -r rubygems sample.rb e [--0---0---3---0--|--3-----] b [--1---0---4---0--|--3---0-] G [--0---1---0---0--|--2---2-] D [--2---2---1---2--|--0---2-] A [--3---2---3---2--|--1-----] E [--3---0-------0--|--------]

=== Text and Sections

Text can be added by using text. To provide structure to your output, use section to separate chords. Here's the previous script with some text and sections.

# sample.rb require 'chordy_script'

text "Some tune"

section "Intro"

play :C play "E"

section "Phrase 1"

play :C, :m play "E", "minor"

section "Phrase 2"

play [-1, 3, 3, 2, 0, 1, -1] play [-1, 0, 2, 2]

print_chords

Here's the output of the modified script.

$ ruby -r rubygems sample.rb Some tune

--Intro---------------------------------

e [--0---0-] b [--1---0-] G [--0---1-] D [--2---2-] A [--3---2-] E [--3---0-]

--Phrase 1------------------------------

e [--3---0-] b [--4---0-] G [--0---0-] D [--1---2-] A [--3---2-] E [------0-]

--Phrase 2------------------------------

e [--3-----] b [--3---0-] G [--2---2-] D [--0---2-] A [--1-----] E [--------]

== Documentation

The {API documentation}[http://rubydoc.info/github/darth10/chordy/frames/file/README.rdoc] is available on RDoc.info. You could also generate the RDoc yourself by using rake rdoc.

Visit the wiki[http://darth10.github.com/chordy] for more information.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.