<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="_c74_vig.xsl" type="text/xsl"?>
<vignette name="gen~ Operators" order="4" package="Gen" rankfactor="3">
  <h1>
	gen~ Operators
</h1>
  <p>
			The following Gen operators are unique to the
			<o>gen~</o>
			object, and operate in the audio domain.
		</p>
  <!--Begin Gen Operators-->
  <h2>
	Buffer
 </h2>
  <ul>
    <li><link name="gen_dsp_buffer" type="genrefpage">buffer</link> :
<span name="dsp_buffer">References a named buffer~ object in the <o>gen~</o> object's parent patch. The first argument specifies a name by which to refer to this data in other objects in the gen patcher (such as peek and poke); the second optional argument specifies the name of the external buffer~ object to reference (if ommitted, the first argument name is used). The first outlet sends the length of the buffer in samples; the second outlet sends the number of channels.</span>
</li>
    <li><link name="gen_dsp_channels" type="genrefpage">channels</link> :
<span name="dsp_channels">The number of channels of a data/buffer object. The first argument should be a name of a data or buffer object in the gen patcher.</span>
</li>
    <li><link name="gen_dsp_cycle" type="genrefpage">cycle</link> :
<span name="dsp_cycle">An interpolating oscillator that reads repeatedly through one cycle of a sine wave. By default it is driven by a frequency input, but if the @index attribute is set to 'phase', it can be driven by a phase input instead.</span>
</li>
    <li><link name="gen_dsp_data" type="genrefpage">data</link> :
<span name="dsp_data">Stores an array of sample data (64-bit floats) usable for sampling, wavetable synthesis and other purposes. The first argument specifies a name by which to refer to this data in other objects in the gen patcher (such as peek and poke); the second optional argument specifies the length of the array (default 512 samples); and the third optional argument specifies the number of channels (default 1). The first outlet sends the length of the buffer in samples; the second outlet sends the number of channels.</span>
</li>
    <li><link name="gen_dsp_dim" type="genrefpage">dim</link> :
<span name="dsp_dim">The length (in samples) of a data/buffer object. The first argument should be a name of a data or buffer object in the gen patcher.</span>
</li>
    <li><link name="gen_dsp_lookup" type="genrefpage">lookup</link> :
<span name="dsp_lookup">Index a data/buffer object using a signal, for waveshaping. The first argument should be a name of a data or buffer object in the gen patcher. The second argument specifies the number of output channels. Input signals in the range -1 to 1 are mapped to the full size of the data/buffer, with linear interpolation. The last inlet specifies a channel offset (default 0).</span>
</li>
    <li><link name="gen_dsp_nearest" type="genrefpage">nearest</link> :
<span name="dsp_nearest">Multi-channel lookup a data/buffer object (no interpolation). The first argument should be a name of a data or buffer object in the gen patcher. The second argument specifies the number of output channels. The input phase ranges from 0 to 1, and wraps outside this range. The last inlet specifies a channel offset (default 0).</span>
</li>
    <li><link name="gen_dsp_peek" type="genrefpage">peek</link> :
<span name="dsp_peek">Read values from a data/buffer object. The first argument should be a name of a data or buffer object in the gen patcher. The second argument specifies the number of output channels. The first inlet specifes a sample index to read (no interpolation); indices out of range return zero. The last inlet specifies a channel offset (default 0).</span>
</li>
    <li><link name="gen_dsp_poke" type="genrefpage">poke</link> :
<span name="dsp_poke">Write values into a data/buffer object. The first argument should be a name of a data or buffer object in the gen patcher. The second argument (or third inlet if omitted) specifies which channel to use. The first inlet specifies a value to write, while the second inlet specifies the sample index within the data/buffer. If the index is out of range, no value is written.</span>
</li>
    <li><link name="gen_dsp_sample" type="genrefpage">sample</link> :
<span name="dsp_sample">Linear interpolated multi-channel lookup of a data/buffer object. The first argument should be a name of a data or buffer object in the gen patcher. The second argument specifies the number of output channels. The last inlet specifies a channel offset (default 0).</span>
</li>
    <li><link name="gen_dsp_splat" type="genrefpage">splat</link> :
