Music is Math – Create a procedural chiptune in 5 lines of C#
What does (t * 5 & t >> 7) | (t * 3 & t >> 10) sound like?
I added Music to my game with 1 C# file consisting of a single small function & swappable sample function. I wanted to show it to you guys!
void OnAudioFilterRead(float[] data, int channels)
{
for (var i = 0; i < data.Length; i = i + channels)
data[i] = data[i] + (float)(Gain * (SampleFunction1(t++)%256)/256f);
}
int SampleFunction1(int t) { return (t * 5 & t >> 7) | (t * 3 & t >> 10); }
Inspiration from here: