Friday, March 25, 2011

Two important C# code snippets

Hi everyone!
And this time especially the AX-team of our little contest!

Here are the two last APXD-snippets in C# :

Converting from a String like '10001000' to an int (this would be 136):

int getint(String bin) {
  int result = 0;
  for(int i = 0; i< 8; i++){
   if(bin[i] == '1'){
    result +=(int) Math.Pow (2,7-i);
  return result;

Converting from an int like 136 to the binary-String:

String getbin(int input) {
   String result = "";
   int ax;
   for (int i = 0; i < 8; i++) {
    ax = (int)Math.Pow(2, 7 - i);
    if (input >= ax) {
     result += "1";
     input -=ax;
    else {
     result += "0";
  return result;

That's all for the moment!
Have a good weekend!


Monday, March 7, 2011

Overdrive and distortion


Whilst doing audio stuff, at some point I got to the point, where I wanted to modify the sound of my instrument.
There are two mayor types of distorting an instrument: overdrive and distortion.

Overdrive is the older sound.
Back when there were people building amplifiers out of glass valves and operating with high voltages,
the amplifiers couldn't handle all the voltages over the input range.
This meant, starting at a certain point, the signal would start to clip.
Add some harmonic signals and some white noise,
which both are characteristic for tube amplifiers, and you get overdrive.
Personally, I don't really like overdrive.
It sounds too dirty and noisy,
but in some settings and genres like hard rock, it sounds really great.
The easiest way to get a mean overdrive this days is to use opamps.
Simply configure one as a non-inverting-amplifier with rather high amplification factor and use high input voltages.
For best retro-sound, use a JFET one (as the TL072). But even the LM324 will work.
Here is a schematic for an overdrive with an opamp per channel:

And this is, how the signal looks like:

Now to the other possibility of generating a sound effect by simply clipping it: distortion.
Distortion means that you generate the clipping effect in a much more controllable way, means by diodes.
Diodes have a U/I curve with a kink at normally around 0.8V. This means, they start leading when signals higher than this kink are applied.
An easy way to use this kink for distortion is the following schematic:
And again an example of the waveform.

In this example, I wanted very strong distortion.
With the distortion-type distortion (not the overdrive one), there is an easier approach to this.
Just use the opamp as an schmitt-trigger:

Notice the small difference in the waveform, compared to the solution with the diode:

This was my small walkthrough through these kinds of distortion systems.
Thank you for reading and until next time!