FLOSS Manuals

 English |  Español |  Français |  Italiano |  Português |  Русский |  Shqip

CSOUND Español

ENVELOPES

Envelopes are used to define how a value evolves over time. In early synthesisers, envelopes were used to define the changes in amplitude in a sound across its duration thereby imbuing sounds characteristics such as 'percussive', or 'sustaining'. Envelopes are also commonly used to modulate filter cutoff frequencies and the frequencies of oscillators but in reality we are only limited by our imaginations in regard to what they can be used for.

Los sobres se utilizan para definir cómo evoluciona un valor con el tiempo. En los primeros sintetizadores, se usaron sobres para definir los cambios de amplitud en un sonido a lo largo de su duración, imbuyendo características sonoras tales como percusión o sostenimiento. Los sobres también se utilizan comúnmente para modular las frecuencias de corte del filtro y las frecuencias de los osciladores, pero en realidad sólo estamos limitados por nuestra imaginación con respecto a lo que se puede utilizar.

Csound offers a wide array of opcodes for generating envelopes including ones which emulate the classic ADSR (attack-decay-sustain-release) envelopes found on hardware and commercial software synthesizers. A selection of these opcodes types shall be introduced here.

Csound ofrece una amplia gama de opcodes para generar sobres incluyendo los que emulan los sobres clásicos ADSR (ataque-decay-sustain-release) encontrados en hardware y sintetizadores de software comercial. Se introducirá aquí una selección de estos tipos de opcodes.

The simplest opcode for defining an envelope is line. line describes a single envelope segment as a straight line between a start value and an end value which has a given duration.

El opcode más simple para definir un sobre es line. Line describe un solo segmento de envolvente como una línea recta entre un valor inicial y un valor final que tiene una duración determinada.

ares line ia, idur, ib

kres line ia, idur, ib

 

In the following example line is used to create a simple envelope which is then used as the amplitude control of a poscil oscillator. This envelope starts with a value of 0.5 then over the course of 2 seconds descends in linear fashion to zero.

En el ejemplo siguiente, se utiliza una línea para crear un sobre simple que se utiliza a continuación como control de amplitud de un oscilador de poscil. Esta envoltura comienza con un valor de 0,5 y luego en el curso de 2 segundos desciende de forma lineal a cero.

   EXAMPLE 05A01_line.csd

<CsoundSynthesizer>

<CsOptions>
-odac ; activates real time sound output
</CsOptions>

<CsInstruments>
sr = 44100
ksmps = 32
nchnls = 1
0dbfs = 1

giSine   ftgen    0, 0, 2^12, 10, 1 ; a sine wave

  instr 1
aEnv     line     0.5, 2, 0         ; amplitude envelope
aSig     poscil   aEnv, 500, giSine ; audio oscillator
         out      aSig              ; audio sent to output
  endin

</CsInstruments>
<CsScore>
i 1 0 2 ; instrument 1 plays a note for 2 seconds
e
</CsScore>
</CsoundSynthesizer>

 

The envelope in the above example assumes that all notes played by this instrument will be 2 seconds long. In practice it is often beneficial to relate the duration of the envelope to the duration of the note (p3) in some way. In the next example the duration of the envelope is replaced with the value of p3 retrieved from the score, whatever that may be. The envelope will be stretched or contracted accordingly.

El sobre en el ejemplo anterior asume que todas las notas tocadas por este instrumento serán 2 segundos de largo. En la práctica, a menudo es beneficioso relacionar la duración del sobre con la duración de la nota (p3) de alguna manera. En el ejemplo siguiente, la duración del sobre se sustituye por el valor de p3 recuperado de la partitura, cualquiera que sea. El sobre se estira o se contrae en consecuencia.

   EXAMPLE 05A02_line_p3.csd

<CsoundSynthesizer>

<CsOptions>
-odac ;activates real time sound output
</CsOptions>

<CsInstruments>
sr = 44100
ksmps = 32
nchnls = 1
0dbfs = 1

giSine   ftgen    0, 0, 2^12, 10, 1 ; a sine wave

  instr 1
; A single segment envelope. Time value defined by note duration.
aEnv     line     0.5, p3, 0
aSig     poscil   aEnv, 500, giSine ; an audio oscillator
         out      aSig              ; audio sent to output
  endin

</CsInstruments>
<CsScore>
; p1 p2  p3
i 1  0    1
i 1  2  0.2
i 1  3    4
e
</CsScore>
</CsoundSynthesizer>

It may not be disastrous if a envelope's duration does not match p3 and indeed there are many occasions when we want an envelope duration to be independent of p3 but we need to remain aware that if p3 is shorter than an envelope's duration then that envelope will be truncated before it is allowed to complete and if p3 is longer than an envelope's duration then the envelope will complete before the note ends (the consequences of this latter situation will be looked at in more detail later on in this section).

