Exemplo n.º 1
0
        /// <summary>
        /// Creates the PCM-format for <see cref="System.Windows.Media.MediaStreamAttributeKeys.CodecPrivateData"/>
        /// </summary>
        /// <param name="waveFormat">A <see cref="WaveFormat"/> instance</param>
        /// <returns>Little endian base16 encoded string</returns>
        public static string ToPcmBase16String(WaveFormat waveFormat)
        {
            var stringBuilder = new StringBuilder(100);

            stringBuilder
                .Append(ToLittleEndianBase16((short) waveFormat.Format))
                .Append(ToLittleEndianBase16((short) waveFormat.Channels))
                .Append(ToLittleEndianBase16(waveFormat.SamplesPerSecond))
                .Append(ToLittleEndianBase16(waveFormat.AverageBytesPerSecond))
                .Append(ToLittleEndianBase16(waveFormat.BlockAlignment))
                .Append(ToLittleEndianBase16((short) waveFormat.BitsPerSample))
                .Append(ToLittleEndianBase16(waveFormat.ExtraInfoSize));

            return stringBuilder.ToString();
        }
Exemplo n.º 2
0
        static PureToneSource()
        {
            var waveFormatBuilder = new WaveFormat.Builder();
            waveFormatBuilder
                .Format(FormatTag.PCM)
                .Channels(SelectedChannelsSetup)
                .SamplesPerSecond(SamplesPerSecond)
                .AverageBytesPerSecond(SamplesPerSecond * (int)SelectedChannelsSetup * BytesPerSample)
                .BlockAlignment((int)SelectedChannelsSetup * BytesPerSample)
                .BitsPerSample(SelectedBitsPerSample)
                .ExtraInfoSize(0);

            DefaultWaveFormat = waveFormatBuilder.Build();
        }