Esempio n. 1
0
        private static void OnDeviceConnected()
        {
            Console.WriteLine("Device connected");
            Frequency = _device.ReadParam <SamplingFrequency>(Parameter.SamplingFrequency);
            Rewrite();

            _device.AddIntChannelDataListener(BatteryChannel_DataReceived, DeviceTraits.GetChannelsWithType(_device, ChannelType.Battery)[0]);
            if (Frequency != SamplingFrequency.Hz250)
            {
                _device.SetParam(Parameter.SamplingFrequency, SamplingFrequency.Hz250);
                Frequency = _device.ReadParam <SamplingFrequency>(Parameter.SamplingFrequency);
            }
            var channelInfos = _device.Channels;

            foreach (var channelInfo in channelInfos)
            {
                if (channelInfo.Type != ChannelType.Signal)
                {
                    continue;
                }

                _device.AddSignalChannelDataListener(SignalChannel_DataReceived, channelInfo);
                _channels[channelInfo.Name] = 0.0;
            }
            _device.Execute(Command.StartSignal);
        }
Esempio n. 2
0
        private void _signalControl_SamplingFrequencySelectedChanged(object sender, SamplingFrequency samplingFrequency)
        {
            if (_device.ReadParam <DeviceState>(Parameter.State) == DeviceState.Disconnected)
            {
                return;
            }

            _device.SetParam(Parameter.SamplingFrequency, samplingFrequency);
            var updatedParam = _device.ReadParam <SamplingFrequency>(Parameter.SamplingFrequency);

            if (updatedParam != samplingFrequency)
            {
                _signalControl.SamplingFrequencyComboValue = updatedParam;
            }
        }
        public Decoder(
            SamplingFrequency samplingFrequency,
            NumChannels channels)
        {
            ErrorCode error;

            this.channels = channels;
            decoder       = Library.OpusDecoderCreate(
                samplingFrequency,
                channels,
                out error);
            if (error != ErrorCode.OK)
            {
                Debug.LogError("[UnityOpus] Failed to create Decoder. Error code is " + error.ToString());
                decoder = IntPtr.Zero;
            }
            softclipMem = new float[(int)channels];
        }
Esempio n. 4
0
        public Encoder(
            SamplingFrequency samplingFrequency,
            NumChannels channels,
            OpusApplication application)
        {
            this.channels = channels;
            ErrorCode error;

            encoder = Library.OpusEncoderCreate(
                samplingFrequency,
                channels,
                application,
                out error);
            if (error != ErrorCode.OK)
            {
                UnityEngine.Debug.LogError("[UnityOpus] Failed to init encoder. Error code: " + error.ToString());
                encoder = IntPtr.Zero;
            }
        }
Esempio n. 5
0
        private bool retrieveSamplingRate()
        {
            string text = sampleRate.Text;

            try
            {
                int value = int.Parse(text);
                foreach (SamplingFrequency hz in Enum.GetValues(typeof(SamplingFrequency)))
                {
                    if ((int)hz == value)
                    {
                        samplingFrequency = hz;
                        return(true);
                    }
                }
            } catch (Exception)
            {
            }
            info(text + " is not a valid sampling frequency. Valid values are: 25, 50, 100, 200, 400, 800");
            return(false);
        }
Esempio n. 6
0
        public string WritePart()
        {
            FFMPEGCommand.AddInput(InputVideoPath);

            if (SamplingFrequency > 0)
            {
                FFMPEGCommand.AddFlag(new SimpleFlag("ar", SamplingFrequency.ToString()));
            }

            if (!string.IsNullOrEmpty(BitRate))
            {
                FFMPEGCommand.AddFlag(new SimpleFlag("b:a", BitRate));
            }

            if (NumAudioChannels >= 2)
            {
                FFMPEGCommand.AddFlag(new SimpleFlag("ac", NumAudioChannels.ToString()));
            }

            FFMPEGCommand.AddFlag(new SimpleFlag("y", null));

            return(FFMPEGCommand.WritePart());
        }
Esempio n. 7
0
 public static extern IntPtr OpusDecoderCreate(
     SamplingFrequency samplingFrequency,
     NumChannels channels,
     out ErrorCode error);
Esempio n. 8
0
 public static extern IntPtr OpusEncoderCreate(
     SamplingFrequency samplingFrequency,
     NumChannels channels,
     OpusApplication application,
     out ErrorCode error);
Esempio n. 9
0
 private static extern int device_set_SamplingFrequency(IntPtr devicePtr, SamplingFrequency freq);
Esempio n. 10
0
 private static extern int device_read_SamplingFrequency(IntPtr devicePtr, out SamplingFrequency outFreq);
Esempio n. 11
0
 byte[] BuildAudioStreamCodingInfo(ElementaryStreamTypes type, AudioPresentationType format, SamplingFrequency rate)
 {
     List<byte> info = new List<byte>();
     info.Add(0x15);
     info.Add((byte)type);
     info.Add((byte)((((byte)format) << 4) | (byte)rate));
     info.Add(0x65);
     info.Add(0x6e);
     info.Add(0x67);
     for (int i = 0; i < 16; i++)
         info.Add(0x00);
     return info.ToArray();
 }
Esempio n. 12
0
 private byte[] BuildAudioStreamAttributes(byte type, AudioPresentationType vf, SamplingFrequency fr)
 {
     if (type != (byte)ElementaryStreamTypes.AUDIO_STREAM_AC3
         && type != (byte)ElementaryStreamTypes.AUDIO_STREAM_AC3_PLUS
         && type != (byte)ElementaryStreamTypes.AUDIO_STREAM_AC3_TRUE_HD
         && type != (byte)ElementaryStreamTypes.AUDIO_STREAM_DTS
         && type != (byte)ElementaryStreamTypes.AUDIO_STREAM_DTS_HD
         && type != (byte)ElementaryStreamTypes.AUDIO_STREAM_DTS_HD_MASTER_AUDIO
         && type != (byte)ElementaryStreamTypes.AUDIO_STREAM_LPCM)
         throw new FormatException(String.Format("Audio stream of type {0} is not supported by Blu Ray", type));
     byte[] attributes = new byte[6];
     attributes[0] = 0x05;
     attributes[1] = type;
     attributes[2] = (byte)((((byte)vf) << 4) & 0xf0);
     attributes[2] |= (byte)(((byte)fr) & 0x0f);
     attributes[3] = 0x65;
     attributes[4] = 0x6e;
     attributes[5] = 0x67;
     return attributes;
 }
Esempio n. 13
0
 public StreamInfo(byte[] data, int index)
 {
     if (null == data)
         throw new ArgumentException("stream data is null");
     if (data.Length + index < 5)
         throw new ArgumentException("stream data too short");
     uint descLength = (uint)((data[3 + index] & 0x0f) << 8) + data[4 + index];
     if (descLength > Constants.TS_SIZE)
         throw new ArgumentException("descriptors data too long");
     if (5 + descLength > data.Length - index)
         throw new ArgumentException("stream data too short");
     mData = new byte[5 + descLength];
     for (int i = 0; i < mData.Length; i++)
     {
         mData[i] = data[i + index];
     }
     mVideoFormat = VideoFormat.Reserved;
     mAspectRatio = AspectRatio.Reserved;
     mFrameRate = FrameRate.Reserved;
     mAudioPresentationType = AudioPresentationType.Reserved;
     mSamplingFrequency = SamplingFrequency.Reserved;
 }