<span name="dsp_splat">Mix values into a data/buffer object, with linear interpolated overdubbing. The first argument should be a name of a data or buffer object in the gen patcher. The second argument (or third inlet if omitted) specifies which channel to use. The first inlet specifies a value to write, while the fractional component of the second inlet specifies a phase (0..1) within the data/buffer (indices out of range will wrap). Splat writes with linear interpolation between samples, and mixes new values with the existing data (overdubbing).</span>
</li>
    <li><link name="gen_dsp_wave" type="genrefpage">wave</link> :
<span name="dsp_wave">Wavetable synthesis using a data/buffer object. The first argument should be a name of a data or buffer object in the gen patcher. The second argument specifies the number of output channels. The first inlet specifies phase (0..1), while the second and third inlets specify start/end sample positions within the data/buffer. The last inlet specifies a channel offset (default 0).</span>
</li>
  </ul>
  <h2>
	Convert
 </h2>
  <ul>
    <li><link name="gen_dsp_atodb" type="genrefpage">atodb</link> :
<span name="dsp_atodb">Convert linear amplitude to deciBel value</span>
</li>
    <li><link name="gen_dsp_dbtoa" type="genrefpage">dbtoa</link> :
<span name="dsp_dbtoa">Convert deciBel value to linear amplitude</span>
</li>
    <li><link name="gen_dsp_ftom" type="genrefpage">ftom</link> :
<span name="dsp_ftom">Frequency given in Hertz is converted to MIDI note number (0-127). Fractional note numbers are supported. The second input sets the tuning base (default 440).</span>
</li>
    <li><link name="gen_dsp_mstosamps" type="genrefpage">mstosamps</link> :
<span name="dsp_mstosamps">Convert period in milliseconds to samples</span>
</li>
    <li><link name="gen_dsp_mtof" type="genrefpage">mtof</link> :
<span name="dsp_mtof">MIDI note number (0-127) is converted to frequency in Hertz. Fractional note numbers are supported. The second input sets the tuning base (default 440).</span>
</li>
    <li><link name="gen_dsp_sampstoms" type="genrefpage">sampstoms</link> :
<span name="dsp_sampstoms">Convert period in samples to milliseconds</span>
</li>
  </ul>
  <h2>
	Constants
 </h2>
  <ul>
    <li><link name="gen_dsp_fftfullspect" type="genrefpage">fftfullspect</link>, <link name="gen_dsp_fftfullspect" type="genrefpage">FFTFULLSPECT</link> : <span name="dsp_fftfullspect">The pfft~ full spectrum flag (0/1)</span>
</li>
    <li><link name="gen_dsp_ffthop" type="genrefpage">ffthop</link>, <link name="gen_dsp_ffthop" type="genrefpage">FFTHOP</link> : <span name="dsp_ffthop">The pfft~ FFT hop size</span>
</li>
    <li><link name="gen_dsp_fftoffset" type="genrefpage">fftoffset</link>, <link name="gen_dsp_fftoffset" type="genrefpage">FFTOFFSET</link> : <span name="dsp_fftoffset">The pfft~ FFT offset</span>
</li>
    <li><link name="gen_dsp_fftsize" type="genrefpage">fftsize</link>, <link name="gen_dsp_fftsize" type="genrefpage">FFTSIZE</link> : <span name="dsp_fftsize">The pfft~ FFT frame size</span>
</li>
    <li><link name="gen_dsp_samplerate" type="genrefpage">samplerate</link>, <link name="gen_dsp_samplerate" type="genrefpage">SAMPLERATE</link> : <span name="dsp_samplerate">The DSP samplerate</span>
</li>
    <li><link name="gen_dsp_vectorsize" type="genrefpage">vectorsize</link>, <link name="gen_dsp_vectorsize" type="genrefpage">VECTORSIZE</link> : <span name="dsp_vectorsize">The DSP vectorsize</span>
</li>
  </ul>
  <h2>
	Dsp
 </h2>
  <ul>
    <li><link name="gen_dsp_fixdenorm" type="genrefpage">fixdenorm</link> :
