clip — Rogne un signal à une limite prédéfinie.
Coupe un signal de taux-a à une limite prédéfinie, de manière « douce », en utilisant une méthode choisie parmi les trois possibles.
imeth -- choisit la méthode de coupure. La valeur par défaut est 0. Les méthodes sont :
0 = méthode de Bram de Jong (par défaut)
1 = coupure par sinus
2 = coupure par tanh
ilimit -- valeur limite
iarg (facultatif, 0.5 par défaut) -- lorsque imeth = 0, indique le point, compris entre 0 et 1, où la coupure commence. N'est pas utilisé si imeth = 1 ou 2. Sa valeur par défaut est 0.5.
asig -- signal de taux-a en entrée
La méthode de Bram de Jong (imeth = 0) applique l'algorithme (en notant ilimit comme limit et iarg comme a :
|x| >= 0 and |x| <= (limit*a): f(x) = f(x) |x| > (limit*a) and |x| <= limit: f(x) = sign(x) * (limit*a+(x-limit*a)/(1+((x-limit*a)/(limit*(1-a)))2)) |x| > limit: f(x) = sign(x) * (limit*(1+a))/2
La seconde méthode (imeth = 1) est la coupure par sinus :
|x| < limit: f(x) = limit * sin(π*x/(2*limit)), |x| >= limit: f(x) = limit * sign(x)
La troisème méthode (imeth = 2) est la coupure par tanh :
|x| < limit: f(x) = limit * tanh(x/limit)/tanh(1), |x| >= limit: f(x) = limit * sign(x)
![]() |
Note |
---|---|
Il semble que la méthode 1 n'était pas fonctionnelle dans la version 4.07 de Csound. |
Voici un exemple de l'opcode clip. Il utilise le fichier clip.csd.
Exemple 84. Exemple de l'opcode clip.
Voir les sections Audio en Temps Réel et Options de la Ligne de Commande pour plus d'information sur l'utilisation des options de la ligne de commande.
<CsoundSynthesizer> <CsOptions> ; Audio out Audio in No messages -odac -iadc -d ;;;RT audio I/O ; -o clip.wav -W ;;; for file output any platform </CsOptions> <CsInstruments> ; Initialize the global variables. sr = 44100 ksmps = 10 nchnls = 1 ; Instrument #1. instr 1 ; Generate a noisy waveform. arnd rand 44100 ; Clip the noisy waveform's amplitude to 20,000 a1 clip arnd, 2, 20000 out a1 endin ; Instrument #2. instr 2 ; Generate a noisy waveform. arnd rand 44100 ; Clip the noisy waveform's amplitude to 10,000 a1 clip arnd, 2, 10000 out a1 endin </CsInstruments> <CsScore> ; Play Instrument #1 for one second. i 1 0 1 ; Play Instrument #2 for one second. i 2 1 1 e </CsScore> </CsoundSynthesizer>