Franklin Hardesty's Logic Distortion. A Vellocet Software Release. Release Notes and Overview. Contents: 1. Preface 2. Parameters 3. A Short Treatise on Binary Operands and Number Storage 3.1 Boolean Logic 3.2 Bit Shifting 4. Programs (Extended Principles) 5. Conclusion 1. Preface This documentation covers the third Logic Distortion release, build date 23/9/2000. The first Logic Distortion release was withdrawn due to an issue with an over length default program name. The second release saw efficiency improvements. This version sees a number of minor issues resolved, together with this documentation and some simple preset programs to demonstrate to use and operation of the filter. Logic Distortion was conceived and implemented by Chris Arnold. Special thanks to Skot MacDonald for invaluable programming assistance and ideas for further functionality. Thanks also to Andrew Simper for ideas not yet implemented. Please forward comments to: chris.arnold@hcoa.maynick.com.au ...see conclusion. 2. Parameters This release of Logic Distortion uses the following parameters: Bitstream/Distance: This parameter acts as a constant coefficient to the bitwise operation. If certain operations are selected, this parameter changes to a bit shifting distance. eMagic Logic will always report the parameter name as "Bitstream." Dry Mix: This parameter controls the pass-through volume of the dry (unprocessed) signal. Wet Mix: Controls the level of the processed signal. Operation: This parameter controls the bitwise operation used to convolve the incoming audio signal with the bitstream or distance. Zero Correction: Prevents unsolicited clicking when shifting the bitstream parameter. 1-Streaming: This parameter allows the bitsream to be filled with 1s from left or right. Master Volume: Controls the overall volume of the mixed wet and dry signals. Specifications: Parameter Allowable Values Bitstream/Distance Bitstream: -32767 to 32768, represented as 0x8000 to 0x7FFF eMagic Logic allows (-)0x8000 to (+)0x8000 Distance: 0 to 16 Dry Mix -infinite dB to 0dB Wet Mix -infinite dB to 0dB Operation: XOR, AND, OR, Shift Left, Shift Right, Roll Left Zero-Correction On/Off 1-Streaming Off, From Left, From Right Master Volume -infinite dB to 0dB 3. A Short Treatise on Binary Operands and Number Storage In order to understand the operation of Logic Distortion, a cursory knowledge of boolean logic operations is required, along with a knowledge of the way that numbers are stored in a computer. 3.1 Boolean Logic The primitives of boolean logic are the two states: True and False. These are represented in a computer with the binary digits 0 and 1. The basic operations that can be applied to two variables of this primitive are: NOT, AND, OR and XOR (exclusive or). The NOT operation simply returns the opposite of the input: x NOT x ---------------- 0 1 1 0 The AND operation, or logical conjunction, returns true if both variables are true: x y x AND y --------------------- 0 0 0 0 1 0 1 0 0 1 1 1 The OR operation, or logical disjunction, returns true if either variable is true: x y x OR y --------------------- 0 0 0 0 1 1 1 0 1 1 1 1 XOR, or exclusive or, returns true if precisely one of the input variables is true: x y x XOR y --------------------- 0 0 0 0 1 1 1 0 1 1 1 0 These operations, when applied to a single boolean (true or false) variable, or pair of variables, are referred to as logical operations. These functions may also be applied across a series of boolean variables, and under these circumstances, the operations are referred to as bitwise operations, as they are applied bit by bit. Eg: take two small numbers, 5 and 12. In a computer, these numbers could be stored as: 0101, and 1100. The numbers that a computer stores and works with are usually 32 bits in length, and Logic Distortion deals with 16 bit numbers, but I will represent these examples as 4 bit numbers for simplification. If we wish to perform the calculation 5 XOR 12, we XOR the four bits of the number as individual pairs: 5: 0 1 0 1 12: 1 1 0 0 5 XOR 12: 0 XOR 1 = 1, 1 XOR 1 = 0, 0 XOR 0 = 0, 1 XOR 0 = 1 = 1 0 0 1 So the result of 6 XOR 12 is (binary)1001 = 9. You may notice that XOR, AND and OR have been included in Logic Distortion, but NOT hasn't. NOT hasn't been included as an operation because it is redundant. This will be discussed further in later sections. 3.2 Bit Shifting There are 3 bit shifting operations included in Logic Distortion. These are shift left, shift right, and roll left. These operations are fairly simple, and illustration is the easiest explanation: Take, again, the example of the number 5: 0101 binary. If we shift left by one bit, each individual bit is moved one place to the left, so 5 shifted left by one results in: 1010 = 10(decimal) (notice that a 0 is introduced into the rightmost bit and the datum that was in the leftmost place has been lost). If we then shift (binary)1010 left by one, we get 0100 = 4. Thus, by extension, 5 shifted left by one equals 10, and 5 shifted left by two bits equals 4. Similarly, shift right gives the results: 0101 shift right by 1 = 0010 0101 shift right by 2 = 0001 Roll left is slightly different. Where a shift left strips the leftmost bit and introduces a zero into the rightmost bit, roll left will take the value from the leftmost bit and introduce it into the rightmost bit, eg: 0101 roll left by 1 = 1010 0101 roll left by 2 = 0101. This symmetric example is probably not the best, so: 0011 roll left by 1 = 0110 0011 roll left by 2 = 1100 0011 roll left by 3 = 1001 0011 roll left by 4 = 0011 Notice that when we roll left by 4, which is the number of bits used to represent the number, we return back to what we started with. That's why there's no Shift Right in Logic Distortion, because the two operations are symmetrical. In the above example, roll left by 3 = roll right by 1. 3.3 Number Representation A concise explanation of the binary counting system is outside the scope of this document, but here's a quick look at how it works: Take, for example, the decimal number 623. This can be broken down into a sum of 3 parts: 623 = 6 * 10^2 (6 times 10 to the power of 2) = 6 * 100 = 600 + 2 * 10^1 = 2 * 10 = 20 + 3 * 10^0 = 3 * 1 = 3 = 600 + 20 + 3 = 623. The binary number system works the same way, but rather than working with powers of 10, we work with powers of 2 (as an electronic signal, or bit, has only 2 states: on or off). Eg: 1011 = 1 * 2^3 = 1 * 8 = 8 + 0 * 2^2 = 0 * 4 = 0 + 1 * 2^1 = 1 * 2 = 2 + 1 * 2^0 = 1 * 1 = 1 = 8 + 2 + 1 = 11. Through all my examples, I've illustrated examples of 4 bit numbers. Most current personal computers deal primarily with 32 bit numbers, and Logic Distortion operates on 16 bit numbers. Notice that the bitstream parameter reads as a string of four characters, ranging from 0 to 9, plus A,B,C,D,E,F. This is a hexadecimal representation (Hexadecimal works just like binary and decimal, only it works with powers of 16. We don't have digits for 10-15, so we use A-F). Hexadecimal translates to binary very naturally. If you translate each of the four digits into binary and put them end-to-end, you'll get the binary representation of the number, eg: (hex)9C3A: 9(hex) = 9 (decimal) = 1001 C(hex) = 12 (decimal) = 1100 3(hex) = 3 (decimal) = 0011 A(hex) = 10 (decimal) = 1010 Therefore (hex)9C3A = (binary)1001 1100 0011 1010 = (decimal)39994 So here's what Logic Distortion does: Logic Distortion reads every sample of your audio input and interprets it as a 16 bit number (most sound cards only output 16 bits per sample, so unless you're using a 24 bit or 32 bit sound card, Logic Distortion won't degrade your incoming signal. But seeing as the purpose of the whole exercise is to degrade your signal, this shouldn't be a hassle for most of you). Logic Distortion then does one of two things, depending on your operation: Using XOR,AND,OR: Logic Distortion applies the operation you have selected, with its two variables being the audio input and the number you've specified for your bitstream. Using Shift Left, Shift Right, Roll Left: Logic Distortion performs the type of shift you have selected, over a distance specified by the Distance parameter. But there's a catch, in terms of number storage. VST sends and accepts floating point numbers between the values of negative one and one. So far, we haven't seen how to represent a negative number (we haven't seen how to represent a floating point number, either, but that's not important for our understanding of Logic Distortion). We've only seen positive numbers, called unsigned numbers. Variables which can be positive or negative numbers are called signed numbers. Computers represent signed numbers by setting the most significant (leftmost) bit if the number is negative. So any binary number that starts with a 1 is negative, and any number that starts with a zero is positive. But it's not as simple as setting a flag, and using the remaining bits as an amplitude. Rather than explaining 2's compliment arithmetic, think of the number system in this range: hex unsigned dec. signed dec. signing bit 7FFF 32767 32767 0 . . . . . . . . . 0000 0 0 0 FFFF 65535 -1 1 . . . . . . . . . 8000 32768 -32768 1 Notice that the signed and unsigned number systems are equivalent until the signing bit becomes one. If you follow the trail upwards from one, you keep incrementing the number until it hits 7FFF, the last number before the signing bit is set. When you add one, you wrap back around to the other end of the number system and keep going until you overflow back to zero. So you can look at both the signed and unsigned number systems as cycles, with different overflow points. When a signed 16 bit number hits 32768, it overflows back to -32768, whereas an unsigned number will overflow to zero when it reaches 65536. Note that this is the behaviour for a 16-bit number. 4. Programs Here are some things to think about. A few programs have been included to demonstrate some of these behaviours. 1. Extensions from the basic principles of bitwise operations: Any number, x AND zero = zero, x AND one = x, x OR one = one, x OR zero = x, x AND x = x OR x = x, x XOR zero = x, x XOR one = NOT x, (the Inverter) x XOR x = zero. 2. Extending from x XOR one = NOT x, notice that XOR distortion with a positive input is constructive, that is, it adds noise. XOR distortion with a negative input is destructive - parts of the signal get clipped out. That's because we're adding the signal to its negative. Similarly, the positive and negative rectifiers work by setting the signing bit, either to zero (positive rectifier) or one (negative rectifier). 3. Notice: (binary)100 = 4 shifted left right by 1 = 010 = 2, shifted left right by 1 = 001 = 1. Every time we shift right by one, we divide by two (rounding down). Similarly , we multiply by two when shifting left. The -6dB program demonstrates this. +6dB is not demonstrated as clipping is inevitable. It is for this reason that shift right is not very interesting - your signal drops to zero very quickly, but the operation was included for completeness. 4. The major source of craziness when it comes to bit shifting and rolling stems from the nature of PCM audio signals. The least significant (rightmost) bit changes very regularly, as it is near the zero point. As you move further to the right, these bits change less often, so when a bit shift left or bit roll is performed, the frequency with which the signing bit changes starts to increase, so your output signal will jump from positive to negative much more regularly. That's why these operations have the habit of introducing a lot of high-frequency noise to the signal. 5. Conclusion Logic Distortion was not designed to be a studio-quality distortion filter, rather to employ a method of scrambling signals and introducing noise which didn't seem to have been used before. If you're like me, and have a taste for noise art (check out some Merzbow, Whitehouse, The Haters or 70s Controlled Bleeding if you're not familiar), I think (and hope) you'll enjoy working with Logic Distortion. Please let me know what you think. -Chris Arnold (chris.arnold@hcoa.maynick.com.au)