Csound Csound-dev Csound-tekno Search About

[Csnd] variable waveshaping

Date2013-09-13 22:03
Fromluis jure
Subject[Csnd] variable waveshaping
to "compand" a signal i'm waveshaping the input with the table opcode and
a hyperbolic tangent function. 

by trial and error i found that a table with these values gives the kind
of results i want:

f1 0 32768 "tanh" -3.5 3.5 0  (i don't want too much distortion)

now i'm looking for a way to do the same but controlling the level of
distortion at k-rate. i found some opcodes like compress, distort,
distort1 and powershape, but i haven't been able to find the proper values
to get the same results as with the table above.

distort is simple and looked very promising for what i want to do. but i'm
either too optimistic about what to expect from the opcode, or it has
some important issues.

any ideas how could i get the effect i'm looking for? perhaps with a
formula with a k-rate factor? i'm afraid i'm not strong at the math...

thanks,


lj

Date2013-09-13 22:22
FromVictor Lazzarini
SubjectRe: [Csnd] variable waveshaping
Generally speaking, the higher the amplitude of the signal going into the waveshaper,
the more distortion. What you can try to do is to create a normalising table with GEN 4
http://www.csounds.com/manual/html/GEN04.html
and then use it to normalise the signal as you change the input signal amplitude
to vary the amount of distortion. That's how variable-spectrum 
waveshaping instruments are implemented.

Victor

On 13 Sep 2013, at 22:03, luis jure wrote:

> 
> to "compand" a signal i'm waveshaping the input with the table opcode and
> a hyperbolic tangent function. 
> 
> by trial and error i found that a table with these values gives the kind
> of results i want:
> 
> f1 0 32768 "tanh" -3.5 3.5 0  (i don't want too much distortion)
> 
> now i'm looking for a way to do the same but controlling the level of
> distortion at k-rate. i found some opcodes like compress, distort,
> distort1 and powershape, but i haven't been able to find the proper values
> to get the same results as with the table above.
> 
> distort is simple and looked very promising for what i want to do. but i'm
> either too optimistic about what to expect from the opcode, or it has
> some important issues.
> 
> any ideas how could i get the effect i'm looking for? perhaps with a
> formula with a k-rate factor? i'm afraid i'm not strong at the math...
> 
> thanks,
> 
> 
> lj
> 
> 
> Send bugs reports to the Sourceforge bug trackers
> csound6:
>            https://sourceforge.net/p/csound/tickets/
> csound5:
>            https://sourceforge.net/p/csound/bugs/
> Discussions of bugs and features can be posted here
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"
> 
> 

Dr Victor Lazzarini
Senior Lecturer
Dept. of Music
NUI Maynooth Ireland
tel.: +353 1 708 3545
Victor dot Lazzarini AT nuim dot ie





Date2013-09-14 00:20
Fromluis jure
SubjectRe: [Csnd] variable waveshaping
AttachmentsNone  var_ws.csd  

Date2013-09-14 00:39
FromVictor Lazzarini
SubjectRe: [Csnd] variable waveshaping
Attachmentswshape2.csd  
What about this one? It uses the method I suggested.
(you can play it safely ;)





On 14 Sep 2013, at 00:20, luis jure wrote:

> 
> 
> i think i found a way to get exactly what i want, please see the attached
> orchestra.
> 
> DO NOT SEND TO -odac !!! 
> 
> the orchestra is just to look at the waveform in an audio editor, to check
> that for a linear input, the output goes from linear to distorted depending
> on kdist.
> 
> 
> 
> 
> Send bugs reports to the Sourceforge bug trackers
> csound6:
>            https://sourceforge.net/p/csound/tickets/
> csound5:
>            https://sourceforge.net/p/csound/bugs/
> Discussions of bugs and features can be posted here
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"
> 
> 
> 

Dr Victor Lazzarini
Senior Lecturer
Dept. of Music
NUI Maynooth Ireland
tel.: +353 1 708 3545
Victor dot Lazzarini AT nuim dot ie




Date2013-09-14 13:44
Fromluis jure
SubjectRe: [Csnd] variable waveshaping
AttachmentsNone  varws_udo.csd  

Date2013-09-14 15:44
Fromluis jure
SubjectRe: [Csnd] variable waveshaping
on 2013-09-14 at 09:44 luis jure wrote:

> i attach the new version. 

ugh, yet another bug in the UDO...

here is the correct version...


	opcode	varws, a, aki

; requires audio input normalized to 1
; works best with tanh or sigmoid transfer tables
; 0 < kist <= 1

ain, kdist, ifn	xin
kscale	table	kdist*.5, ifn, 1, .5
adist	table	ain*kdist*.5, ifn, 1, .5
	xout	adist/kscale

	endop