Sunday, July 24, 2016

MIDI Variable Length Value Code

I added a Type 1 MIDI export function to my sequencer software today, so I thought I'd post the MIDI delta time code I used as I couldn't find any other code snippets online.

lword tempstore[4], tempstorecounter, i, deltatime, trackbuffersize;
char trackbuffer[];
.
.
.
// This will convert a long word time variable in deltatime into variable bit rate MIDI delta time
// format, storing it as a string of chars in "trackbuffer"
// tempstore is used to invert the significance of the bits, as the MBS's need to come first

for (tempstorecounter=0; deltatime>127; deltatime=(deltatime>>7))
tempstore[tempstorecounter++]=(char)(deltatime&0x7f);
tempstore[tempstorecounter++]=deltatime;
for (i=0; i<tempstorecounter; i++)
{
if (i<tempstorecounter-1)
trackbuffer[trackbuffersize++]=(char)(0x80|tempstore[tempstorecounter-1-i]);
else
trackbuffer[trackbuffersize++]=(char)tempstore[tempstorecounter-1-i];
}

Wednesday, July 06, 2016

A Free Will of Infinite Possibility

Free will is our ability to imagine any possible future, even though we are destined to enact only the one that was always fated. It is the barrier between these states that causes all of our agonies.

The mind-body gap, the gap between the real world and our thoughts, is the gap between the certainty of the universe and fate and the uncertainty, the infinite possibility of the imagination. If time is a dimension then the future is necessarily as firm as the past, and destiny is certain, but we can think anything that we do not enact. It is this very freedom, akin to a quantum state of flux that gives us the illusion of freewill.

The very moment when our thoughts are read by our perception then, those thoughts snap into reality, but before this our thoughts are free to conceptualise anything. This is pure freedom versus containment on one level. Perhaps at that point, the ball is already rolling and fate will create a pattern of thought and argument that will end with an inevitable action on the world, but crucially, there is a point where infinite possibility exists, or at least a fluid potential that is not a definite and certain action. This is freedom, and the barrier between this free state and a future certain state marks the boundary between free-will and fate.

In emotional terms, I suspect that wrestling with this barrier, which much surely be an organic, evolving and fluid, psychological membrane, is the root of human distress.