<span name="dsp_fixdenorm">This operator detects denormal numbers and replaces them with zero. Note: As of Max 6.0 the x87 control flags are set to flush to zero and disable exception handling in audio processing, so denormal fixing should only be required for exported code. A denormal number is a floating point value very close to zero (filling the underflow gap). Calculations with denormal values can be up to 100 times more expensive, so it is often beneficial to replace them with zeroes. Denormals often occur in feedback loops with multipliers, such as filters, delays and exponential decays. Denormal detection is based on a bitmask. Note that feedback operators in gen~ (delay, history) apply fixdenorm to their input signals by default.</span>
</li>
    <li><link name="gen_dsp_fixnan" type="genrefpage">fixnan</link> :
<span name="dsp_fixnan">This operator replaces NaNs with zero. A NaN (Not a Number) is a floating point data value which represents an undefined or unrepresentable value, such as the result of dividing by zero. Computations on NaNs produce more NaNs, and so it is often preferable to replace the NaN with a zero value. Note that division and modulo operators in gen~ protect against generating NaNs by default.</span>
</li>
    <li><link name="gen_dsp_isdenorm" type="genrefpage">isdenorm</link> :
<span name="dsp_isdenorm">This operator detects denormal numbers and returns 1 if the input is denormal, and zero otherwise. Note: As of Max 6.0 the x87 control flags are set to flush to zero and disable exception handling in audio processing, so denormal fixing should only be required for exported code. A denormal number is a floating point value very close to zero (filling the underflow gap). Calculations with denormal values can be up to 100 times more expensive, so it is often beneficial to replace them with zeroes. Denormals often occur in feedback loops with multipliers, such as filters, delays and exponential decays. Denormal detection is based on a bitmask. Note that feedback operators in gen~ (delay, history) apply fixdenorm to their input signals by default.</span>
</li>
    <li><link name="gen_dsp_isnan" type="genrefpage">isnan</link> :
<span name="dsp_isnan">This operator detects the presence of NaN values, returning 1 if the input is NaN, and zero otherwise. A NaN (Not a Number) is a floating point data value which represents an undefined or unrepresentable value, such as the result of dividing by zero. Computations on NaNs produce more NaNs, and so it is often preferable to replace the NaN with a zero value. Note that division and modulo operators in gen~ protect against generating NaNs by default.</span>
</li>
    <li><link name="gen_dsp_t60" type="genrefpage">t60</link> :
		<span name="dsp_t60">Given an input T, returns a number X such that, after T multiplications of a signal by X, that signal would be attenuated by 60 decibels. Roughly, -60db = 0db * pow(X, T). This could be used as a per-sample multiplier (X) to ensure a decay time (of T samples), for example. The name t60 is borrowed from the RT60 time used to measure reverberation time, which specifies the time taken for a signal to decay by 60db, as an approximation of fading to inaudibility.</span>
	</li>
    <li><link name="gen_dsp_t60time" type="genrefpage">t60time</link> :
		<span name="dsp_t60time">Estimates the decay time (in samples) of a given decay factor. That is, given a multiplier X, returns a number T such that, after T multiplications of a signal by X, that signal would be attenuated by 60 decibels. It is the dual of the t60 object.</span>
	</li>
  </ul>
  <h2>
	Feedback
 </h2>
  <ul>
    <li><link name="gen_dsp_delay" type="genrefpage">delay</link> :
<span name="dsp_delay">Delays a signal by a certain amount of time (specified in samples). The first argument specifies the maximum delay time (in samples, default samplerate). The second argument specifies the number of tap inlet/outlet pairs (default 1). The first inlet is the signal to be delayed. Additional inlets specify the delay time per tap (in samples). With @feedback 1, like history, delay allows feedback loops in the patcher, but minium delay is 1 sample. With @feedback 0, minimum delay time is zero samples (or more if @interp is cubic, spline, or spline6)</span>
</li>
    <li><link name="gen_dsp_history" type="genrefpage">history</link> :
