Skip to content

y-usuzumi/dechorder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dechorder

A library that aims to be a complete MIDI composition toolkit

Features

  • A stupid pitch and interval parser
  • Absolute pitch and interval arithmetic
  • Pitch to frequency conversion under a given tuning system (now supports 12-equal temperament)

Guide

  • Playing with pitches and intervals
import TOSPIO.Musician.Notation.IPN
import TOSPIO.Musician.Notation.IPN.Parser

main :: IO ()
main = do
  let p = pp "A#4"           -- Pitch (4, PitchClass (A, [Sharp]))
      majorThird = ip "3M"   -- Major third
      p' = p <:+ majorThird  -- Pitch (5, PitchClass (C, [Sharp, Sharp]))
  print $ showReadable p'    -- "C##5"
  
  print $ map showReadable $ take 12 $ iterate (<:+ ip "5") $ pp "C3"  -- Circle
  of fifths
  • Pitch to frequency
import Data.Proxy
import TOSPIO.Musician.Notation.IPN
import TOSPIO.Musician.Notation.IPN.Parser
import TOSPIO.Musician.Tuning

main :: IO ()
main = do
  let p = pp "A#4"           -- Pitch (4, PitchClass (A, [Sharp]))
      majorThird = ip "3M"   -- Major third
      p' = p <:+ majorThird  -- Pitch (5, PitchClass (C, [Sharp, Sharp]))
  print $ toFreq (Proxy :: Proxy EqualTemperament) (pp "A4")    -- "440.0"
  print $ toFreq (Proxy :: Proxy EqualTemperament) (pp "C5")    -- "523.2511306011972"

Releases

No releases published

Packages

No packages published