/// <summary>
        /// Marshals a native AUDIO_VOLUME_NOTIFICATION_DATA structure to a <see cref="AudioVolumeNotificationData"/> object.
        /// </summary>
        /// <param name="ptr">A pointer to an AUDIO_VOLUME_NOTIFICATION_DATA structure.</param>
        /// <returns>The marshaled <see cref="AudioVolumeNotificationData"/> object.</returns>
        public static AudioVolumeNotificationData MarshalFromPtr(IntPtr ptr)
        {
            AUDIO_VOLUME_NOTIFICATION_DATA data = (AUDIO_VOLUME_NOTIFICATION_DATA)Marshal.PtrToStructure(ptr, typeof(AUDIO_VOLUME_NOTIFICATION_DATA));
            IntPtr channelVolumesPtr            = new IntPtr(ptr.ToInt64() + Marshal.OffsetOf <AUDIO_VOLUME_NOTIFICATION_DATA>("ChannelVolume0").ToInt64());

            // Read dynamic channel volumes array
            float[] channelVolume = new float[data.Channels];
            Marshal.Copy(channelVolumesPtr, channelVolume, 0, data.Channels);

            // Construct the complete AudioVolumeNotificationData object
            AudioVolumeNotificationData notificationData = new AudioVolumeNotificationData()
            {
                EventContext  = data.EventContext,
                Muted         = data.Muted,
                MasterVolume  = data.MasterVolume,
                Channels      = data.Channels,
                ChannelVolume = channelVolume,
            };

            return(notificationData);
        }