hmt-0.20: Haskell Music Theory
Safe HaskellSafe-Inferred
LanguageHaskell2010

Music.Theory.Array.Csv.Midi.Mnd

Description

Functions for reading midi note data (Mnd) from Csv files.

This is not a generic text midi notation. The required columns are documented at Mnd and Mndd. The defined commands are on and off, but others may be present. Non-integral note number and key velocity data are allowed.

Synopsis

Param ; Sound.SC3.Server.Param

type Param = [(String, Double)] Source #

Mnd

data_value_pp :: Real t => Int -> t -> String Source #

If r is whole to k places then show as integer, else as float to k places.

type Channel = Int Source #

Channel values are 4-bit (0-15).

csv_mnd_hdr :: [String] Source #

The required header (column names) field.

type Mnd t n = (t, String, n, n, Channel, Param) Source #

Midi note data, the type parameters are to allow for fractional note & velocity values.

The command is a string, on and off are standard, other commands may be present. note and velocity data is (0-127), channel is (0-15), param are ;-separated key:string=value:float.

unwords csv_mnd_hdr == "time on/off note velocity channel param"
all_notes_off = zipWith (\t k -> (t,"off",k,0,0,[])) [0.0,0.01 ..] [0 .. 127]
csv_mnd_write 4 "/home/rohan/sw/hmt/data/csv/mnd/all-notes-off.csv" all_notes_off

csv_mnd_parse_f :: (Read t, Real t, Read n, Real n) => (n -> m) -> Csv_Table String -> [Mnd t m] Source #

csv_mnd_parse :: (Read t, Real t, Read n, Real n) => Csv_Table String -> [Mnd t n] Source #

csv_mnd_read :: (Read t, Real t, Read n, Real n) => FilePath -> IO [Mnd t n] Source #

Midi note data.

let fn = "/home/rohan/cvs/uc/uc-26/daily-practice/2014-08-13.1.csv"
let fn = "/home/rohan/sw/hmt/data/csv/mnd/1080-C01.csv"
m <- csv_mnd_read fn :: IO [Mnd Double Int]
length m -- 1800 17655
csv_mnd_write 4 "/tmp/t.csv" m

csv_mnd_write :: (Real t, Real n) => Int -> FilePath -> [Mnd t n] -> IO () Source #

Writer.

Mnd Seq forms

type Event n = (n, n, Channel, Param) Source #

(p0=midi-note,p1=velocity,channel,param)

event_mnn :: Event t -> t Source #

mnn = midi-note-number

event_ch :: Event t -> Channel Source #

ch = channel

event_eq_mnn :: Eq t => Event t -> Event t -> Bool Source #

Are events equal at mnn field?

event_eq_ol :: Eq t => Event t -> Event t -> Bool Source #

Are events equal at mnn and ch fields?

event_map :: (t -> u, t -> u, Channel -> Channel, Param -> Param) -> Event t -> Event u Source #

Apply (mnn-f,vel-f,ch-f,param-f) to Event.

event_cast :: (t -> u) -> Event t -> Event u Source #

Apply f at mnn and vel fields.

event_transpose :: Num a => a -> Event a -> Event a Source #

Add x to mnn field.

midi_tseq_to_midi_wseq :: (Num t, Eq n) => Tseq t (Begin_End (Event n)) -> Wseq t (Event n) Source #

Translate from Tseq form to Wseq form.

mnd_to_tseq :: Num n => [Mnd t n] -> Tseq t (Begin_End (Event n)) Source #

Ignores non on/off messages.

csv_mnd_read_tseq :: (Read t, Real t, Read n, Real n) => FilePath -> IO (Tseq t (Begin_End (Event n))) Source #

Tseq form of csv_mnd_read, channel information is retained, off-velocity is zero.

csv_mnd_write_tseq :: (Real t, Real n) => Int -> FilePath -> Tseq t (Begin_End (Event n)) -> IO () Source #

Tseq form of csv_mnd_write, data is .

Mndd (simplifies cases where overlaps on the same channel are allowed).

csv_mndd_hdr :: [String] Source #

Message should be note for note data.

type Mndd t n = (t, t, String, n, n, Channel, Param) Source #

Midi note/duration data. The type parameters are to allow for fractional note & velocity values. The command is a string, note is standard, other commands may be present.

unwords csv_mndd_hdr == "time duration message note velocity channel param"

mndd_compare :: (Ord t, Ord n) => Mndd t n -> Mndd t n -> Ordering Source #

Compare sequence is: start-time,channel-number,note-number,velocity,duration,param.

csv_mndd_parse_f :: (Read t, Real t, Read n, Real n) => (n -> m) -> Csv_Table String -> [Mndd t m] Source #

csv_mndd_parse :: (Read t, Real t, Read n, Real n) => Csv_Table String -> [Mndd t n] Source #

Pars midi note/duration data from Csv table.

csv_mndd_write :: (Real t, Real n) => Int -> FilePath -> [Mndd t n] -> IO () Source #

Writer.

Mndd Seq forms

mndd_to_wseq :: [Mndd t n] -> Wseq t (Event n) Source #

Ignores non note messages.

csv_mndd_read_wseq :: (Read t, Real t, Read n, Real n) => FilePath -> IO (Wseq t (Event n)) Source #

Wseq form of csv_mndd_read.

csv_mndd_write_wseq :: (Real t, Real n) => Int -> FilePath -> Wseq t (Event n) -> IO () Source #

Wseq form of csv_mndd_write.

Composite

csv_midi_parse_wseq_f :: (Read t, Real t, Read n, Real n, Num m, Eq m) => (n -> m) -> Csv_Table String -> Wseq t (Event m) Source #

Parse either Mnd or Mndd data to Wseq, Csv type is decided by header.

csv_midi_read_wseq :: (Read t, Real t, Read n, Real n) => FilePath -> IO (Wseq t (Event n)) Source #