h*E      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~                                                                            !!"""""""""""""""""""""""""""""""""""""#$$$$%&&''''''''''''(()))))*******************************************************************************************************************+++++++,,,,,,------...................////////00000000000000000000000001111111111111111111111111111222222222222222222233333334444455555555555555666666677777777788888888888888888888888888888888888888888888999999:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::;;;<<<;;;;;;;===>>>>>??@@@@@@AAAAAAAAAAAAAAAAABBBBBBBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCDDDDDDDDDDDDDDDEEEEEEEEEEEEEEEEEFFFFFFFFFFFFFFFFGGGGGGGGGGGGGGGGGGGGGGGGGGGGG G G G G G G G G G G G G G G G G G H H H H I I I I I I I I J J J J J J J J J J J J K K K K K K K K                                                  L L L L M M N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O P P P P P P P P Q Q Q Q Q Q Q Q Q Q Q Q R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R S S S S T T T T T T T T T T T T T T T U U U U V V V V W W W W W W W W W W W W W W W W W W W W W W X X X X X X X X X X X X X X Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Z Z Z Z Z Z Z Z [ [ [ [ [ [ [ [ [ [ [ \ \ ] ] ] ] ] ] ] ^ ^ _ ` ` ` ` a a a a b b b b b b b b b c c c d d d d d d d d e e e e e e e e e e e e e e e f f f f f f f f f f f f f f f f f f f g g h h h h h h h h h h h h h h h h h h h h i i i i i i i i i i i i i j j j j j j j j j j j j j j j j j j k k k k k k k k k k k k k k k k k k k l m m m m m m m m m m m m m m m m m m m m m m m m m m m m m n n n n n n n n n n n n n n n n o p p q q r r r s s s t t t t t t t t t t t t t t u u u u u v v w w w w w w w w x x x x x x x x x x x x x y y y y y y y y y y y y y y y y y y z z z z z z { { { { { { { { { { { { { | |||||||||||}}}}}}}~~~~~~~~~~~~~~~~~~~0.8.4 Safe-Inferred(/synthesizer-coreCreate a loop (feedback) from one node to another one. That is, compute the fix point of a process iteration.0synthesizer-coreThis corresponds to 1synthesizer-core Instead of mixMulti $:: map f xs the caller should write mixMulti $: mapM f xs in order to save the user from learning another infix operator.6synthesizer-core&Our signal processors have types like f (a -> b -> c) . They could also have the type  a -> b -> f c or f a -> f b -> f c. We did not choose the last variant for reduction of redundancy in type signatures and for simplifying sharing, and we did not choose the second variant for easy composition of processors. However the forms are freely convertible, and if you prefer the last one because you do not want to sprinkle 0 in your code, then you may want to convert the processors using the following functions, that can be defined purely in the  class./synthesizer-core#process chain that shall be looped ,-./0123456789,-./0123456789001029 3049 50 Safe-Inferred(y Safe-Inferred.-#:synthesizer-corelimit, fuzz booster;synthesizer-core logit, tanh<synthesizer-corezig-zag=synthesizer-coresine>synthesizer-coreOdd Chebyshev polynomialoddChebyshev n: is an appropriately scaled Chebyshev polynomial of order 2*n+1. The argument n must be non-negative. Graphics.Gnuplot.Simple.plotFuncs [Graphics.Gnuplot.Simple.YRange (-1,1)] (Graphics.Gnuplot.Simple.linearScale 1000 (-7,7::Double)) (List.map oddChebyshev [0..5])synthesizer-coreA polynomial function with zeros at every integral point weighted in order to equalize the local extreme points.However, the weighting is difficult enough, that it might be easier to use just a truncated Taylor series of sine.We could compute a weighting denominator polynomial by dividing our equidistant zeros polynomial by the sine series.1equidist / weight = sine weight = equidist / sineHowever we have to normalize the zeros, thus powers of pi enter the scene and then power series division becomes inexact.@synthesizer-core Power function. Roughly the map  p x -> x**p but retains the sign of x.:;<=>?@:;<=>?@ Safe-Inferred.-Asynthesizer-corelimit, fuzz boosterBsynthesizer-core logit, tanhCsynthesizer-corezig-zagDsynthesizer-coresineABCDEABCDE Safe-Inferred..synthesizer-coreCompute the variance of the Gaussian such that its Fourier transform has value ratio at frequency freq. Safe-Inferred.FGHIJKFGHIJK (c) Henning Thielemann 2006-2010GPL!synthesizer@henning-thielemann.de provisional%requires multi-parameter type classes Safe-Inferred.Qq-Rsynthesizer-coreThis is similar to Polar coordinates, but the range of the phase is from 0 to 1, not 0 to 2*pi.If you need to represent a harmonic by complex coefficients instead of the polar representation, then please build a complex valued polynomial from your coefficients and use it to distort a b. distort (Poly.evaluate (Poly.fromCoeffs complexCoefficients)) helix_synthesizer-coreTurn an unparametrized waveform into a parametrized one, where the parameter is a phase offset. This way you may express a phase modulated oscillator using a shape modulated oscillator.flip phaseOffset could have also be named  rotateLeft(, since it rotates the wave to the left.`synthesizer-core$map a phase to value of a sine wave csynthesizer-coreApproximation of sine by parabolas. Surprisingly it is not really faster than `(. The wave results from integrating the v wave, thus it the k-th harmonic has amplitude  recip (k^3).esynthesizer-core>Piecewise third order polynomial approximation by integrating c.gsynthesizer-core?Piecewise fourth order polynomial approximation by integrating e.isynthesizer-coreLeast squares approximation of sine by fourth order polynomials computed with MuPad.jsynthesizer-coreThe coefficient of the highest power is the reciprocal of an element from  http://oeis.org/A000111% and the polynomial coefficients are  http://oeis.org/A119879 . mapM_ print $ map (\p -> fmap ((round :: Rational -> Integer) . (/last(Poly.coeffs p))) p) (take 10 $ fastSinePolynomials)lsynthesizer-coreThis is a helix that is distorted in phase such that it becomes a purely rational function. It is guaranteed that the magnitude of the wave is one. For the distortion factor recip pi you get the closest approximation to an undistorted helix. We have chosen this scaling in order to stay with field operations.nsynthesizer-coreHere we distort the rational helix in phase using tangent approximations by a sum of 2*n reciprocal functions. For the tangent function we obtain perfect cosine and sine, thus for  k = recip pi and high n* we approach an undistorted complex helix.osynthesizer-coresaw tooth, it's a ramp down in order to have a positive coefficient for the first partial sinepsynthesizer-core8This wave has the same absolute Fourier coefficients as o but the partial waves are shifted by 90 degree. That is, it is the Hilbert transform of the saw wave. The formula is derived from q.qsynthesizer-core sawCos + i*sawThis is an analytic function and thus it may be used for frequency shifting.The formula can be derived from the power series of the logarithm function.rsynthesizer-core superSaw n d requires 1 <= n and n*d <= 1.synthesizer-core superSaw n d requires 1 <= n and n*d <= 1.ssynthesizer-coresquare tsynthesizer-core8This wave has the same absolute Fourier coefficients as s but the partial waves are shifted by 90 degree. That is, it is the Hilbert transform of the saw wave.usynthesizer-core squareCos + i*squareThis is an analytic function and thus it may be used for frequency shifting.The formula can be derived from the power series of the area tangens function.vsynthesizer-core triangle wsynthesizer-core,A truncated cosine. This has rich overtones.xsynthesizer-coreFor parameter zero this is o.ysynthesizer-coreA truncated cosine plus a ramp that guarantees a bump of high 2 at the boundaries.It is >truncCosine (2 * fromIntegral n + 0.5) == truncOddCosine (2*n){synthesizer-core Power function. Roughly the map  p x -> x**p but retains the sign of x* and it should normalize the mapping over [-1,1]. to an L2 norm of 1, but I got this one wrong.$The sign is flipped with respect to o and `! which is an historical artifact.|synthesizer-core Power function. Roughly the map  p x -> x**p but retains the sign of x! and normalizes the mapping over [0,1] to an L2 norm of 1.}synthesizer-coreTangens hyperbolicus allows interpolation between some kind of saw tooth and square wave. In principle it is not necessary because you can distort a saw tooth oscillation by map tanh.~synthesizer-coreTangens hyperbolicus of a sine allows interpolation between some kind of sine and square wave. In principle it is not necessary because you can distort a square oscillation by map tanh.synthesizer-coreInterpolation between ` and s.synthesizer-coreInterpolation between c and o. We just shrink the parabola towards the borders and insert a linear curve such that its slope matches the one of the parabola.synthesizer-coreInterpolation between ` and o. We just shrink the sine towards the borders and insert a linear curve such that its slope matches the one of the sine.synthesizer-coreInterpolation between ` and o4 with smooth intermediate shapes but no perfect saw.synthesizer-coreInterpolation between ` and o1 with perfect saw, but sharp intermediate shapes.synthesizer-coreHarmonics of a saw wave that is smoothed by a Gaussian lowpass filter. This can also be used to interpolate between saw wave and sine. The parameter is the cutoff-frequency defined as the standard deviation of the Gaussian in frequency space. That is, high values approximate a saw and need many harmonics, whereas low values tend to a sine and need only few harmonics.synthesizer-coresaw with spacesynthesizer-coretriangle with spacesynthesizer-coretriangle with space and shiftsynthesizer-coresquare with space, can also be generated by mixing square waves with different phasessynthesizer-coresquare with space and shiftsynthesizer-core,square with different times for high and lowsynthesizer-coreLike  but with zero average. It could be simulated by adding two saw oscillations with 180 degree phase difference and opposite sign.synthesizer-coretrianglesynthesizer-coreMixing  and & you can get back a triangle wave formsynthesizer-coreTrapezoid with distinct high and low time. That is the high and low trapezoids are symmetric itself, but the whole waveform is not symmetric.synthesizer-coretrapezoid with distinct high and low time and zero direct current offsetsynthesizer-coreparametrized trapezoid that can range from a saw ramp to a square waveform.synthesizer-core"Specify the wave by its harmonics.The function is implemented quite efficiently by applying the Horner scheme to a polynomial with complex coefficients (the harmonic parameters) using a complex exponential as argument.synthesizer-core0 for `, 1 for s synthesizer-core0 for c, 1 for o synthesizer-core0 for `, 1 for o synthesizer-core0 for `, 1 for o synthesizer-core0 for `, 1 for o synthesizer-core)pike width ranging from 0 to 1, 1 yields o synthesizer-core)pike width ranging from 0 to 1, 1 yields v synthesizer-corepike width ranging from 0 to 1 synthesizer-core$shift ranges from -1 to 1; 0 yields  synthesizer-core)pike width ranging from 0 to 1, 1 yields s synthesizer-corepike width ranging from 0 to 1 synthesizer-core$shift ranges from -1 to 1; 0 yields  synthesizer-corevalue between -1 and 1 controlling the ratio of high and low time: -1 turns the high time to zero, 1 makes the low time zero, 0 yields s synthesizer-coreasymmetry parameter ranging from -1 to 1: For 0 you obtain the usual triangle. For -1 you obtain a falling saw tooth starting with its maximum. For 1 you obtain a rising saw tooth starting with a zero. synthesizer-corewidth of the plateau ranging from 0 to 1: 0 yields v , 1 yields s synthesizer-coresum of the plateau widths ranging from 0 to 1: 0 yields , 1 yields  synthesizer-core5asymmetry of the plateau widths ranging from -1 to 1 synthesizer-corewidth of the ramp, that is 1 yields a downwards saw ramp and 0 yields a square wave. VWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~RSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~RSTU (c) Henning Thielemann 2006GPL!synthesizer@henning-thielemann.de provisional%requires multi-parameter type classes Safe-Inferred.UVsynthesizer-coreUse this function for waves which are sufficiently smooth. If the Nyquist frequency is exceeded the wave is simply replaced by a constant zero wave.synthesizer-core$map a phase to value of a sine wave synthesizer-coresaw tooth, it's a ramp down in order to have a positive coefficient for the first partial sinesynthesizer-coresquare synthesizer-core triangle synthesizer-core"Specify the wave by its harmonics.The function is implemented quite efficiently by applying the Horner scheme to a polynomial with complex coefficients (the harmonic parameters) using a complex exponential as argument.RR  Safe-Inferred.WKsynthesizer-core.Mix two signals. Unfortunately we have to use  semantic here, that is the result is as long as the shorter of both inputs.synthesizer-coreAdd a number to all of the signal values. This is useful for adjusting the center of a modulation.synthesizer-coreIn Synthesizer.Basic.Distortion; you find a collection of appropriate distortion functions.  Safe-Inferred.XWsynthesizer-core"simulate an moving sounding objectconvert the way of the object through 2D or 3D space into a delay and attenuation information, sonicDelay is the reciprocal of the sonic velocity  Safe-InferredX  Safe-InferredX000 Safe-InferredYQ Safe-InferredYsynthesizer-core:Run a causal process independently on each stereo channel.     Safe-Inferred.[ksynthesizer-coreWarning: This may produce negative results for positive input in some cases! The problem is that (maxBound :: Int32) cannot be represented exactly as Float, the Float value is actually a bit larger than the Int32 value. Thus when converting the Float back to Int32 it becomes negative. Better use .   Safe-Inferred._synthesizer-core.The full description of a control curve piece.synthesizer-core?The curve type of a piece of a piecewise defined control curve.synthesizer-core0The 6 operators simplify constructing a list of  PieceData a. The description consists of nodes (namely the curve values at nodes) and the connecting curve types. The naming scheme is as follows: In the middle there is a bar |*. With respect to the bar, the pad symbol # is at the side of the curve type, at the other side there is nothing, a minus sign -, or an equality sign =. Nothing means that here is the start or the end node of a curve.Minus means that here is a node where left and right curve meet at the same value. The node description is thus one value.Equality sign means that here is a split node, where left and right curve might have different ending and beginning values, respectively. The node description consists of a pair of values.555555 Safe-Inferred`f(c) Henning Thielemann 2008GPL!synthesizer@henning-thielemann.de provisional%requires multi-parameter type classes Safe-Inferred.asynthesizer-coreDescription of a filter pole. synthesizer-coreResonance, that is the amplification of the band center frequency. synthesizer-coreBand center frequency. (c) Henning Thielemann 2008GPL!synthesizer@henning-thielemann.de provisional%requires multi-parameter type classes Safe-Inferred.csynthesizer-coreCompute coefficients for an allpass that shifts low frequencies by approximately the shift you want. To achieve this we solve a linear least squares problem, where low frequencies are more weighted than high ones. The output is a list of coefficients for an arbitrary order allpass.  Safe-Inferredf?synthesizer-corelittle endian (Intel)synthesizer-corelittle endian (Intel)synthesizer-coreWrite a little endian 16 bit integer stream via String data and .synthesizer-core-Uses endianess of the machine, like Sox does.synthesizer-coreThe end of the list is undefined, if the file has odd length. It would be better if it throws an exception.synthesizer-coreThe end of the list is undefined, if the file has odd length. It would be better if it throws an exception. Safe-Inferred.hsynthesizer-coreSee .synthesizer-coreThe output format is determined by SoX by the file name extension. The sample precision is determined by the provided  function.Example: import qualified Synthesizer.Plain.Builder as Builder write (Builder.put :: Builder.Put Int16) "test.aiff" 44100 soundsynthesizer-core?You hardly need this routine since you can use a filename with .mp3 or .ogg extension for 7 and SoX will do the corresponding compression for you.synthesizer-core1I suspect we cannot handle file closing properly. Safe-Inferred.iA Safe-Inferredksynthesizer-coremodif is a process controlled by values of type c with an internal state of type s, it converts an input value of type a into an output value of type b while turning into a new state0ToDo: Shall finite signals be padded with zeros?synthesizer-core)Here the control may vary over the time. synthesizer-core)Here the control may vary over the time. synthesizer-coreThe number of stacked state monads depends on the size of the list of state values. This is like a dynamically nested StateT. Safe-Inferred.lYsynthesizer-coreSee .synthesizer-coreSee .   (c) Henning Thielemann 2008-2011GPL!synthesizer@henning-thielemann.de provisionalportable Safe-InferredqZsynthesizer-coremodif is a process controlled by values of type c with an internal state of type s, it converts an input value of type a into an output value of type b while turning into a new state0ToDo: Shall finite signals be padded with zeros?synthesizer-core)Here the control may vary over the time. synthesizer-core)Here the control may vary over the time. synthesizer-coreFeed back signal into signal processor, and apply a delay by one value.  is a kind of .synthesizer-coredropMarginRem n m xs drops at most the first m elements of xs and ensures that xs still contains n elements. Additionally returns the number of elements that could not be dropped due to the margin constraint. That is dropMarginRem n m xs == (k,ys) implies length xs - m == length ys - k . Requires length xs >= n.synthesizer-core!Test whether a list has at least n elements.synthesizer-core1Can be implemented more efficiently than just by  and  for other data structures. Safe-Inferred.rMsynthesizer-core$impulse train with static frequency synthesizer-core'impulse train with modulated frequency  Safe-Inferred.tAsynthesizer-coreDeterministic white noise, uniformly distributed between -1 and 1. That is, variance is 1/3.synthesizer-coreApproximates normal distribution with variance 1 by a quadratic B-spline distribution.synthesizer-coremomentary densities, p means that there is about one peak in the time range of 1/p samples synthesizer-coreEvery occurence of  represents a peak. (c) Henning Thielemann 2008GPL!synthesizer@henning-thielemann.de provisional%requires multi-parameter type classes Safe-Inferred.v$synthesizer-coreIntegrate with initial value zero. However the first emitted value is the value of the input signal. It maintains the length of the signal.synthesizer-coreIntegrate with initial condition. First emitted value is the initial condition. The signal becomes one element longer. Safe-Inferred.xsynthesizer-core&Mix two signals. In opposition to 1 the result has the length of the longer signal. synthesizer-core$Mix an arbitrary number of signals. synthesizer-coreAdd a number to all of the signal values. This is useful for adjusting the center of a modulation. synthesizer-coreIn Synthesizer.Basic.Distortion; you find a collection of appropriate distortion functions.(c) Henning Thielemann 2006GPL!synthesizer@henning-thielemann.de provisional%requires multi-parameter type classes Safe-Inferred.{.synthesizer-coreTake signal until it falls short of a certain amplitude for a given time.synthesizer-coreTake values until the predicate p holds for n successive values. The list is truncated at the beginning of the interval of matching values.synthesizer-coreGiven a list of signals with time stamps, mix them into one signal as they occur in time. Ideally for composing music.Cf. synthesizer-coreA list of pairs: (relative start time, signal part), The start time is relative to the start time of the previous event. synthesizer-coreThe mixed signal.  Safe-Inferred.synthesizer-coreMinimize rounding errors by reducing number of operations per element to a logarithmuc number.synthesizer-coreLinear curve starting at zero.synthesizer-core)As stable as the addition of time values.synthesizer-coreIt computes the same like  but in a numerically more stable manner, namely using a subdivision scheme. The division needed is a division by two. 50 4 8 0 2 4 6 8 0 1 2 3 4 5 6 7 8synthesizer-core*Intersperse linearly interpolated values. synthesizer-coreLinear curve of a fixed length. The final value is not actually reached, instead we stop one step before. This way we can concatenate several lines without duplicate adjacent values.synthesizer-coreThis is an extension of  to vectors which is straight-forward but requires more explicit signatures. But since it is needed rarely I setup a separate function. synthesizer-core 0 16 0 8 16 0 4 8 12 16 0 2 4 6 8 10 12 14 16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16synthesizer-core steepness synthesizer-coreinitial value synthesizer-corelinear progression synthesizer-corelength synthesizer-coreinitial and final value synthesizer-corelinear progression synthesizer-core9time where the function reaches 1/e of the initial value synthesizer-coreinitial value synthesizer-coreexponential decay synthesizer-core9time where the function reaches 1/e of the initial value synthesizer-coreinitial value synthesizer-coreexponential decay synthesizer-core9time where the function reaches 1/e of the initial value synthesizer-coreinitial value synthesizer-coreexponential decay synthesizer-core9time where the function reaches 1/e of the initial value synthesizer-coreexponential decay synthesizer-core half life synthesizer-coreinitial value synthesizer-coreexponential decay synthesizer-core half life synthesizer-coreinitial value synthesizer-coreexponential decay synthesizer-core half life synthesizer-coreinitial value synthesizer-coreexponential decay synthesizer-core half life synthesizer-coreexponential decay synthesizer-core9time where the function reaches 1/e of the initial value synthesizer-coreinitial value synthesizer-corevalue after given time synthesizer-coreexponential decay synthesizer-core9time where the function reaches 1/e of the initial value synthesizer-coreinitial value synthesizer-corevalue after given time synthesizer-coreexponential decay synthesizer-core9time where the function reaches 1/e of the initial value synthesizer-coreinitial value synthesizer-coreexponential decay synthesizer-core half life synthesizer-coreinitial value synthesizer-coreexponential decay synthesizer-coretime t0 where 1 is approached synthesizer-coretime t1 where -1 is approached synthesizer-core7a cosine wave where one half wave is between t0 and t1 synthesizer-coretime t0 where 1 is approached synthesizer-coretime t1 where -1 is approached synthesizer-core7a cosine wave where one half wave is between t0 and t1 synthesizer-coretime t0 where 1 is approached synthesizer-coretime t1 where -1 is approached synthesizer-core7a cosine wave where one half wave is between t0 and t1 synthesizer-coretime t0 where 1 is approached synthesizer-coretime t1 where -1 is approached synthesizer-core7a cosine wave where one half wave is between t0 and t1   (c) Henning Thielemann 2006-2009GPL!synthesizer@henning-thielemann.de provisional%requires multi-parameter type classes Safe-Inferred.V synthesizer-core!Unmodulated non-recursive filter synthesizer-coreUnmodulated non-recursive filter Output has same length as the input.It is elegant but leaks memory.synthesizer-coreeps is the threshold relatively to the maximum. That is, if the gaussian falls below eps * gaussian 0, then the function truncated.synthesizer-coreMoving (uniformly weighted) average in the most trivial form. This is very slow and needs about  n * length x operations.synthesizer-coreGiven a list of numbers and a list of sums of (2*k) of successive summands, compute a list of the sums of (2*k+1) or (2*k+2) summands.Example for 2*k+1  [0+1+2+3, 2+3+4+5, 4+5+6+7, ...] -> [0+1+2+3+4, 1+2+3+4+5, 2+3+4+5+6, 3+4+5+6+7, 4+5+6+7+8, ...] Example for 2*k+2  [0+1+2+3, 2+3+4+5, 4+5+6+7, ...] -> [0+1+2+3+4+5, 1+2+3+4+5+6, 2+3+4+5+6+7, 3+4+5+6+7+8, 4+5+6+7+8+9, ...] synthesizer-coreCompute the sum of the values from index l to (r-1). (I.e. somehow a right open interval.) This can be used for implementation of a moving average filter. However, its counterpart " is much faster for large windows.synthesizer-core)This function should be much faster than - but slower than the recursively implemented  movingAverage. However in contrast to  movingAverage' it should not suffer from cancelation.synthesizer-coreMoving average, where window bounds must be always non-negative.The laziness granularity is 2^height.synthesizer-coreThe first argument is the amplification. The main reason to introduce it, was to have only a Module constraint instead of Field. This way we can also filter stereo signals.A control value n# corresponds to filter window size 2*n+1.synthesizer-coreForward difference quotient. Shortens the signal by one. Inverts  in the sense that 'differentiate (zero : integrate x) == x,. The signal is shifted by a half time unit.synthesizer-coreCentral difference quotient. Shortens the signal by two elements, and shifts the signal by one element. (Which can be fixed by prepending an appropriate value.) For linear functions this will yield essentially the same result as . You obtain the result of  if you smooth the one of ' by averaging pairs of adjacent values.ToDo: Vector variantsynthesizer-coreSecond derivative. It is /differentiate2 == differentiate . differentiate but  should be faster.synthesizer-core the envelope synthesizer-corethe signal to be enveloped synthesizer-core the envelope synthesizer-corethe signal to be enveloped !(c) Henning Thielemann 2008GPL!synthesizer@henning-thielemann.de provisional%requires multi-parameter type classes Safe-Inferred.?synthesizer-coreLike   but in a recursive form. This needs only linear time (independent of the window size) but may accumulate rounding errors. ys = xs * (1,0,0,0,-1) / (1,-1) ys * (1,-1) = xs * (1,0,0,0,-1) ys = xs * (1,0,0,0,-1) + ys * (0,1) synthesizer-core0Sig.T a must contain only non-negative elements.synthesizer-coreShift sampling points by a half sample period in order to preserve signals for window widths below 1." Safe-Inferred.Dsynthesizer-coreVolume based on Manhattan norm.synthesizer-coreVolume based on Energy norm.synthesizer-coreVolume based on Sum norm.synthesizer-coreVolume based on Manhattan norm.synthesizer-coreVolume based on Energy norm.synthesizer-coreVolume based on Sum norm.synthesizer-coreCompute minimum and maximum value of the stream the efficient way. Input list must be non-empty and finite.synthesizer-coreInput list must be finite. List is scanned twice, but counting may be faster.synthesizer-coreInput list must be finite. If the input signal is empty, the offset is  undefined. List is scanned twice, but counting may be faster. The sum of all histogram values is one less than the length of the signal.synthesizer-coreInput list must be finite. If the input signal is empty, the offset is  undefined/. List is scanned once, counting may be slower.synthesizer-coreRequires finite length. This is identical to the arithmetic mean.synthesizer-core must be non-zero.synthesizer-coreDetects zeros (sign changes) in a signal. This can be used as a simple measure of the portion of high frequencies or noise in the signal. It ca be used as voiced/unvoiced detector in a vocoder. zeros x !! n is True if and only if "(x !! n >= 0) /= (x !! (n+1) >= 0)6. The result will be one value shorter than the input.synthesizer-core$Detect thresholds with a hysteresis.synthesizer-coreAlmost naive implementation of the chirp transform, a generalization of the Fourier transform.More sophisticated algorithms like Rader, Cooley-Tukey, Winograd, Prime-Factor may follow.synthesizer-coreA kind of discretization for signals with sample values between -1 and 1. If you smooth the resulting signal (after you transformed with 'map binaryLevelToNumber'), you should obtain an approximation to the input signal.synthesizer-coreA kind of discretization for signals with sample values between 0 and a threshold. We accumulate input values and emit a threshold value whenever the accumulator exceeds the threshold. This is intended for generating clicks from input noise. See also .""# Safe-Inferredsynthesizer-coreDetermine optimal filter coefficients and residue by adaptive approximation. The number of initial filter coefficients is used as filter order.$ Safe-Inferred% Safe-Inferred.synthesizer-core less-than comparison where  means "unbounded".synthesizer-coreboth up and down$ threshold must be positive numbers.synthesizer-core Usage: removeClicks slopeDistance maxSpikeWidth minSpikeDistance thresholdUp thresholdDown slopeDistance is the distance of samples in which we analyse differences. The smoother the spike slope the larger  slopeDistance must be. slopeDistance3 should be smaller than the _minimal_ spike width.  maxSpikeWidth should be smaller than the minimal spike distance. Spike distance is measured from one spike beginning to the next one. thresholdUp- is the minimal difference of two samples at  slopeDistance+ that are to be considered an upward jump.  thresholdDown* is for downward jumps. If a threshold is  then jumps in this direction are ignored. You should only use this if you are very sure that spikes with the according sign do not occur. Otherwise the algorithm will be confused by the jump in reverse direction at the end of the spike. Example: )removeClicks 1 5 20 (Just 0.1) (Just 0.1).The algorithm works as follows: Chop the signal at jumps. Then begin at a certain distance behind the jump and search backwards for the matching jump at the end of the spike. If the borders of a spike are found this way, then they are connected by a linear ramp. Safe-Inferredsynthesizer-coreThis implementation generates laziness breaks whereever one of the original sequences has laziness breaks. It should be commutative in this respect.It is more efficient than  since it appends the rest of the longer signal without copying.synthesizer-coreMix while maintaining the pattern of the second operand. This is closer to the behavior of Vector.zipWithLastPattern.synthesizer-coreIt also preserves the chunk structure of the second signal, which is essential if you want to limit look-ahead.0This implementation seems to have a memory leak!synthesizer-core.processor that shall be run in a feedback loopsynthesizer-core5prefix of the output, its length determines the delaysynthesizer-coreProcessor that shall be run in a feedback loop. It's absolutely necessary that this function preserves the chunk structure and that it does not look a chunk ahead. That's guaranteed for processes that do not look ahead at all, like , $" and all of type Causal.Process. synthesizer-coreinputsynthesizer-core'output has the same length as the input,*)(' !"$+&%#,*)(' !"$+&%#& Safe-Inferred.synthesizer-coreLatency is high using Sox - We can achieve better results using ALSA's sound output! See synthesizer-alsa package.'(c) Henning Thielemann 2006GPL!synthesizer@henning-thielemann.de provisional%requires multi-parameter type classes Safe-Inferred. synthesizer-coreConvert a list of phase steps into a list of momentum phases phase is a number in the interval [0,1) freq contains the phase steps synthesizer-core#oscillator with constant frequency synthesizer-core oscillator with modulated phase synthesizer-core oscillator with modulated shape synthesizer-core$oscillator with modulated frequency synthesizer-core4oscillator with both phase and frequency modulation synthesizer-core4oscillator with both shape and frequency modulation synthesizer-core&sine oscillator with static frequency synthesizer-core)sine oscillator with modulated frequency synthesizer-core>sine oscillator with modulated phase, useful for FM synthesis synthesizer-core.saw tooth oscillator with modulated frequency synthesizer-core.saw tooth oscillator with modulated frequency  ( Safe-Inferredsynthesizer-coreclickTrack silenceChunkSize barBeepFreq beatBeepFreq beepDur beatsPerBar beatPeriod generates click track for one bar. You may cycle it infinitely or replicate it as often as you want.) Safe-Inferred5synthesizer-coreChunk sizes are adapted to the time differences. Explicit ChunkSize parameter is only required for zero padding. Since no ST monad is needed, this can be generalized to Generic.Signal.Transform class.synthesizer-coreThis function also uses the time differences as chunk sizes, but may occasionally use smaller chunk sizes due to the chunk structure of an input signal until the next signal starts.synthesizer-coreThe result is a Lazy StorableVector with chunks of the given size.synthesizer-corechunk must fit into the buffer synthesizer-corechunk must fit into the buffer synthesizer-coreA list of pairs: (relative start time, signal part), The start time is relative to the start time of the previous event. synthesizer-coreThe mixed signal. synthesizer-coreA list of pairs: (relative start time, signal part), The start time is relative to the start time of the previous event. synthesizer-coreThe mixed signal. synthesizer-coreA list of pairs: (relative start time, signal part), The start time is relative to the start time of the previous event. synthesizer-coreThe mixed signal. synthesizer-coreA list of pairs: (relative start time, signal part), The start time is relative to the start time of the previous event. synthesizer-coreThe mixed signal. * Safe-Inferred .Csynthesizer-coreCf. StreamFusion Data.Streamsynthesizer-coreIt is a common pattern to use switchL or viewL in a loop in order to traverse a signal. However this needs repeated packing and unpacking of the  function and the state. It seems that GHC is not clever enough to detect, that the view function does not change. With 3 you can unpack a stream once and use an efficient  in the loop.synthesizer-core= 0) /= (x !! (n+1) >= 0)6. The result will be one value shorter than the input.synthesizer-core$Detect thresholds with a hysteresis.synthesizer-coreAlmost naive implementation of the chirp transform, a generalization of the Fourier transform.More sophisticated algorithms like Rader, Cooley-Tukey, Winograd, Prime-Factor may follow.1 Safe-Inferredsynthesizer-coreA special reader monad.synthesizer-core Given that scale zero v == Additive.zero> this type class is equivalent to Module in the following way: scaleAndAccumulate (a,x) = let ax = a *> x in (ax, (ax+))(see implementation of ) and x+y = scaleAccumulate one y $ scale one x zero = scale zero x s*>x = scale s xBut this redundancy is only because of a lack of the type system or lack of my imagination how to solve it better. Use this type class for all kinds of interpolation, that is where addition and scaling alone make no sense.I intended to name this class AffineSpace, because all interpolations should be affine combinations. This property is equivalent to interpolations that preserve constant functions. However, I cannot easily assert this property and I'm not entirely sure that all reasonable interpolations are actually affine.Early versions had a zero method, but this is against the idea of interpolation. For implementing zero we needed a Maybe wrapper for interpolation of StorableVectors. Btw. having zero instead of scale is also inefficient, since every sum must include a zero summand, which works well only when the optimizer simplifies addition with a constant.We use only one class method that contains actually two methods: scale and scaleAccumulate. We expect that instances are always defined on record types lifting interpolations from scalars to records. This should be done using  and friends or the  type and the * interface for records with many elements.synthesizer-coreInfix variant of .62 Safe-Inferred.synthesizer-core)interpolation requires a total number of synthesizer-coreinterpolation requires  values before the currentsynthesizer-core'interpolation as needed for resampling synthesizer-coreConsider the signal to be piecewise constant, where the leading value is used for filling the interval [0,1).3 Safe-Inferred.synthesizer-coreOnly for finite input signals.synthesizer-coreThe extrapolation may miss some of the first and some of the last points4 Safe-Inferred.<synthesizer-coreThis is essentially different for constant interpolation, because this function "looks forward" whereas the other two variants "look backward". For the symmetric interpolation functions of linear and cubic interpolation, this does not really matter.5(c) Henning Thielemann 2008GPL!synthesizer@henning-thielemann.de provisional%requires multi-parameter type classes Safe-Inferred.synthesizer-core!Unmodulated non-recursive filter synthesizer-coreMoving (uniformly weighted) average in the most trivial form. This is very slow and needs about  n * length x operations.synthesizer-coreThis is inverse to frequency modulation. If all control values in ctrl are above one, then it holds:  frequencyModulation ctrl (inverseFrequencyModulationFloor ctrl xs) == xs  . Otherwise 0 is lossy. For the precise property we refer to *Test.Sound.Synthesizer.Plain.Interpolation. The modulation uses constant interpolation. Other interpolation types are tricky to implement, since they would need interpolation on non-equidistant grids. Ok, at least linear interpolation could be supported with acceptable effort, but perfect reconstruction would be hard to get. The process is not causal in any of its inputs, however control and input are aligned.If you use interpolation for resampling or frequency modulation, you may want to smooth the signal before resampling according to the local resampling factor. However you cannot simply use the resampling control to also control the smoothing, because of the subsequent distortion by resampling. Instead you have to stretch the control inversely to the resampling factor. This is the task of this function. It may be applied like: frequencyModulation ctrl (smooth (inverseFrequencyModulationFloor ctrl ctrl) xs)synthesizer-coreForward difference quotient. Shortens the signal by one. Inverts L in the sense that 'differentiate (zero : integrate x) == x,. The signal is shifted by a half time unit.synthesizer-coreCentral difference quotient. Shortens the signal by two elements, and shifts the signal by one element. (Which can be fixed by prepending an appropriate value.) For linear functions this will yield essentially the same result as . You obtain the result of  if you smooth the one of ' by averaging pairs of adjacent values.ToDo: Vector variantsynthesizer-coreSecond derivative. It is /differentiate2 == differentiate . differentiate but  should be faster.synthesizer-core the envelope synthesizer-corethe signal to be enveloped synthesizer-core the envelope synthesizer-corethe signal to be enveloped 6 Safe-Inferred.\synthesizer-core,Consider the signal to be piecewise linear. synthesizer-coreConsider the signal to be piecewise cubic, with smooth connections at the nodes. It uses a cubic curve which has node values x0 at 0 and x1 at 1 and derivatives (x1-xm1) 2 and (x2-x0)2, respectively. You can see how it works if you evaluate the expression for t=0 and t=1 as well as the derivative at these points.synthesizer-coreSee cubicHalfModule.synthesizer-core$List of functions must be non-empty.synthesizer-corewith this wrapper you can use the collection of interpolating functions from Donadio's DSP library synthesizer-core(left extent, right extent), e.g. (1,1) for linear hat  7 Safe-Inferred.synthesizer-coreConvert from the (shape,phase) parameter pair to the index within a wave (step) and the index of a wave (leap) in the sampled prototype tone.)For this routine it would be simpler, if shape would measure in multiples of period/ (we would only need a Ring instance), but for  shapeLimit it is better the way it is.  8 Safe-Inferred`synthesizer-coreEvaluating the first value of the signal is necessary for avoiding a space leaks if you repeatedly drop a prefix from the signal and do not consume something from it.synthesizer-coreLike %lengthAtLeast n xs = length xs >= n1, but is more efficient, because it is more lazy.synthesizer-coreWe abuse event lists for efficient representation of piecewise constant signals.synthesizer-coreThe function defined here are based on the interpretation of event lists as piecewise constant signals. They do not fit to the interpretation of atomic events. Because e.g. it makes no sense to split an atomic event into two instances by splitAt, and it is also not clear, whether dropping the first chunk shall leave a chunk of length zero or remove that chunk completely.However, sometimes we also need lists of events. In this case the  method would be different. For an event-oriented instance of EventList.TimeTime see NoteOffList in synthesizer-alsa package.9 Safe-Inferred Safe-Inferred.=synthesizer-coreThe first pair member in powerOfTwoFactors n is the maximum factor of n, that is a power of two.synthesizer-coreList all factorizations of an odd number where the first factor is at most the second factor and the first factors are in descending order.synthesizer-coreArgument must be a prime. Usage of Set for efficient filtering of candidates seems to be overkill, since the multiplicative generator seems to be small in most cases, i.e. 2 or 3./Smallest multiplicative generators for primes: http://oeis.org/A001918Especially large generators: $ filter ((>31) . snd) $ map (n -> (n, multiplicativeGenerator n)) $ tail NumberTheory.primes [(36721,37),(48889,34),(51361,37),(55441,38),(63361,37),(64609,35),(71761,44),(88321,34),(92401,34),(93481,35),(95471,43),(97441,37),(104711,43),(110881,69)$ filter ((>63) . snd) $ map (n -> (n, multiplicativeGenerator n)) $ tail NumberTheory.primes [(110881,69),(760321,73)A solution with medium complexity could at least observe the least 64 numbers using a Word64.synthesizer-coreDoes not emit values in ascending order and may return duplicates (e.g. primitiveRootsOfUnityFullOrbit 70000 10). I hoped it would be faster than the other implementations since it eliminates non-roots in large blocks. However it seems that managing the root candidates in a Set reduces performance significantly.The idea: Start with a seed that is a unit. Compute its orbit until a one is reached. Since it is a unit, we always encounter a one. We do not need to check for non-unit seeds, since (gcd modu seed) will be a divisor of all seed powers. In the orbit all numbers are powers of each other. Now finding the roots is a matter of solving a Diophantine equation of the exponents. In one such step all powers in an orbit are classified as roots or non-roots and thus we can remove them all from the set of root candidates and continue with the remaining candidates. Duplicates can occur if a seed in a later iteration is found again as power of another seed.synthesizer-coreComputes a list of seeds and according maximum orders of roots of unity. All divisors of those maximum orders are possible orders of roots of unity, too.synthesizer-coremodu and x must be coprime. If they are not, then none of the numbers in the orbit is a root of unity and the function enters an infinite loop.synthesizer-coreGiven an order find integer residue rings where roots of unity of this order exist. The way they are constructed also warrants, that order, is a unit (i.e. invertible) in those rings.The list is not exhaustive but computes suggestions quickly. The first found modulus is often the smallest one that exist, but not always (smallest counter-example: Order 80). However, the first modulus is not the smallest one among the ones that only have the wanted primitive root, but where order is not necessarily a unit. E.g. =ringsWithPrimitiveRootOfUnityAndUnit 840 == 2521 : 3361 : ...!but the smallest modulus is 1763.Most of the numbers are primes. For these the recursion property of the Carmichael function immediately yields that there are primitive roots of unity of order order.synthesizer-coreList all numbers that only contain prime factors 2 and 3 in ascending order. http://oeis.org/A003586synthesizer-core0It's not awfully efficient, but ok for our uses.synthesizer-coreCompute the smallest composite of 2 and 3 that is as least as large as the input. This can be interpreted as solving an integer linear programming problem with min ((a,b) -> a * log 2 + b * log 3) over the domain {(a,b) : a>=0, b>=0, a * log 2 + b * log 3 >= log n}synthesizer-coreceilingSmoothsTrace a b n m replaces successively a factors in m by b) factors while keeping the product above n.synthesizer-coreCompute all primes that occur in the course of dividing a Fourier transform into sub-transforms.synthesizer-core5Prime factors and their exponents in ascending order.synthesizer-coreFind lengths of signals that require many interim Rader transforms and end with the given length. raderWorstCases 2 = raderWorstCases 5 = tail Smallest raderWorstCase numbers are 2,5,13,17,19,31,37,41,43,61,... This matches the definition of  http://oeis.org/A061303.synthesizer-coreThis is usually faster than  since it does not need to factor large numbers. However, the generated modulus is usually much greater.synthesizer-coreDetermine an integer residue ring in which a Fast Fourier transform of size n can be performed. It must contain certain primitive roots. If we choose a non-primitive root, then some off-diagonal values in F^-1F are non-zero.<: Safe-Inferredsynthesizer-coreWe could provide the  by a Reader monad, but we don't do that because we expect that the choice of the lazy size is more local than say the choice of the sample rate. E.g. there is no need to have the same laziness coarseness for multiple signal processors.synthesizer-coreThis type is used for specification of the maximum size of strict packets. Packets can be smaller, can have different sizes in one signal. In some kinds of streams, like lists and stateful generators, the packet size is always 1. The packet size is not just a burden caused by efficiency, but we need control over packet size in applications with feedback.ToDo: Make the element type of the corresponding signal a type parameter. This helps to distinguish chunk sizes of scalar and vectorised signals.synthesizer-core When using  for traversing a signal, it is certainly better to convert to State signal first, since this might involve optimized traversing like in case of Storable signals.synthesizer-coreThis can be used for internal signals that have no observable effect on laziness. E.g. when you construct a list by repeat defaultLazySize zero we assume that zero# is defined for all Additive types.synthesizer-coretakeStateMatch len xs keeps a prefix of xs+ of the same length and block structure as len0 and stores it in the same type of container as len.synthesizer-coreLike tail<, but for an empty signal it simply returns an empty signal.synthesizer-core)Here the control may vary over the time. synthesizer-coreOnly non-empty suffixes are processed. More oftenly we might need zipWithTails :: (Read sig b, Transform2 sig a) => (b -> sig a -> a) -> sig b -> sig a -> sig a+this would preserve the chunk structure of sig a0, but it is a bit more hassle to implement that.synthesizer-core.processor that shall be run in a feedback loopsynthesizer-core5prefix of the output, its length determines the delaysynthesizer-coreProcessor that shall be run in a feedback loop. It's absolutely necessary that this function preserves the chunk structure and that it does not look a chunk ahead. That's guaranteed for processes that do not look ahead at all, like , $" and all of type Causal.Process. synthesizer-coreinputsynthesizer-core'output has the same length as the input Safe-Inferredsynthesizer-core!Returns a list of non-zero times.< Safe-Inferred; Safe-Inferred.1synthesizer-coreSubdivide lazy times into chunks that fit into the number range representable by Int.synthesizer-coreWhen a lazy time value is split into chunks then do not just replicate the sample for the whole time, but insert s.  = Safe-Inferred Safe-Inferred Fsynthesizer-core /inverse (transposition n m) = transposition m nsynthesizer-core )inverse (skewGrid n m) == skewGridInv n mIn general the inverse of a skewGrid cannot be expressed like skewGrid or skewGridCRT. E.g. inverse $ skewGrid 3 4.synthesizer-core6Beware of 0-based indices stored in the result vector.synthesizer-coreWe only need to compute the inverse permutation explicitly, because not all signal structures support write to arbitrary indices, thus Generic.Write does not support it. For strict StorableVector it would be more efficient to build the vector directly. It holds: inverse . inverse == id > Safe-Inferred."Ksynthesizer-coreDeterministic white noise, uniformly distributed between -1 and 1. That is, variance is 1/3.synthesizer-coreApproximates normal distribution with variance 1 by a quadratic B-spline distribution.synthesizer-coremomentary densities, p means that there is about one peak in the time range of 1/p samples synthesizer-coreEvery occurence of  represents a peak.  Safe-Inferred.# synthesizer-core It must hold delay <= length a.synthesizer-core*Each fmap must preserve the signal length.?(c) Henning Thielemann 2008GPL!synthesizer@henning-thielemann.de provisional%requires multi-parameter type classes Safe-Inferred.$synthesizer-coreIntegrate with initial value zero. However the first emitted value is the value of the input signal. It maintains the length of the signal.synthesizer-coreIntegrate with initial condition. First emitted value is the initial condition. The signal become one element longer.@ Safe-Inferred.&synthesizer-core&Mix two signals. In opposition to 1 the result has the length of the longer signal. synthesizer-coreMix one or more signals. synthesizer-coreAdd a number to all of the signal values. This is useful for adjusting the center of a modulation. synthesizer-coreIn Synthesizer.Basic.Distortion; you find a collection of appropriate distortion functions.A Safe-Inferred.0msynthesizer-coreMinimize rounding errors by reducing number of operations per element to a logarithmuc number.synthesizer-coreLinear curve starting at zero.synthesizer-coreLinear curve of a fixed length. The final value is not actually reached, instead we stop one step before. This way we can concatenate several lines without duplicate adjacent values.synthesizer-coreThis is an extension of  to vectors which is straight-forward but requires more explicit signatures. But since it is needed rarely I setup a separate function. synthesizer-core steepness synthesizer-coreinitial value synthesizer-corelinear progression synthesizer-corelength synthesizer-coreinitial and final value synthesizer-corelinear progression synthesizer-core9time where the function reaches 1/e of the initial value synthesizer-coreinitial value synthesizer-coreexponential decay synthesizer-core9time where the function reaches 1/e of the initial value synthesizer-coreinitial value synthesizer-coreexponential decay synthesizer-core9time where the function reaches 1/e of the initial value synthesizer-coreexponential decay synthesizer-core half life synthesizer-coreinitial value synthesizer-coreexponential decay synthesizer-core half life synthesizer-coreinitial value synthesizer-coreexponential decay synthesizer-core half life synthesizer-coreexponential decay synthesizer-core9time where the function reaches 1/e of the initial value synthesizer-coreinitial value synthesizer-coreexponential decay synthesizer-core half life synthesizer-coreinitial value synthesizer-coreexponential decay synthesizer-coretime t0 where 1 is approached synthesizer-coretime t1 where -1 is approached synthesizer-core7a cosine wave where one half wave is between t0 and t1 synthesizer-coretime t0 where 1 is approached synthesizer-coretime t1 where -1 is approached synthesizer-core7a cosine wave where one half wave is between t0 and t1 synthesizer-coretime t0 where 1 is approached synthesizer-coretime t1 where -1 is approached synthesizer-core7a cosine wave where one half wave is between t0 and t1 B Safe-Inferred.1Ssynthesizer-core Graphics.Gnuplot.Simple.plotList [] $ Sig.toList $ run $ 1 |# (10.9, halfSine FlatRight) #| 2  C (c) Henning Thielemann 2008-2011GPL!synthesizer@henning-thielemann.de provisional%requires multi-parameter type classes Safe-Inferred.; synthesizer-coreThe pad value y must be defined, otherwise the chunk size of the padding can be observed.synthesizer-coreMoving (uniformly weighted) average in the most trivial form. This is very slow and needs about  n * length x operations.synthesizer-coreMoving average, where window bounds must be always non-negative.The laziness granularity is 2^height.synthesizer-coreThe first argument is the amplification. The main reason to introduce it, was to have only a Module constraint instead of Field. This way we can also filter stereo signals.synthesizer-coreForward difference quotient. Shortens the signal by one. Inverts ? in the sense that 'differentiate (zero : integrate x) == x,. The signal is shifted by a half time unit.synthesizer-coreCentral difference quotient. Shortens the signal by two elements, and shifts the signal by one element. (Which can be fixed by prepending an appropriate value.) For linear functions this will yield essentially the same result as . You obtain the result of  if you smooth the one of ' by averaging pairs of adjacent values.ToDo: Vector variantsynthesizer-coreSecond derivative. It is /differentiate2 == differentiate . differentiate but  should be faster.synthesizer-core.Unmodulated non-recursive filter (convolution)Brute force implementation.synthesizer-coreBoth should signals should have similar length. If they have considerably different length, then better use .Implementation using Karatsuba trick and split-and-overlap-add. This way we stay in a ring, are faster than quadratic runtime but do not reach log-linear runtime.synthesizer-coreThe first operand must be finite and the second one can be infinite. For efficient operation we expect that the second signal is longer than the first one.synthesizer-core It must hold delay <= length a.synthesizer-core8Reasonable choices for the multiplication operation are , , convolve.synthesizer-core the envelope synthesizer-corethe signal to be enveloped synthesizer-core the envelope synthesizer-corethe signal to be enveloped 66D (c) Henning Thielemann 2008-2009GPL!synthesizer@henning-thielemann.de provisional%requires multi-parameter type classes Safe-Inferred.Asynthesizer-coreThe Maybe type carries an unpaired value from one block to the next one.synthesizer-coreoffset must be zero or one.synthesizer-coreMoving average, where window bounds must be always non-negative.The laziness granularity is 2^height.This function is only slightly more efficient than its counterpart from Generic.Filter, since it generates strict blocks and not one-block chunky signals.synthesizer-coreThe first argument is the amplification. The main reason to introduce it, was to have only a Module constraint instead of Field. This way we can also filter stereo signals.synthesizer-coreThe function is like that of 5=, but this function preserves in a sense the chunk structure.The result will have laziness breaks at least at the chunk boundaries that correspond to the breaks in the input signal. However we insert more breaks, such that a maximum chunk size can be warrented. (Since control and input signal are aligned in time, we might as well use the control chunk structure. Currently I do not know what is better. For the above example it doesn't matter. We might implement a variant in Causal.Filter.NonRecursive.)This function cannot be written using generic functions, since we have to inspect the chunks individually.E Safe-Inferred.F synthesizer-coreVolume based on Manhattan norm.synthesizer-coreVolume based on Energy norm.synthesizer-coreVolume based on Sum norm.synthesizer-coreVolume based on Manhattan norm.synthesizer-coreVolume based on Energy norm.synthesizer-coreVolume based on Sum norm.synthesizer-coreCompute minimum and maximum value of the stream the efficient way. Input list must be non-empty and finite.synthesizer-coreRequires finite length. This is identical to the arithmetic mean.synthesizer-core must be non-zero.synthesizer-coreDetects zeros (sign changes) in a signal. This can be used as a simple measure of the portion of high frequencies or noise in the signal. It ca be used as voiced/unvoiced detector in a vocoder. zeros x !! n is True if and only if "(x !! n >= 0) /= (x !! (n+1) >= 0)6. The result will be one value shorter than the input.synthesizer-core$Detect thresholds with a hysteresis.synthesizer-coreAlmost naive implementation of the chirp transform, a generalization of the Fourier transform.More sophisticated algorithms like Rader, Cooley-Tukey, Winograd, Prime-Factor may follow.F Safe-InferredH]synthesizer-core It must hold n <= CutG.length x.synthesizer-core)length of the input signals must be equalsynthesizer-core-The size of both input signals must be equal.?Could be optimized by computing only first (length x) elements.G Safe-Inferred.RFsynthesizer-coreFilter window stored as spectrum such that it can be applied efficiently to long signals.synthesizer-coreCache powers of the primitive root of unity in a storage compatible to the processed signal.synthesizer-coreMemorize factorizations of the data size and permutation vectors.synthesizer-core It must hold: 2uncurry (*) (conjugatePrimitiveRootsOfUnity n) = 1 mapPair ((^m), (^m)) (conjugatePrimitiveRootsOfUnity (n*m) y) == conjugatePrimitiveRootsOfUnity n y@since we need for caching that the cache is uniquely determined by singal length and transform direction.synthesizer-coreShall we divide the result values by the length of the signal? Our dimensional wrapper around the Fourier transform does not expect this.synthesizer-coreThe size of the signal must match the size, that the plan was generated for.synthesizer-coreThe size and type of the signal must match the parameters, that the cache was generated for.synthesizer-core#Detect and re-use common sub-plans.synthesizer-coreThe expression cacheForward prototype precomputes all data that is needed for forward Fourier transforms for signals of the type and length  prototype. You can use this cache in .synthesizer-coreSee .synthesizer-coreIt is 1(cacheForward x, cacheBackward x) = cacheDuplex x but # shared common data of both caches.synthesizer-core$Detect and re-use common sub-caches.synthesizer-core;Cooley-Tukey specialised to one factor of the size being 2.&Size of the input signal must be even.synthesizer-coreFor transformComposite z (n,m) sig, it must hold n*m == length sig and z ^ length sig == 1.Cooley-Tukey-algorithmsynthesizer-coreFor transformCoprime z (n,m) sig, the parameters n and m must be relatively prime and n*m == length sig and z ^ length sig == 1.Good-Thomas algorithmsynthesizer-core+Rader's algorithm for prime length signals.synthesizer-coreEfficient convolution of a large filter window with a probably infinite signal.synthesizer-core2Signal must have equal size and must not be empty.synthesizer-coreThis function does not apply scaling. That is you have to scale the spectrum by recip (length x)! if you want a plain convolution.H Safe-InferredR  I(c) Henning Thielemann 2006GPL!synthesizer@henning-thielemann.de provisional%requires multi-parameter type classes Safe-Inferred.X synthesizer-coreTake signal until it falls short of a certain amplitude for a given time. synthesizer-coreTake values until the predicate p holds for n successive values. The list is truncated at the beginning of the interval of matching values. synthesizer-coreGiven a list of signals with time stamps, mix them into one signal as they occur in time. Ideally for composing music.Cf.  synthesizer-coreSplit a storable signal into a sequence of signals. A new piece is started whenever the Boolean signal contains a . The first piece in the result is the part from the beginning until the first . That is, if the signal  starts with a ', then the first result piece is empty.When the control signal is at least as long as the storable signal and if we neglect the chunking structure, then it holds !concat (chopStorable bs xs) == xs synthesizer-coreA list of pairs: (relative start time, signal part), The start time is relative to the start time of the previous event. synthesizer-coreThe mixed signal. synthesizer-coreA list of pairs: (relative start time, signal part), The start time is relative to the start time of the previous event. synthesizer-coreThe mixed signal.   J Safe-InferredX  K Safe-InferredY0   Safe-Inferred\Z synthesizer-coreCf. StreamFusion * synthesizer-core0I think this function does too much. Better use   and (>>>). synthesizer-core0I think this function does too much. Better use   and (>>>). synthesizer-core0I think this function does too much. Better use   and (>>>). synthesizer-core0I think this function does too much. Better use   and (>>>). synthesizer-core$applyConst c x == apply c (repeat x) synthesizer-corePrepend an element to a signal, but keep the signal length, i.e. drop the last element. synthesizer-coreIf T would be the function type -> then replicateControlled 3 f computes (c,x) -> f(c, f(c, f(c, x))).)   )   L(c) Henning Thielemann 2008GPL!synthesizer@henning-thielemann.de provisional%requires multi-parameter type classes Safe-Inferred._T synthesizer-coreIntegrate with initial value zero. However the first emitted value is the value of the input signal. It maintains the length of the signal. synthesizer-coreIntegrate with initial condition. First emitted value is the initial condition. The signal become one element longer. synthesizer-coreIntegrate with initial condition. First emitted value is the initial condition. The signal become one element longer.  M(c) Henning Thielemann 2008GPL!synthesizer@henning-thielemann.de provisional%requires multi-parameter type classes Safe-Inferred.a synthesizer-coreLike 5 but in a recursive form. This needs only linear time (independent of the window size) but may accumulate rounding errors. ys = xs * (1,0,0,0,-1) / (1,-1) ys * (1,-1) = xs * (1,0,0,0,-1) ys = xs * (1,0,0,0,-1) + ys * (0,1) synthesizer-core0Sig.T a must contain only non-negative elements.synthesizer-coreShift sampling points by a half sample period in order to preserve signals for window widths below 1.  N(c) Henning Thielemann 2008GPL!synthesizer@henning-thielemann.de provisional%requires multi-parameter type classes Safe-Inferred.d  synthesizer-core8Parameters for a general recursive filter of 2nd order. synthesizer-coreGiven a function which computes the filter parameters of a lowpass filter for a given frequency, turn that into a function which generates highpass parameters, if requested filter type is Highpass. synthesizer-coreChange filter parameter such that result is amplified by a given factor.  O (c) Henning Thielemann 2008-2012GPL!synthesizer@henning-thielemann.de provisional%requires multi-parameter type classes Safe-Inferred.n synthesizer-coreThe computation of the internal parameters is a bit complicated, but it fulfills the following properties:At the resonance frequency the band pass has 180 degree phase shift. This is also approximately the frequency where the filter has maximum output. Even more important, this is the frequency where the band limit filter works.At the resonance frequency highpass, lowpass, and bandpass amplify by the factor  resonance.5The lowpass amplifies the frequency zero by factor 1.The highpass amplifies the highest representable (Nyquist) frequency by the factor 1.The bandlimit amplifies both frequency zero and Nyquist frequency by factor one and cancels the resonance frequency. synthesizer-coreThe computation of the internal parameters is a bit complicated, but it fulfills the following properties:At the resonance frequency the band pass has 180 degree phase shift. This is also approximately the frequency where the filter has maximum output. Even more important, this is the frequency where the band limit filter works.At the resonance frequency highpass, lowpass, and bandpass amplify by the factor  resonance.5The lowpass amplifies the frequency zero by factor 1.The highpass amplifies the highest representable (Nyquist) frequency by the factor 1.The bandlimit amplifies both frequency zero and Nyquist frequency by factor one and cancels the resonance frequency. synthesizer-coreThe computation of the internal parameters is a bit complicated, but it fulfills the following properties:At the resonance frequency the band pass has 180 degree phase shift. This is also approximately the frequency where the filter has maximum output. Even more important, this is the frequency where the band limit filter works.At the resonance frequency highpass, lowpass, and bandpass amplify by the factor  resonance.5The lowpass amplifies the frequency zero by factor 1.The highpass amplifies the highest representable (Nyquist) frequency by the factor 1.The bandlimit amplifies both frequency zero and Nyquist frequency by factor one and cancels the resonance frequency. synthesizer-coreConvert parameters of universal filter to general second order filter parameters. Filtering with these parameters does not yield exactly the same result since the initial conditions are different. synthesizer-coreUniversal filter: Computes high pass, band pass, low pass in one go   P(c) Henning Thielemann 2008GPL!synthesizer@henning-thielemann.de provisional%requires multi-parameter type classes Safe-Inferred.o  Q(c) Henning Thielemann 2008GPL!synthesizer@henning-thielemann.de provisional%requires multi-parameter type classes Safe-Inferred.v synthesizer-coreWe use complex numbers as result types, since the particular filter type is determined by the parameter generator. synthesizer-core/The internal parameters are computed such that:At the resonance frequency the filter amplifies by the factor  resonance with no phase shift.At resonance frequency plus half sample rate the filter amplifies by facter recip $ 2 - recip resonance with no phase shift, but you cannot observe this immediately, because it is outside the Nyquist band. synthesizer-core/The internal parameters are computed such that:At the resonance frequency the filter amplifies by the factor  resonance with no phase shift.At resonance frequency plus and minus band width the filter amplifies by facter 1 with a non-zero phase shift. synthesizer-core/The internal parameters are computed such that:At the resonance frequency the filter amplifies by the factor  resonance with a non-zero phase shift.The filter amplifies the direct current (frequency zero) by factor 1 with no phase shift.The real component is a lowpass, the imaginary component is a highpass. You can interpolate between them using other complex projections. synthesizer-coreUniversal filter: Computes high pass, band pass, low pass in one go R (c) Henning Thielemann 2008-2011GPL!synthesizer@henning-thielemann.de provisional%requires multi-parameter type classes Safe-Inferred.w# synthesizer-core.Convert cut-off frequency to feedback factor.   S(c) Henning Thielemann 2008GPL!synthesizer@henning-thielemann.de provisional%requires multi-parameter type classes Safe-Inferred.zq synthesizer-coreThe most simple version of the Karplus-Strong algorithm which is suitable to simulate a plucked string. It is similar to the   function. synthesizer-coreInfinitely many equi-delayed exponentially decaying echos. The echos are clipped to the input length. We think it is easier (and simpler to do efficiently) to pad the input with zeros or whatever instead of cutting the result according to the input length. synthesizer-coreEchos of different delays. synthesizer-core:Echos can be piped through an arbitrary signal processor.   T(c) Henning Thielemann 2008GPL!synthesizer@henning-thielemann.de provisional%requires multi-parameter type classes Safe-Inferred.| synthesizer-core Feedback of the lowpass cascade synthesizer-core/Feedback of each of the lowpasses of 1st order synthesizer-core(Choose one of the implementations below synthesizer-coreSimulate the Moog cascade by a list of states of the partial lowpasses synthesizer-core>The elegant way of implementing the Moog cascade by recursion U(c) Henning Thielemann 2008GPL!synthesizer@henning-thielemann.de provisional%requires multi-parameter type classes Safe-Inferred. synthesizer-coreThe most simple version of the Karplus-Strong algorithm which is suitable to simulate a plucked string. It is similar to the   function. synthesizer-coreInfinitely many equi-delayed exponentially decaying echos. The echos are clipped to the input length. We think it is easier (and simpler to do efficiently) to pad the input with zeros or whatever instead of cutting the result according to the input length. synthesizer-coreEchos of different delays. synthesizer-core:Echos can be piped through an arbitrary signal processor.   V(c) Henning Thielemann 2008GPL!synthesizer@henning-thielemann.de provisional%requires multi-parameter type classes Safe-Inferred.J synthesizer-coreThe most simple version of the Karplus-Strong algorithm which is suitable to simulate a plucked string. It is similar to the   function. synthesizer-coreInfinitely many equi-delayed exponentially decaying echos. The echos are clipped to the input length. We think it is easier (and simpler to do efficiently) to pad the input with zeros or whatever instead of cutting the result according to the input length. synthesizer-coreEchos of different delays. Chunk size must be smaller than all of the delay times. synthesizer-core:Echos can be piped through an arbitrary signal processor. synthesizer-coreAlternative to   that uses 2 at the beginning instead of adding a zero signal.  W(c) Henning Thielemann 2008GPL!synthesizer@henning-thielemann.de provisional%requires multi-parameter type classes Safe-Inferred.synthesizer-corecompute the partial filter of the second order from the pole informationsynthesizer-corecompute the partial filter of the second order from the pole information  X(c) Henning Thielemann 2008GPL!synthesizer@henning-thielemann.de provisional%requires multi-parameter type classes Safe-Inferred. synthesizer-coreWhen called as runPole kind order ratio freqs?, the filter amplifies frequency 0 with factor 1 and frequency freq with factor ratio.It uses the frequency and ratio information directly and thus cannot benefit from efficient parameter interpolation (asynchronous run of a ControlledProcess).  Y (c) Henning Thielemann 2008-2010GPL!synthesizer@henning-thielemann.de provisional%requires multi-parameter type classes Safe-Inferred. synthesizer-coreFeedback factor. synthesizer-coreCompute the filter parameter such that a given phase shift is achieved at a certain frequency.Both frequency and phase are with respect to unit 1. This is conform to Phase definition and allows to avoid Transcendental constraint in some cases since we need no factor 2*pi. See for instance  . However, it is intended that the phase parameter is not of type Phase, because for the   we divide by the cascade order and then there is a difference between phase pi and 3*pi. synthesizer-coreThis is the same as   , but for phase = frequency it has a division of a zero by a zero of multiplicity 2, whereas  4 has a division of a non-zero number by zero. Thus  # suffers less from cancellation if phase is close to  frequency. synthesizer-coreAn approximation to   for small phase and frequency values. It needs only field operations due to our choice of the unit 1 for the phase parameter. synthesizer-core7Compute phase shift of an allpass at a given frequency. synthesizer-core(Choose one of the implementations below synthesizer-coreSimulate the Allpass cascade by a list of states of the partial allpasses synthesizer-coreDirectly implement the allpass cascade as multiple application of allpasses of 1st order  synthesizer-core8The phase shift to be achieved for the given frequency. synthesizer-core0The frequency we specified the phase shift for. synthesizer-core8The phase shift to be achieved for the given frequency. synthesizer-core0The frequency we specified the phase shift for. synthesizer-core8The phase shift to be achieved for the given frequency. synthesizer-core0The frequency we specified the phase shift for. synthesizer-core4The number of equally designed 1st order allpasses. synthesizer-core8The phase shift to be achieved for the given frequency. synthesizer-core0The frequency we specified the phase shift for.   Z(c) Henning Thielemann 2010GPL!synthesizer@henning-thielemann.de provisional%requires multi-parameter type classes Safe-Inferred.b synthesizer-core oscillator with modulated phase synthesizer-core oscillator with modulated shape synthesizer-coreConvert a list of phase steps into a list of momentum phases. phase is a number in the interval [0,1). freq contains the phase steps. The last element is omitted. synthesizer-coreLike  " but the first element is omitted. synthesizer-core$oscillator with modulated frequency synthesizer-core4oscillator with both phase and frequency modulation synthesizer-core4oscillator with both shape and frequency modulation   [ Safe-Inferred synthesizer-corecells are organised in a transposed style, when compared with Plain.ToneModulation synthesizer-coreThis function should not be used, since it requires recomputation of shapes and freqs lists. \ Safe-Inferred synthesizer-coreInterpolate first within waves and then across waves, which is simpler but maybe less efficient for lists. However for types with fast indexing/drop like StorableVector this is optimal.  ] Safe-Inferredp synthesizer-coreIn contrast to the counterpart of this function for plain lists, it does not use sophisticated list transposition tricks, but seeks through the prototype signal using . Since  is used in an inner loop, it must be fast. This is true for StorableVectors. synthesizer-coreDelays output by one element and shorten it by one element at the end.  ^(c) Henning Thielemann 2009GPL!synthesizer@henning-thielemann.de provisional%requires multi-parameter type classes Safe-Inferred._ synthesizer-coreIntegrate with initial value zero. However the first emitted value is the value of the input signal. It maintains the length of the signal. synthesizer-coreIntegrate with initial condition. First emitted value is the initial condition. The signal becomes one element longer.  _ Safe-Inferred.  ` Safe-Inferred.  a Safe-Inferred   Safe-Inferred"b Safe-Inferred= synthesizer-coreIf two values are equal, then return one of them, otherwise raise an error. synthesizer-core%This one should be more precise than  # in floating computations whenever x1 is small and x0 is big. c Safe-Inferred.S synthesizer-coreThe interpolators for module operations do not simply compute a straight linear combination of some vectors. Instead they add then scale, then add again, and so on. This is efficient whenever scaling and addition is cheap. In this case they might save multiplications. I can't say much about numeric cancellations, however.synthesizer-coret -> cubicHalf t x x'= has a double zero at 1 and at 0 it has value x and slope x'.  d Safe-Inferred. synthesizer-core,Consider the signal to be piecewise linear. synthesizer-coreConsider the signal to be piecewise cubic, with smooth connections at the nodes. It uses a cubic curve which has node values x0 at 0 and x1 at 1 and derivatives (x1-xm1) 2 and (x2-x0)2, respectively. You can see how it works if you evaluate the expression for t=0 and t=1 as well as the derivative at these points. synthesizer-corewith this wrapper you can use the collection of interpolating functions from Donadio's DSP library  synthesizer-core(left extent, right extent), e.g. (1,1) for linear hat   e Safe-Inferred. synthesizer-coreOnly for finite input signals. synthesizer-coreThe extrapolation may miss some of the first and some of the last points synthesizer-corealternative implementation of  synthesizer-core6All values of frequency control must be non-negative. synthesizer-coreThe extrapolation may miss some of the first and some of the last points        f(c) Henning Thielemann 2006GPL!synthesizer@henning-thielemann.de provisional%requires multi-parameter type classes Safe-Inferred. synthesizer-coreConvert a list of phase steps into a list of momentum phases phase is a number in the interval [0,1) freq contains the phase steps synthesizer-coreAvoids negative numbers and thus can be used with Chunky numbers.  g Safe-Inferred. synthesizer-coreWe assume that a tone was generated by a shape modulated oscillator. We try to reconstruct the wave function (with parameters shape control and phase) from a tone by interpolation.The unit for the shape control parameter is the sampling period. That is the shape parameter is a time parameter pointing to a momentary shape of the prototype signal. Of course this momentary shape does not exist and we can only guess it using interpolation.At the boundaries we repeat the outermost shapes that can be reconstructed entirely from interpolated data (that is, no extrapolation is needed). This way we cannot reproduce the shape at the boundaries because we have no data for cyclically extending it. On the other hand this method guarantees a nice wave shape with the required fractional period.It must be length tone >= Interpolation.number ipStep + Interpolation.number ipLeap * ceiling period.  h(c) Henning Thielemann 2006GPL!synthesizer@henning-thielemann.de provisional%requires multi-parameter type classes Safe-Inferred. synthesizer-core#oscillator with constant frequency synthesizer-core$oscillator with modulated frequency synthesizer-core oscillator with modulated phase synthesizer-core oscillator with modulated shape synthesizer-core4oscillator with both phase and frequency modulation synthesizer-core4oscillator with both shape and frequency modulation synthesizer-coreoscillator with a sampled waveform with constant frequency This is essentially an interpolation with cyclic padding. synthesizer-coreoscillator with a sampled waveform with modulated frequency Should behave homogenously for different types of interpolation. synthesizer-coreShape control is a list of relative changes, each of which must be non-negative in order to allow lazy processing. '1' advances by one wave. Frequency control can be negative. If you want to use sampled waveforms as well then use  in the list of waveforms. With sampled waves this function is identical to HunkTranspose in Assampler.+Example: interpolate different versions of  and .You could also chop a tone into single waves and use the waves as input for this function but you certainly want to use  or  . instead, because in the wave information for  ( shape and phase are strictly separated. synthesizer-core8Time stretching and frequency modulation of a pure tone.We consider a tone as the result of a shape modulated oscillator, and virtually reconstruct the waveform function (a function of time and phase) by interpolation and resample it. This way we can alter frequency and time progress of the tone independently.$This function is identical to using  % with a wave function constructed by  but it consumes the sampled source tone lazily and thus allows only relative shape control with non-negative control steps.The function is similar to   but respects that in a sampled tone, phase and shape control advance synchronously. Actually we could re-use   with modified phase values. But we would have to cope with negative shape control jumps, and waves would be padded locally cyclically. The latter one is not wanted since we want padding according to the adjacencies in the source tone. Note that differently from   the shape control difference 1 does not mean to skip to the next wave, since this oscillator has no discrete waveforms. Instead 1 means that the shape alters as fast as in the prototype signal.Although the shape difference values must be non-negative I hesitate to give them the type Number.NonNegative.T t because then you cannot call this function with other types of non-negative numbers like .+The prototype tone signal is reproduced if freqs == repeat (1/period) and shapes == repeat 1. synthesizer-core$impulse train with static frequency synthesizer-core'impulse train with modulated frequency synthesizer-core&sine oscillator with static frequency synthesizer-core)sine oscillator with modulated frequency synthesizer-core>sine oscillator with modulated phase, useful for FM synthesis synthesizer-core+saw tooth oscillator with static frequency synthesizer-core.saw tooth oscillator with modulated frequency   i Safe-Inferredɷ synthesizer-corePlay a simple sine tone at 44100 sample rate and 16 bit. These are the parameters used for compact disks. The period of the tone is 2*pi*107. Playing at sample rate 44100 Hz results in a tone of 44100 / (20*pi) Hz, that is about 702 Hz. This is simple enough to be performed in real-time, at least on my machine. For playback we use SoX. synthesizer-coreNow the same for a stereo signal. Both stereo channels are slightly detuned in order to achieve a stereophonic phasing effect. In principle there is no limit of the number of channels, but with more channels playback becomes difficult. Many signal processes in our package support any tuple and even nested tuples using the notion of an algebraic module (see ). A module is a vector space where the scalar numbers do not need to support division. A vector space is often also called a linear space, because all we require of vectors is that they can be added and scaled and these two operations fulfill some natural laws. synthesizer-core1Of course we can also write a tone to disk using sox. synthesizer-coreFor the following examples we will stick to monophonic sounds played at 44100 Hz. Thus we define a function for convenience. synthesizer-coreNow, let's repeat the  8 example in a higher level style. We use the oscillator   that does not allow any modulation. We can however use any waveform. The waveform is essentially a function which maps from the phase to the displacement. Functional programming proves to be very useful here, since anonymous functions as waveforms are optimally supported by the language. We can also expect, that in compiled form the oscillator does not have to call back the waveform function by an expensive explicit function call, but that the compiler will inline both oscillator and waveform such that the oscillator is turned into a simple loop which handles both oscillation and waveform computation.Using the oscillator with `9 also has the advantage that we do not have to cope with s any longer. The frequency is given as ratio of the sample rate. That is, 0.01 at 44100 Hz sample rate means 441 Hz. This way all frequencies are given in the low-level signal processing.It is not optimal to handle frequencies this way, since all frequency values are bound to the sample rate. For overcoming this problem, see the high level routines using physical dimensions. For examples see 3Synthesizer.Dimensional.RateAmplitude.Demonstration. synthesizer-coreIt is very simple to switch to another waveform like a saw tooth wave. Instead of a sharp saw tooth, we use an extreme asymmetric triangle. This is a poor man's band-limiting approach that shall reduce aliasing at high oscillation frequencies. We should really work on band-limited oscillators, but this is hard in the general case. synthesizer-coreWhen we apply a third power to each value of the saw tooths we get an oscillator with cubic polynomial functions as waveform. The distortion function applied to a saw wave can be used to turn every function on the interval [-1,1] into a waveform. synthesizer-coreNow let's start with modulated tones. The first simple example is changing the degree of asymmetry according to a slow oscillator (LFO = low frequency oscillator). synthesizer-core:It's also very common to modulate the frequency of a tone. synthesizer-core9A simple sine wave with exponentially decaying amplitude. synthesizer-coreThe   sound can also be used to modulate the phase another oscillator. This is a well-known effect used excessively in FM synthesis, that was introduced by the Yamaha DX-7 synthesizer. synthesizer-coreOne of the most impressive sounds effects is certainly frequency filtering, especially when the filter parameters are modulated. In this example we use a resonant lowpass whose resonance frequency is controlled by a slow sine wave. The frequency filters usually use internal filter parameters that are not very intuitive to use directly. Thus we apply a function (here  ) in order to turn the intuitive parameters "resonance frequency" and "resonance" (resonance frequency amplification while frequency zero is left unchanged) into internal filter parameters. We have not merged these two steps since the computation of internal filter parameters is more expensive then the filtering itself and you may want to reduce the computation by computing the internal filter parameters at a low sample rate and interpolate them. However, in the list implementation this will not save you much time, if at all, since the list operations are too expensive.Now this is the example where my machine is no longer able to produce a constant audio stream in real-time. For tackling this problem, please continue with Synthesizer.Generic.Tutorial. j Safe-Inferred.  k(c) Henning Thielemann 2009GPL!synthesizer@henning-thielemann.de provisional%requires multi-parameter type classes Safe-Inferred.Ρ synthesizer-core+Convert sample rate to allpass parameters. synthesizer-coreAlthough we get (almost) only the right-rotating part of the real input signal, the amplitude is as large as the input amplitude. That is, the amplitude actually doubled. synthesizer-coreApproximation to perfect lowpass. However in the low frequencies the above filter is far away from being a perfect Hilbert filter, thus the cut is not straight as expected. This implementation is lazy, but shifts phases. synthesizer-coreIf we could achieve lowpass filtering while maintaining phases, we could do approximate Whittaker interpolation. Here we try to do this by filtering forward and backward. However, this does not work since we move the spectrum between two Hilbert transforms and thus the phase distortions do not match. It does not even yield a fine lowpass, since reversing the signal does not reverse the spectrum.  l Safe-Inferred.ϖ synthesizer-coreWe try to simulate the sound of broken glass as a mixture of short percussive sounds with random pitch   m Safe-Inferred.? synthesizer-coreCreate a sound of a slightly changed frequency just as needed for a simple stereo sound. synthesizer-corelow pass with resonance synthesizer-coreaccumulate multiple similar saw sounds and observe the increase of volume The oscillator osc# must accept relative frequencies. synthesizer-coreA tone with a waveform with roughly the dependency x -> x**p, where the waveform is normalized to constant quadratic norm synthesizer-coreBuild a saw sound from its harmonics and modulate it. Different to normal modulation I modulate each harmonic with the same depth rather than a proportional one. synthesizer-coreShort pulsed Noise.white, i.e. Noise.white amplified with pulses of varying H/L ratio. synthesizer-coreDrum sound using the Karplus-Strong-Algorithm This is a Noise.white enveloped by an exponential2 which is piped through the Karplus-Strong machine for generating some frequency. The whole thing is then frequency modulated to give a falling frequency.  synthesizer-core,A function mapping a frequency to a signal. synthesizer-core3The factor to the frequency, should be close to 1. synthesizer-core.The base (undeviated) frequency of the sound. synthesizer-corefrequency of the pulses, interesting ones are around 100 Hz and below   n Safe-Inferred  o Safe-Inferred.B  p Safe-Inferred.Bsynthesizer-coreThis function uses suffixes of the reversed signal. This way small delays perform well but the big drawback is that the garbage collector can not deallocate old samples. synthesizer-coreThis is essentially different for constant interpolation, because this function "looks forward" whereas the other two variants "look backward". For the symmetric interpolation functions of linear and cubic interpolation, this does not really matter.  q Safe-Inferred.synthesizer-coreDrop elements from a blocked list. The offset must lie in the leading block.  r Safe-Inferred.ٕ synthesizer-coreThe test for constant interpolation will fail, due to different point of views in forward and backward interpolation.  s Safe-Inferred. synthesizer-corestereo sound of a humming fly   t Safe-Inferred.{ synthesizer-coreOnly for finite input signals. synthesizer-coreThe extrapolation may miss some of the first and some of the last points synthesizer-core6All values of frequency control must be non-negative. synthesizer-coreThe extrapolation may miss some of the first and some of the last points    u Safe-Inferred. synthesizer-coreThis is essentially different for constant interpolation, because this function "looks forward" whereas the other two variants "look backward". For the symmetric interpolation functions of linear and cubic interpolation, this does not really matter.  v(c) Henning Thielemann 2008GPL!synthesizer@henning-thielemann.de provisional%requires multi-parameter type classes Safe-Inferred.| synthesizer-coreLike C but in a recursive form. This needs only linear time (independent of the window size) but may accumulate rounding errors. ys = xs * (1,0,0,0,-1) / (1,-1) ys * (1,-1) = xs * (1,0,0,0,-1) ys = xs * (1,0,0,0,-1) + ys * (0,1) synthesizer-coresig a) must contain only non-negative elements.synthesizer-coreShift sampling points by a half sample period in order to preserve signals for window widths below 1.  w Safe-Inferred.[ synthesizer-core6All values of frequency control must be non-negative. synthesizer-coreThe extrapolation may miss some of the first and some of the last points   x(c) Henning Thielemann 2006GPL!synthesizer@henning-thielemann.de provisional%requires multi-parameter type classes Safe-Inferred. synthesizer-core oscillator with modulated phase synthesizer-core oscillator with modulated shape synthesizer-core$oscillator with modulated frequency synthesizer-core$oscillator with modulated frequency synthesizer-core4oscillator with both phase and frequency modulation synthesizer-core4oscillator with both shape and frequency modulation synthesizer-coreoscillator with a sampled waveform with modulated frequency Should behave homogenously for different types of interpolation. synthesizer-core)sine oscillator with modulated frequency synthesizer-core>sine oscillator with modulated phase, useful for FM synthesis synthesizer-core.saw tooth oscillator with modulated frequency y(c) Henning Thielemann 2006GPL!synthesizer@henning-thielemann.de provisional%requires multi-parameter type classes Safe-Inferred. synthesizer-coreOscillator with constant frequency. It causes aliasing effects for sharp waveforms and high frequencies. synthesizer-coreOscillator with constant frequency that suppresses aliasing effects using waveforms with controllable smoothness. synthesizer-core oscillator with modulated phase synthesizer-core oscillator with modulated shape synthesizer-core$oscillator with modulated frequency synthesizer-core$oscillator with modulated frequency synthesizer-core4oscillator with both phase and frequency modulation synthesizer-core4oscillator with both shape and frequency modulation synthesizer-coreoscillator with a sampled waveform with constant frequency This essentially an interpolation with cyclic padding. synthesizer-coreoscillator with a sampled waveform with modulated frequency Should behave homogenously for different types of interpolation. synthesizer-core&sine oscillator with static frequency synthesizer-core)sine oscillator with modulated frequency synthesizer-core>sine oscillator with modulated phase, useful for FM synthesis synthesizer-core.saw tooth oscillator with modulated frequency synthesizer-core.saw tooth oscillator with modulated frequency   z Safe-Inferred.k synthesizer-coreMost simple of looping: You give start and length of the loop body and this part is repeated. The data behind start+length is ignored. synthesizer-coreCreate a smooth loop by cross-fading a part with delayed versions of itself. The loop length will be rounded to the next smaller even number. synthesizer-coreResample a sampled sound with a smooth loop using our time manipulation algorithm. Time is first controlled linearly, then switches to a sine or triangular control. Loop start must be large enough in order provide enough spare data for interpolation at the beginning and loop start plus length must preserve according space at the end. One period is enough space for linear interpolation.In order to get a loopable sound with finite space we have to reduce the loop length to a multiple of a wave period. We will also modify the period a little bit, such that in our loop body there is an integral number of periods.3We return the modified period and the looped sound.  {(c) Henning Thielemann 2006GPL!synthesizer@henning-thielemann.de provisional%requires multi-parameter type classes Safe-Inferred.! synthesizer-core#oscillator with constant frequency synthesizer-core$oscillator with modulated frequency synthesizer-core oscillator with modulated phase synthesizer-core oscillator with modulated shape synthesizer-core4oscillator with both phase and frequency modulation synthesizer-core4oscillator with both shape and frequency modulation synthesizer-coreoscillator with a sampled waveform with constant frequency This is essentially an interpolation with cyclic padding. synthesizer-coreoscillator with a sampled waveform with modulated frequency Should behave homogenously for different types of interpolation. synthesizer-core&sine oscillator with static frequency synthesizer-core)sine oscillator with modulated frequency synthesizer-core>sine oscillator with modulated phase, useful for FM synthesis synthesizer-core.saw tooth oscillator with modulated frequency synthesizer-core.saw tooth oscillator with modulated frequency | Safe-Inferred w synthesizer-coreFirst, we define a play routine for lazy storable vectors. Storable lazy vectors are lazy lists of low-level arrays. They are both efficient in time and memory consumption, but the blocks disallow feedback by small delays. Elements of a storable vector must be of type class Storable. This means that elements must have fixed size and advanced data types like functions cannot be used. synthesizer-coreHere is a simple oscillator generated as lazy storable vector. An oscillator is a signal generator, that is it produces a signal without consuming other signals that correspond in time. Signal generators have the maximal block size as parameter. This is the lower limit of possible feedback delays.synthesizer-coreA routine just for the case that we want to post-process a signal somewhere else.synthesizer-coreThe simple brass sound demonstrates how to generate piecewise defined curves. Some infix operators are used in order to make the pieces fit in height. There are also operators for intended jumps.synthesizer-coreWe rewrite the filter example   in terms of type classes for more signal types. The constraints become quite large because we must assert, that a particular sample type can be used in the addressed signal type.synthesizer-coreHere we instantiate  for storable vectors and play it. This means that all operations convert a storable vector into another storable vector. While every single operation probably is as efficient as possible, the composition of all those processes could be more efficient. So keep on reading.synthesizer-coreThe next signal type we want to consider is the stateful signal generator. It is not a common data structure, where the sample values are materialized. Instead it is a description of how to generate sample values iteratively. This is almost identical to the  Data.Stream module from the  stream-fusion package. With respect to laziness and restrictions of the sample type (namely none), this signal representation is equivalent to lists. You can convert one into the other in a lossless way. That is, function as sample type is possible. Combination of such signal generators is easily possible and does not require temporary storage, because this signal representation needs no sample value storage at all. However at the end of such processes, the signal must be materialized. Here we write the result into a lazy storable vector and play that. What the compiler actually does is to create a single loop, that generates the storable vector to be played in one go.synthesizer-core=We demonstrate the stateful signal generator using the known  example. Actually we can reuse the code from above, because the signal generator is also an instance of the generic signal class.synthesizer-coreMerging subsequent signal processes based on signal generators into an efficient large signal processor is easy. Not storing intermediate results is however a problem in another situation: Sometimes you want to share one signal between several processes.synthesizer-coreIn the following example we generate an exponential curve which shall be used both as envelope and as resonance frequency control of a resonant lowpass. Actually, recomputing an exponential curve is not an issue, since it only needs one multiplication per sample. But it is simple enough to demonstrate the problem and its solutions. The expression let env = exponential2 50000 1, fools the reader of the program, since the env that is shared, is only the signal generator, that is, the description of how to compute the exponential curve successively. That is wherever a signal process reads env, it is computed again.synthesizer-coreYou can achieve sharing by a very simple way. You can write the result of the signal generator in a list (3) and use this list as source for a new generator ().  provides a signal generator that generates new sample values by delivering the next sample from the list.2In a real world implementation you would move the Sig.fromList . Sig.toList to , since the caller cannot know, that this function uses the signal twice, and the implementor of / cannot know, how expensive the computation of env is.You can use any other signal type for sharing, e.g. storable vectors, but whatever type you choose, you also get its disadvantages. Namely, storable vectors only work for storable samples and lists are generally slow, and they also cannot be optimized away, since this only works, when no sharing is required.Whenever a signal is shared as input between several signal processes, the actual materialized data is that between the slowest and the fastest reading process. This is due to lazy evaluation and garbage collection. If the different readers read with different speed, then you will certainly need a temporary sample storage.synthesizer-coreIt is however not uncommon that all readers read with the same speed. In this case we would in principle only need to share the input signal per sample. This way we would not need a data structure for storing a sub-sequence of samples temporarily. But how to do that practically?The solution is not to think in terms of signals and signal processors, e.g. Sig.T a and Sig.T a -> Sig.T b -> Sig.T c, respectively, but in terms of signal processors, that are guaranteed to run in sync. That is we must assert that signal processors process the samples in chronological order and emit one sample per input sample. We call such processes "causal" processes. For example Causal.T (a,b) c represents the function Sig.T (a,b) -> Sig.T c but it also carries the guarantee, that for each input of type (a,b) one sample of type c is emitted or the output terminates. Internally it is the Kleisli arrow of the  StateT Maybe monad.Another important application of the Causal arrow is feedback. Using causal processes guarantees, that a process cannot read ahead, such that it runs into future data, which does still not exist due to recursion.Programming with arrows needs a bit experience or Haskell extensions. Haskell extensions are either an Arrow syntax preprocessor or the preprocessor that is built into GHC. However, for computing with physical dimensions you can no longer use the original Arrow class and thus you cannot use the arrow syntax. So here is an example of how to program  using Arrow combinators.  } Safe-Inferred. ~ Safe-Inferred#synthesizer-core4Parallel combination of two signals of equal length.synthesizer-coreZip together two signals. It is a checked error if their lengths differ.synthesizer-coreZip together two signals and shorten them to the length of the shorter one. Safe-Inferredsynthesizer-coreThis function converts a process into a function on lazy storable vectors. To this end it must call unsafePerformIO, that is, the effects of all functions called in the process must not be observable.,I am not sure, we need this function at all.synthesizer-coreThe same restrictions as for  apply.synthesizer-coreIf the first process does not produce any output, then the continuing process will not be started.synthesizer-corePass the last non-empty output chunk as parameter to the continuing process. This breaks the abstraction from the chunk sizes, but we need it for implementing vectorized processing.synthesizer-coremappend should be used sparingly. In a loop it will have to construct types at runtime which is rather expensive.   Safe-Inferredsynthesizer-core*Chunk represents a chunk of a Gate signal./It means (Chunk chunkDuration sustainDuration).sustainDuration means: Just (t,a) - key is released at time t with attribute a, e.g. the note-off-velocity, t must be smaller than chunkDuration! Nothing - key is in pressed or released state over the whole chunksynthesizer-core2smart constructor that checks the time constraintssynthesizer-core.Pass the second signal while the gate is open.For completeness we would need a data type analogously to ChunkySize, that measures signal duration in CausalIO processes.  could then be written as >shorten = Zip.second ^<< Zip.arrowFirstShort Gate.toChunkySize                                                                            !!"""""""""""""""""""""""""""""""""""""#$$$$%&&''''''''''''(()))))*******************************************************************************************************************+++++++,,,,,,------...................////////00000000000000000000000001111111111111111111111111111222222222222222222233333334444455555555555555666666677777777788888888888888888888888888888888888888888888999999:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::<<<;;;;;;;===>>>>>??@@@@@@AAAAAAAAAAAAAAAAABBBBBBBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCDDDDDDDDDDDDDDDEEEEEEEEEEEEEEEEEFFFFFFFFFFFFFFFFGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGHHHHIIIIIIIIJJJJJJJJJJJJKKKKKKKKLLLLMMNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOPPPPPPPPQQQQQQQQQQQQRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRSSSSTTTTTTTTTTTTTTTUUUUVVVVWWWWWWWWWWWWWWWWWWWWWWXXXXXXXXXXXXXXYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYZZZZZZZZ[[[[[[[[[[[\\]]]]]]]^^_````aaaabbbbbbbbbcccddddddddeeeeeeeeeeeeeeeffffffffffff fff fff f ggh hhhhhhh h h h h h hhhhhhhii i i i iii i i i i i j j j j j j j j j j j j j j j j j j kkk k k k kk k kk k kk k k k k kl m m m m m m m m m m m m m m m m m m m m m m m m m m m m m n n n n n n n n n n n n n n n n op pqq r r r s s s ttttttttttttttuuuuuvvw w w w w w w w xxxxxxx x x x xxxyy yyyyyyy y y y y yyyyyz z z z z z {{{{{{{ { {{{{{| | || | | | | | | | | }}}}} }} ~~~~~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~~~~~                                      ! ! %   %  ) ) 6                                                                : : : : : ;           D D G G G G G G G G G G  M M QT T V W W  c  p q v v -synthesizer-core-0.8.4-Lu8k3cYJgjdApk2h3moVTySynthesizer.Causal.ProcessSynthesizer.Frame.StereoSynthesizer.Storable.SignalSynthesizer.ApplicativeUtilitySynthesizer.Basic.Distortion&Synthesizer.Basic.DistortionControlledSynthesizer.Basic.PhaseSynthesizer.Basic.WaveSynthesizer.Basic.WaveSmoothedSynthesizer.Causal.DisplacementSynthesizer.Causal.SpatialSynthesizer.Causal.UtilitySynthesizer.Causal.ClassSynthesizer.FormatSynthesizer.Basic.BinarySynthesizer.PiecewiseSynthesizer.Plain.Builder"Synthesizer.Plain.Filter.Recursive.Synthesizer.Plain.Filter.Recursive.AllpassPolySynthesizer.Plain.IOSynthesizer.Plain.File!Synthesizer.Plain.LorenzAttractorSynthesizer.Plain.ModifierSynthesizer.Plain.PlaySynthesizer.Plain.Signal(Synthesizer.Plain.Oscillator.BandLimitedSynthesizer.Plain.Noise.Synthesizer.Plain.Filter.Recursive.IntegrationSynthesizer.Plain.DisplacementSynthesizer.Plain.CutSynthesizer.Plain.Control%Synthesizer.Plain.Filter.NonRecursive0Synthesizer.Plain.Filter.Recursive.MovingAverageSynthesizer.Plain.Analysis)Synthesizer.Plain.Filter.LinearPredictiveSynthesizer.RandomKnuthSynthesizer.Storable.RepairSynthesizer.Storable.PlaySynthesizer.Storable.OscillatorSynthesizer.Storable.GenerateSynthesizer.Storable.CutSynthesizer.State.SignalSynthesizer.State.NoiseCustomSynthesizer.State.NoiseSynthesizer.State.DisplacementSynthesizer.State.ControlSynthesizer.State.PieceSynthesizer.State.AnalysisSynthesizer.Interpolation.ClassSynthesizer.InterpolationSynthesizer.State.InterpolationSynthesizer.State.Filter.Delay%Synthesizer.State.Filter.NonRecursive Synthesizer.Interpolation.Custom Synthesizer.Basic.ToneModulationSynthesizer.Generic.CutSynthesizer.Generic.CutChunkySynthesizer.Generic.Signal$Synthesizer.PiecewiseConstant.Signal&Synthesizer.PiecewiseConstant.Storable%Synthesizer.PiecewiseConstant.GenericSynthesizer.Generic.Noise0Synthesizer.Generic.Filter.Recursive.Integration Synthesizer.Generic.DisplacementSynthesizer.Generic.ControlSynthesizer.Generic.Piece'Synthesizer.Generic.Filter.NonRecursive(Synthesizer.Storable.Filter.NonRecursiveSynthesizer.Generic.AnalysisSynthesizer.Generic.CyclicSynthesizer.Generic.FourierSynthesizer.ChunkySizeSynthesizer.State.CutSynthesizer.ChunkySize.CutSynthesizer.ChunkySize.Signal.Synthesizer.State.Filter.Recursive.Integration0Synthesizer.State.Filter.Recursive.MovingAverage.Synthesizer.Plain.Filter.Recursive.SecondOrder,Synthesizer.Plain.Filter.Recursive.Universal5Synthesizer.Plain.Filter.Recursive.SecondOrderCascade4Synthesizer.Plain.Filter.Recursive.FirstOrderComplex-Synthesizer.Plain.Filter.Recursive.FirstOrder'Synthesizer.State.Filter.Recursive.Comb'Synthesizer.Plain.Filter.Recursive.Moog'Synthesizer.Plain.Filter.Recursive.Comb)Synthesizer.Generic.Filter.Recursive.Comb,Synthesizer.Plain.Filter.Recursive.Chebyshev.Synthesizer.Plain.Filter.Recursive.Butterworth*Synthesizer.Plain.Filter.Recursive.Allpass"Synthesizer.Causal.Oscillator.Core Synthesizer.State.ToneModulationSynthesizer.Generic.Wave!Synthesizer.Causal.ToneModulation/Synthesizer.Causal.Filter.Recursive.IntegrationSynthesizer.Causal.CutSynthesizer.Causal.AnalysisSynthesizer.Causal.ArrowSynthesizer.UtilitySynthesizer.Interpolation.Core Synthesizer.Interpolation.ModuleSynthesizer.Plain.Interpolation Synthesizer.Plain.ToneModulationSynthesizer.Plain.WaveSynthesizer.Plain.OscillatorSynthesizer.Plain.Tutorial'Synthesizer.Plain.Filter.Recursive.Test*Synthesizer.Plain.Filter.Recursive.HilbertSynthesizer.Plain.Effect.GlassSynthesizer.Plain.InstrumentSynthesizer.Plain.Effect!Synthesizer.Plain.Filter.Delay.ST#Synthesizer.Plain.Filter.Delay.List$Synthesizer.Plain.Filter.Delay.BlockSynthesizer.Plain.Filter.DelaySynthesizer.Plain.Effect.Fly!Synthesizer.Generic.Interpolation Synthesizer.Generic.Filter.Delay2Synthesizer.Generic.Filter.Recursive.MovingAverage Synthesizer.Causal.InterpolationSynthesizer.Causal.OscillatorSynthesizer.State.OscillatorSynthesizer.Generic.LoopSynthesizer.Generic.OscillatorSynthesizer.Generic.Tutorial&Synthesizer.Causal.Filter.NonRecursiveSynthesizer.ZipSynthesizer.CausalIO.ProcessSynthesizer.CausalIO.Gatesynthesizer-coreSynthesizer.Basic.ComplexModule%Synthesizer.Basic.Filter.NonRecursivewriteSignalgenerateMathObj.LaurentPolynomialseriesrunsums Data.MonoidmconcatSynthesizer.Basic.NumberTheory%Synthesizer.PiecewiseConstant.PrivateSynthesizer.Generic.Permutation Synthesizer.Generic.LengthSignalinverseFrequencyModulationFloorTSynthesizer.StorageWavesample oddCosine oddTriangle sampledToneNumber.NonNegativeChunkybase Control.Arrowfirstloopsecond)sample-frame-0.0.4-G4HBWumlUnKCioWTSombsrSound.Frame.StereoChannelLeftRightleftrightconsmapswapselect interleavesequenceliftApplicative.storablevector-0.2.13.2-KG19V4DMPAV5rzrHbQBKzKData.StorableVector.Lazy ChunkSizechunks chunkSizeempty fromChunksunfoldriteraterepeat replicatenullappendconcatreversefoldrviewLviewRswitchLswitchRcrochetLtakedropsplitAtspanzipWithhPut writeFileliftA4liftA5liftA6$:$::.:$^.^$#liftPliftP2liftP3liftP4cliplogitzigZagsine oddChebyshevquantize powerSignedfromRepresentativetoRepresentative increment decrementmultiply$fCT $fArbitraryT $fRandomT $fStorableT$fShowT$fEqTHarmonic harmonicPhaseharmonicAmplitudeConsdecons fromFunctionraiseamplifydistortovertoneapply phaseOffsetcosinehelix fastSine2 fastSine2Alt fastSine3 fastSine3Alt fastSine4 fastSine4AltfastSine4LeastSquaresfastSinePolynomials fastSinesrationalHelix1rationalHelix1Alt rationalHelixsawsawCos sawComplexsuperSawsquare squareCos squareComplextriangletruncOddCosinetruncOddTriangle truncCosine truncTriangle powerNormed powerNormed2logitSaw logitSine sineSquarepiecewiseParabolaSawpiecewiseSineSaw sineSawSmooth sineSawSharpsawGaussianHarmonicssawPike trianglePiketrianglePikeShift squarePikesquarePikeShiftsquareAsymmetricsquareBalancedtriangleAsymmetric trapezoidtrapezoidAsymmetrictrapezoidBalanced trapezoidSkewharmoniccomposedHarmonics$fApplicativeT $fFunctorT$fCaTfromWavefromControlledWavemix mapLinearmapExponential moveAroundpurechainControlledreplicateControlledCSignalOftoSignal fromSignal ProcessOfapplyFstapplySnd applyConst applyConstFst applyConstSndfeedFstfeedSnd feedConstFst feedConstSnd$*$<$>format arrowFromMonoarrowFromMonoControlledarrowFromChannelsoutputFromCanonicalnumberOfChannelsnumberOfSignalChannelsfromCanonicalWithfromCanonicalSimpleWithint16FromCanonicalint16FromFloatint16FromDouble toCanonicalint16ToCanonical$fC(,) $fCDouble$fCFloat FlatPositionFlatLeft FlatRight PieceDistPDPieceRightDoublePRDPieceRightSinglePRS PieceData pieceTypepieceY0pieceY1pieceDurPiece computePiecepieceFromFunction#|--|##|==|##||#splitDurations$fShowFlatPosition$fEqFlatPosition$fOrdFlatPosition$fIxFlatPosition$fEnumFlatPositionPutputsignalToBinarysignalToBinaryMonosignalToBinaryStereo $fMonoidT $fSemigroupTPassbandLowpassHighpassPole poleResonance poleFrequency$fCaPole$fCPole$fShowPassband $fEqPassband$fEnumPassband$fEqPole $fShowPole $fReadPole Parameter shiftParam makePhasescalarProdScrewExp screwProdintegrateScrewExp integrateNum$fShowParametertwoLECharsToIntintToTwoLECharswriteLEInt16StreamwriteInt16StreamputInt16StreamChunkyputInt16StreamreadLEInt16StreamreadInt16StreamStrictrender renderToInt16renderMonoToInt16renderStereoToInt16 writeToInt16writeMonoToInt16writeStereoToInt16writeRawwriteRawCompressed rawToAIFFcompress readAIFFMonoreadMonoFromInt16 getInt16ListcomputeDerivatives explicitEuler equilibriumexample0example InitializedinitInitinitStepSimpleinitstepstatic modulated initialize staticInit modulatedInit stackStatesR stackStatesLstackStatesStorableRstackStatesStorableLstackStatesStorableVaryLautotoInt16 monoToInt16 stereoToInt16raw exampleMono exampleStereo ModifierInitModifier modifyStaticmodifyModulatedmodifierInitializemodifyStaticInitmodifyModulatedInitunfoldRreduceL mapAccumLfix1 dropMarginRem dropMargin lengthAtLeast zipWithTails zipWithRestzipWithRestRec zipWithAppendstaticImpulsesfreqModImpulseswhitewhiteGenwhiteQuadraticBSplineGen randomPeeksrandomPeeksGenrunInitmixMultitakeUntilPausetakeUntilInterval selectBoolarrangeconstantlinearlinearMultiscalelinearMultiscaleNeutral linearStable linearMeanline exponentialexponentialMultiscaleexponentialStableexponentialMultiscaleNeutral exponential2exponential2Multiscaleexponential2Stableexponential2MultiscaleNeutralexponentialFromToexponentialFromToMultiscalevectorExponentialvectorExponential2cosineMultiscale cosineSubdiv cosineStablecosineWithSlope cubicHermite cubicFunccubicHermiteStablecurveMultiscalecurveMultiscaleNeutral amplifyVectorenvelopeenvelopeVector fadeInOut fadeInOutAltdelaydelayPadgeneric genericAlt propGenericgaussianbinomial binomial1sumsDownsample2 downsample2 sumsPyramidsumRangepyramidsumRangeFromPyramidminRangegetRangeFromPyramidsumRangeFromPyramidRecsumRangeFromPyramidFoldrsumsPosModulatedsumsPosModulatedPyramidmovingAverageModulatedPyramid differentiatedifferentiateCenterdifferentiate2 sumsStaticInt modulatedFrac BinaryLevelLowHigh volumeMaximumvolumeEuclideanvolumeEuclideanSqr volumeSumvolumeVectorMaximumvolumeVectorEuclideanvolumeVectorEuclideanSqrvolumeVectorSumboundshistogramDiscreteArrayhistogramLinearArrayhistogramDiscreteIntMaphistogramLinearIntMaphistogramIntMapspreaddirectCurrentOffset scalarProductcentroid centroidAlt firstMomentaveragerectifyzerosbinaryLevelFromBoolbinaryLevelToNumberflipFlopHysteresisflipFlopHysteresisStepchirpTransform binarySigndeltaSigmaModulationdeltaSigmaModulationPositive$fEqBinaryLevel$fShowBinaryLevel$fEnumBinaryLevelapproxCoefficients $fRandomGenT removeClicksdefaultChunkSizefromListtoListscanL mixSndPattern genericLength splitAtPadmixSize delayLoopdelayLoopOverlap takeCrochet freqToPhasephaseModshapeModfreqMod phaseFreqMod shapeFreqMod staticSine freqModSine phaseModSine staticSaw freqModSaw clickTrackclickTrackExamplearrangeAdaptive arrangeListarrangeEquidistaddChunkToBufferrunViewL runSwitchLgenerateInfinitefromStorableSignalfromStrictStorableSignaltoStorableSignaltoStrictStorableSignaltoStorableSignalVaryfromPiecewiseConstantiterateAssociative scanLClipunzipunzip3delay1 takeWhilezipWithStorablezipWith3zipWith4zipzip3zip4foldL'foldLfoldL1lengthequalfoldR singleton viewRSizeextendConstant dropMatchindex splitAtSize dropWhilespanSizecyclesubneg appendStoredappendStoredSize concatStoredconcatStoredSizeliftA2 reverseStoredreverseStoredSizesummaximum sliceVertzapWith zapWithAlt mapAdjacent linearCombmapTails zipWithTails1zipWithTailsInfzipStep sequence_mapM_fold monoidConcatfoldMapmonoidConcatMap catMaybes flattenPairs interleaveAlt$fCyT$fMonadT $fFoldableT$fCT0randomRsrandomRhalfSinecubiccentroidRecomputeaverageRecomputeMACrunMacscaleAndAccumulatescalescaleAccumulate+.*combine2 combineManyscaleAndAccumulateRingscaleAndAccumulateModulescaleAndAccumulateApplicative!scaleAndAccumulateRingApplicative#scaleAndAccumulateModuleApplicativeelementmakeMacmakeMac2makeMac3$fCa(,,)$fCa(,)$fCTT$fCaT0$fCDoubleDouble $fCFloatFloat$fApplicativeMAC $fFunctorMAC PrefixReaderMargin marginNumber marginOffsetmarginfuncnumberoffsetgetNodefromPrefixReader$fArbitraryMargin$fApplicativePrefixReader$fFunctorPrefixReader $fShowMargin $fEqMarginzeroPad constantPad cyclicPadextrapolationPadskipsingle staticPad staticPos staticNeg!inverseFrequencyModulationCeiling piecewisepiecewiseConstantpiecewiseLinearpiecewiseCubicfunctionSkipCoordsuntangleShapePhaseuntangleShapePhaseAnalyticflattenShapePhaseflattenShapePhaseAnalytic shapeLimitsinterpolationOffsetinterpolationNumber Transform NormalForm evaluateHeadReaddropMarginRemChunky intToChunky intToChunky98 lengthAtMost sliceVertical$fReadT$fReadT0$fReadT1$fReadT2$fReadT3 $fReadList $fReadVector $fReadVector0 $fNormalFormT$fNormalFormT0$fNormalFormT1$fNormalFormT2$fNormalFormList$fNormalFormVector$fNormalFormVector0 $fTransformT $fTransformT0 $fTransformT1 $fTransformT2 $fTransformT3$fTransformList$fTransformVector$fTransformVector0ChunktoChunks $fCVectorWriteWrite0LazySize Transform0Read0toStateStorage Constraints constraintsdefaultLazySizereadSVLwriteSVLwithStorableContextreadSVwriteSV zipWithState zipWithState3takeStateMatchsum1tailslaxTail fromStatesnoc mapTailsAlt indexByDrop $fStorageT $fStorageT0 $fStorageList$fStorageVector$fStorageVector0$fRead0T $fRead0T0 $fRead0List $fRead0Vector$fRead0Vector0$fReadTy $fReadTy0 $fReadListy $fReadVectory$fReadVectory0 $fTransform0T$fTransform0List$fTransform0Vector$fTransform0Vector0 $fTransformTy$fTransformTy0$fTransformListy$fTransformVectory$fTransformVectory0$fTransform0T0$fTransformLazySize$fReadLazySize$fArbitraryLazySize $fCLazySize $fCLazySize0$fMonoidLazySize$fSemigroupLazySize $fWrite0T $fWrite0T0 $fWrite0List$fWrite0Vector $fWriteTy $fWriteTy0 $fWriteListy$fWriteVectory $fEqLazySize $fOrdLazySize$fShowLazySize $fCLazySize1 $fCLazySize2 $fCLazySize3 $fCLazySize4 $fCLazySize5 $fCLazySize6 $fCLazySize7 $fCLazySize8ShortStrictTime StrictTime chopLongTime toSignalInittoSignalInitWithLazyTime subdivideLazysubdivideLazyToShortlongFromShortTimesubdivideLongStrictcosineMultiscaleLinear QuadrupleTriplePairnegate normalizedelayPosdelayNeg delayLazySizedelayPadLazySizedelayPosLazySize binomialMask downsamplesumRangeFromPyramidReversemaybeAccumulateRangeFromPyramidconsumeRangeFromPyramid!accumulatePosModulatedFromPyramidwithPaddedInputkaratsubaFinitekaratsubaFiniteInfinitekaratsubaInfiniteaddShiftedSimple convolvePairsumAndConvolvePairconvolvePairTripleconvolveTriplesumAndConvolveTriplesumAndConvolveTripleAltconvolveQuadruplesumAndConvolveQuadruplesumAndConvolveQuadrupleAltsumsDownsample2AltconvolveDownsample2accumulatePosModulatedPyramid accumulateBinPosModulatedPyramid movingAccumulateModulatedPyramid reperiodizeconvolve filterNaive convolveNaiveWindowElement recipIntegeraddIdmultIdconjugatePrimitiveRootsOfUnitytransformForwardtransformBackwardtransformWithCache cacheForward cacheBackward cacheDuplexwindowconvolveWithWindowconvolveCyclic $fElementT $fElementT0$fOrdLevelComposite$fEqLevelComposite$fOrdLevelCoprime$fEqLevelCoprime$fOrdLevelPrime$fEqLevelPrime $fOrdPlan$fEqPlan $fShowWindow $fShowCache$fShowLevelCachePrime $fShowPlan$fShowLevelPrime$fShowLevelCoprime$fShowLevelCacheComposite$fShowLevelComposite$fShowLevelCacheRadix2$fShowLevelRadix2$fEqLevelRadix2$fOrdLevelRadix2$fShowLevelCacheSmall$fShowLevelSmall$fEqLevelSmall$fOrdLevelSmall$fEnumLevelSmall$fShowLevelCacheNaive$fShowDirection $fEqDirection$fOrdDirectionfromStorableVectorSizetoStorableVectorSize toNullList chopStorablechopChunkySizeunfoldRNiterateNfromStateMaybefromSimpleModifierfromInitializedModifieridcomposesplitfanout applySameType applyFst' applySnd'apply2apply3applyStorableChunkfeedfeedGenericFstfeedGenericSndscanL1consInitfeedbackfeedbackControlled $fFractionalT$fNumT$fCT1$fCT2 $fArrowLoopT$fArrowT$fCategoryTYPETcausal causalInitStateu1u2y1y2c0c1c2d1d2 zeroStateadjustPassband modifierInitmodifier$fStorableParameter $fCaParameter$fTraversableParameter$fFoldableParameter$fApplicativeParameter$fFunctorParameter$fStorableState$fTraversableState$fFoldableState$fApplicativeState$fFunctorState $fShowStateResulthighpassbandpasslowpass bandlimitk1k2ampInampI1ampI2ampLimit parameter parameterAlt parameterOldparameterToSecondOrderLowpass$fStorableResult $fCaResult $fCResult$fTraversableResult$fFoldableResult$fApplicativeResult$fFunctorResultparameterFromPeakWidthparameterFromPeakToDCRatio highpass_lowpass_ getParameter lowpassSteplowpassModifierInitlowpassModifier lowpassCausal lowpassInit highpassStephighpassModifierInithighpassModifier highpassInithighpassInitAlt$fArbitraryParameter$fArbitraryResult $fEqResult $fEqParameter karplusStrongrunMultirunProc lowpassParam ParameterB ParameterAmakeCirclePointspartialParameterApartialParameterB parameterAcanonicalizeParameterA parameterBcausalAcausalBrunAPolerunBPole causalAPole causalBPolelowpassACausalPolehighpassACausalPolelowpassBCausalPolehighpassBCausalPole lowpassAPole highpassAPole lowpassBPole highpassBPole makeSines partialRatiopartialParameter checkedHalfrunPole causalPolelowpassCausalPolehighpassCausalPole lowpassPole highpassPoleparameterApproxfirstOrderStepfirstOrderModifierfirstOrderCausal firstOrdercascadeParameter flangerPhaseflangerParameter cascadeStepcascadeStepStackcascadeStepReccascadeStepScanlcascadeModifier cascadeCausalcascadeCausalStackedcascadeCausalModifiercascade cascadeStatecascadeIterativecascadeDiverseStep freqModSyncfreqModAntiAlias PrototypeCellinterpolateCell makePrototypesampledToneCelloscillatorCells checkNonNegmakeCelloscillatorCoordslimitRelativeShapeslimitMinRelativeValuesseekCelloscillatorSuffixesintegrateFractionalintegrateFractionalClip movingMedian$fCFUNcommonfwrapfmodfmodAltpropFMod affineComb affineCombAlt balanceLevelrandomRsBalancedcubicAlt singleRec multiRelativemultiRelativeZeroPadmultiRelativeConstantPadmultiRelativeCyclicPadmultiRelativeExtrapolationPadmultiRelativeZeroPadConstantmultiRelativeZeroPadLinearmultiRelativeZeroPadCubicdropFrac propDropFracdropRem propDropRem freqsToPhaseslimitMaxRelativeValueslimitMaxRelativeValuesNonNegPhase staticSample freqModSampleshapeFreqModSampleshapePhaseFreqModSampleshapeFreqModFromSampledTone shapePhaseFreqModFromSampledTone sineStereo writeSineplay oscillatorsawMorphlaserpingSigpingfmPing filterSaw sampleRatechirpfilter2ndOrderTestbutterworthLowpassTest0butterworthLowpassTest1butterworthLowpassTest2chebyParameterAchebyParameterBchebyshevALowpassTest0chebyshevBLowpassTest0chebyshevLowpassTest1chebyshevALowpassTest2chebyshevBLowpassTest2moogLowpassTest universalTestcomplexRealTest chirpComplex complexTestparameterCosine parameterSine polesCosine polesSinestep2 modifierInit2causal2causalComplex2 causalComplexrunInit2run2 lowpassStreamlowpassMaintainPhaseglass stereoPhaser allpassPlain allpassDownmoogDownmoogResobell bellHarmonicfastBell squareBellfmBell moogGuitarmoogGuitarSoft filterSweepfatSawChordFilter fatSawChord filterDown simpleSaw modulatedWaveaccumulatedSaws choirWavechoirfatSaw osciDoubleSaw osciSharp osciAbsModSaw pulsedNoise noiseBass electroTommainsoundEcFreqsoundBsoundAsound9sound8sound7sound6sound5sound4sound3sound2sound1sound0soundm0 modulatedRevpropDropphaserplanepropAllflyrelativerelativeZeroPadrelativeConstantPadrelativeCyclicPadrelativeExtrapolationPadrelativeZeroPadConstantrelativeZeroPadLinearrelativeZeroPadCubicstaticAntiAlias TimeControlsimplefade timeReversetimeControlSinetimeControlZigZagbrass filterSawSig playStatefilterSawStatefilterPingStateProcfilterPingStatefilterPingSharefilterPingCausal crossfadesumsPosModulatedFromPyramid consChecked consShorten arrowFirst arrowSecondarrowFirstShortenarrowSecondShorten arrowFanout arrowSplitarrowFanoutShortenarrowSplitShorten fromCausalmapAccumtraverserunContrunStorableChunkyContcontinue continueChunkchunkallToStorableVectortoStorableVectorallToChunkySize toChunkySizeshorten$fTransformChunk $fMonoidChunk$fSemigroupChunk$fNormalFormChunk $fReadChunk $fShowChunkGHC.Base<*> Applicativemulproject_swingratioFreqToVarianceunitSizesFromPyramidsumRangePreparesymmetricRangePrepare _superSawGHC.ListleCharsToInt16int16ToLEChars System.IO Data.OldListghc-prim GHC.TypesTruelinearSubdivisionsumsUpsampleOddsumDiffsModulatedsumsModulatedHalfmaybeLT GHC.MaybeNothing splitAtJump_zipWithAppendRestunsafeAddChunkToBuffer_unsafeAddChunkToBufferFoldr cubicHalfpowerOfTwoFactors fermatFactorsmultiplicativeGeneratorSetprimitiveRootsOfUnityFullOrbit!ordersOfPrimitiveRootsOfUnityTest orderOfOrbit$ringsWithPrimitiveRootOfUnityAndUnitnumbers3Smooth ceilingPowerceiling3SmoothScanceilingSmoothsTrace partialPrimes primeFactorsraderWorstCases_fastFourierRingAltfastFourierRinguniquePrimeFactorsmultiplicativeGeneratorOrdergetOrder PrimitiveRootprimitiveRootCandidates#maximumOrderOfPrimitiveRootsOfUnityprimitiveRootsOfUnitylcmMultiprimitiveRootsOfOrbithasPrimitiveRootOfUnityNaivehasPrimitiveRootOfUnityInteger$ordersOfPrimitiveRootsOfUnityIntegerordersOfRootsOfUnityInteger$ordersOfRootsOfUnityIntegerCondensedrootsOfUnityPower+ringsWithPrimitiveRootsOfUnityAndUnitsNaive%ringWithPrimitiveRootsOfUnityAndUnitsringWithPrimitiveRootsOfUnity is3Smooth is5Smoothnumbers5SmoothceilingPowerOfTwo ceilingLogdivideByMaximumPowerceiling3Smoothceiling5SmoothisPrimemultiplicativeGeneratorDivisorsprimitiveRootsOfUnityPowerprimitiveRootsOfUnityNaive"primitiveRootsOfUnityFullOrbitTest(maximumOrderOfPrimitiveRootsOfUnityNaive*maximumOrderOfPrimitiveRootsOfUnityIntegerdivideByMaximumPowerRecursivenumbers3SmoothCorecnumbers3SmoothFoldrnumbers3SmoothSetnumbers5SmoothCorecnumbers5SmoothFoldrnumbers5SmoothSetceiling5SmoothScanceiling3SmoothNaiveceiling5SmoothNaiveceiling3SmoothTraceceiling5SmoothTraceStorableLazyConstraintsStorableConstraintsListConstraintsStateConstraintsEventListConstraintssubdivideMaybe transposition skewGridInvmultiplicativeinversesizeskewGrid skewGridCRTskewGridCRTInvbody,numeric-prelude-0.4.4-CRo4YZ5tJQfEddjYHGmG9q Algebra.Ring*Algebra.Module*>accumulateDownsample2Strictdownsample2StrictCachePlan_transformPlan planWithMapcacheFromPlanWithMap#transformRadix2InterleavedFrequencytransformCompositetransformCoprimetransformPrimeconvolveSpectrumCyclicCacheBool _lowpassStatelowpassRecursive_runpartialLowpassParameterApartialLowpassParameterBAlgebra.TranscendentalpimodulatedRevCore_dropSingleBlocksToList