Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        public void SendNow(SequencerEvent evt)
        {
            ThrowIfDisposed();

            evt.ThrowIfDisposed();

            LibFluidsynth.fluid_sequencer_send_now(Handle, evt.Handle);
        }
Ejemplo n.º 3
0
        public void SendAt(SequencerEvent evt, uint time, bool absolute)
        {
            ThrowIfDisposed();

            evt.ThrowIfDisposed();

            var ret = LibFluidsynth.fluid_sequencer_send_at(Handle, evt.Handle, time, absolute ? 1 : 0);

            if (ret == LibFluidsynth.FluidFailed)
            {
                throw new FluidSynthInteropException("fluid_sequencer_send_at failed");
            }
        }