HTML5 Audio Experiments and the Future of the Internet

I have just finished reading the “Experiments with audio” blog post collection by David Humphrey. I must say I am pretty impressed by what has been achieved in such a short time.

I am sure that there are many people out there who would be interested in accessing the raw data APIs for HTML5 audio to directly modify and generate graphics for the music, up until now something that could only be done with technologies such as Flash.

This may well be another step forward for the open web and will certainly expand the usefulness of the HTML5 audio and video tags. I am looking forward to seeing how this develops. This should also hold benefits for other people, even those who are not interested directly in the technology since this and other such APIs should push forward the performance improvements of JavaScript on the internet since the graphic and processing engines are entirely written in JavaScript.

Good work guys!

Microsoft’s and a Lack of Documentation

Today I have been working on the operating system identification engine for CSIT. However. I have been quite frustrated by Mirosoft’s lack of documentation for some items. I have been using the GetProductInfo function call via pinvoke from C#. After digging around in the WinNT.h header file that came with Visual Studio I found the definitions for the product versions that can be returned.

However, to my disappointment some of them are complete undocumented by Microsoft! Items such as these:

#define PRODUCT_SB_SOLUTION_SERVER_EM               0x00000036
#define PRODUCT_SERVER_FOR_SB_SOLUTIONS_EM          0x00000037

… have absolutely no definition, anywhere. Without a definition I cannot use these and so they are totally useless. I ask you Microsoft, why do you include definitions but fail to provide an exploitation of what they are? They must mean something but what that is, I have no idea until Microsoft choose to update their documentation.

Hopefully someone from Microsoft with the power to change this will read this post and do something about it. But if anyone has any idea what these keys mean and have a reference somewhere – please let me know!

CSIT Update

Hi everyone!

I am pleased to report that I have finally made some decent progress with CSIT. I now have the pinvoke links completed and functioning, I can also get access to the features that a CPU supports as well as information about the caches and other information about the CPU – yay!

Below is a screenshot showing some of the information that I have succeeded in extracting from the deep code calls.

CSIT Information Screen v0.1

Looks simple doesn’t it? Well. You probably wouldn’t believe it but the framework code written to reach this point has just passed four thousand lines!

If anyone has any comments or suggestions about other features that should be included or improved then please let me know! However please note that this is nowhere near completed and these are just testing features. I have lots more planned yet!

First Code Snippet – Simple Hertz and Bytes Converters (C#)

Hi everyone!

These are my first code snippets. These were written as part of my CSIT project and are used to convert sizes and frequencies easily from one type to another. First lets look at the byte conversion function.

[cc lang=”c#”]
public enum ByteUnits : int
{
B,
kB,
MB,
GB,
TB,
PB
}

public static string Bytes2Size(double value, ByteUnits fromType = ByteUnits.B)
{
// If the bytes are 0 then we can logically go no further.
if (value == 0)
{
return “0 B”;
}

// First we need to convert the value back into the smallest unit.
double from = (value * Math.Pow(1024, (double)fromType));

// This will give us the index of the best size to use.
double exponent = Math.Floor(Math.Log(from) / Math.Log(1024));

// Return the processed value.
return (from / Math.Pow(1024, exponent)).ToString(“n2″) + ” ” + Enum.GetName(typeof(ByteUnits), (int)exponent);
}
[/cc]

As you can see the code above is relatively simple. Here is a a basic description of the process:

  1. lines 9 – 11 do a check to ensure that no 0’s fall into the function. Since, if they did, it would break the result.
  2. Line 15 converts the original value into the most basic unit that this type supports. In the case of the example above it converts the value back into bytes.
  3. Line 18 gathers the exponent. This will represent the index of the enumeration that the value should be converted into (basically anyway).
  4. Line 21 converts the value and then adds the symbol thanks to some .NET magic, then returns the result.

As you can see, these are pretty simple. They just contain the sets of units to be used in the conversions. One of the best features of this approach is that you simply need to add the symbol for the next unit to be able to translate to that higher unit. Simple no? I also promised you a version of the above function that converts the hertz unit – so here it is.

[cc lang=”c#”]
public enum HertzUnits : int
{
Hz,
KHz,
MHz,
GHz,
THz,
PHz
}

public static string Hertz2Frequency(double value, HertzUnits fromType = HertzUnits.Hz)
{
// If the bytes are 0 then we can logically go no further.
if (value == 0)
{
return “0 Hz”;
}

// Get the original value.
double from = (value * Math.Pow(1000, (double)fromType));

// This will give us the index of the best size to use.
double exponent = Math.Floor(Math.Log(from) / Math.Log(1000));

// Return the processed value.
return (from / Math.Pow(1000, exponent)).ToString(“n2″) + ” ” + Enum.GetName(typeof(HertzUnits), (int)exponent);
}
[/cc]

I hope you enjoyed this snippet. If you have anything you wish to say or suggest feel free to comment.

Hello World!

Welcome to my new blog!

I am looking forward to sharing my thoughts and ideas with the world. I plan on putting some pages up on here about my projects and hopefully some code snippet pages too. That way others can benefit from any pieces of code I think may be helpful to others.

As with all things, if anyone has a suggestion about something I should talk about or anything I should include on the site – please let me know!