Esempio n. 1
0
 public NormalSourceVoice(SoundSystem system, WaveFormat format)
 {
     this.system            = system;
     sourceVoice            = new SourceVoice(system.AudioDevice, format);
     sourceVoice.StreamEnd += new EventHandler(sourceVoice_StreamEnd);
     defaultOutputMatrix    = sourceVoice.GetOutputMatrix(sourceVoice.VoiceDetails.InputChannels, system.DeviceDetails.OutputFormat.Channels);
 }
Esempio n. 2
0
        private void PrepareVoiceSource(WaveFormat format)
        {
            if (_voice == null)
            {
                _linkedWaveFormat = format;
                //Voice Creation
                _voice = new SourceVoice(_soundEngine.Xaudio2, _linkedWaveFormat, true);

                //Do we have a special channel sound Mapping for this channel/speaker configuration ?
                float[] customMapping;
                if (_soundEngine.GetCustomChannelMapping(_voice.VoiceDetails.InputChannelCount, _soundEngine.DeviceDetail.OutputFormat.Channels, out customMapping))
                {
                    _defaultChannelMapping = customMapping;
                    _voice.SetOutputMatrix(_voice.VoiceDetails.InputChannelCount, _soundEngine.DeviceDetail.OutputFormat.Channels, _defaultChannelMapping);
                }
                else
                {
                    //Get default channel mapping
                    _defaultChannelMapping = new float[_voice.VoiceDetails.InputChannelCount * _soundEngine.DeviceDetail.OutputFormat.Channels];
                    _voice.GetOutputMatrix(null, _voice.VoiceDetails.InputChannelCount, _soundEngine.DeviceDetail.OutputFormat.Channels, _defaultChannelMapping);
                }

                _voice.BufferEnd += _callback;
            }
            else
            {
                if (_linkedWaveFormat.SampleRate != format.SampleRate)
                {
                    _voice.SourceSampleRate = format.SampleRate;
                    _linkedWaveFormat       = format;
                }
            }
        }
 public NormalSourceVoice(SoundSystem system, WaveFormat format)
 {
     this.system = system;
     sourceVoice = new SourceVoice(system.AudioDevice, format);
     sourceVoice.StreamEnd += new EventHandler(sourceVoice_StreamEnd);
     defaultOutputMatrix = sourceVoice.GetOutputMatrix(sourceVoice.VoiceDetails.InputChannels, system.DeviceDetails.OutputFormat.Channels);
 }
        private static void PrintVoiceInfo(int inputChannels, int outputChannels, SourceVoice sourceVoice)
        {
            float[] channelVolumes = sourceVoice.GetChannelVolumes(inputChannels);
            float[] outputMatrix   = sourceVoice.GetOutputMatrix(inputChannels, outputChannels);

            // volume, channelvolumes, outputmatrix
            Console.WriteLine("Volume:\t\t" + sourceVoice.Volume);
            Console.WriteLine("VolumeLevels:");
            PrintArray(channelVolumes);
            Console.WriteLine("OutputMatrix:");
            PrintArray(outputMatrix);
            float c1 = 0, c2 = 0;

            for (int i = 0; i < outputMatrix.Length / 2; i++)
            {
                c1 += outputMatrix[i];
                c2 += outputMatrix[i + outputMatrix.Length / 2];
            }
            Console.WriteLine("Sum OM: ({0}, {1})", c1, c2);
            Console.WriteLine("--------------------------------------------------------");
        }
        private static void PrintVoiceInfo(int inputChannels, int outputChannels, SourceVoice sourceVoice)
        {
            float[] channelVolumes = sourceVoice.GetChannelVolumes(inputChannels);
            float[] outputMatrix = sourceVoice.GetOutputMatrix(inputChannels, outputChannels);

            // volume, channelvolumes, outputmatrix
            Console.WriteLine("Volume:\t\t" + sourceVoice.Volume);
            Console.WriteLine("VolumeLevels:");
            PrintArray(channelVolumes);
            Console.WriteLine("OutputMatrix:");
            PrintArray(outputMatrix);
            float c1 = 0, c2 = 0;
            for (int i = 0; i < outputMatrix.Length / 2; i++)
            {
                c1 += outputMatrix[i];
                c2 += outputMatrix[i + outputMatrix.Length / 2];
            }
            Console.WriteLine("Sum OM: ({0}, {1})", c1, c2);
            Console.WriteLine("--------------------------------------------------------");
        }