fadno-1.1.9.1: Minimal library for music generation and notation
Safe HaskellSafe-Inferred
LanguageHaskell2010

Fadno.Midi

Synopsis

Documentation

type MidiData = T Source #

Serializable midi data.

type IPitch = Int Source #

type IDur = Int Source #

class MidiNotes a where Source #

Convert some note value to midi-ready values.

Methods

toMidiNotes :: a -> [([IPitch], IDur)] Source #

Instances

Instances details
MidiNotes [([IPitch], IDur)] Source # 
Instance details

Defined in Fadno.Midi

Methods

toMidiNotes :: [([IPitch], IDur)] -> [([IPitch], IDur)] Source #

(Integral p, Traversable c, Integral d, Traversable t) => MidiNotes (t (Note (c p) d)) Source # 
Instance details

Defined in Fadno.Midi

Methods

toMidiNotes :: t (Note (c p) d) -> [([IPitch], IDur)] Source #

(Integral p, Integral d, Traversable t) => MidiNotes (t (Note p d)) Source # 
Instance details

Defined in Fadno.Midi

Methods

toMidiNotes :: t (Note p d) -> [([IPitch], IDur)] Source #

newtype MidiTempo Source #

Tempo in microseconds per quarter. See fromBPM.

Constructors

MidiTempo Int 

Instances

Instances details
Bounded MidiTempo Source # 
Instance details

Defined in Fadno.Midi

Enum MidiTempo Source # 
Instance details

Defined in Fadno.Midi

Num MidiTempo Source # 
Instance details

Defined in Fadno.Midi

Integral MidiTempo Source # 
Instance details

Defined in Fadno.Midi

Real MidiTempo Source # 
Instance details

Defined in Fadno.Midi

Methods

toRational :: MidiTempo -> Rational

Show MidiTempo Source # 
Instance details

Defined in Fadno.Midi

Methods

showsPrec :: Int -> MidiTempo -> ShowS

show :: MidiTempo -> String

showList :: [MidiTempo] -> ShowS

Eq MidiTempo Source # 
Instance details

Defined in Fadno.Midi

Methods

(==) :: MidiTempo -> MidiTempo -> Bool

(/=) :: MidiTempo -> MidiTempo -> Bool

Ord MidiTempo Source # 
Instance details

Defined in Fadno.Midi

Methods

compare :: MidiTempo -> MidiTempo -> Ordering

(<) :: MidiTempo -> MidiTempo -> Bool

(<=) :: MidiTempo -> MidiTempo -> Bool

(>) :: MidiTempo -> MidiTempo -> Bool

(>=) :: MidiTempo -> MidiTempo -> Bool

max :: MidiTempo -> MidiTempo -> MidiTempo

min :: MidiTempo -> MidiTempo -> MidiTempo

newtype MidiChan Source #

Midi channel, 1-16 presumably.

Constructors

MidiChan Int 

Instances

Instances details
Bounded MidiChan Source # 
Instance details

Defined in Fadno.Midi

Enum MidiChan Source # 
Instance details

Defined in Fadno.Midi

Num MidiChan Source # 
Instance details

Defined in Fadno.Midi

Integral MidiChan Source # 
Instance details

Defined in Fadno.Midi

Real MidiChan Source # 
Instance details

Defined in Fadno.Midi

Methods

toRational :: MidiChan -> Rational

Show MidiChan Source # 
Instance details

Defined in Fadno.Midi

Methods

showsPrec :: Int -> MidiChan -> ShowS

show :: MidiChan -> String

showList :: [MidiChan] -> ShowS

Eq MidiChan Source # 
Instance details

Defined in Fadno.Midi

Methods

(==) :: MidiChan -> MidiChan -> Bool

(/=) :: MidiChan -> MidiChan -> Bool

Ord MidiChan Source # 
Instance details

Defined in Fadno.Midi

Methods

compare :: MidiChan -> MidiChan -> Ordering

(<) :: MidiChan -> MidiChan -> Bool

(<=) :: MidiChan -> MidiChan -> Bool

(>) :: MidiChan -> MidiChan -> Bool

(>=) :: MidiChan -> MidiChan -> Bool

max :: MidiChan -> MidiChan -> MidiChan

min :: MidiChan -> MidiChan -> MidiChan

newtype MidiVelocity Source #

note velocity, 0-127

Constructors

MidiVelocity Int 

Instances

Instances details
Bounded MidiVelocity Source # 
Instance details

Defined in Fadno.Midi

Enum MidiVelocity Source # 
Instance details

Defined in Fadno.Midi

Num MidiVelocity Source # 
Instance details

Defined in Fadno.Midi

Integral MidiVelocity Source # 
Instance details

Defined in Fadno.Midi

Real MidiVelocity Source # 
Instance details

Defined in Fadno.Midi

Methods

toRational :: MidiVelocity -> Rational

Show MidiVelocity Source # 
Instance details

Defined in Fadno.Midi

Methods

showsPrec :: Int -> MidiVelocity -> ShowS

show :: MidiVelocity -> String

showList :: [MidiVelocity] -> ShowS

