[Tool]Bytebeat

bytebeat

Worried about that background music eats all of your precious ROM and there is nothing left for the game? Bytebeat comes to rescue :wink: It is generated music based on an algorithm, which normally is an one liner!

The function which generates the music is on screen:
((t<<1)^((t<<1)+(t>>7)&t>>12))|t>>(4-(1^7&(t>>19)))|t>>7

9 Likes

Thats another badge for you for a cool trick!

2 Likes

How did you pick the function?
Did you just choose random bit operations to use or is there some method to the madness?

I bet an LSFR or LCG would produce interesting results :P

@Hanski Source code please!!

1 Like

Released, ā€œByteBeat3ā€. https://os.mbed.com/teams/Pokitto-Community-Team/code/ByteBeat3/

Btw. I accidentally created a library called ā€œByteBeatā€, but I cannot remove it. It can be deleted.

I have not invented that function. It is from http://canonical.org/~kragen/bytebeat/ .

Here is some theoretical background: http://countercomplex.blogspot.fi/2011/10/algorithmic-symphonies-from-one-line-of.html

1 Like

A bit of a long read but seeing it visualised makes more sense.
The bit about the pitch shifting with multiplication makes sense.
I think itā€™s probably either a mixture of knowing what some of the operations do and then just trying different numbers or the people doing it know about sound.

1 Like

Its a really useful technique, Iā€™m surprised I havenā€™t seen it being used more often. Iā€™ve been using it in an Arduboy game Iā€™m making.

	   playChiptune([](uint16_t t){
		   return t>>5|t>>6|t>>1;
	       });
1 Like

Sorry to resurrect this, but @uXe recently showed me this useful website for testing bytebeat music:

http://wurstcaptures.untergrund.net/music/

Iā€™m not quite sure how much it correlates to what the Pokitto outputs,
but it seems quite handy if itā€™s relatively close.

2 Likes

Glad you resurrected this, this freaking blows my mind! I have to read how it works. (Once Iā€™ve been trying to create procedural music too, but on a MIDI level, not soundwave.)

EDIT: That whole website looks awesome.

EDIT2: Alright, goes to my favorites :smiley:

1 Like

Thereā€™s an academic paper (!) you could read about it:

https://arxiv.org/abs/1112.1368

2 Likes

You can hear bytebeat music in my Mars Attack game for Pokitto :slight_smile:

2 Likes

How is it with bytebeat copyright? Such small code canā€™t possibly be copyrighted, but the emerging result is a quite big piece of art and a lot of effort goes into its creationā€¦ so? Iā€™ve seen some licensed CC-BY, but I donā€™t know if all of these shouldnā€™t be public domain, just like mathematical formulas. Actually this is nothing but mathematical formulas to me, so I think the result falls under copyright, but not the code. Do you people agree?

Itā€™s a grey area because while functional formulas canā€™t be copyrighted, things that require a degree of creativity can be, and obviously music crosses the border into the realm of creativity.
And of course code can by copyrighted and patented,
so thereā€™s a grey area of where to draw the line between maths and code.

1 Like

You might want to have a look at the superformula for a parallel (used for generating images instead of music, covered by a patent).

1 Like

Patents are a different thing, these can be applied to all kinds of small formulas, but they also have to be explicitly registered and have to go through some manual approvals etc. But this issue definitely covers similar algorithms for visual art etc.

I agree itā€™s probably a very grey area, but my honest believe is that the formulas canā€™t fall under copyright, even if they require or spawn creativity ā€“ these are both true about mathematical formulas as well. You can probably claim copyright on the resulting sound wave that you generate yourself using your own computer from this formula, but effectively anyone else can do the same and itā€™s unprovable whether youā€™ve ā€œstolenā€ (copied) such music or generated it yourself, so in the result the final music is practically uncopyrightable as well.

Oh well, another copyright headache is coming :slight_smile:

Has anyone came up with some ā€˜niceā€™ tunes using this method, Iā€™m hoping to use this to add something to Sensitive, but everything I try just sounds like a room full alarm clocks.

[edit]

This sounds good, but I have no idea how to convert it from javascript to cā€¦

(3e3/(y=t&16383)&1)*35+(x=t*"6689"[t>>16&3]/24&127)*y/4e4+((t>>8^t>>10|t>>14|x)&63)

Anyone able to do this?

1 Like

Supposing this takes one of the chars (a 8-bit or 16-bit value?) of ā€œ6689ā€ depending on the value of t. So the char array index [t>>16&3] is always between 0 and 3.

No idea why exactly ā€œ6689ā€ was used?!

1 Like

If you extend the song generation, youā€™ll hear this is a loop of 4 parts, 2 identical ones then 2 different ones after and that seems to match this pattern

1 Like

Need more info:

  • What size are t, x and y? 32-bit? 64-bit?
  • Are they signed, unsigned?
  • What is the type of the result?
  • Is ^ xor or pow in this context?
  • The use of floats is an odd choice, does the behaviour change if you exchange them for their integer equivalents? (3e3 -> 3,000, 4e4 -> 40,000)
  • What were you using to test these? Are you sure it was JavaScript?