public static bool BASS_ChannelSet3DPosition(int handle, BASS_3DVECTOR pos, BASS_3DVECTOR orient, BASS_3DVECTOR vel) { IntPtr[] ptr = new IntPtr[3]; object[] args = new object[3]; bool result; args[0] = pos; args[1] = orient; args[2] = vel; for (int i = 0; i < ptr.Length; i++) { if (args[i] != null) { ptr[i] = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(BASS_3DVECTOR))); Marshal.StructureToPtr(args[i], ptr[i], false); } else ptr[i] = IntPtr.Zero; } result = BASS_ChannelSet3DPosition(handle, ptr[0], ptr[1], ptr[2]); foreach (var p in ptr) { if (p != IntPtr.Zero) Marshal.FreeHGlobal(p); } return result; }
public static bool BASS_ChannelGet3DPosition(int handle, BASS_3DVECTOR pos, BASS_3DVECTOR orient, BASS_3DVECTOR vel) { IntPtr[] ptr = new IntPtr[3]; BASS_3DVECTOR[] args = new BASS_3DVECTOR[4]; bool result; args[0] = pos; args[1] = orient; args[2] = vel; for (int i = 0; i < ptr.Length; i++) { if (args[i] != null) { ptr[i] = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(BASS_3DVECTOR))); Marshal.StructureToPtr(args[i], ptr[i], false); } else ptr[i] = IntPtr.Zero; } result = BASS_ChannelGet3DPosition(handle, ptr[0], ptr[1], ptr[2]); for (int i = 0; i < ptr.Length; i++) { if (ptr[i] != IntPtr.Zero) { args[3] = (BASS_3DVECTOR)Marshal.PtrToStructure(ptr[i], typeof(BASS_3DVECTOR)); args[i].SetValue(args[3].x, args[3].y, args[3].z); Marshal.FreeHGlobal(ptr[i]); } } return result; }