There are several classes that support functions of 1 variable such as envelopes or waveforms. These objects can be created (e.g.,) using linear or exponential interpolation between break-points, Fourier sine summation, cubic splines, or as raw sampled data.
In addition to the instance-creation methods, Functions understand array-like accessing method atX: to get at their values.
Examples
Basic ramp up/down
[(LinearFunction from: #((0 0) (0.5 1) (1 0))) atX: 0.25]
[(ExponentialFunction from: #((0 0 5) (0.5 1 -5) (1 0))) atX: 0.25 ]
ADSR-line envelopes
[(LinearFunction from: #((0 0) (0.1 1) (0.2 0.7) (0.9 0.5) (1 0))) edit]
[(ExponentialFunction from: #((0 0 5) (0.1 1 -3) (0.8 0.5 -2) (1 0))) edit]
[FunctionView multiFunctionExample]
Sine Summation
[(FourierSummation from: #((1 1 0) (3 0.3 0) (5 0.2 0) (7 0.15 0) (9 0.11 0) (11 0.09 0))) edit]
Others
[(Function randomOfSize: 128 from: 0.2 to: 0.9) edit]
[FunctionView onFunction:
(Function from: #( 0 1 0 0.5 1.0 0.5 0 1 0 0.3 0.6 0.9 1 0.5 0.25 0.125 0.0625 0 1 0))]
Using Functions
Apply a function to a property of an event list--make a crescendo/decrescendo
[ | list fcn |
list := EventList newNamed: #test3.
(0 to: 4000 by: 100) do: "4 seconds, 10 notes per second"
[ :index | "add the same note"
list add: (MusicEvent dur: 100 pitch: 36 ampl: 120) at: index].
fcn := ExponentialFunction from: #((0 0 2) (0.5 1 -2) (1 0)).
list applyFunction: fcn to: #loudness.
list play ]
Spectra and Signal Analysis (Not yet ported)
Create a swept sine wave and take its fft.
[Display restoreAfter: [Spectrum sweepExample]]
Read a file ("unbelichtet," etc. in German) and show the spectrogram
[Display restoreAfter: [Spectrum fileExample]]