y-usuzumi / dechorder

Mirror of https://gitlab.com/tospio/musician/dechorder (private for now)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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"

About

Mirror of https://gitlab.com/tospio/musician/dechorder (private for now)

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:Haskell 100.0%