-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Handling of MIDI messages and files
--
-- MIDI is the Musical Instrument Digital Interface. The package contains
-- definition of MIDI messages, reading and writing MIDI files. It
-- contains no sending and receiving of MIDI messages. Cf. alsa-midi
-- package. For music composition with MIDI output, see Haskore.
@package midi
@version 0.0.7
-- | Taken from Haskore.
module Sound.MIDI.IO
-- | Like openFile, but open the file in binary mode. On Windows,
-- reading a file in text mode (which is the default) will translate CRLF
-- to LF, and writing will translate LF to CRLF. This is usually what you
-- want with text files. With binary files this is undesirable; also, as
-- usual under Microsoft operating systems, text mode treats control-Z as
-- EOF. Binary mode turns off all special treatment of end-of-line and
-- end-of-file characters. (See also hSetBinaryMode.)
openBinaryFile :: FilePath -> IOMode -> IO Handle
readBinaryFile :: FilePath -> IO ByteString
-- | Hugs makes trouble here because it performs UTF-8 conversions. E.g.
-- [255] is output as [195,191] It would be easy to
-- replace these routines by FastPackedString(fps).ByteString.Lazy,
-- however this introduces a new package dependency.
writeBinaryFile :: FilePath -> ByteString -> IO ()
type ByteString = [Word8]
stringCharFromByte :: ByteString -> String
stringByteFromChar :: String -> ByteString
-- | Datatype for MIDI events as they can be sent to a synthesizer. That
-- is, no timing is handled here.
--
-- Taken from Haskore.
module Sound.MIDI.Event
data T
NoteOff :: Pitch -> Velocity -> T
NoteOn :: Pitch -> Velocity -> T
PolyAfter :: Pitch -> Pressure -> T
ProgramChange :: Program -> T
Control :: Controller -> ControllerValue -> T
PitchBend :: PitchBendRange -> T
MonoAfter :: Pressure -> T
data Pitch
data Program
data Channel
-- | Types of predefined MIDI controllers.
data Controller
BankSelectMSB :: Controller
ModulationMSB :: Controller
BreathControlMSB :: Controller
Controller03 :: Controller
FootControlMSB :: Controller
PortamentoTimeMSB :: Controller
DataEntryMSB :: Controller
MainVolumeMSB :: Controller
BalanceMSB :: Controller
Controller09 :: Controller
PanoramaMSB :: Controller
ExpressionMSB :: Controller
Controller0C :: Controller
Controller0D :: Controller
Controller0E :: Controller
Controller0F :: Controller
GeneralPurpose1MSB :: Controller
GeneralPurpose2MSB :: Controller
GeneralPurpose3MSB :: Controller
GeneralPurpose4MSB :: Controller
Controller14 :: Controller
Controller15 :: Controller
Controller16 :: Controller
Controller17 :: Controller
Controller18 :: Controller
Controller19 :: Controller
Controller1A :: Controller
Controller1B :: Controller
Controller1C :: Controller
Controller1D :: Controller
Controller1E :: Controller
Controller1F :: Controller
BankSelectLSB :: Controller
ModulationLSB :: Controller
BreathControlLSB :: Controller
Controller23 :: Controller
FootControlLSB :: Controller
PortamentoTimeLSB :: Controller
DataEntryLSB :: Controller
MainVolumeLSB :: Controller
BalanceLSB :: Controller
Controller29 :: Controller
PanoramaLSB :: Controller
ExpressionLSB :: Controller
Controller2C :: Controller
Controller2D :: Controller
Controller2E :: Controller
Controller2F :: Controller
GeneralPurpose1LSB :: Controller
GeneralPurpose2LSB :: Controller
GeneralPurpose3LSB :: Controller
GeneralPurpose4LSB :: Controller
Controller34 :: Controller
Controller35 :: Controller
Controller36 :: Controller
Controller37 :: Controller
Controller38 :: Controller
Controller39 :: Controller
Controller3A :: Controller
Controller3B :: Controller
Controller3C :: Controller
Controller3D :: Controller
Controller3E :: Controller
Controller3F :: Controller
Sustain :: Controller
Porta :: Controller
Sustenuto :: Controller
SoftPedal :: Controller
Controller44 :: Controller
Hold2 :: Controller
Controller46 :: Controller
Controller47 :: Controller
Controller48 :: Controller
Controller49 :: Controller
Controller4A :: Controller
Controller4B :: Controller
Controller4C :: Controller
Controller4D :: Controller
Controller4E :: Controller
Controller4F :: Controller
GeneralPurpose5 :: Controller
GeneralPurpose6 :: Controller
GeneralPurpose7 :: Controller
GeneralPurpose8 :: Controller
Controller54 :: Controller
Controller55 :: Controller
Controller56 :: Controller
Controller57 :: Controller
Controller58 :: Controller
Controller59 :: Controller
Controller5A :: Controller
ExtDepth :: Controller
TremoloDepth :: Controller
ChorusDepth :: Controller
CelesteDepth :: Controller
PhaserDepth :: Controller
DataIncrement :: Controller
DataDecrement :: Controller
NonRegisteredParameterLSB :: Controller
NonRegisteredParameterMSB :: Controller
RegisteredParameterLSB :: Controller
RegisteredParameterMSB :: Controller
Controller66 :: Controller
Controller67 :: Controller
Controller68 :: Controller
Controller69 :: Controller
Controller6A :: Controller
Controller6B :: Controller
Controller6C :: Controller
Controller6D :: Controller
Controller6E :: Controller
Controller6F :: Controller
Controller70 :: Controller
Controller71 :: Controller
Controller72 :: Controller
Controller73 :: Controller
Controller74 :: Controller
Controller75 :: Controller
Controller76 :: Controller
Controller77 :: Controller
Controller78 :: Controller
Controller79 :: Controller
Controller7A :: Controller
Controller7B :: Controller
Controller7C :: Controller
Controller7D :: Controller
Controller7E :: Controller
Controller7F :: Controller
type ControllerValue = Int
type PitchBendRange = Int
type Pressure = Int
data Velocity
isNote :: T -> Bool
isNoteOn :: T -> Bool
isNoteOff :: T -> Bool
-- | A MIDI problem is that one cannot uniquely map a MIDI key to a
-- frequency. The frequency depends on the instrument. I don't know if
-- the deviations are defined for General MIDI. If this applies one could
-- add transposition information to the use patch map. For now I have
-- chosen a value that leads to the right frequency for some piano sound
-- in my setup.
zeroKey :: Pitch
-- | The velocity of an ordinary key stroke and the maximum possible
-- velocity.
maximumVelocity :: (Num quant) => quant
normalVelocity :: (Num quant) => quant
-- | 64 is given as default value by the MIDI specification and thus we map
-- it to 1. 0 is mapped to 0. All other values are interpolated linearly.
toFloatVelocity :: (Integral a, Fractional b) => a -> b
-- | Map integral MIDI controller value to floating point value. Maximum
-- integral MIDI controller value 127 is mapped to 1. Minimum integral
-- MIDI controller value 0 is mapped to 0.
toFloatController :: (Integral a, Fractional b) => a -> b
bankSelect :: Controller
modulation :: Controller
breathControl :: Controller
footControl :: Controller
portamentoTime :: Controller
dataEntry :: Controller
mainVolume :: Controller
balance :: Controller
panorama :: Controller
expression :: Controller
generalPurpose1 :: Controller
generalPurpose2 :: Controller
generalPurpose3 :: Controller
generalPurpose4 :: Controller
vectorX :: Controller
vectorY :: Controller
bankSelectMSB :: Controller
modulationMSB :: Controller
breathControlMSB :: Controller
footControlMSB :: Controller
portamentoTimeMSB :: Controller
dataEntryMSB :: Controller
mainVolumeMSB :: Controller
balanceMSB :: Controller
panoramaMSB :: Controller
expressionMSB :: Controller
generalPurpose1MSB :: Controller
generalPurpose2MSB :: Controller
generalPurpose3MSB :: Controller
generalPurpose4MSB :: Controller
bankSelectLSB :: Controller
modulationLSB :: Controller
breathControlLSB :: Controller
footControlLSB :: Controller
portamentoTimeLSB :: Controller
dataEntryLSB :: Controller
mainVolumeLSB :: Controller
balanceLSB :: Controller
panoramaLSB :: Controller
expressionLSB :: Controller
generalPurpose1LSB :: Controller
generalPurpose2LSB :: Controller
generalPurpose3LSB :: Controller
generalPurpose4LSB :: Controller
sustain :: Controller
porta :: Controller
sustenuto :: Controller
softPedal :: Controller
hold2 :: Controller
generalPurpose5 :: Controller
generalPurpose6 :: Controller
generalPurpose7 :: Controller
generalPurpose8 :: Controller
extDepth :: Controller
tremoloDepth :: Controller
chorusDepth :: Controller
celesteDepth :: Controller
phaserDepth :: Controller
dataIncrement :: Controller
dataDecrement :: Controller
nonRegisteredParameterLSB :: Controller
nonRegisteredParameterMSB :: Controller
registeredParameterLSB :: Controller
registeredParameterMSB :: Controller
fromPitch :: Pitch -> Int
toPitch :: Int -> Pitch
fromVelocity :: Velocity -> Int
toVelocity :: Int -> Velocity
fromProgram :: Program -> Int
toProgram :: Int -> Program
fromChannel :: Channel -> Int
toChannel :: Int -> Channel
increasePitch :: Int -> Pitch -> Pitch
subtractPitch :: Pitch -> Pitch -> Int
instance Show Controller
instance Eq Controller
instance Ord Controller
instance Enum Controller
instance Show T
instance Eq T
instance Ord T
instance Show Channel
instance Eq Channel
instance Ord Channel
instance Ix Channel
instance Show Program
instance Eq Program
instance Ord Program
instance Ix Program
instance Show Velocity
instance Eq Velocity
instance Ord Velocity
instance Show Pitch
instance Eq Pitch
instance Ord Pitch
instance Ix Pitch
instance Bounded Channel
instance Bounded Program
instance Bounded Velocity
instance Bounded Pitch
instance Enum Pitch
instance Enum Channel
instance Enum Program
-- | MIDI-File Datatype
--
-- Taken from Haskore.
module Sound.MIDI.File
-- | The datatypes for MIDI Files and MIDI Events
data T
Cons :: Type -> Division -> [Track] -> T
data Division
Ticks :: Tempo -> Division
SMPTE :: Int -> Int -> Division
type Track = T ElapsedTime Event
data Type
Mixed :: Type
Parallel :: Type
Serial :: Type
type SchedEvent = (ElapsedTime, Event)
data Event
MIDIEvent :: Channel -> T -> Event
MetaEvent :: MetaEvent -> Event
SysExStart :: ByteString -> Event
SysExCont :: ByteString -> Event
type ElapsedTime = Integer
type Tempo = Int
type SMPTEHours = Int
type SMPTEMins = Int
type SMPTESecs = Int
type SMPTEFrames = Int
type SMPTEBits = Int
data MetaEvent
SequenceNum :: Int -> MetaEvent
TextEvent :: String -> MetaEvent
Copyright :: String -> MetaEvent
TrackName :: String -> MetaEvent
InstrName :: String -> MetaEvent
Lyric :: String -> MetaEvent
Marker :: String -> MetaEvent
CuePoint :: String -> MetaEvent
MIDIPrefix :: Channel -> MetaEvent
EndOfTrack :: MetaEvent
SetTempo :: Tempo -> MetaEvent
SMPTEOffset :: SMPTEHours -> SMPTEMins -> SMPTESecs -> SMPTEFrames -> SMPTEBits -> MetaEvent
TimeSig :: Int -> Int -> Int -> Int -> MetaEvent
KeySig :: Key -> Mode -> MetaEvent
SequencerSpecific :: ByteString -> MetaEvent
Unknown :: Int -> ByteString -> MetaEvent
maybeMIDIEvent :: Event -> Maybe (Channel, T)
maybeMetaEvent :: Event -> Maybe MetaEvent
-- | The following enumerated type lists all the keys in order of their key
-- signatures from flats to sharps. (Cf = 7 flats, Gf =
-- 6 flats ... F = 1 flat, C = 0 flats/sharps,
-- G = 1 sharp, ... Cs = 7 sharps.) Useful for
-- transposition.
data Key
KeyCf :: Key
KeyGf :: Key
KeyDf :: Key
KeyAf :: Key
KeyEf :: Key
KeyBf :: Key
KeyF :: Key
KeyC :: Key
KeyG :: Key
KeyD :: Key
KeyA :: Key
KeyE :: Key
KeyB :: Key
KeyFs :: Key
KeyCs :: Key
-- | The Key Signature specifies a mode, either major or minor.
data Mode
Major :: Mode
Minor :: Mode
defltST :: Tempo
-- | Default duration of a whole note, in seconds; and the default SetTempo
-- value, in microseconds per quarter note. Both express the default of
-- 120 beats per minute.
defltDurT :: ElapsedTime
-- | An empty MIDI file.
empty :: T
-- | Show the T with one event per line, suited for comparing
-- MIDIFiles with diff. Can this be replaced by
-- Sound.MIDI.Load.showFile?
showLines :: T -> String
-- | A hack that changes the velocities by a rational factor.
changeVelocity :: Double -> T -> T
getTracks :: T -> [Track]
-- | Change the time base.
resampleTime :: Double -> T -> T
showEvent :: Event -> ShowS
showTime :: ElapsedTime -> ShowS
-- | Sort MIDI note events lexicographically. This is to make MIDI files
-- unique and robust against changes in the computation. In principle
-- Performance.merge should handle this but due to rounding errors in
-- Float the order of note events still depends on some internal issues.
-- The sample rate of MIDI events should be coarse enough to assert
-- unique results.
sortEvents :: T -> T
-- | Old versions of Haskore.Interface.MIDI.Write wrote
-- ProgramChange and SetTempo once at the beginning of a
-- file in that order. The current version supports multiple
-- ProgramChanges in a track and thus a ProgramChange is
-- set immediately before a note. Because of this a ProgramChange
-- is now always after a SetTempo. For checking equivalence with
-- old MIDI files we can switch this back.
progChangeBeforeSetTempo :: T -> T
instance Show Mode
instance Eq Mode
instance Ord Mode
instance Enum Mode
instance Show Key
instance Eq Key
instance Ord Key
instance Ix Key
instance Enum Key
instance Show MetaEvent
instance Eq MetaEvent
instance Ord MetaEvent
instance Show Event
instance Eq Event
instance Ord Event
instance Show Division
instance Eq Division
instance Show Type
instance Eq Type
instance Enum Type
instance Show T
instance Eq T
-- | Loading MIDI Files
--
-- This module loads and parses a MIDI File. It can convert it into a
-- T data type object or simply print out the contents of the
-- file.
module Sound.MIDI.File.Load
-- | The main load function.
fromFile :: FilePath -> IO T
fromStream :: ByteString -> T
maybeFromStream :: ByteString -> Either String (T, ByteString)
maybeEventFromStream :: ByteString -> Either String (Event, ByteString)
-- | Functions to show the decoded contents of a MIDI file in an
-- easy-to-read format. This is for debugging purposes and should not be
-- used in production code.
showFile :: FilePath -> IO ()
instance Eq Chunk
-- | Save MIDI data to files.
--
-- The functions in this module allow Ts to be written into
-- Standard MIDI files (*.mid) that can be read and played by
-- music programs such as Cakewalk.
module Sound.MIDI.File.Save
-- | The function toFile is the main function for writing T
-- values to an actual file.
toFile :: FilePath -> T -> IO ()
-- | Convert a MIDI file to a ByteString.
toStream :: T -> ByteString
-- | Convert a MIDI file to a ByteString while replacing chunk lengths by
-- (-1). This way writing the file is more lazy. I don't know whether
-- this is useful for anything, thus simply don't use it.
toOpenStream :: T -> ByteString
eventToStream :: Event -> ByteString
-- | General-MIDI definitions.
--
-- Taken from Haskore.
module Sound.MIDI.General
instrumentNameToProgram :: String -> Maybe Program
instrumentNames :: [String]
instrumentPrograms :: [(String, Program)]
instrumentFromProgram :: Program -> Instrument
instrumentToProgram :: Instrument -> Program
instrumentChannels :: [Channel]
instruments :: [Instrument]
data Instrument
AcousticGrandPiano :: Instrument
BrightAcousticPiano :: Instrument
ElectricGrandPiano :: Instrument
HonkyTonk :: Instrument
ElectricPiano1 :: Instrument
ElectricPiano2 :: Instrument
Harpsichord :: Instrument
Clavinet :: Instrument
Celesta :: Instrument
Glockenspiel :: Instrument
MusicBox :: Instrument
Vibraphone :: Instrument
Marimba :: Instrument
Xylophone :: Instrument
TubularBells :: Instrument
Dulcimer :: Instrument
DrawbarOrgan :: Instrument
PercussiveOrgan :: Instrument
RockOrgan :: Instrument
ChurchOrgan :: Instrument
ReedOrgan :: Instrument
Accordion :: Instrument
Harmonica :: Instrument
TangoAccordian :: Instrument
AcousticGuitarNylon :: Instrument
AcousticGuitarSteel :: Instrument
ElectricGuitarJazz :: Instrument
ElectricGuitarClean :: Instrument
ElectricGuitarMuted :: Instrument
OverdrivenGuitar :: Instrument
DistortionGuitar :: Instrument
GuitarHarmonics :: Instrument
AcousticBass :: Instrument
ElectricBassFinger :: Instrument
ElectricBassPick :: Instrument
FretlessBass :: Instrument
SlapBass1 :: Instrument
SlapBass2 :: Instrument
SynthBass1 :: Instrument
SynthBass2 :: Instrument
Violin :: Instrument
Viola :: Instrument
Cello :: Instrument
Contrabass :: Instrument
TremoloStrings :: Instrument
PizzicatoStrings :: Instrument
OrchestralHarp :: Instrument
Timpani :: Instrument
StringEnsemble1 :: Instrument
StringEnsemble2 :: Instrument
SynthStrings1 :: Instrument
SynthStrings2 :: Instrument
ChoirAahs :: Instrument
VoiceOohs :: Instrument
SynthVoice :: Instrument
OrchestraHit :: Instrument
Trumpet :: Instrument
Trombone :: Instrument
Tuba :: Instrument
MutedTrumpet :: Instrument
FrenchHorn :: Instrument
BrassSection :: Instrument
SynthBrass1 :: Instrument
SynthBrass2 :: Instrument
SopranoSax :: Instrument
AltoSax :: Instrument
TenorSax :: Instrument
BaritoneSax :: Instrument
Oboe :: Instrument
EnglishHorn :: Instrument
Bassoon :: Instrument
Clarinet :: Instrument
Piccolo :: Instrument
Flute :: Instrument
Recorder :: Instrument
PanFlute :: Instrument
BlownBottle :: Instrument
Skakuhachi :: Instrument
Whistle :: Instrument
Ocarina :: Instrument
Lead1Square :: Instrument
Lead2Sawtooth :: Instrument
Lead3Calliope :: Instrument
Lead4Chiff :: Instrument
Lead5Charang :: Instrument
Lead6Voice :: Instrument
Lead7Fifths :: Instrument
Lead8BassLead :: Instrument
Pad1NewAge :: Instrument
Pad2Warm :: Instrument
Pad3Polysynth :: Instrument
Pad4Choir :: Instrument
Pad5Bowed :: Instrument
Pad6Metallic :: Instrument
Pad7Halo :: Instrument
Pad8Sweep :: Instrument
FX1Rain :: Instrument
FX2Soundtrack :: Instrument
FX3Crystal :: Instrument
FX4Atmosphere :: Instrument
FX5Brightness :: Instrument
FX6Goblins :: Instrument
FX7Echoes :: Instrument
FX8SciFi :: Instrument
Sitar :: Instrument
Banjo :: Instrument
Shamisen :: Instrument
Koto :: Instrument
Kalimba :: Instrument
Bagpipe :: Instrument
Fiddle :: Instrument
Shanai :: Instrument
TinkleBell :: Instrument
Agogo :: Instrument
SteelDrums :: Instrument
Woodblock :: Instrument
TaikoDrum :: Instrument
MelodicTom :: Instrument
SynthDrum :: Instrument
ReverseCymbal :: Instrument
GuitarFretNoise :: Instrument
BreathNoise :: Instrument
Seashore :: Instrument
BirdTweet :: Instrument
TelephoneRing :: Instrument
Helicopter :: Instrument
Applause :: Instrument
Gunshot :: Instrument
drumChannel :: Channel
drumProgram :: Program
drumMinKey :: Pitch
drumKeyTable :: [(Drum, Pitch)]
drumFromKey :: Pitch -> Drum
drumToKey :: Drum -> Pitch
drums :: [Drum]
data Drum
AcousticBassDrum :: Drum
BassDrum1 :: Drum
SideStick :: Drum
AcousticSnare :: Drum
HandClap :: Drum
ElectricSnare :: Drum
LowFloorTom :: Drum
ClosedHiHat :: Drum
HighFloorTom :: Drum
PedalHiHat :: Drum
LowTom :: Drum
OpenHiHat :: Drum
LowMidTom :: Drum
HiMidTom :: Drum
CrashCymbal1 :: Drum
HighTom :: Drum
RideCymbal1 :: Drum
ChineseCymbal :: Drum
RideBell :: Drum
Tambourine :: Drum
SplashCymbal :: Drum
Cowbell :: Drum
CrashCymbal2 :: Drum
Vibraslap :: Drum
RideCymbal2 :: Drum
HiBongo :: Drum
LowBongo :: Drum
MuteHiConga :: Drum
OpenHiConga :: Drum
LowConga :: Drum
HighTimbale :: Drum
LowTimbale :: Drum
HighAgogo :: Drum
LowAgogo :: Drum
Cabasa :: Drum
Maracas :: Drum
ShortWhistle :: Drum
LongWhistle :: Drum
ShortGuiro :: Drum
LongGuiro :: Drum
Claves :: Drum
HiWoodBlock :: Drum
LowWoodBlock :: Drum
MuteCuica :: Drum
OpenCuica :: Drum
MuteTriangle :: Drum
OpenTriangle :: Drum
enumRandomR :: (Enum a, RandomGen g) => (a, a) -> g -> (a, g)
boundedEnumRandom :: (Enum a, Bounded a, RandomGen g) => g -> (a, g)
chooseEnum :: (Enum a, Bounded a, Random a) => Gen a
instance Show Drum
instance Eq Drum
instance Ord Drum
instance Ix Drum
instance Enum Drum
instance Bounded Drum
instance Show Instrument
instance Eq Instrument
instance Ord Instrument
instance Ix Instrument
instance Enum Instrument
instance Bounded Instrument
instance Arbitrary Drum
instance Random Drum
instance Arbitrary Instrument
instance Random Instrument