private DoubleData readNextFrame()
        {
            int num  = 0;
            int num2 = this.bytesPerRead;

            byte[]     array             = new byte[this.bytesPerRead];
            long       firstSampleNumber = this.totalValuesRead;
            DoubleData result;

            try
            {
                int num3;
                do
                {
                    num3 = this.dataStream.read(array, num, num2 - num);
                    if (num3 > 0)
                    {
                        num += num3;
                    }
                }while (num3 != -1 && num < num2);
                if (num > 0)
                {
                    long num4 = this.totalValuesRead;
                    int  num5 = num;
                    int  num6 = this.bytesPerValue;
                    this.totalValuesRead = num4 + (long)((num6 != -1) ? (num5 / num6) : (-(long)num5));
                    if (num < num2)
                    {
                        bool flag = num != 0;
                        int  num7 = 2;
                        num = ((num7 != -1 && (flag ? 1 : 0) % num7 != 0) ? (num + 3) : (num + 2));
                        byte[] array2 = new byte[num];
                        ByteCodeHelper.arraycopy_primitive_1(array, 0, array2, 0, num);
                        array = array2;
                        this.closeDataStream();
                    }
                    goto IL_B9;
                }
                this.closeDataStream();
                result = null;
            }
            catch (IOException ex)
            {
                throw new DataProcessingException("Error reading data", ex);
            }
            return(result);

IL_B9:
            double[] values;
            if (this.bigEndian)
            {
                values = DataUtil.bytesToValues(array, 0, num, this.bytesPerValue, this.signedData);
            }
            else
            {
                values = DataUtil.littleEndianBytesToValues(array, 0, num, this.bytesPerValue, this.signedData);
            }
            return(new DoubleData(values, this.sampleRate, firstSampleNumber));
        }
示例#2
0
            private Data readData(Utterance utterance)
            {
                byte[] array             = new byte[Microphone.access_1400(this.this_0)];
                int    channels          = Microphone.access_500(this.this_0).getFormat().getChannels();
                long   num               = this.totalSamplesRead;
                long   num2              = (long)channels;
                long   firstSampleNumber = (num2 != -1L) ? (num / num2) : (-num);
                int    num3              = Microphone.access_500(this.this_0).read(array, 0, array.Length);

                if (!this.started)
                {
                    lock (this)
                    {
                        this.started = true;
                        System.Threading.Thread.MemoryBarrier();
                        Object.instancehelper_notifyAll(this);
                    }
                }
                if (Microphone.access_1500(this.this_0).isLoggable(Level.FINE))
                {
                    Microphone.access_1600(this.this_0).info(new StringBuilder().append("Read ").append(num3).append(" bytes from audio stream.").toString());
                }
                if (num3 <= 0)
                {
                    return(null);
                }
                int  num4 = Microphone.access_500(this.this_0).getFormat().getSampleSizeInBits() / 8;
                long num5 = this.totalSamplesRead;
                int  num6 = num3;
                int  num7 = num4;

                this.totalSamplesRead = num5 + (long)((num7 != -1) ? (num6 / num7) : (-(long)num6));
                if (num3 != Microphone.access_1400(this.this_0))
                {
                    bool flag = num3 != 0;
                    int  num8 = num4;
                    if (num8 != -1 && (flag ? 1 : 0) % num8 != 0)
                    {
                        string text = "Incomplete sample read.";

                        throw new Error(text);
                    }
                    array = Arrays.copyOf(array, num3);
                }
                if (Microphone.access_300(this.this_0))
                {
                    utterance.add(array);
                }
                double[] array2;
                if (Microphone.access_1700(this.this_0))
                {
                    array2 = DataUtil.bytesToValues(array, 0, array.Length, num4, Microphone.access_1800(this.this_0));
                }
                else
                {
                    array2 = DataUtil.littleEndianBytesToValues(array, 0, array.Length, num4, Microphone.access_1800(this.this_0));
                }
                if (channels > 1)
                {
                    array2 = Microphone.access_1900(this.this_0, array2, channels);
                }
                return(new DoubleData(array2, ByteCodeHelper.f2i(Microphone.access_500(this.this_0).getFormat().getSampleRate()), firstSampleNumber));
            }