Code module proof of concept

I’m not much of a coder, but I know enough to tell an ai assistant what to do. I got a byte beat proof of concept running in the new code module.


Here is the code if you want to try it out:

#persample


// Speed controls the fundamental pitch feel

speed = param(value, Speed)

rate = 1 + floor(speed * 63) // 1 to 64x increment


t = t + rate

t = t > 1000000 ? 0 : t


tf = floor(t)


// --- Voice 1 ---

a = mod(tf, 64)

b = mod(floor(t / 32), 64)

c = mod(floor(t / 8), 64)

v1 = a + b + c


// --- Voice 2 ---

// Tune knob shifts voice 2 to a different harmonic relationship

tune = param(value, Tune)

tdiv = 2 + floor(tune * 14) // divisor 2 to 16


d = mod(floor(t / tdiv), 64)

e = mod(floor(t / (tdiv * 4)), 64)

f = mod(floor(t / (tdiv * 8)), 64)

v2 = d + e + f


// --- Mix ---

mix = param(value, Mix)

s = v1 * (1 - mix) + v2 * mix


// Normalize to -1 to 1

s = mod(s, 256)

s = (s / 128) - 1


output(s, audio)

Comments

  • edited March 22

    That is great. You could do a if/else ladder to have a parameter (“index”) select different formulas. Something like this (say N is number of formulas):

    index=param(value, index)

    N=3

    if (index<1/N) { out=formula1 } else {

    if (index<2/N) { out=formula2 } else {

    if (index<3/N) { out=formula3 }}}

    output(out,audio)


    (last one would not need a comparison by exclusion but you get the idea)

  • I’m working on another code module thing that uses a lot of data baked into the code. It is unclear to me if there is some kind of max length or complexity with these things. All the examples are pretty small.


    if anyone is trying to take new formulas to use, be aware that the code modules don’t have the bitwise operators that are the main thing in byte beat recipes. This example uses regular mod expressions to fake it.

  • Another one lost into the bytebeat rabbit hole. Let’s share a moment of silence 🫡

  • But seriously @zachthms I dug into that rabbit hole (again), a few months ago, and did a version with 60 formulas, for a different project

    your mod approach is the way to go, since there’s no bitwise operations you can decompose those into multiplication/division by powers of 2, etc

    I might have to revisit this project if nothing for the brain tease

  • t*("000000=0?0F000F0D000000?0?0D000D0B0A0?0=0?0B000D0A0?0=000=0D000B00000000?0?0F000F0D000000?0?0K000A0B0?000?0?0B000D0A000=000=0D0F0D".charCodeAt(t>>10&127)-48)


    guess the melody

  • “never gonna give you up” - rick astley

  • Oh man, did we just get Rick-Rolled in the code module?

    lol@aardvark 👊

Sign In or Register to comment.