This is my first post here! I'm beginning with chuck and would like to add some distorsion to sounds, what's the best way to do it? I've seen GenX functions in the last version, but there's much hardcore math in it... any example or advice ?

after this, try changing signal's gain and freq.
gain from around 0.4 up will definitely show off some warm overdrive.
the more gain, the more distortion it gets.
With lots of gain, you'll get lots of harmonics out of a simple input signal.

You can replace the overdrive with TriOsc, SqrOsc (or even a SawOsc!)
and hear different kinds of overdrive / clipping..
(but most'd not sound as smooth as SinOsc..
TriOsc is interesting, it can produce a trianglish harmonics heheh)

This is one fast idea I want you to try out.
There are a number of methods left.
I still haven't implemented a lot.

Glad you enjoy one of my simple method.
That sine waveshaper is one of my favourite warm overdrive sound,
but it can sound too complex sometimes..
especially with high gains..

There is also another method,
but require longer code:
Using a shred to continuously calculating value of the waveshaping transfer function.
This can burn a lot more CPU power,
but you have more freedom to choose the function you'd like to use.

These are two quite-short code for applying Sine waveshaping and Atan waveshaping.
These two are my favourites.
It has a warm kinda character..
it reminds me of Tube drive or something
but I don't know about theory.

Like in trigonometry? sin, cos and tan? ChucK has one but it's expensive on the cpu to calculate that every sample. I seem to remember that tan(x) = sin(x) / cos(x) and that would be doable using Kijjaz's trick of using a oscilator as a lookup table and with a "gain" sety to devide.... I'll look into that, thanks!_________________Kassen

This (on Wikipedia) seems quite an interesting optimization.
But never tried Tanh myself.
I like the soft clipping sound of atan.
- - -

Blue Hell:

Yes.
I've used Tan for distortion.
but we can noticed that Tan can yeild very big values..
so it's not usually appropriate for straight connect to dac.

Waveshaping it in someway, or using it to modulate other signals seems to be safer.
(But I still insist you all hear out that destructive clipping created by sending Tan waveshaped signal to DAC hahahahah!)
- - -

There's an easy way to achive tan with ChucK's UGens
It's by dividing a sin with a cos of the same input.

In distortion you want low-level input to be basically unchanged, but higher amplitude values should be "squished" lower. So the transfer function should have an s-curve, with a higher slope in the center and lower at the edges.

The normal trigonometric tangent has an infinite slope at pi * x where x is 2*i + 0.5, so it's not a good candidate for classic distortion (though it may be good for other outrageous sounds).

Graphed in SuperCollider, tanh looks like this, ranging from -1.0 to +1.0.

I can't claim credit, of course -- I just looked at the source code for the .distort primitive. But I agree, it's simple and elegant and sounds good. I use it routinely when I need a little grit in the sound.

I had sent you an email about this through the board a couple of days ago, but I have no way of knowing whether you received it, so I thought I'd ask here.

I implemented your distortion algorithms, as well as the SC one, in a system called Jesusonic, which is part of the Reaper DAW. However, before releasing my little JS plug-in on the world (under the GPL), I wanted to get your permission to use your derived functions, as well as find out how you want to be credited.

I look forward to hearing back from you. Thanks!

Here's what the Jesusonic script looks like, if you're curious:

Code:

// Tristortion
//
// This is an implementation of f(x) = x/(1+|x|), f(x) = x^3 / (1 + |x^3|),
// and f(x) = x/(1+x^2) as distortion algorithms. The first is courtesy of
// SuperCollider. The second and third are courtesy of Kijjaz from the ChucK
// forums on electromusic.com.
//
// (C) 2007 Darren Landrum
// Licensed under the GNU General Public License, Version 2.
// Uses algos from Kijjaz of the ChucK forums, and Supercollider.

"Never be afraid to try something new. Remember that a lone amateur built the Ark. A large group of professionals built the Titanic." - Dave BarryLast edited by Consul on Thu Aug 30, 2007 5:54 am; edited 2 times in total

NOTE: This is NOT what the code looks like! For some reason, this board is parsing out and removing pieces of the code, which means copying and pasting this into Jesusonic would NOT WORK! However, the algorithms did survive just fine, so you can at least see how I did it.

Most likely you accidentally didn't tick the box to disable HTML. If you don't the board will think it's HTML as soon as it sees triangular brackets, even within the CODE tag. This is a known bug._________________Kassen

Kassen, thank for the tip. I'm not used to phpBB ever being configured to allow HTML, so I never thought of this one. It's fixed now. I also fixed the misspelling of Kijjaz's name.

Kijjaz,

I don't understand completely, but it sounds like you're asking me NOT to release this. If that's the case, I'll remove the second two algos and just go with the SC one, since that's GPL IIRC. Really, I just did this for the learning experience, and to get my feet wet with Jesusonic. It's also still quite beta, and has some behaviors I'd like to fix, but don't quite know how.

There are some really talented DSP guys on the Reaper boards. If I release this over there, they can comment further on things, including maybe how I can do better scaling of the input slider._________________Darren Landrum

"Never be afraid to try something new. Remember that a lone amateur built the Ark. A large group of professionals built the Titanic." - Dave Barry

Sorry for the triple-in-a-row post, but I'm afraid the Kijjaz algorithms didn't work out for now. They were soaking up about 28% of mine and others' CPU, which is outrageously high. Until I can sort that out, I'm back to the good old SC one, which maxes out at 2%. It's now called Compstortion.

I still give you credit for the inspiration. _________________Darren Landrum

"Never be afraid to try something new. Remember that a lone amateur built the Ark. A large group of professionals built the Titanic." - Dave Barry

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot vote in polls in this forumYou cannot attach files in this forumYou can download files in this forum

Please support our site. If you click through and buy from our affiliate partners, we earn a small commission.