Tuesday, December 18, 2007

Bitwise.rhythm generator

I have been working on a rhythm generator that uses simple bitwise logic to create drum patterns.

The program accepts two 16-bit unsigned integers (represented by a high byte and a low byte). These two integers are labeled input A and input B. These sixteen bits are represented by toggles that are either on (for high or 1) or off (for low or 0).

Eight logic gates exist that take the current input states of A and B and perform a bitwise manipulation on the numbers. The resulting calculation is also represented by toggles as part of the gate. The computer reads through the sixteen bits of each gate in a step-by-step fashion, and generates a MIDI note where a high (1) bit is located. Additionally, each gate can be assigned a whole note divisor (currently limited 1/4 notes, 1/8 notes, 1/16 notes and 1/32 notes). This will be updated soon to include triplets.

The note pitch and velocity for each bit can be assigned by the user. Whenever A and B are updated, the entire gate array is also automatically updated.

The following bit manipulations are allowed:
  • 0: set all bits to off (effectively mutes that gate)
  • 1: set all bits to on
  • A: set to the bits that make up A
  • B: set to the bits that make up B
  • NOT A: set to the bitwise inversion of A
  • NOT B: set to the bitwise inversion of B
  • A AND B: if the A and B bits are both high, set high else low
  • A OR B: if the A or B bits are high, set high else low
  • A NAND B: if the A and B bits are both high, set low else high
  • A NOR B: if the A or B bits are high, set low else high
  • A XOR B: if the A bit is the opposite of the B bit, set high else low
  • A XNOR B: if the A bit is the opposite of B bit, set low else high

0 comments: