-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gen chord names now; less ambig chord notation; split up files; no warns
- Loading branch information
Showing
7 changed files
with
224 additions
and
96 deletions.
There are no files selected for viewing
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
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
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,31 @@ | ||
module ChordQual where | ||
|
||
data ChordQual = | ||
CQM | CQm | CQdim | CQaug | | ||
CQ7 | CQM7 | CQm7 | CQdim7 | CQm7b5 | CQmM7 | | ||
CQaug7 | CQaugM7 | CQ9 | CQM9 | CQm9 | CQ7S9 | ||
deriving (Eq, Ord, Show) | ||
|
||
cqShow :: ChordQual -> String | ||
cqShow = map (repl 'S' '+') . map (repl 'b' '-') . drop 2 . show | ||
|
||
cqShowLong :: ChordQual -> String | ||
cqShowLong CQM = "major" | ||
cqShowLong CQm = "minor" | ||
cqShowLong CQdim = "diminished" | ||
cqShowLong CQaug = "augmented" | ||
cqShowLong CQ7 = "dominant seventh" | ||
cqShowLong CQM7 = "major seventh" | ||
cqShowLong CQm7 = "minor seventh" | ||
cqShowLong CQdim7 = "diminished seventh" | ||
cqShowLong CQm7b5 = "half-diminished seventh" | ||
cqShowLong CQmM7 = "minor major seventh" | ||
cqShowLong CQaug7 = "augmented seventh" | ||
cqShowLong CQaugM7 = "augmented major seventh" | ||
cqShowLong CQ9 = "ninth" | ||
cqShowLong CQM9 = "major ninth" | ||
cqShowLong CQm9 = "minor ninth" | ||
cqShowLong CQ7S9 = "dominant seventh sharp ninth (hendrix chord)" | ||
|
||
repl :: Eq a => a -> a -> a -> a | ||
repl targ r x = if x == targ then r else x |
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,9 @@ | ||
module ChordSig where | ||
|
||
import ChordQual | ||
|
||
data ChordSig = ChordSig { | ||
csSig :: [Int], | ||
csIntvlOrd :: Int, | ||
csQual :: ChordQual} | ||
deriving Show |
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
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,23 @@ | ||
module Pitch where | ||
|
||
import Control.Arrow | ||
import Data.Function | ||
|
||
import PitchClass | ||
|
||
type Pitch = (PitchClass, Int) | ||
|
||
intToPitch :: Int -> Pitch | ||
intToPitch = first toEnum . swap . (`divMod` octaveInt) | ||
|
||
pitchDiff :: Pitch -> Pitch -> Int | ||
pitchDiff = (-) `on` pitchToInt | ||
|
||
pitchPlus :: Pitch -> Int -> Pitch | ||
pitchPlus p n = intToPitch (pitchToInt p + n) | ||
|
||
pitchToInt :: Pitch -> Int | ||
pitchToInt = uncurry (+) . second (octaveInt *) . first fromEnum | ||
|
||
swap :: (a, b) -> (b, a) | ||
swap (a, b) = (b, a) |
Oops, something went wrong.