Module

Hylograph.Music.Attributes

Package
purescript-hylograph-music
Repository
afcondon/purescript-hylograph-music

#time Source

time :: forall datum. (Int -> datum -> Number) -> AudioAttribute datum

When to play the note (time offset in seconds)

Maps to: AudioContext scheduling time Typical range: 0.0 to several seconds

Example:

time (\i _ -> toNumber i * 0.5)  -- Play every 0.5 seconds

#pitch Source

pitch :: forall datum. (Int -> datum -> Number) -> AudioAttribute datum

Pitch/frequency in Hz

Maps to: Oscillator frequency Typical range: 20 Hz to 4000 Hz

Common reference: A4 = 440 Hz, Middle C = 261.63 Hz

Example:

pitch (\_ d -> 200.0 + d.value * 10.0)  -- Map data to frequency

#duration Source

duration :: forall datum. (Int -> datum -> Number) -> AudioAttribute datum

Note duration in seconds

Maps to: How long the oscillator plays Typical range: 0.05 to 2.0 seconds

Example:

duration (\_ _ -> 0.3)  -- All notes 300ms

#volume Source

volume :: forall datum. (Int -> datum -> Number) -> AudioAttribute datum

Volume/amplitude

Maps to: Gain node value Range: 0.0 (silent) to 1.0 (full volume)

Example:

volume (\_ d -> d.value / 100.0)  -- Map data to volume

#timbre Source

timbre :: forall datum. (Int -> datum -> String) -> AudioAttribute datum

Waveform type (timbre)

Maps to: Oscillator type Valid values: "sine", "square", "sawtooth", "triangle"

Example:

timbre (\_ _ -> "sine")  -- Pure sine wave tone

#AudioAttribute Source

type AudioAttribute datum = Attribute datum

Audio-specific attributes for sonification

These parallel visual attributes (cx, cy, fill) but map to sonic parameters. They use the same Attribute infrastructure as Hylograph, allowing the same attribute-setting mechanisms to work for both visual and audio output. Type alias for clarity - these are still Hylograph Attributes but we use them for audio parameters