ToString() public method

Reports this WaveFormat as a string
public ToString ( ) : string
return string
Ejemplo n.º 1
0
        public void SetMicrophone(MMDevice mic)
        {
            microphone     = mic;
            micAudioClient = mic.AudioClient;

            // Initialize AudioClient
            NAudio.Wave.WaveFormat waveFormat = micAudioClient.MixFormat;
            micAudioClient.Initialize(AudioClientShareMode.Shared, AudioClientStreamFlags.None, 1000, 0, waveFormat, audioSession);
            int bufferSize = micAudioClient.BufferSize;

            micFrameSize = waveFormat.Channels * waveFormat.BitsPerSample / 8; // size in bytes
            Console.WriteLine("INFO: Microphone Buffer size " + bufferSize.ToString() + " Frame size " + micFrameSize.ToString());
            Console.WriteLine("INFO: Microphone wave format " + waveFormat.ToString());
        }
Ejemplo n.º 2
0
        public void SetSpeaker(MMDevice speak)
        {
            speaker          = speak;
            speakAudioClient = speak.AudioClient;

            // Is 7.1 supported?
            Console.WriteLine(speakAudioClient.IsFormatSupported(AudioClientShareMode.Shared, new NAudio.Wave.WaveFormat(44100, 32, 2)));

            // Initalize AudioClient
            NAudio.Wave.WaveFormat waveFormat = speakAudioClient.MixFormat;
            speakAudioClient.Initialize(AudioClientShareMode.Shared, AudioClientStreamFlags.None, 100000000, 0, waveFormat, audioSession);
            int bufferSize = speakAudioClient.BufferSize;

            speakFrameSize = waveFormat.Channels * waveFormat.BitsPerSample / 8; // size in bytes
            Console.WriteLine("INFO: Speaker Buffer size " + bufferSize.ToString() + " Frame Size " + speakFrameSize.ToString());
            Console.WriteLine("INFO: Speaker wave format " + waveFormat.ToString() + " encoding " + waveFormat.Encoding);
        }
Ejemplo n.º 3
0
        private void readToArrays(WaveFileReader pcm)
        {
            wf = pcm.WaveFormat;
            fname = wf.ToString();
            int samplesDesired = (int)pcm.Length;

            buffer = new byte[samplesDesired];
            left = new float[samplesDesired / 2];
            right = new float[samplesDesired / 2];

            int bytesRead = pcm.Read(buffer, 0, samplesDesired);

            if (wf.BitsPerSample == 16) {

                if (wf.Channels == 1) {
                    for (int i = 0; i < buffer.Length / 4; i++)
                        left[i] = BitConverter.ToInt16(buffer, i * 4);
                }
                else if (wf.Channels == 2) {
                    int index = 0;
                    for (int sample = 0; sample < bytesRead / 4; sample++) {
                        left[sample] = BitConverter.ToInt16(buffer, index);
                        index += 2;
                        right[sample] = BitConverter.ToInt16(buffer, index);
                        index += 2;
                    }
                }
            }
            else if (wf.BitsPerSample == 8) {
                if (wf.Channels == 1) {

                }
                else if (wf.Channels == 2) {

                }
            }
        }