Spectral Types
Sensing and Control
Signal Input and Output
These units generate and process non-standard signal data types, such as down-sampled time-domain control signals and audio signals, and their frequency-domain (spectral) representations. The new data types (d-, w-) are self-defining, and the contents are not processable by any other Csound units. These unit generators are experimental, and subject to change between releases; they will also be joined by others later.
dsig octdown xsig, iocts, isamps[, idisprd] wsig noctdft dsig, iprd, ifrqs, iq[, ihann, idbout, idsines] wsig specaddm wsig1, wsig2[, imul2] wsig specdiff wsigin wsig specscal wsigin, ifscale, ifthresh wsig spechist wsigin, wsig specfilt wsigin, ifhtim koct specptrk wsigin, inptls, irollof, iodd,[,interp, ifprd, iwtflg] ksum specsum wsig[, interp] specdisp wsig, iprd[, iwtflg]
dsig octdown xsig, iocts, isamps[, idisprd] wsig noctdft dsig, iprd, ifrqs, iq[, ihann, idbout, idsines]
idisprd (optional) - if non-zero, display the output every idisprd seconds. The default value is 0 (no display).
ihann, idbout, idsines (optional) - if non-zero, then respectively: apply a hanning window to the input; convert the output magnitudes to dB; display the windowed sinusoids used in DFT filtering. The default values are 0,0,0 (rectangular window, magnitude output, no sinusoid display).
octdown - put signal asig or ksig through iocts successive applications of octave decimation and downsampling, and preserve isamps down-sampled values in each octave. Optionally display the composite buffer every idisprd seconds.
noctdft - generate a constant-Q, exponentially-spaced DFT across all octaves of the multiply-downsampled input dsig. Every iprd seconds, each octave of dsig is optionally windowed (ihann non-zero), filtered (using ifrqs parallel filters per octave, exponentially spaced, and with frequency/bandwidth Q of iq), and the output magnitudes optionally converted to dB (idbout non-zero). This unit produces a self-defining spectral datablock wsig, whose characteristics are readable by any units that receive it as input, and for which it becomes the template for output. The information used in producing this wsig (iprd, iocts, ifrqs) is passed via the data block to all derivative wsigs, and is thus available to subsequent spectral operators if needed.
asig in ; get external audio dsamp octdown asig, 6, 180, 0 ; downsample in 6 octaves wsig1 noctdft dsamp, .02, 12, 33, 0, 1, 1 ; and calc 72-point dft (dB)
wsig specaddm wsig1, wsig2[, imul2] wsig specdiff wsigin wsig specscal wsigin, ifscale, ifthresh wsig spechist wsigin wsig specfilt wsigin, ifhtim
imul2 (optional) - if non-zero, scale the wsig2 magnitudes before adding. The default value is 0.
specaddm - do a weighted add of two input spectra. For each channel of the two input spectra, the two magnitudes are combined and written to the output according to: magout = mag1in + mag2in * imul2. The operation is performed whenever the input wsig1 is sensed to be new. This unit will (at Initialization) verify the consistency of the two spectra (equal size, equal period, equal mag types).
specdiff - find the positive difference values between consecutive spectral frames. At each new frame of wsigin, each magnitude value is compared with its predecessor, and the positive changes written to the output spectrum. This unit is useful as an energy onset detector.
specscal - scale an input spectral datablock with spectral envelopes. Function tables ifthresh and ifscale are initially sampled across the (logarithmic) frequency space of the input spectrum; then each time a new input spectrum is sensed the sampled values are used to scale each of its magnitude channels as follows: if ifthresh is non-zero, each magnitude is reduced by its corresponding table-value (to not less than zero); then each magnitude is rescaled by the corresponding ifscale value, and the resulting spectrum written to wsig.
spechist - accumulate the values of successive spectral frames. At each new frame of wsigin, the accumulations-to-date in each magnitude track are written to the output spectrum. This unit thus provides a running histogram of spectral distribution.
specfilt - filter each channel of an input spectrum. At each new frame of wsigin, each magnitude value is injected into a 1st-order lowpass recursive filter, whose half-time constant has been initially set by sampling the ftable ifhtim across the (logarithmic) frequency space of the input spectrum. This unit effectively applies a persistence factor to the data occurring in each spectral channel, and is useful for simulating the energy integration that occurs during auditory perception. It may also be used as a time-attenuated running histogram of the spectral distribution.
wsig2 specdiff wsig1 ; sense onsets wsig3 specfilt wsig2, 2 ; absorb slowly specdisp wsig2, .1 ; & display both spectra specdisp wsig3, .1
koct specptrk wsig, inptls, irolloff, iodd[, interp, ifprd, iwtflg] ksum specsum wsig[, interp] specdisp wsig, iprd[, iwtflg]
interp (optional) - if non-zero, interpolate the output signal (koct or ksum). The default value is 0 (repeat the signal value between changes).
ifprd (optional) - if non-zero, display the internally computed fundamental spectrum. The default value is 0 (no display).
iwtflg (optional) - wait flag. If non-zero, hold each display until released by the user. The default value is 0 (no wait).
specptrk - estimate the pitch of the most prominent complex tone in the spectrum. At note initialization this unit creates a set of inptls harmonically related partials (odd if iodd non-zero) with amplitude rolloff to the fraction irolloff per octave. Then at each new frame of wsig, the spectrum is cross-correlated with this set, and the result at each point added to an internal copy of the spectrum (optionally displayed). A pitch is then estimated, and the result is released in decimal octave form. Between frames, the output is either repeated or interpolated at the K-rate.
specsum - sum the magnitudes across all channels of the spectrum. At each new frame of wsig, the magnitudes are summed and released as a scalar ksum signal. Between frames, the output is either repeated or interpolated at the K-rate. This unit produces a k-signal summation of the magnitudes present in the spectral data, and is thereby a running measure of its moment-to-moment overall strength.
specdisp - display the magnitude values of spectrum wsigevery iprd seconds (rounded to some integral number of wsig's originating iprd).
ksum specsum wsig, 1 ; sum the spec bins, and ksmooth if ksum < 2000 kgoto zero ; if sufficient amplitude koct specptrk wsig ; pitch-track the signal kgoto contin zero: koct = 0 ; else output zero contin:
ktemp tempest kin, iprd, imindur, imemdur, ihp, ithresh, \ ihtim, ixfdbak,istartempo, ifn[, idisprd, \ [itweek] kx, ky xyin iprd, ixmin, ixmax, iymin, iymax[, ixinit, iyinit] tempo ktempo, istartempo kr timek kr times ir itimek ir itimes kr instimek kr instimes
ktemp tempest kin, iprd, imindur, imemdur, ihp, ithresh, \ ihtim, ixfdbak, istartempo, ifn[, idisprd, itweek]
Estimate the tempo of beat patterns in a control signal.
iprd - period between analyses (in seconds). Typically about .02 seconds.
imindur - minimum duration (in seconds) to serve as a unit of tempo. Typically about .2 seconds.
imemdur - duration (in seconds) of the kin short-term memory buffer which will be scanned for periodic patterns. Typically about 3 seconds.
ihp - half-power point (in cps) of a low-pass filter used to smooth input kin prior to other processing. This will tend to suppress activity that moves much faster. Typically 2 cps.
ithresh- loudness threshold by which the low-passed kin is center-clipped before being placed in the short-term buffer as tempo-relevant data. Typically at the noise floor of the incoming data.
ihtim - half-time (in seconds) of an internal forward-masking filter that masks new kin data in the presence of recent, louder data. Typically about .005 seconds.
ixfdbak - proportion of this unit's anticipated value to be mixed with the incoming kin prior to all processing. Typically about .3.
istartempo - initial tempo (in beats per minute). Typically 60.
ifn - table number of a stored function (drawn left-to-right) by which the short-term memory data is attenuated over time.
idisprd (optional) - if non-zero, display the short-term past and future buffers every idisprd seconds (normally a multiple of iprd). The default value is 0 (no display).
itweek (optional) - fine-tune adjust this unit so that it is stable when analyzing events controlled by its own output. The default value is 1 (no change).
tempest examines kin for amplitude periodicity, and estimates a current tempo. The input is first low-pass filtered, then center-clipped, and the residue placed in a short-term memory buffer (attenuated over time) where it is analyzed for periodicity using a form of autocorrelation. The period, expressed as a tempo in beats per minute, is output as ktemp. The period is also used internally to make predictions about future amplitude patterns, and these are placed in a buffer adjacent to that of the input. The two adjacent buffers can be periodically displayed, and the predicted values optionally mixed with the incoming signal to simulate expectation.
This unit is useful for sensing the metric implications of any k-signal (e.g- the RMS of an audio signal, or the second derivative of a conducting gesture), before sending to a tempo statement.
ksum specsum wsignal, 1 ; sum the amps of a spectrum ktemp tempest ksum, .02, .1, 3, 2, 800, .005, 0, 60, 4, .1, .995 ; and look for beats
kx, ky xyin iprd, ixmin, ixmax, iymin, iymax[, ixinit, iyinit] tempo ktempo, istartempo
Sense the cursor position in an input window. Apply tempo control to an uninterpreted score.
iprd- period of cursor sensing (in seconds). Typically .1 seconds.
xmin, xmax, ymin, ymax - edge values for the x-y coordinates of a cursor in the input window.
ixinit, iyinit (optional) - initial x-y coordinates reported; the default values are 0,0. If these values are not within the given min-max range, they will be coerced into that range.
istartempo - initial tempo (in beats per minute). Typically 60.
xyin samples the cursor x-y position in an input window every iprd seconds. Output values are repeated (not interpolated) at the K-rate, and remain fixed until a new change is registered in the window. There may be any number of input windows. This unit is useful for Realtime control, but continuous motion should be avoided if iprd is unusually small.
tempo allows the performance speed of Csound scored events to be controlled from within an orchestra. It operates only in the presence of the csound -t flag. When that flag is set, scored events will be performed from their uninterpreted p2 and p3 (beat) parameters, initially at the given command-line tempo. When a tempo statement is activated in any instrument (ktempo > 0.), the operating tempo will be adjusted to ktempo beats per minute. There may be any number of tempo statements in an orchestra, but coincident activation is best avoided.
kx,ky xyin .05, 30, 0, 120, 0, 75 ; sample the cursor tempo kx, 75 ; and control the tempo of performance
kr timek kr times ir itimek ir itimes kr instimek kr instimes
Opcodes to read absolute time since the start of the performance or of an instance of an instrument - in two formats.
timek and itimek are for time in krate cycles. So with:
sr = 44100 kr = 6300 ksmps = 7
then after half a second, the timek or itimek ugen would report 3150. It will always report an integer.
Time in seconds is available with times or itimes. These would return 0.5 after half a second.
itimes and itimek are similar ugens which only operate at the start of the instance of the instrument. Both produce an i rate variable (starting with i or gi) as their output.
timek and times both produce a k rate variable for output.
There are no input parameters.
instimek and instimes are similar to timek and times, except they return the time since the start of this instance of the instrument.
Robin Whittle
Australia
May 1997
a1 in a1, a2 ins a1, a2, a3, a4 inq a1 soundin ifilcod[, iskptim][, iformat] a1, a2 soundin ifilcod[, iskptim][, iformat] a1, a2, a3, a4 soundin ifilcod[, iskptim][, iformat] a1[,a2[,a3,a4]] diskin ifilcod, kpitch[, iskiptim] \ [, iwraparound][, iformat] a1[,a2[,a3,a4]] playram out asig outs1 asig outs2 asig outs asig1, asig2 outq1 asig outq2 asig outq3 asig outq4 asig outq asig1, asig2, asig3, asig4 a1, a2, a3, a4 pan asig, kx, ky, ifn[, imode][,ioffset] aLeft, aRight hrtfer asig, kAz, kElev, "HRTFcompact" kdump ksig, ifilname,iformat,iprd kdump2 ksig1, ksig2, ifilname,iformat,iprd kdump3 ksig1, ksig2, ksig3, ifilname,iformat,iprd kdump4 ksig1, ksig2, ksig3, ksig4, ifilname,iformat,iprd print iarg[, iarg,...] display xsig, iprd[, iwtflg] dispfft xsig, iprd, iwsiz[, iwtyp][, idbouti][, iwtflg] printk kval, ispace [, itime] printks "txtstring", itime, kval1, kval2, kval3, kval4
a1 in a1, a2 ins a1, a2, a3, a4 inq a1 soundin ifilcod[, iskptim][, iformat] a1, a2 soundin ifilcod[, iskptim][, iformat] a1, a2, a3, a4 soundin ifilcod[, iskptim][, iformat] a1[,a2[,a3,a4]] diskin ifilcod, kpitch[, iskiptim] \ [, iwraparound][, iformat] a1[,a2[,a3,a4]] playram out asig outs1 asig outs2 asig outs asig1, asig2 outq1 asig outq2 asig outq3 asig outq4 asig outq asig1, asig2, asig3, asig4
These units read/write audio data from/to an external device or stream.
ifilcod - integer or character-string denoting the source soundfile name. An integer denotes the file soundin.filcod ; a character-string (in double quotes, spaces permitted) gives the filename itself, optionally a full pathname. If not a full path, the named file is sought first in the current directory, then in that given by the environment variable SSDIR (if defined) then by SFDIR. See also GEN01.
iskptim (optional) - time in seconds of input sound to be skipped. The default value is 0.
iformat (optional) - specifies the audio data file format:
1 = 8-bit signed char (high-order 8 bits of a 16-bit integer), 2 = 8-bit A-law bytes, 3 = 8-bit U-law bytes, 4 = 16-bit short integers, 5 = 32-bit long integers, 6 = 32-bit floats.
If iformat = 0 it is taken from the soundfile header, and if no header from the csound -o command flag. The default value is 0.
kpitch - can be any real number. a negative number signifies backwards playback. The given number is a pitch ratio, where:
1 = norm pitch, 2 = oct higher, 3 = 12th higher,etc; .5 = oct lower, .25 = 2oct lowr, etc; -1 = norm pitch backwards, -2 = oct higher backwrds,etc..
iwraparound - 1=on, 0=off (wraps around to end of file either direction)
in, ins, inq - copy the current values from the standard audio input buffer. If the command-line flag -i is set, sound is read continuously from the audio input stream (e.g. stdin or a soundfile) into an internal buffer. Any number of these units can read freely from this buffer.
soundin is functionally an audio generator that derives its signal from a pre-existing file. The number of channels read in is controlled by the number of result cells, a1, a2, etc., which must match that of the input file. A soundin unit opens this file whenever the host instrument is initialized, then closes it again each time the instrument is turned off. There can be any number of soundin units within a single instrument or orchestra; also, two or more of them can read simultaneously from the same external file.
diskin is identical to soundin, except that it can alter the pitch of the sound that is being read.
playram - pretty self explanatory. (and pretty obnoxious). Reads your RAM starting at address 0. It will only play for ((RAM size)/(sampframesize*sr)) seconds, then will output silence.
out, outs, outq send audio samples to an accumulating output buffer (created at the beginning of performance) which serves to collect the output of all active instruments before the sound is written to disk. There can be any number of these output units in an instrument. The type (mono, stereo, or quad) must agree with nchnls, but units can be chosen to direct sound to any particular channel: outs1 sends to stereo channel 1, outq3 to quad channel 3, etc.
Barry Vercoe, Matt Ingalls/Myike Berry
MIT, Mills College
1993-1997
a1, a2, a3, a4 pan asig, kx, ky, ifn[, imode][, ioffset]
Distribute an audio signal amongst four channels with localization control.
ifn - function table number of a stored pattern describing the amplitude growth in a speaker channel as sound moves towards it from an adjacent speaker. Requires extended guard-point.
imode (optional) - mode of the kx, ky position values. 0 signifies raw index mode, 1 means the inputs are normalized (0 - 1). The default value is 0.
ioffset (optional) - offset indicator for kx, ky. 0 infers the origin to be at channel 3 (left rear); 1 requests an axis shift to the quadraphonic center. The default value is 0.
pan takes an input signal asig and distributes it amongst four outputs (essentially quad speakers) according to the controls kx and ky. For normalized input (mode=1) and no offset, the four output locations are in order: left-front at (0,1), right-front at (1,1), left-rear at the origin (0,0), and right-rear at (1,0). In the notation (kx, ky), the coordinates kx and ky, each ranging 0 - 1, thus control the 'rightness' and 'forwardness' of a sound location.
Movement between speakers is by amplitude variation, controlled by the stored function table ifn. As kx goes from 0 to 1, the strength of the right-hand signals will grow from the left-most table value to the right-most, while that of the left-hand signals will progress from the right-most table value to the left-most. For a simple linear pan, the table might contain the linear function 0 - 1. A more correct pan that maintains constant power would be obtained by storing the first quadrant of a sinusoid. Since pan will scale and truncate kx and ky in simple table lookup, a medium-large table (say 8193) should be used.
kx, ky values are not restricted to 0 - 1. A circular motion passing through all four speakers (enscribed) would have a diameter of root 2, and might be defined by a circle of radius R = root 1/2 with center at (.5,.5). kx, ky would then come from Rcos(angle), Rsin(angle), with an implicit origin at (.5,.5) (i.e. ioffset = 1). Unscaled raw values operate similarly. Sounds can thus be located anywhere in the polar or cartesian plane; points lying outside the speaker square are projected correctly onto the square's perimeter as for a listener at the center.
instr 1 k1 phasor 1/p3 ; fraction of circle k2 tablei k1, 1, 1 ; sin of angle (sinusoid in f1) k3 tablei k1, 1, 1, .25, 1 ; cos of angle (sin offset 1/4 circle) a1 oscili 10000,440, 1 ; audio signal.. a1,a2,a3,a4 pan a1, k2/2, k3/2, 2, 1, 1 ; sent in a circle (f2=1st quad sin) outq a1, a2, a3, a4 endin
aLeft, aRight hrtfer asig, kAz, kElev, "HRTFcompact"
Output is binaural (headphone) 3D audio.
kAz - azimuth value in degrees. Positive values represent position on the right, negative values are positions on the left.
kElev - elevation value in degrees. Positive values represent position on the right, negative values are positions on the left.
At present, the only file which can be used with hrtfer is HRTFcompact. It must be passed to the u.g. as the last argument within qoutes as shown above.
These unit generators place a mono input signal in a virtual 3D space around the listner by convolving the input with the appropriate HRTF data specified by the opcode's azimuth and elevation values. hrtfer allows these values to be k-values, allowing for dynamic spatialization. hrtfer can only place the input at the reqeusted position because the HRTF is loaded in at i-time (remember that currently, csound has a limit of 20 files it can hold in memory, otherwise it causes a segmentation fault). The output will need to be scaled either by using balance or by multiplying the output by some scaling constant.
Note - the sampling rate of the orchestra must be 44.1kHz. This is because 44.1kHz is the sampling rate at which the HRTFs were measured. In order to be used at a different rate, the HRTFs need to be resampled at the desired rate.
kaz linseg 0, p3, -360 ; move the sound in circle kel linseg -40, p3, 45 ; around the listener, changing ; elevation as its turning asrc soundin "soundin.1" aleft,aright hrtfer asrc, kaz, kel, "HRTFcompact" aleftscale = aleft * 200 arightscale = aright * 200 outs aleftscale, arightscale
print iarg[, iarg,...] display xsig, iprd[, iwtflg] dispfft xsig, iprd, iwsiz[, iwtyp][, idbouti][, iwtflg]
These units will print orchestra Init-values, or produce graphic display of orchestra control signals and audio signals. Uses X11 windows if enabled, else (or if -g flag is set) displays are approximated in ascii characters.
iprd - the period of display in seconds.
iwsiz - size of the input window in samples. A window of iwsiz points will produce a Fourier transform of iwsiz/2 points, spread linearly in frequency from 0 to sr/2. iwsiz must be a power of 2, with a minimum of of 16 and a maximum of 4096. The windows are permitted to overlap.
iwtyp (optional) - window type. 0 = rectangular, 1 = hanning. The default value is 0 (rectangular).
idbout (optional) - units of output for the Fourier coefficients. 0 = magnitude, 1 = decibels. The default is 0 (magnitude).
iwtflg (optional) - wait flag. If non-zero, each display is held until released by the user. The default value is 0 (no wait).
print - print the current value of the I-time arguments (or expressions) iarg at every I-pass through the instrument.
display - display the audio or control signal xsig every iprd seconds, as an amplitude vs. time graph.
dispfft - display the Fourier Transform of an audio or control signal (asig or ksig) every iprd seconds using the Fast Fourier Transform method.
k1 envlpx l, .03, p3, .05, l, .5, .0l ; generate a note envelope display k1, p3 ; and display entire shape
printk kval, ispace [, itime] printks "txtstring", itime, kval1, kval2, kval3, kval4
These ugens are intended to facilitate the debugging of orchestra code.
ispace - How many spaces to insert before it is printed. (Max 130.)
itime - How much time in seconds is to elapse between printings. (Default 1 second.)
The first print is on the first k cycle of the instance of the instrument. This may not be 0.000 seconds, but the first k cycle afterwards. I want to investigate this - I thought that k rate code should run from time 0.
txtstring -
Text to be printed first - can be up to 130 characters at least. Must be in double quotes.
The string is printed as is, but standard printf %f etc. codes are interpreted to print the four parameters.
However (at least with DJGPP) the \n style of character codes are not
interpreted by printf. This ugen therefore provides certain specific codes
which are expanded:
\n or \N Newline
\t or \T Tab
^ Escape character
^^ ^
~ Escape and '[' These are the lead in codes for MSDOS ANSI.SYS screen control characters.
~~ ~
An init error is generated if the first parameter is not a string of length > 0 enclosed in double quotes.
[For some reason (at least with the DJGPP version, the program crashes if a null string - "" - is given. This seems not to be due to this ugen. This should be tidied up sometime.]
A special mode of operation allows this ugen to convert kval1 input parameter into a 0 to 255 value and to use it as the first character to be printed.
This enables a Csound program to send arbitrary characters to the console - albeit with a little awkwardness.
[printf() does not have a format specifier to read a float and turn it into a byte for direct output. We could add extra code to do this if we really wanted to put arbitrary characters out with ease.]
To acheive this, make the first character of the string a # and then, if desired continue with normal text and format specifiers. Three more format specifers may be used - they access kval2, kval3 and kval4.
itime - How much time in seconds is to elapse between printings. (Default 1 second.)
kvalx - The k rate values to be printed. Use 0 for those which are not used.
printk prints one k rate value on every k cycle, every second or at intervals specified. First the instrument number is printed, then the absolute time in seconds, then a specified number of spaces, then the kval value. The variable number of spaces enables different values to be spaced out across the screen - so they are easier to view.
printks is a completely different ugen - similar to printf() in C.
It is highly flexible, and if used together with cursor positioning codes, could be used to write specific values to locations in the screen as the Csound processing proceeds. With MSDOS, a colour screen and ANSI.SYS, it would be possible to have multiple colours, flashing displays - looking like NASA mission control, with k rate variables controlling the values displayed, the location on the screen where they are displayed, their colour etc.
There is also a special mode where a float variable is rounded to the next lowest integer, and ANDed with 0 1111 1111 to produce a character between 0 and 255 to be sent to be printed.
This elaborate use is a bit over the top - a hacker's paradise. But printks can be used simply, just to print variables for debugging.
printks prints numbers and text, with up to four printable numbers - which can be i or k rate values.
For instance:
printks \"Volume = %6.2f Freq = %8.3f\n\", 0.1, kvol, kfreq, 0, 0
This would print:
Volume = 1234.56 Freq = 12345.678
printks \"#x\\y = %6.2\n\", 0.1, kxy, 0, 0, 0
This would print a tab character followed by:
x\y = 1234.56
Both these printing ugens can be made to run on every k cycle - or at least every k cycle they are run in the instrument. Conditional goto statements can be used to run them only at certain times or when something goes wrong. To make them run on every k cycle like this, set itime to 0.
When itime is not 0, then (if the orchestra code runs the ugen on every k cycle) then the ugen will decide when to print. It will always print on the first k cycle it is called. This means that if you set one of these to print only every 10 seconds, and conditional code in the instrument causes it to be run for the very first time at 3 seconds, then it will print at 3 seconds.
Subsequent runs of the ugen at between 3 and 9.999 seconds would not cause it to print. This could be very useful - set the time to longer than the piece and conditional code in the instrument can be used to report a bug just once, on its first occurrence. You almost certainly do not want a print operation happening every k cycle - it slows the program down too much.
Staying with the 10 second cycle example, if such a printk or printks ugen was called every k cycle, then it would print at 0 seconds (actually the first k cycle after 0), at 10.0 seconds, at 20.0 seconds etc.
The time cycles start from the time the ugen is initialized - typically the initialisation of the instrument.
Damien Miller pointed out an interesting application of these ugens - get the output of the program and sort the lines with a line sorter. The result would be the printed lines sorted first by instrument number, and then by time - for printk. However printks can be made to produce almost anything. The instrument is available as p1 and the time can easily be found and made available as a printks parameter.
One option I have considered but not implemented is for these printed lines to be written to a file as well as to the screen. Let me know if you like this idea, or have any other ideas about debugging.
printf() style %f formatting
One of the less enjoyable parts of C programming is trying to figure out what magic incantations to offer to printf()
All the parameters are floats, so this reduces our decisions to two main issues:
1 - How many decimal points of precision do we want? (0 means no decimal point.) 2 - How many digits (or spaces) do we want printed in total - _including_ those after the decimal point? %f Just prints with full precision - 123.123456 %6.2f Prints 1234.12 %5.0f Prints 12345
There is more to the printf() codes than this - see an ANSI C library reference. Instead of 'f', you can use 'e' to get scientific notation. Using any other format specifiers than f, e, g, E and G will cause unpredictable results, because the parameters are always floating point numbers.
Robin Whittle
Australia
May 1997
kdump ksig, ifilname, iformat, iprd kdump2 ksig1, ksig2, ifilname, iformat, iprd kdump3 ksig1, ksig2, ksig3, ifilname, iformat, iprd kdump4 ksig1, ksig2, ksig3, ksig4, ifilname, iformat, iprd
Periodically write orchestra control-signal values to a named external file in a specific format.
ifilname - character string(in double quotes, saces ermitted ) denoting the external file name. May either be a full path name with target directory specified or a simple filename to be created within the current directory
iformat - specifies the output data format: 1 = 8-bit signed char(high order 8 bits of a 16-bit integer, 4 = 16-bit short integers, 5 = 32bit long integers, 6 = 32-bit floats, 7=ASCII long integers, 8=ASCII floats (2 decimal places). Note that A-law and U-law ouput are not availble,and that all formats except the lsat two are binary. The outpu file contains no header information.
iprd - the period of ksig output i seconds, rounded to the nearest orchestra control period. A value of 0 implies one control period (the enforced minimum), which will create an ouput file sampled at the orchestra control rate.
These units allow up to four generated control signal values to be saved in a named external file. The file contains no sef-defining header information, but there is a regularly sampled time series, suitable for later input or analysis. There may be a number of kdump units in an instrument or orchestra.
knum = knum+1 ; at each k-perio ktemp tempest krms, .02, .1, 3, 2, 800, .005, 0, 60, 4, .1, .995 ;estimate the tempo koct specptrk wsig, 6, .9, 0 ;and the pitch kdump3 knum, ktemp, cpsoct(koct), "what happened when", 8 0 ;& save them