temporal-music-notation-0.4.1: music notation

Safe HaskellNone
LanguageHaskell98

Temporal.Music.Pitch

Contents

Description

This module defines notion of pitch.

Synopsis

Documentation

type Hz = Double Source

Cycles per second

type Interval = Double Source

Multiplier of Hz

c1 :: Hz Source

Middle C (261.626 Hz)

a1 :: Hz Source

Middle A (440 Hz)

transpose :: Interval -> Hz -> Hz Source

Transpose cycles per second by some interval.

Pitch

data Pitch Source

Pitch denotes Hz value. But it's not a double for ease of performing some musical transformations, transposition, bend, inversion, changing scales. Pitch can be converted to Hz with function hz. Pitch contains Scale, and point on the tone plane. The point is a triple (bend, octave, step). Bend denotes divergens from vertices of scale grid. Octave and Step are integers.

Constructors

Pitch 

fromStep :: Int -> Pitch Source

Constructs Pitch from some step value. Bend and Octave are set to zeroes. Scale is set to default scale which is defined in HasScale class.

type Bend = Double Source

Bend represents tone's diversion from scale grid.

type Step = Int Source

Scale

data Scale Source

Scale defines 2D grid (octave, step) in space of Hz units. Bend is a level of diversion from grid vertices. 1-level bend is equal to 1 step. For tones with fractional bends frequency is calculated with linear interpolation by nearest values in scale. Example:

s = Scale f0 d intervals

Here scale s defines 2D grid that mapps center point (0, 0) to frequency f0 Hz. Value d is octave interval. Octave interval is divided on steps. Steps are Interval s from base frequency f0 to desired frequency. Let's define equal temperament scale:

eqt = Scale c1 2 $ Vector.fromList $ (map ((2 **) . (/12)) [0..11])

fromIntervals :: Interval -> [Interval] -> Hz -> Scale Source

Scale constructor.

scaleStep :: Scale -> Int -> Interval Source

Gives scale multiplier

scaleLength :: Scale -> Int Source

Gives number of steps in one octave.

PitchLike

class PitchLike a where Source

Pitch can be used alongside with many other parameters (they can define timbre or loudness). Class PitchLike provides getters and setters for data types that contain value of type Pitch. In Temporal.Music.Score module you can find many functions that are defined in terms of this class. Once you have chosen some note representation you can make an instance for it and use all pitch-modifiers.

Methods

setPitch :: Pitch -> a -> a Source

getPitch :: a -> Pitch Source

Instances

mapPitch :: PitchLike a => (Pitch -> Pitch) -> a -> a Source

Pitch modifier.

Render

absPitch :: PitchLike a => a -> Hz Source

Calculates cycles per second for a pitch.

pitchAsDouble :: Pitch -> Double Source

Calculates position on tone plane for value of type Pitch.

scaleAt :: Scale -> Double -> Hz Source

Scale value on doubles