No puede ser desastroso si la duración de los sobres no coincide con p3 y de hecho hay muchas ocasiones cuando queremos que la duración de una envolvente sea independiente de p3, pero debemos seguir siendo conscientes de que si p3 es más corto que una duración de sobres, Truncado antes de que se le permita completar y si p3 es más largo que una duración de sobres, el sobre se completará antes de que finalice la nota (las consecuencias de esta última situación serán examinadas con más detalle más adelante en esta sección).

 

line (and most of Csound's envelope generators) can output either k or a-rate variables. k-rate envelopes are computationally cheaper than a-rate envelopes but in envelopes with fast moving segments quantisation can occur if they output a k-rate variable, particularly when the control rate is low, which in the case of amplitude envelopes can lead to clicking artefacts or distortion.

Line (y la mayoría de los generadores de sobres Csounds) pueden generar variables k o a-rate. Las envolventes de k-velocidad son computacionalmente más baratas que las sobres de velocidad pero en sobres con segmentos de movimiento rápido la cuantificación puede ocurrir si producen una variable de k-velocidad, particularmente cuando la velocidad de control es baja, lo que en el caso de sobres de amplitud puede conducir a hacer clic Artefactos o distorsión.

linseg is an elaboration of line and allows us to add an arbitrary number of segments by adding further pairs of time durations followed envelope values. Provided we always end with a value and not a duration we can make this envelope as long as we like.

Linseg es una elaboración de línea y nos permite agregar un número arbitrario de segmentos añadiendo pares de duraciones de tiempo seguidas de valores de envolvente. Siempre que siempre terminan con un valor y no una duración que podemos hacer este sobre, siempre y cuando nos gusta.

In the next example a more complex amplitude envelope is employed by using the linseg opcode. This envelope is also note duration (p3) dependent but in a more elaborate way. An attack-decay stage is defined using explicitly declared time durations. A release stage is also defined with an explicitly declared duration. The sustain stage is the p3 dependent stage but to ensure that the duration of the entire envelope still adds up to p3, the explicitly defined durations of the attack, decay and release stages are subtracted from the p3 dependent sustain stage duration. For this envelope to function correctly it is important that p3 is not less than the sum of all explicitly defined envelope segment durations. If necessary, additional code could be employed to circumvent this from happening.

En el ejemplo siguiente se emplea una envolvente de amplitud más compleja utilizando el código de operación linseg. Este sobre es también la duración de la nota (p3) dependiente pero de una manera más elaborada. Una etapa ataque-decadencia se define utilizando duraciones de tiempo explícitamente declaradas. Una etapa de liberación también se define con una duración explícitamente declarada. La etapa de sustentación es la etapa dependiente de p3 pero para asegurar que la duración de toda la envolvente todavía se agrega a p3, las duraciones explícitamente definidas de las etapas de ataque, decaimiento y liberación se restan de la duración de la etapa de sostenimiento dependiente de p3. Para que este sobre funcione correctamente es importante que p3 no sea menor que la suma de todas las duraciones del segmento de envolvente definidas explícitamente. Si fuera necesario, podría emplearse código adicional para evitar que esto suceda.

   EXAMPLE 05A03_linseg.csd

<CsoundSynthesizer>

<CsOptions>
-odac ; activates real time sound output
</CsOptions>

<CsInstruments>
sr = 44100
ksmps = 32
nchnls = 1
0dbfs = 1

giSine   ftgen    0, 0, 2^12, 10, 1 ; a sine wave

  instr 1
; a more complex amplitude envelope:
;                 |-attack-|-decay--|---sustain---|-release-|
aEnv     linseg   0, 0.01, 1, 0.1,  0.1, p3-0.21, 0.1, 0.1, 0
aSig     poscil   aEnv, 500, giSine
         out      aSig
  endin

</CsInstruments>

<CsScore>
i 1 0 1
i 1 2 5
e
</CsScore>

</CsoundSynthesizer>

The next example illustrates an approach that can be taken whenever it is required that more than one envelope segment duration be p3 dependent. This time each segment is a fraction of p3. The sum of all segments still adds up to p3 so the envelope will complete across the duration of each note regardless of duration.

El siguiente ejemplo ilustra un enfoque que se puede tomar siempre que se requiera que más de una duración de segmento de sobre sea p3 dependiente. Esta vez cada segmento es una fracción de p3. La suma de todos los segmentos todavía se suma a p3, por lo que el sobre se completará a lo largo de la duración de cada nota independientemente de la duración.

   EXAMPLE 05A04_linseg_p3_fractions.csd 

<CsoundSynthesizer>

<CsOptions>
-odac ;activates real time sound output
</CsOptions>

<CsInstruments>
sr = 44100
ksmps = 32
nchnls = 1
0dbfs = 1

giSine   ftgen    0, 0, 2^12, 10, 1 ; a sine wave

  instr 1
aEnv     linseg   0, p3*0.5, 1, p3*0.5, 0 ; rising then falling envelope
aSig     poscil   aEnv, 500, giSine
         out      aSig
  endin

</CsInstruments>

<CsScore>
; 3 notes of different durations are played
i 1 0   1
i 1 2 0.1
i 1 3   5
e
</CsScore>
</CsoundSynthesizer>

The next example highlights an important difference in the behaviours of line and linseg when p3 exceeds the duration of an envelope.

El siguiente ejemplo resalta una diferencia importante en los comportamientos de line y linseg cuando p3 excede la duración de un sobre.

When a note continues beyond the end of the final value of a linseg defined envelope the final value of that envelope is held. A line defined envelope behaves differently in that instead of holding its final value it continues in the trajectory defined by its one and only segment.

Cuando una nota continúa más allá del final del valor final de un sobre definido de linseg, se mantiene el valor final de ese sobre. Un sobre definido en la línea se comporta de manera diferente en que en lugar de mantener su valor final, continúa en la trayectoria definida por su único segmento.

This difference is illustrated in the following example. The linseg and line envelopes of instruments 1 and 2 appear to be the same but the difference in their behaviour as described above when they continue beyond the end of their final segment is clear when listening to the example.

Esta diferencia se ilustra en el siguiente ejemplo. El lino y la línea envolvente de los instrumentos 1 y 2 parecen ser los mismos, pero la diferencia en su comportamiento como se describe anteriormente cuando continúan más allá del final de su segmento final es clara al escuchar el ejemplo.


 

   EXAMPLE 05A05_line_vs_linseg.csd

 

<CsoundSynthesizer>

<CsOptions>
-odac ; activates real time sound output
</CsOptions>

<CsInstruments>
sr = 44100
ksmps = 32
nchnls = 1
0dbfs = 1

giSine   ftgen    0, 0, 2^12, 10, 1 ; a sine wave

  instr 1 ; linseg envelope
aCps     linseg   300, 1, 600       ; linseg holds its last value
aSig     poscil   0.2, aCps, giSine
         out      aSig
  endin

  instr 2 ; line envelope
aCps     line     300, 1, 600       ; line continues its trajectory
aSig     poscil   0.2, aCps, giSine
         out      aSig
  endin

</CsInstruments>

<CsScore>
i 1 0 5 ; linseg envelope
i 2 6 5 ; line envelope
e
</CsScore>

</CsoundSynthesizer> 

 

expon and expseg are versions of line and linseg that instead produce envelope segments with concave exponential shapes rather than linear shapes. expon and expseg can often be more musically useful for envelopes that define amplitude or frequency as they will reflect the logarithmic nature of how these parameters are perceived. On account of the mathematics that are used to define these curves, we cannot define a value of zero at any node in the envelope and an envelope cannot cross the zero axis. If we require a value of zero we can instead provide a value very close to zero. If we still really need zero we can always subtract the offset value from the entire envelope in a subsequent line of code.

Expon y expseg son versiones de line y linseg que en su lugar producen segmentos de envolvente con formas exponenciales cóncavas en lugar de formas lineales. Expon y expseg a menudo pueden ser más musicalmente útiles para sobres que definen amplitud o frecuencia, ya que reflejarán la naturaleza logarítmica de cómo se perciben estos parámetros. Debido a las matemáticas que se utilizan para definir estas curvas, no podemos definir un valor de cero en ningún nodo en el sobre y un sobre no puede cruzar el eje cero. Si requerimos un valor de cero, en vez de eso podemos proporcionar un valor muy cercano a cero. Si todavía necesitamos realmente cero siempre podemos restar el valor de offset de todo el sobre en una línea de código subsiguiente.

The following example illustrates the difference between line and expon when applied as amplitude envelopes.

El ejemplo siguiente ilustra la diferencia entre la línea y el exponente cuando se aplica como sobres de amplitud.

   EXAMPLE 05A06_line_vs_expon.csd 

<CsoundSynthesizer>

<CsOptions>
-odac ; activates real time sound output
</CsOptions>

<CsInstruments>
sr = 44100
ksmps = 32
nchnls = 1
0dbfs = 1

giSine   ftgen    0, 0, 2^12, 10, 1 ; a sine wave

  instr 1 ; line envelope
aEnv     line     1, p3, 0
aSig     poscil   aEnv, 500, giSine
         out      aSig
  endin

  instr 2 ; expon envelope
aEnv     expon    1, p3, 0.0001
aSig     poscil   aEnv, 500, giSine
         out      aSig
  endin

</CsInstruments>

<CsScore>
i 1 0 2 ; line envelope
i 2 2 1 ; expon envelope
e
</CsScore>

</CsoundSynthesizer> 

The nearer our 'near-zero' values are to zero the quicker the curve will appear to reach 'zero'. In the next example smaller and smaller envelope end values are passed to the expon opcode using p4 values in the score. The percussive 'ping' sounds are perceived to be increasingly short.

Cuanto más cercanos estén nuestros valores cero-cero, más rápido aparecerá la curva para llegar a cero. En el ejemplo siguiente, los valores finales de envolvente más pequeños y más pequeños se pasan al código de operación de exponencia usando valores de p4 en la partitura. Los sonidos percusivos de ping son percibidos como cada vez más cortos.

   EXAMPLE 05A07_expon_pings.csd

 

<CsoundSynthesizer>

<CsOptions>
-odac ; activates real time sound output
</CsOptions>

<CsInstruments>
sr = 44100
ksmps = 32
nchnls = 1
0dbfs = 1

giSine   ftgen    0, 0, 2^12, 10, 1 ; a sine wave

  instr 1; expon envelope
iEndVal  =        p4 ; variable 'iEndVal' retrieved from score
aEnv     expon    1, p3, iEndVal
aSig     poscil   aEnv, 500, giSine
         out      aSig
  endin

</CsInstruments>

<CsScore>
;p1  p2 p3 p4
i 1  0  1  0.001
i 1  1  1  0.000001
i 1  2  1  0.000000000000001
e
</CsScore>

</CsoundSynthesizer>

Note that expseg does not behave like linseg in that it will not hold its last final value if p3 exceeds its entire duration, instead it continues its curving trajectory in a manner similar to line (and expon). This could have dangerous results if used as an amplitude envelope.

Tenga en cuenta que expseg no se comporta como linseg en que no mantendrá su último valor final si p3 excede su duración entera, sino que continúa su trayectoria curvada de una manera similar a la línea (y expon). Esto podría tener resultados peligrosos si se usa como una envolvente de amplitud.

When dealing with notes with an indefinite duration at the time of initiation (such as midi activated notes or score activated notes with a negative p3 value), we do not have the option of using p3 in a meaningful way. Instead we can use one of Csound's envelopes that sense the ending of a note when it arrives and adjust their behaviour according to this. The opcodes in question are linenr, linsegr, expsegr, madsr, mxadsr and envlpxr. These opcodes wait until a held note is turned off before executing their final envelope segment. To facilitate this mechanism they extend the duration of the note so that this final envelope segment can complete.

Cuando se trata de notas con una duración indefinida en el momento de la iniciación (como las notas midi activadas o la puntuación activada notas con un valor p3 negativo), no tenemos la opción de usar p3 de una manera significativa. En su lugar, podemos usar uno de los sobres Csounds que detecte el final de una nota cuando llegue y ajustar su comportamiento de acuerdo a esto. Los opcodes en cuestión son linenr, linsegr, expsegr, madsr, mxadsr y envlpxr. Estos opcodes esperan hasta que una nota retenida se apague antes de ejecutar su segmento de envolvente final. Para facilitar este mecanismo se extiende la duración de la nota para que este segmento de la envoltura final pueda completarse.

The following example uses midi input (either hardware or virtual) to activate notes. The use of the linsegr envelope means that after the short attack stage lasting 0.1 seconds, the penultimate value of 1 will be held as long as the note is sustained but as soon as the note is released the note will be extended by 0.5 seconds in order to allow the final envelope segment to decay to zero.

El siguiente ejemplo utiliza la entrada midi (hardware o virtual) para activar las notas. El uso de la envolvente de linsegr significa que después de la etapa de ataque corto que dura 0,1 segundos, se mantendrá el penúltimo valor de 1 mientras la nota se mantenga, pero tan pronto como se libere la nota, la nota se extenderá 0,5 segundos en orden Para permitir que el segmento de envoltura final se desintegre hasta cero.

   EXAMPLE 05A08_linsegr.csd

 

<CsoundSynthesizer>

<CsOptions>
-odac -+rtmidi=virtual -M0
; activate real time audio and MIDI (virtual midi device)
</CsOptions>

<CsInstruments>
sr = 44100
ksmps = 32
nchnls = 1
0dbfs = 1

giSine   ftgen    0, 0, 2^12, 10, 1        ; a sine wave

  instr 1
icps     cpsmidi
;                 attack-|sustain-|-release
aEnv     linsegr  0, 0.01,  0.1,     0.5,0 ; envelope that senses note releases
aSig     poscil   aEnv, icps, giSine       ; audio oscillator
         out      aSig                     ; audio sent to output
  endin

</CsInstruments>

<CsScore>
f 0 240 ; csound performance for 4 minutes
e
</CsScore>

</CsoundSynthesizer>

Sometimes designing our envelope shape in a function table can provide us with shapes that are not possible using Csound's envelope generating opcodes. In this case the envelope can be read from the function table using an oscillator. If the oscillator is given a frequency of 1/p3 then it will read though the envelope just once across the duration of the note.

A veces, el diseño de nuestra forma de envolvente en una tabla de funciones nos puede proporcionar formas que no son posibles utilizando el envolvente Csounds que genera opcodes. En este caso, el sobre se puede leer desde la tabla de funciones utilizando un oscilador. Si al oscilador se le da una frecuencia de 1 / p3, entonces leerá el sobre sólo una vez a través de la duración de la nota.

The following example generates an amplitude envelope which uses the shape of the first half of a sine wave.

El ejemplo siguiente genera una envolvente de amplitud que utiliza la forma de la primera mitad de una onda sinusoidal.

   EXAMPLE 05A09_sine_env.csd 

<CsoundSynthesizer>

<CsOptions>
-odac ; activate real time sound output
</CsOptions>

<CsInstruments>
sr = 44100
ksmps = 32
nchnls = 1
0dbfs = 1

giSine   ftgen    0, 0, 2^12, 10, 1        ; a sine wave
giEnv    ftgen    0, 0, 2^12, 9, 0.5, 1, 0 ; envelope shape: a half sine

  instr 1
; read the envelope once during the note's duration:
aEnv     poscil   1, 1/p3, giEnv
aSig     poscil   aEnv, 500, giSine        ; audio oscillator
         out      aSig                     ; audio sent to output
  endin

</CsInstruments>

<CsScore>
; 7 notes, increasingly short
i 1 0 2
i 1 2 1
i 1 3 0.5
i 1 4 0.25
i 1 5 0.125
i 1 6 0.0625
i 1 7 0.03125
f 0 7.1
e
</CsScore>

</CsoundSynthesizer>

 

Comparison of the Standard Envelope Opcodes

 

Comparación de las Opcodes estándar de sobre

The precise shape of the envelope of a sound, whether that envelope refers to its amplitude, its pitch or any other parameter, can be incredibly subtle and our ears, in identifying and characterising sounds, are fantastically adept at sensing those subtleties. Csound's original envelope generating opcode linseg, whilst capable of emulating the envelope generators of vintage electronic synthesisers, may not produce convincing results in the emulation of acoustic instruments and natural sound. linseg has, since Csound's creation, been augmented with a number of other envelope generators whose usage is similar to that of linseg but whose output function is subtly different in shape.

La forma precisa de la envolvente de un sonido, ya sea que se refiera a su amplitud, su tono o cualquier otro parámetro, puede ser increíblemente sutil y nuestros oídos, al identificar y caracterizar los sonidos, son fantásticamente adeptos a detectar esas sutilezas. Csounds envolvente original que genera opcode linseg, aunque capaz de emular los generadores de envolvente de los sintetizadores electrónicos vintage, no puede producir resultados convincentes en la emulación de instrumentos acústicos y sonido natural. Linseg tiene, desde la creación de Csounds, aumentado con un número de otros generadores de envolvente cuyo uso es similar al de linseg pero cuya función de salida es sutilmente diferente en forma.

If we consider a basic envelope that ramps up across ¼ of the duration of a note, then sustains for ½ the durations of the and finally ramps down across the remaining ¼ duration of the note, we can implement this envelope using linseg thus:

Si consideramos una envolvente básica que sube a ¼ de la duración de una nota, entonces soporta durante ½ las duraciones de la y finalmente rampas hacia abajo a lo largo de la duración restante ¼ de la nota, podemos implementar este sobre usando linseg así:

kEnv linseg 0, p3/4, 0.9, p3/2, 0.9, p3/4, 0

The resulting envelope will look like this:

El sobre resultante se verá así:

 

The expseg opcode, introduced sometime after linseg, attempted to address the issue of dynamic response when mapping an envelope to amplitude. Two caveats exist in regard to the use of expseg: firstly a single expseg definition cannot cross from the positive domain to the negative domain (and vice versa), and secondly it cannot reach zero. This second caveat means that an amplitude envelope created using expseg cannot express 'silence' unless we remove the offset away form zero that the envelope employs. An envelope with similar input values to the linseg envelope above but created with expseg could use the following code:

El opcode expseg, introducido algún tiempo después de linseg, intentó abordar el problema de la respuesta dinámica al mapear un sobre a amplitud. Existen dos advertencias con respecto al uso de expseg: en primer lugar, una única definición de expseg no puede cruzar del dominio positivo al dominio negativo (y viceversa), y en segundo lugar no puede alcanzar cero. Esta segunda advertencia significa que una envolvente de amplitud creada usando expseg no puede expresar silencio a menos que quitemos el desplazamiento de la forma cero que el sobre emplea. Un sobre con valores de entrada similares a la sobre linseg anterior, pero creado con expseg podría utilizar el código siguiente:

kEnv expseg 0.001, p3/4, 0.901, p3/2, 0.901, p3/4, 0.001

kEnv = kEnv – 0.001

and would look like this:

Y se vería así:

 

In this example the offset above zero has been removed. This time we can see that the sound will build in a rather more natural and expressive way, however the change from crescendo to sustain is even more abrupt this time. Adding some lowpass filtering to the envelope signal can smooth these abrupt changes in direction. This could be done with, for example, the port opcode given a half-point value of 0.05.

En este ejemplo se ha eliminado el desplazamiento por encima de cero. Esta vez podemos ver que el sonido se construirá de una manera más natural y expresiva, sin embargo el cambio de crescendo a sostener es aún más abrupto esta vez. Añadir algunos filtros de paso bajo a la señal de envolvente puede suavizar estos cambios abruptos en la dirección. Esto podría hacerse con, por ejemplo, el opcode de puerto dado un valor de medio punto de 0,05.

kEnv port kEnv, 0.05

The resulting envelope looks like this:

El sobre resultante se ve así:

 

 

The changes to and from the sustain portion have clearly been improved but close examination of the end of the envelope reveals that the use of port has prevented the envelope from reaching zero. Extending the duration of the note or overlaying a second 'anti-click' envelope should obviate this issue.

Los cambios hacia y desde la parte de mantenimiento se han mejorado claramente, pero un examen detallado del final de la envoltura revela que el uso del puerto ha impedido que la envolvente alcance cero. Extender la duración de la nota o superponer un segundo sobre anti-clic debería evitar este problema.

xtratim 0.1

will extend the note by 1/10 of a second.

Extenderá la nota en 1/10 de segundo.

aRamp linseg 1, p3-0.1, 1, 0.1, 0

will provide a quick ramp down at the note conclusion if multiplied to the previously created envelope.

Proporcionará una rampa rápida hacia abajo en la conclusión de la nota si se multiplica al sobre creado anteriormente.

 

A more recently introduced alternative is the cosseg opcode which applies a cosine transfer function to each segment of the envelope. Using the following code:

Una alternativa más recientemente introducida es el opcode cosseg que aplica una función de transferencia de coseno a cada segmento de la envolvente. Utilizando el código siguiente:

kEnv cosseg 0, p3/4, 0.9, p3/2, 0.9, p3/4, 0

the resulting envelope will look like this:

El sobre resultante se verá así:

 

Another alternative that offers enhanced user control and that might in many situations provide more natural results is the transeg opcode. transeg allows us to specify the curvature of each segment but it should be noted that the curvature is dependent upon whether the segment is rising or falling. For example a positive curvature will result in a concave segment in a rising segment but a convex segment in a falling segment. The following code:

Otra alternativa que ofrece un mayor control de usuario y que en muchas situaciones puede proporcionar resultados más naturales es el opcode transeg. Transeg nos permite especificar la curvatura de cada segmento, pero debe señalarse que la curvatura depende de si el segmento está subiendo o bajando. Por ejemplo, una curvatura positiva dará como resultado un segmento cóncavo en un segmento ascendente, pero un segmento convexo en un segmento descendente. El código siguiente:

kEnv transeg 0, p3/4, -4, 0.9, p3/2, 0, 0.9, p3/4, -4, 0

will produce the following envelope:

Producirá el siguiente sobre:

This looks perhaps rather lopsided but in emulating acoustic instruments can actually produce more natural results. Considering an instrument such as a clarinet, it is in reality very difficult to fade a note in smoothly from silence. It is more likely that a note will 'start' slightly abruptly in spite of the player's efforts. This aspect is well represented by the attack portion of the envelope above. When the note is stopped, its amplitude will decay quickly and exponentially as reflected in the envelope also. Similar attack and release characteristics can be observed in the slight pitch envelopes expressed by wind instruments.

Esto parece quizá más bien desequilibrado, pero en la emulación de instrumentos acústicos en realidad puede producir resultados más naturales. Considerando un instrumento como un clarinete, en realidad es muy difícil desvanecer una nota suavemente del silencio. Es más probable que una nota empiece ligeramente abruptamente a pesar de los esfuerzos de los jugadores. Este aspecto está bien representado por la porción de ataque del sobre anterior. Cuando la nota se detiene, su amplitud se descompondrá rápida y exponencialmente como se refleja en el sobre también. Características de ataque y liberación similares se pueden observar en los envolventes de paso leve expresados por instrumentos de viento.

 

lpshold, loopseg and looptseg - A Csound TB303

The next example introduces three of Csound's looping opcodes, lpshold, loopseg and looptseg.

El siguiente ejemplo introduce tres de Csounds looping opcodes, lpshold, loopseg y looptseg.

These opcodes generate envelopes which are looped at a rate corresponding to a defined frequency. What they each do could also be accomplished using the 'envelope from table' technique outlined in an earlier example but these opcodes provide the added convenience of encapsulating all the required code in one line without the need for phasors, tables and ftgens. Furthermore all of the input arguments for these opcodes can be modulated at k-rate.

Estos opcodes generan sobres que se enganchan a una velocidad correspondiente a una frecuencia definida. Lo que cada uno de ellos también se puede lograr utilizando la técnica de sobre de la tabla descrita en un ejemplo anterior, pero estos opcodes proporcionan la conveniencia adicional de encapsular todo el código requerido en una línea sin la necesidad de fasores, tablas y ftgens. Además, todos los argumentos de entrada para estos opcodes se pueden modular en k-rate.

lpshold generates an envelope in which each break point is held constant until a new break point is encountered. The resulting envelope will contain horizontal line segments. In our example this opcode will be used to generate the notes (as MIDI note numbers) for a looping bassline in the fashion of a Roland TB303. Because the duration of the entire envelope is wholly dependent upon the frequency with which the envelope repeats - in fact it is the reciprocal of the frequency – values for the durations of individual envelope segments are not defining times in seconds but instead represent proportions of the entire envelope duration. The values given for all these segments do not need to add up to any specific value as Csound rescales the proportionality according to the sum of all segment durations. You might find it convenient to contrive to have them all add up to 1, or to 100 – either is equally valid. The other looping envelope opcodes discussed here use the same method for defining segment durations.

Lpshold genera un sobre en el que cada punto de ruptura se mantiene constante hasta que se encuentra un nuevo punto de ruptura. El sobre resultante contendrá segmentos de línea horizontales. En nuestro ejemplo, este código de operación se utilizará para generar las notas (como números de notas MIDI) para una línea de bajo en bucle a la manera de un Roland TB303. Debido a que la duración de toda la envolvente depende totalmente de la frecuencia con la que se repite la envolvente -en realidad es el recíproco de la frecuencia- los valores para las duraciones de los segmentos de envolvente individuales no están definiendo tiempos en segundos sino que representan proporciones de la totalidad Duración del sobre. Los valores dados para todos estos segmentos no necesitan sumar un valor específico ya que Csound rescala la proporcionalidad de acuerdo con la suma de todas las duraciones de los segmentos. Puede resultarle conveniente hacer que todos ellos sumen 1, o 100 - o es igualmente válido. Los otros opcodes de envolvente de bucle descritos aquí usan el mismo método para definir duraciones de segmentos.

loopseg allows us to define a looping envelope with linear segments. In this example it is used to define the amplitude envelope for each individual note. Take note that whereas the lpshold envelope used to define the pitches of the melody repeats once per phrase, the amplitude envelope repeats once for each note of the melody, therefore its frequency is 16 times that of the melody envelope (there are 16 notes in our melodic phrase).

Loopseg nos permite definir un envolvente de bucle con segmentos lineales. En este ejemplo se utiliza para definir la envolvente de amplitud para cada nota individual. Tenga en cuenta que mientras que la envolvente de lpshold usada para definir los tonos de la melodía se repite una vez por frase, la envolvente de amplitud se repite una vez por cada nota de la melodía, por lo tanto su frecuencia es 16 veces la de la envolvente de melodía Melódico).