Eq MidiVelocity Source # 
Instance details

Defined in Fadno.Midi

Methods

(==) :: MidiVelocity -> MidiVelocity -> Bool

(/=) :: MidiVelocity -> MidiVelocity -> Bool

Ord MidiVelocity Source # 
Instance details

Defined in Fadno.Midi

newtype MidiProgram Source #

Midi program. See fromInstrument.

Constructors

MidiProgram Int 

Instances

Instances details
Bounded MidiProgram Source # 
Instance details

Defined in Fadno.Midi

Enum MidiProgram Source # 
Instance details

Defined in Fadno.Midi

Num MidiProgram Source # 
Instance details

Defined in Fadno.Midi

Integral MidiProgram Source # 
Instance details

Defined in Fadno.Midi

Real MidiProgram Source # 
Instance details

Defined in Fadno.Midi

Methods

toRational :: MidiProgram -> Rational

Show MidiProgram Source # 
Instance details

Defined in Fadno.Midi

Methods

showsPrec :: Int -> MidiProgram -> ShowS

show :: MidiProgram -> String

showList :: [MidiProgram] -> ShowS

Eq MidiProgram Source # 
Instance details

Defined in Fadno.Midi

Methods

(==) :: MidiProgram -> MidiProgram -> Bool

(/=) :: MidiProgram -> MidiProgram -> Bool

Ord MidiProgram Source # 
Instance details

Defined in Fadno.Midi

newtype MidiTicks Source #

Midi ticks per quarter.

Constructors

MidiTicks Int 

Instances

Instances details
Bounded MidiTicks Source # 
Instance details

Defined in Fadno.Midi

Enum MidiTicks Source # 
Instance details

Defined in Fadno.Midi

Num MidiTicks Source # 
Instance details

Defined in Fadno.Midi

Integral MidiTicks Source # 
Instance details

Defined in Fadno.Midi

Real MidiTicks Source # 
Instance details

Defined in Fadno.Midi

Methods

toRational :: MidiTicks -> Rational

Show MidiTicks Source # 
Instance details

Defined in Fadno.Midi

Methods

showsPrec :: Int -> MidiTicks -> ShowS

show :: MidiTicks -> String

showList :: [MidiTicks] -> ShowS

Eq MidiTicks Source # 
Instance details

Defined in Fadno.Midi

Methods

(==) :: MidiTicks -> MidiTicks -> Bool

(/=) :: MidiTicks -> MidiTicks -> Bool

Ord MidiTicks Source # 
Instance details

Defined in Fadno.Midi

Methods

compare :: MidiTicks -> MidiTicks -> Ordering

(<) :: MidiTicks -> MidiTicks -> Bool

(<=) :: MidiTicks -> MidiTicks -> Bool

(>) :: MidiTicks -> MidiTicks -> Bool

(>=) :: MidiTicks -> MidiTicks -> Bool

max :: MidiTicks -> MidiTicks -> MidiTicks

min :: MidiTicks -> MidiTicks -> MidiTicks

toTicks :: MidiTicks -> Iso' Rational IDur Source #

Rational to ticks

data MidiEvent Source #

Internal type for midi event or pad.

Constructors

Pad IDur 
Event T 

type MidiTrack = Track Source #

cover our tracks

writeMidiFile :: FilePath -> MidiData -> IO () Source #

write to disk.

showMidiFile :: FilePath -> IO () Source #

debug midi file.

midi :: MidiTicks -> [MidiTrack] -> MidiData Source #

Make midi file data

makeTrackFull :: MidiNotes notes => MidiTempo -> MidiChan -> MidiProgram -> MidiVelocity -> notes -> MidiTrack Source #

make a standard track which specifies tempo and program. | see makeTrack for more control.

fromBPM :: (Real a, Show a) => a -> MidiTempo Source #

BPM to microseconds per quarter note.

fromInstrument :: Instrument -> MidiProgram Source #

convert a General MIDI Instrument.

makeTrack :: [MidiEvent] -> MidiTrack Source #

make a track from track events.

toNoteEvents :: MidiNotes notes => MidiChan -> MidiVelocity -> notes -> [MidiEvent] Source #

turn notes into track events.

voiceEvent :: MidiChan -> T -> MidiEvent Source #

create a Voice MIDI event

setTempo :: MidiTempo -> MidiEvent Source #

tempo meta event.

metaEvent :: T -> MidiEvent Source #

create a Meta MIDI event

midiEvent :: MidiChan -> Body -> MidiEvent Source #

create a Voice or Mode MIDI event.

programChange :: MidiChan -> MidiProgram -> MidiEvent Source #

program change MIDI Voice event.

noteEvents :: MidiChan -> MidiVelocity -> ([IPitch], IDur) -> [MidiEvent] Source #

note on + note off events, using Pad to carve out space.

noteEvent :: (Pitch -> Velocity -> T) -> MidiChan -> MidiVelocity -> IPitch -> MidiEvent Source #

note on or note off event.

test1 :: IO () Source #

playMidi :: MidiNotes n => FilePath -> Int -> [(Instrument, n)] -> IO () Source #