Safe Haskell | None |
---|
SHARC XML file IO.
- data Instrument = Instrument {
- instrument_id :: String
- notes :: [Note]
- data Note = Note {}
- data Partial = Partial {}
- read_sharc :: FilePath -> IO (Either String [Instrument])
- partial_frequency :: Double -> Partial -> Double
- partial_triple :: Double -> Partial -> (Double, Double, Double)
- note_spectra :: Note -> [(Double, Double, Double)]
- note_n_partials :: Note -> Int
- partial_scale_amplitude :: Double -> Partial -> Partial
- note_scale_amplitude :: Double -> Note -> Note
- note_amplitude_minmax :: Note -> (Double, Double)
- note_normalise :: Note -> Note
- instrument_amplitude_minmax :: Instrument -> (Double, Double)
- instrument_normalise :: Instrument -> Instrument
- parse_tree :: Element -> [Instrument]
- parse_instrument :: Element -> Instrument
- parse_note :: Element -> Note
- parse_partial :: Element -> Partial
Documentation
read_sharc :: FilePath -> IO (Either String [Instrument])Source
Read a SHARC XML file.
Partial analysis
partial_frequency :: Double -> Partial -> DoubleSource
Calculate the frequency of a Partial
given the fundamental frequency.
partial_frequency 440 (Partial 3 0.1 0) == 1320
partial_triple :: Double -> Partial -> (Double, Double, Double)Source
Calculate the (frequency,amplitude,phase)
triple of a
Partial
given the fundamental frequency.
partial_triple 440 (Partial 3 0.1 pi) == (1320,0.1,pi)
Note analysis
note_spectra :: Note -> [(Double, Double, Double)]Source
Translate a Note
into (frequency,amplitude,phase) triples.
note_spectra (Note 440 [Partial 3 0.1 pi]) == [(1320,0.1,pi)]
note_n_partials :: Note -> IntSource
The number of partials at a Note
.
Amplitude transformations
partial_scale_amplitude :: Double -> Partial -> PartialSource
Apply a linear scalar to the amplitude of a Partial
.
note_scale_amplitude :: Double -> Note -> NoteSource
note_amplitude_minmax :: Note -> (Double, Double)Source
note_normalise :: Note -> NoteSource
instrument_amplitude_minmax :: Instrument -> (Double, Double)Source
Find the minimum and maximum amplitudes of all Partial
s at all
Note
s of an Instrument
.
instrument_normalise :: Instrument -> InstrumentSource
Normalise an Instrument
so the maximum amplitude of any
Partial
is 1.0
.
XML parsers
parse_tree :: Element -> [Instrument]Source
The root Element
of a SHARC xml graphs is a tree
, which
parses to a list of Instrument
s.
parse_instrument :: Element -> InstrumentSource
Parse an instrument
Element
.
parse_note :: Element -> NoteSource
Parse a note
Element
.
parse_partial :: Element -> PartialSource
Parse an a
Element
.