<span name="dsp_history">The history operator allows feedback in the gen patcher through the insertion of a single-sample delay. The first argument is an optional name for the history operator, which allows it to also be set externally (in the same way as the param operator). The second argument specifies an initial value of stored history (defaults to zero).</span>
</li>
  </ul>
  <h2>
	FFT
 </h2>
  <ul>
    <li><link name="gen_dsp_fftinfo" type="genrefpage">fftinfo</link> :
<span name="dsp_fftinfo">fftinfo gets constant data about the FFT frames in a patcher loaded by pfft~. If it is used in a patcher that is not loaded by pfft~, it returns default constants instead.</span>
</li>
  </ul>
  <h2>
	Filter
 </h2>
  <ul>
    <li><link name="gen_dsp_change" type="genrefpage">change</link> :
<span name="dsp_change">Returns the sign of the difference between the current and previous input: 1 if the input is increasing, -1 if decreasing, and 0 if unchanging.</span>
</li>
    <li><link name="gen_dsp_dcblock" type="genrefpage">dcblock</link> :
<span name="dsp_dcblock">A one-pole high-pass filter to remove DC components. Equivalent to the GenExpr:
		History x1, y1;
	y = in1 - x1 + y1*0.9997;
	x1 = in1;
	y1 = y;
	out1 = y;
</span>
</li>
    <li><link name="gen_dsp_delta" type="genrefpage">delta</link> :
<span name="dsp_delta">Returns the difference between the current and previous input.</span>
</li>
    <li><link name="gen_dsp_interp" type="genrefpage">interp</link> :
<span name="dsp_interp">Smoothly mix between inputs, according to an interpolation factor in the range of 0 to 1 (first inlet). The @mode attribute can choose between linear or cosine interpolation to mix between two additional inlets, cubic or spline to mix between four inlets, and spline6 to mix between six inlets. The default mode is linear.</span>
</li>
    <li><link name="gen_dsp_latch" type="genrefpage">latch</link> :
<span name="dsp_latch">Conditionally passes or holds input. The first inlet is the 'input' and the second inlet is the 'control'. When the control is non-zero, the input value is passed through. When the control is zero, the previous input value is output. It can be used to periodically sample &amp; hold a source signal with a simpler trigger logic than the sah operator.</span>
</li>
    <li><link name="gen_dsp_phasewrap" type="genrefpage">phasewrap</link> :
<span name="dsp_phasewrap">Wrap input to the range -pi to +pi</span>
</li>
    <li><link name="gen_dsp_sah" type="genrefpage">sah</link> :
<span name="dsp_sah">The first inlet is the 'input' and the second inlet is the 'control'. When the control makes a transition from being at or below the trigger value to being above the trigger threshold, the input is sampled. The sampled value is output until another control transition occurs, at which point the input is sampled again. The default threshold value is 0, but can be specified as the last inlet/argument. The @init attribute sets the initial previous value to compare to (default 0).</span>
</li>
    <li><link name="gen_dsp_slide" type="genrefpage">slide</link> :
		<span name="dsp_slide">Use the slide operator for envelope following and lowpass filtering. Related to the MSP slide~ object.</span>
	</li>
  </ul>
  <h2>
	Global
 </h2>
  <ul>
    <li><link name="gen_dsp_elapsed" type="genrefpage">elapsed</link> :
		<span name="dsp_elapsed">The number of samples elapsed since the patcher DSP began, or since the last reset.</span>
	</li>
    
	
	<li>
		<link name="gen_dsp_mc_channel" type="genrefpage">mc_channel</link> :
		<span name="dsp_mc_channel">If used within a patcher inside mc.gen~, the mc_channel operator will return the current channel index. Otherwise, it always returns 1.</span>
	</li>
	<li>
		<link name="gen_dsp_mc_channelcount" type="genrefpage">mc_channelcount</link> :
		<span name="dsp_mc_channelcount">If used within a patcher inside mc.gen~, the mc_channelcount operator will return the channel count of the mc.gen~. Otherwise, it always returns 1.</span>
	</li>
	<li><link name="gen_dsp_voice" type="genrefpage">voice</link> :
		<span name="dsp_voice">If used within a poly~ patcher, the voice operator will return the current voice index (similar to thispoly~). Otherwise, it always returns 1.</span>
	</li>
  
	<li>
		<link name="gen_dsp_voicecount" type="genrefpage">voicecount</link> :
		<span name="dsp_voicecount">If used within a poly~ patcher, the voicecount operator will return the current voice count. Otherwise, it always returns 1.</span>
	</li>
	</ul>
  <h2>
	Integrator
 </h2>
  <ul>
    <li><link name="gen_dsp_mulequals" type="genrefpage">*=</link>, <link name="gen_dsp_mulequals" type="genrefpage">mulequals</link> :
