Previous Entry Share Next Entry
Bytebeat with feedback
x31eq
I've got the bytebeat bug!

The standard method is to use an expression and drive it with a ramp, so that losing the upper bits gives oscillation. I decided to use the inaudible bits to add some feedback to stop the repetition. This tends not to give an infinitely changing signal, but it does make the period longer. Here's an example, where the expression's simplified from the example at http://canonical.org/~kragen/bytebeat/

/*
 * A simpler crowd expression with shorter lines
 */
company(t){
    int a,b,c;
    a = t*2;
    b = t>>7;
    c = a+b&t>>7;
    return a^c;
}

/*
 * Feedback timebase
 */
main(){
    int i,x;
    for(i=0;;i++) {
        x = company(i);
        i += (x>>10)&7;
        putchar(x);
    }
}

You can put any bytebeat expression in the called function. There are two new parameters: the amount of shift and the mask. An &1 is the least destructive way of adding variation to a piece you like.

For even more variety, have the shift keep changing:
/*
 * A simpler crowd expression with shorter lines
 */
company(t){
    int a,b,c;
    a = t*2;
    b = t>>7;
    c = a+b&t>>7;
    return a^c;
}

/*
 * Feedback timebase
 */
main(){
    unsigned i,x;
    for(i=0;;i++) {
        x = company(i);
        i += (x>>(i>>16))&5;
        putchar(x);
    }
}

It can still get stuck for a bit but it gets kicked out of cycles. Travel down this path and you'll end up with one bytebeat expression feeding into another.
Tags:

?

Log in