boopadoop-0.0.0.1: Mathematically sound sound synthesis

Safe HaskellSafe
LanguageHaskell2010

Boopadoop

Description

A music theory library for just intonation and other mathematically pure ideas.

Synopsis

Documentation

type DWave = Waveform Double Double Source #

A Double valued wave with time also in terms of Double. This models a real-valued waveform which typically has values in [-1,1] and is typically supported on either the entire real line (sinWave) or on a compact subset (compactWave)

newtype Waveform t a Source #

A Waveform is a function (of time) that we can later sample.

Constructors

Waveform 

Fields

Instances
Show (Waveform Double Double) Source #

Show a waveform by pretty printing some of the actual waveform in dot matrix form.

Instance details

Defined in Boopadoop

sampleFrom :: (t -> a) -> Waveform t a Source #

Build a Waveform by sampling the given function.

sampleAt :: t -> Waveform t a -> a Source #

Sample a Waveform at specified time. sampleAt = flip sample

sinWave :: Double -> DWave Source #

Pure sine wave of the given frequency

compactWave :: (Ord t, Num t) => (t, t) -> Waveform t Bool Source #

compactWave (l,h) is a wave which is 1 on [l,h) and 0 elsewhere

modulateMuting :: Num a => Waveform t Bool -> Waveform t a -> Waveform t a Source #

Modulate the muting or non-muting of another wave with a Bool value wave, such as compactWave.

modulate :: (a -> b -> c) -> Waveform t a -> Waveform t b -> Waveform t c Source #

Modulate one wave with another according to the given function pointwise. This means you can't implement phaseModulate using only this combinator because phase modulation requires information about the target wave at times other than the current time.

amplitudeModulate :: Num a => Waveform t a -> Waveform t a -> Waveform t a Source #

Modulate the amplitude of one wave with another. This is simply pointwise multiplication: amplitudeModulate = modulate (*)

phaseModulate Source #

Arguments

:: Num t 
=> t

Tuning parameter. Modulation signal is amplitudeModulated by (const beta)

-> Waveform t t

Modulation signal. Outputs the phase shift to apply

-> Waveform t a

Target wave to be modulated

-> Waveform t a 

Modulate the phase of one wave with another. Used in synthesis. phaseModulate beta (setVolume 0.2 $ sinWave concertA) (setVolume 0.38 $ triWave concertA) (try beta=0.0005)

changeSpeed :: (Ord a, Fractional a) => a -> a -> a -> Waveform a a -> Waveform a a Source #

Smoothly transition to playing a wave back at a different speed after some time

balanceChord :: Fractional a => [Waveform t a] -> Waveform t a Source #

Play several waves on top of each other, normalizing so that e.g. playing three notes together doesn't triple the volume.

mergeWaves :: Fractional a => [Waveform t a] -> Waveform t a Source #

Play several waves on top of each other, without worrying about the volume. See balanceChord for a normalized version.

waveformToWAVE :: Double -> DWave -> WAVE Source #

waveformToWAVE outputLength gives a WAVE file object by sampling the given DWave at 44100Hz. May disbehave or clip based on behavior of doubleToSample if the DWave takes values outside of [-1,1].

triWave :: (Ord a, RealFrac a) => a -> Waveform a a Source #

Triangle wave of the given frequency

testWave :: DWave -> IO () Source #

Output the first ten seconds of the given DWave to the file test.wav for testing. The volume is also attenuated by 50% to not blow out your eardrums. Also pretty prints the wave.

testDiagram :: PitchFactorDiagram -> IO () Source #

Outputs a sound test of the given PitchFactorDiagram as an interval above concertA as a sinWave to the file diag.wav for testing.

sequenceToBeat :: Double -> Double -> Beat DWave -> DWave Source #

Converts a rhythm of DWave notes to a combined DWave according to the timing rules of Beat.

sequenceNotes :: (Ord t, Fractional t, Fractional a) => [((t, t), Waveform t a)] -> Waveform t a Source #

Sequences some waves to play on the given time intervals.

buildChord :: [Double] -> Double -> DWave Source #

Builds a chord out of the given ratios relative to the root pitch buildChord ratios root

buildChordNoBalance :: [Double] -> Double -> DWave Source #

Builds a chord out of the given ratios relative to the root pitch, without normalizing the volume. (Warning: may be loud)

majorChordOver :: Double -> DWave Source #

Builds a just-intonated major chord over the given root pitch

minorChordOver :: Double -> DWave Source #

Builds an equal temperament minor chord over the given root pitch

concertA :: Num a => a Source #

Concert A4 frequency is 440Hz

envelope :: Double -> Double -> Double -> Double -> Double -> Double -> DWave Source #

Build an envelope waveform with the given parameters: Predelay Time, Attack Time, Hold Time, Decay Time, Sustain Level, Release Time

timeShift :: Num t => t -> Waveform t a -> Waveform t a Source #

Shift a wave in time to start at the specified time after its old start time

equalTime :: Double -> [DWave] -> DWave Source #

Play several waves in a row with eqqual time each, using sequenceNotes.

setVolume :: Num a => a -> Waveform t a -> Waveform t a Source #

Modify the amplitude of a wave by a constant multiple

emptyWave :: Num a => Waveform t a Source #

The empty wave that is always zero when sampled