Improved API usage

Hi there, I wanted to propose the addition of the following API calls to reduce the amount of object allocations. And hopefully make it a bit easier to retrieve some data.

Retrieving data by index

The following API calls I’m proposing to allow retrieving data without having to allocate a new array with every getXXXList invocation. Additionally getParameterDescriptionByIndex is also available, so it would be following the same format.

  • public RESULT getBankByIndex(int index, out Bank bank)
  • public RESULT getEventDescriptionByIndex(int index, out EventDescription eventDescription)

Improved parameter retrieval

The following API calls I’m proposing as PARAMETER_DESCRIPTION includes a guid. Additionally retrieving EventDescription and Bank is possibly through a guid. It would probably be needed to clarify that this would return the parameter description based on the parameter preset. I’m not sure if this is something that’s desired. However, it would make it a lot easier to retrieve parameters as you don’t have to iterate through banks → event descriptions → parameters to try and find a parameter.

  • public RESULT getParameterDescriptionById(GUID guid, out PARAMETER_DESCRIPTION parameterDescription)
  • public RESULT getParameterDescriptionByPath(string path, out PARAMETER_DESCRIPTION parameterDescription)

Small Side Note
I’m currently storing/retrieving my object references by System.Guid instead of the FMOD.GUID object provided by FMOD. Converting from a System.Guid to an FMOD.GUID allocates a byte array. Which isn’t required if the conversion is done using System.Guid.TryWriteGuid where the required Span<byte> refers to a static readonly byte[] which is already sized accordingly.

For example:

private static readonly byte[] byteBuffer = new byte[16];

public GUID(Guid guid)
{
	Span<byte> bytesBuffer = byteBuffer.AsSpan();
	if (guid.TryWriteBytes(bytesBuffer))
	{
		Data1 = BitConverter.ToInt32(bytesBuffer[..4]);
		Data2 = BitConverter.ToInt32(bytesBuffer.Slice(4, 4));
		Data3 = BitConverter.ToInt32(bytesBuffer.Slice(8, 4));
		Data4 = BitConverter.ToInt32(bytesBuffer[12..]);
	}
	else
	{
		Data1 = 0;
		Data2 = 0;
		Data3 = 0;
		Data4 = 0;
	}
}
1 Like

Hi,

Thank you for the detailed suggestions! I have passed them on to our development team to investigate further.

2 Likes