looptseg is an elaboration of loopseg in that is allows us to define the shape of each segment individually, whether that be convex, linear or concave. This aspect is defined using the 'type' parameters. A 'type' value of 0 denotes a linear segement, a positive value denotes a convex segment with higher positive values resulting in increasingly convex curves. Negative values denote concave segments with increasing negative values resulting in increasingly concave curves. In this example looptseg is used to define a filter envelope which, like the amplitude envelope, repeats for every note. The addition of the 'type' parameter allows us to modulate the sharpness of the decay of the filter envelope. This is a crucial element of the TB303 design.

Looptseg es una elaboración de loopseg en la que nos permite definir la forma de cada segmento individualmente, ya sea convexo, lineal o cóncavo. Este aspecto se define mediante los parámetros de tipo. Un valor de tipo de 0 denota un segmento lineal, un valor positivo denota un segmento convexo con valores positivos más altos dando lugar a curvas cada vez más convexas. Los valores negativos denotan segmentos cóncavos con valores negativos crecientes que dan lugar a curvas cada vez más cóncavas. En este ejemplo looptseg se utiliza para definir una envolvente de filtro que, al igual que la envolvente de amplitud, se repite para cada nota. La adición del parámetro de tipo nos permite modular la nitidez del decaimiento de la envolvente del filtro. Este es un elemento crucial del diseño TB303.

