Exemple #1
0
        /// <summary>
        /// Retrieves the current time position for playback.
        /// </summary>
        /// <param name="formatType">One of the <see cref="TimeFormatTypes"/> enumerated values, except Smpte.</param>
        /// <returns>Returns the current time in the requested time <paramref name="formatType"/>.
        /// When the value is negative, the requested time <paramref name="formatType"/> was not supported
        /// and the return value specifies the proposed time format type (as a negative value).</returns>
        public long GetTime(TimeFormatTypes formatType)
        {
            ThrowIfDisposed();
            if (formatType == TimeFormatTypes.Smpte)
            {
                throw new InvalidOperationException(
                          Properties.Resources.MidiStreamOutPort_InvalidTimeFormatType);
            }

            MmTime time = new MmTime();

            time.Type = (uint)formatType;

            this.GetTime(ref time);

            if (time.Type == (uint)formatType)
            {
                // for all types (except Smpte) same field is used.
                return(time.Ticks);
            }
            else
            {
                // return the supported time format as error
                return(-time.Type);
            }
        }
Exemple #2
0
        /// <summary>
        /// Gets the current time position from the port.
        /// </summary>
        /// <param name="time">A reference to the time structure that receives the value.</param>
        private void GetTime(ref MmTime time)
        {
            int result = NativeMethods.midiStreamPosition(
                MidiSafeHandle,
                ref time,
                (uint)MemoryUtil.SizeOfMmTime);

            ThrowIfError(result);
        }
Exemple #3
0
 public static extern int midiStreamPosition(MidiSafeHandle handle, ref MmTime time, uint sizeOfMmTime);