<span name="dsp_mulequals">The object multiplies by, and then outputs, an internal value. This occurs at sample-rate, so the stored value can grow very large or very small, very fast. The value to be multiplied by is specified by either the first inlet or argument. The internal sum can be reset to the minimum by sending a nonzero value to the right-most inlet. The minimum value is 0 by default, but can be changed with the @min attribute. An optional maximum value can be specified with the @max attribute; values will wrap at the maximum.</span>
</li>
    <li><link name="gen_dsp_plusequals" type="genrefpage">+=</link>, <link name="gen_dsp_accum" type="genrefpage">accum</link>, <link name="gen_dsp_plusequals" type="genrefpage">plusequals</link> :
<span name="dsp_plusequals">The object adds to, and then outputs, an internal sum. This occurs at sample-rate, so the sum can grow very large, very fast. The value to be added is specified by either the first inlet or argument. The internal sum can be reset to the minimum by sending a nonzero value to the right-most inlet. The minimum value is 0 by default, but can be changed with the @min attribute. An optional maximum value can be specified with the @max attribute; values will wrap at the maximum.</span>
</li>
    <li><link name="gen_dsp_counter" type="genrefpage">counter</link> :
<span name="dsp_counter">Accumulates and outputs a stored count, similarly to Max's counter object, but triggered at sample-rate. The amount to accumulate per sample is set by the first input (incr). The count can be reset by a non-zero value in the second input (reset). The third inlet (max) sets a maximum value; the counter will wrap if it reaches this value. However if the maximum value is set to 0 (the default), the counter will assume no limit and count indefinitely. The first outlet outputs the current count, the second outlet outputs 1 when the count wraps at the maximum and zero otherwise, and the third outlet outputs the number of wraps (the carry count).</span>
</li>
  </ul>
  <h2>
	Numeric
 </h2>
  <ul>
    <li><link name="gen_dsp_round" type="genrefpage">round</link> :
		<span name="dsp_round">Returns the integral value that is nearest to the input, with halfway cases rounded away from zero.</span>
	</li>
  </ul>
  <h2>
	Waveform
 </h2>
  <ul>
    <li><link name="gen_dsp_phasor" type="genrefpage">phasor</link> :
<span name="dsp_phasor">A non-bandlimited sawtooth-waveform signal generator which can be used as LFO audio signal or a sample-accurate timing/control signal.</span>
</li>
    <li><link name="gen_dsp_rate" type="genrefpage">rate</link> :
<span name="dsp_rate">The rate operator time-scales an input phase (such as from a phasor) by a multiplier. Multipliers less than 1 create several ramps per phase cycle.</span>
</li>
    <li><link name="gen_dsp_train" type="genrefpage">train</link> :
<span name="dsp_train">train~ generates a pulse signal whose period is specifiable in terms of samples. The first input sets the pulse period (in samples). The second input sets the pulse width (default 0.5). The third inlet sets the phase of the 'on' portion (default 0.)</span>
</li>
    <li><link name="gen_dsp_triangle" type="genrefpage">triangle</link> :
<span name="dsp_triangle">A triangle/ramp wavetable with input to change phase offset of the peak value. The phase ranges from 0 to 1 (and wraps outside these values). With a duty cycle of 0, it produces a descending sawtooth; with a duty cycle of 1 it produces ascending sawtooth; with a duty cycle of 0.5 it produces a triangle waveform. Output values always bounded in 0 to 1.</span>
</li>
  </ul>
  <!--End Gen Operators-->
  <seealsolist>
    <seealso name="mc_gen" type="vignette" module="core"/>
  </seealsolist>
</vignette>