Other crucial features of this instrument, such as 'note on/off' and 'hold' for each step, are also implemented using lpshold.

Otras características cruciales de este instrumento, como la nota on / off y hold para cada paso, también se implementan usando lpshold.

A number of the input parameters of this example are modulated automatically using the randomi opcodes in order to keep it interesting. It is suggested that these modulations could be replaced by linkages to other controls such as CsoundQt widgets, FLTK widgets or MIDI controllers. Suggested ranges for each of these values are given in the .csd.

Un número de los parámetros de entrada de este ejemplo se modulan automáticamente usando los opcodes aleatorios para mantenerlo interesante. Se sugiere que estas modulaciones podrían ser reemplazadas por enlaces a otros controles como widgets CsoundQt, widgets FLTK o controladores MIDI. Los rangos sugeridos para cada uno de estos valores se dan en el .csd.

 

EXAMPLE 05A10_lpshold_loopseg.csd

<CsoundSynthesizer>
<CsOptions>
-odac ;activates real time sound output
</CsOptions>
<CsInstruments>
; Example by Iain McCurdy

sr = 44100
ksmps = 4
nchnls = 1
0dbfs = 1

seed 0; seed random number generators from system clock

  instr 1; Bassline instrument
kTempo    =            90          ; tempo in beats per minute
kCfBase   randomi      1,4, 0.2    ; base filter frequency (oct format)
kCfEnv    randomi      0,4,0.2     ; filter envelope depth
kRes      randomi      0.5,0.9,0.2 ; filter resonance
kVol      =            0.5         ; volume control
kDecay    randomi      -10,10,0.2  ; decay shape of the filter.
kWaveform =            0           ; oscillator waveform. 0=sawtooth 2=square
kDist     randomi      0,1,0.1     ; amount of distortion
kPhFreq   =            kTempo/240  ; freq. to repeat the entire phrase
kBtFreq   =            (kTempo)/15 ; frequency of each 1/16th note
; -- Envelopes with held segments  --
; The first value of each pair defines the relative duration of that segment,
; the second, the value itself.
; Note numbers (kNum) are defined as MIDI note numbers.
; Note On/Off (kOn) and hold (kHold) are defined as on/off switches, 1 or zero
;                    note:1      2     3     4     5     6     7     8
;                         9     10    11    12    13    14    15    16    0
kNum  lpshold kPhFreq, 0, 0,40,  1,42, 1,50, 1,49, 1,60, 1,54, 1,39, 1,40, \
                       1,46, 1,36, 1,40, 1,46, 1,50, 1,56, 1,44, 1,47,1
