Functions for manipulating a sound whose amplitude representation is arrays of doubles.
Functions for manipulating a sound whose amplitude representation is arrays of doubles.
(->stereo s)
(->stereo l r)
Creates a stereo sound. If given one single-channel sound, duplicates channel zero on two channels. If given a single stereo sound, returns it. If given two single-channel sounds, returns a sound with the first sound on channel 0 and the second sound on channel 1.
Creates a stereo sound. If given one single-channel sound, duplicates channel zero on two channels. If given a single stereo sound, returns it. If given two single-channel sounds, returns a sound with the first sound on channel 0 and the second sound on channel 1.
(append s1 s2)
Concatenates two sounds together
Concatenates two sounds together
(constant duration chans x)
Returns a sound of duration
that has chans
channels, each of
which is constant at x
.
Returns a sound of `duration` that has `chans` channels, each of which is constant at `x`.
(defsound name
duration-param
channels-param
docstring
args
[sample-rate num-samples index c]
expr)
Expands to define a function name
that accepts arguments args
returns a sound with duration
, channels
whose samples are
determined by expr
. Inside expr, the sample rate, the total number
of samples, the current sample index, and the current channel number
will be bound to the four symbols in bindings
.
Expands to define a function `name` that accepts arguments `args` returns a sound with `duration`, `channels` whose samples are determined by `expr`. Inside expr, the sample rate, the total number of samples, the current sample index, and the current channel number will be bound to the four symbols in `bindings`.
(envelope s1 s2)
Multiplies the amplitudes of s1
and s2
, trimming the sound to
the shorter of the two.
Multiplies the amplitudes of `s1` and `s2`, trimming the sound to the shorter of the two.
(fade-in s fade-duration)
Fades s
linearly from zero at the beginning to full volume at
duration
.
Fades `s` linearly from zero at the beginning to full volume at `duration`.
(fade-out s fade-duration)
Fades the s to zero for the last duration
.
Fades the s to zero for the last `duration`.
(fn-sound duration chans f)
Creates a SampledSound duration
seconds long where the amplitudes
are produced by f
, a function of a channel number and a time in
seconds.
Creates a SampledSound `duration` seconds long where the amplitudes are produced by `f`, a function of a channel number and a time in seconds.
(gain s g)
Changes the amplitude of s
by g
.
Changes the amplitude of `s` by `g`.
(linear duration chans start end)
Returns a sound of duration
that has chans
channels, each of
which changes linearly from start
to end
.
Returns a sound of `duration` that has `chans` channels, each of which changes linearly from `start` to `end`.
(mix s1 s2)
Mixes sounds s1
and s2
together.
Mixes sounds `s1` and `s2` together.
(multiplex s n)
Takes a single-channel sound s
and returns an n
-channel sound
whose channels are all identical to channel 0 of s
.
Takes a single-channel sound `s` and returns an `n`-channel sound whose channels are all identical to channel 0 of `s`.
(pan s amount)
Takes a two-channel sound and mixes the channels together by
amount
, a float on the range [0.0, 1.0]. The ususal use is to take
a sound with separate left and right channels and combine them so
each appears closer to stereo center. An amount
of 0.0 would leave
both channels unchanged, 0.5 would result in both channels being the
same (i.e. appearing to be mixed to stereo center), and 1.0 would
switch the channels.
Takes a two-channel sound and mixes the channels together by `amount`, a float on the range [0.0, 1.0]. The ususal use is to take a sound with separate left and right channels and combine them so each appears closer to stereo center. An `amount` of 0.0 would leave both channels unchanged, 0.5 would result in both channels being the same (i.e. appearing to be mixed to stereo center), and 1.0 would switch the channels.
(peak s sample-rate)
(peak s sample-rate limit)
Returns the maximum absolute amplitude of s
when sampled at
sample-rate
. If provided, will return immediately on finding a
value above limit
.
Returns the maximum absolute amplitude of `s` when sampled at `sample-rate`. If provided, will return immediately on finding a value above `limit`.
(play s sample-rate)
Plays s
asynchronously. Returns a value that can be passed to stop
.
Plays `s` asynchronously. Returns a value that can be passed to `stop`.
(read-sound path)
Given a path to a .wav or .mp3 file, return a SampledSound instance over it.
Given a path to a .wav or .mp3 file, return a SampledSound instance over it.
Represents a sound as a sequence of vectors of Java double arrays.
Represents a sound as a sequence of vectors of Java double arrays.
(channels this)
Returns the number of channels in the sound.
Returns the number of channels in the sound.
(chunks this sample-rate)
Returns a sequence of sequences each containing a sequence of double arrays - one per channel - populated with the data for this sound. The total number of samples per channel will be (* duration sample-rate)
Returns a sequence of sequences each containing a sequence of double arrays - one per channel - populated with the data for this sound. The total number of samples per channel will be (* duration sample-rate)
(duration this)
Returns the duration of the sound in seconds.
Returns the duration of the sound in seconds.
(save s path sample-rate)
Save sound s
to path
as a 16-bit WAV at sample-rate
.
Save sound `s` to `path` as a 16-bit WAV at `sample-rate`.
(save-to-stream s output-stream sample-rate)
Save sound s
to output-stream
as a 16-bit WAV at sample-rate
.
Save sound `s` to `output-stream` as a 16-bit WAV at `sample-rate`.
(segmented-linear chans & spec)
Produces a sound with chans
channels whose amplitudes change
linearly as described by spec
. Spec is a sequence of interleaved
amplitudes and durations. For example the spec
1.0 30 0 10 0 0.5 1.0
(written that way on purpose - durations and amplitudes are in columns) would produce a sound whose amplitude starts at 1.0, linearly changes to 0.0 at time 30, stays at 0 for 10 seconds, then ramps up to its final value of 1.0 over 0.5 seconds
Produces a sound with `chans` channels whose amplitudes change linearly as described by `spec`. Spec is a sequence of interleaved amplitudes and durations. For example the spec 1.0 30 0 10 0 0.5 1.0 (written that way on purpose - durations and amplitudes are in columns) would produce a sound whose amplitude starts at 1.0, linearly changes to 0.0 at time 30, stays at 0 for 10 seconds, then ramps up to its final value of 1.0 over 0.5 seconds
(shortify f)
Takes a floating-point number f in the range [-1.0, 1.0] and scales it to the range of a 16-bit integer. Clamps any overflows.
Takes a floating-point number f in the range [-1.0, 1.0] and scales it to the range of a 16-bit integer. Clamps any overflows.
(silence dur chans)
Returns a sound of duration
with chans
channels of silence.
Returns a sound of `duration` with `chans` channels of silence.
(sinusoid duration frequency)
Returns a single-channel sound of duration
and frequency
Returns a single-channel sound of `duration` and `frequency`
(square-wave duration frequency)
Produces a single-channel sound that toggles between 1.0 and -1.0
at frequency freq
.
Produces a single-channel sound that toggles between 1.0 and -1.0 at frequency `freq`.
(stop player)
Stops playing the sound represented by player
(returned from play
).
Stops playing the sound represented by `player` (returned from `play`).
(timeshift s dur)
Inserts dur
seconds of silence at the beginning of s
Inserts `dur` seconds of silence at the beginning of `s`
(trim s start end)
Truncates s
to the region between start
and end
. If end
is
beyond the end of the sound, just trim to the end.
Truncates `s` to the region between `start` and `end`. If `end` is beyond the end of the sound, just trim to the end.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close