Beispiel #1
0
        /// <summary>
        /// Gets the length of the voice note
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        private string GetVoiceNoteLength(byte[] data)
        {
            int seconds      = 0;
            int milliseconds = 0;

            if (data.Length > 0)
            {
                //The fmt descrption of the wave data starts at byte 20
                byte[] buffer = new byte[data.Length - 20];
                for (int x = 20; x < data.Length; x++)
                {
                    buffer[x - 20] = data[x];
                }
                //Put a try/catch incase the data is corrupt
                try
                {
                    WaveFormat2 wave = new WaveFormat2(buffer);

                    //Calculate the length
                    seconds      = buffer.Length / wave.AvgBytesPerSec;
                    milliseconds = buffer.Length % wave.AvgBytesPerSec;
                }
                catch { }
            }

            //Format to something nice
            int minute = (seconds / 60);
            int hour   = minute / 60;

            return(string.Format("{0}:{1}:{2}.{3}", hour.ToString("00"), minute.ToString("00"), seconds.ToString("00"), milliseconds.ToString("000")));
        }
Beispiel #2
0
        /// <summary>
        /// Set the volume for the default waveOut device (device ID = 0)
        /// </summary>
        /// <param name="Volume"></param>
        public static void SetVolume(int Volume)
        {
            WaveFormat2 format   = new WaveFormat2();
            IntPtr      hWaveOut = IntPtr.Zero;

            OpenNETCF.Media.WaveAudio.NativeMethods.waveOutOpen(out hWaveOut, 0, format.GetBytes(), IntPtr.Zero, 0, 0);
            OpenNETCF.Media.WaveAudio.NativeMethods.waveOutSetVolume(hWaveOut, Volume);
            OpenNETCF.Media.WaveAudio.NativeMethods.waveOutClose(hWaveOut);
        }
Beispiel #3
0
        /// <summary>
        /// Get the current volume setting for the default waveOut device (device ID = 0)
        /// </summary>
        /// <returns></returns>
        public static int GetVolume()
        {
            WaveFormat2 format   = new WaveFormat2();
            IntPtr      hWaveOut = IntPtr.Zero;
            int         volume   = 0;

            OpenNETCF.Media.WaveAudio.NativeMethods.waveOutOpen(out hWaveOut, 0, format.GetBytes(), IntPtr.Zero, 0, 0);
            OpenNETCF.Media.WaveAudio.NativeMethods.waveOutGetVolume(hWaveOut, ref volume);
            OpenNETCF.Media.WaveAudio.NativeMethods.waveOutClose(hWaveOut);

            return(volume);
        }