hsharc-0.12: Haskell SHARC bindings

Safe HaskellNone

Sound.Analysis.SHARC

Contents

Description

SHARC XML file IO.

Synopsis

Documentation

data Instrument Source

A SHARC instrument.

Constructors

Instrument 

Fields

instrument_id :: String
 
notes :: [Note]
 

data Note Source

A SHARC note.

Constructors

Note 

Fields

frequency :: Double
 
partials :: [Partial]
 

data Partial Source

A SHARC partial.

Constructors

Partial 

Fields

partial :: Int
 
amplitude :: Double
 
phase :: Double
 

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

Apply a linear scalar to the amplitudes of all Partials at a Note.

note_amplitude_minmax :: Note -> (Double, Double)Source

Find the minimum and maximum amplitudes of all Partials at a Note.

note_normalise :: Note -> NoteSource

Normalise a Note so the maximum amplitude of any Partial is 1.0.

instrument_amplitude_minmax :: Instrument -> (Double, Double)Source

Find the minimum and maximum amplitudes of all Partials at all Notes 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 Instruments.

parse_note :: Element -> NoteSource

Parse a note Element.