kOn   lpshold kPhFreq, 0, 0,1,   1,1,  1,1,  1,1,  1,1,  1,1,  1,0,  1,1,  \
                       1,1,  1,1,  1,1,  1,1,  1,1,  1,1,  1,0,  1,1,  1
kHold lpshold kPhFreq, 0, 0,0,   1,1,  1,1,  1,0,  1,0,  1,0,  1,0,  1,1,  \
                       1,0,  1,0,  1,1,  1,1,  1,1,  1,1,  1,0,  1,0,  1
kHold     vdel_k       kHold, 1/kBtFreq, 1 ; offset hold by 1/2 note duration
kNum      portk        kNum, (0.01*kHold)  ; apply portamento to pitch changes
                                           ; if note is not held: no portamento
kCps      =            cpsmidinn(kNum)     ; convert note number to cps
kOct      =            octcps(kCps)        ; convert cps to oct format
; amplitude envelope                  attack    sustain       decay  gap
kAmpEnv   loopseg      kBtFreq, 0, 0, 0,0.1, 1, 55/kTempo, 1, 0.1,0, 5/kTempo,0,0
kAmpEnv   =            (kHold=0?kAmpEnv:1)  ; if a held note, ignore envelope
kAmpEnv   port         kAmpEnv,0.001

; filter envelope
kCfOct    looptseg      kBtFreq,0,0,kCfBase+kCfEnv+kOct,kDecay,1,kCfBase+kOct
; if hold is off, use filter envelope, otherwise use steady state value:
kCfOct    =             (kHold=0?kCfOct:kCfBase+kOct)
kCfOct    limit        kCfOct, 4, 14 ; limit the cutoff frequency (oct format)
aSig      vco2         0.4, kCps, i(kWaveform)*2, 0.5 ; VCO-style oscillator
aFilt      lpf18        aSig, cpsoct(kCfOct), kRes, (kDist^2)*10 ; filter audio
aSig      balance       aFilt,aSig             ; balance levels
kOn       port         kOn, 0.006              ; smooth on/off switching
; audio sent to output, apply amp. envelope,
; volume control and note On/Off status
aAmpEnv   interp       kAmpEnv*kOn*kVol
          out          aSig * aAmpEnv
  endin

</CsInstruments>
<CsScore>
i 1 0 3600 ; instr 1 plays for 1 hour
e
</CsScore>
</CsoundSynthesizer>

Hopefully this final example has provided some idea as to the extend of parameters that can be controlled using envelopes and also an allusion to their importance in the generation of musical 'gesture'.

Esperemos que este último ejemplo haya proporcionado alguna idea en cuanto a la extensión de los parámetros que pueden ser controlados usando sobres y también una alusión a su importancia en la generación del gesto musical.


 

There has been error in communication with Booktype server. Not sure right now where is the problem.

You should refresh this page.