public unsafe SequencerClientId RegisterClient(string name, SequencerEventCallback callback) { ThrowIfDisposed(); LibFluidsynth.fluid_event_callback_t wrapper = null; var callbackPtr = IntPtr.Zero; if (callback != null) { wrapper = (time, @event, seq, data) => { using (var ev = new SequencerEvent(@event)) { callback(time, ev); } }; callbackPtr = Marshal.GetFunctionPointerForDelegate(wrapper); } var id = LibFluidsynth.fluid_sequencer_register_client(Handle, name, callbackPtr, null); if (id == LibFluidsynth.FluidFailed) { throw new FluidSynthInteropException("fluid_sequencer_register_client failed"); } if (wrapper != null) { _clientCallbacks.Add(id, wrapper); } return(new SequencerClientId(id)); }