private void process(DoubleData doubleData)
        {
            double[]   values     = doubleData.getValues();
            int        i          = this.overflowBuffer.getOccupancy() + values.Length;
            LinkedList linkedList = new LinkedList();

            linkedList.add(doubleData);
            Data data = null;

            while (i < this.cosineWindow.Length)
            {
                Data data2 = this.getPredecessor().getData();
                if (data2 is DoubleData)
                {
                    linkedList.add((DoubleData)data2);
                    i += ((DoubleData)data2).getValues().Length;
                }
                else
                {
                    if (data2 is DataEndSignal || data2 is SpeechEndSignal)
                    {
                        data = data2;
                        break;
                    }
                    this.outputQueue.add(data2);
                }
            }
            double[] array = values;
            int      num;

            if (i != values.Length)
            {
                array = new double[i];
                ByteCodeHelper.arraycopy_primitive_8(this.overflowBuffer.getBuffer(), 0, array, 0, this.overflowBuffer.getOccupancy());
                num = this.overflowBuffer.getOccupancy();
                Iterator iterator = linkedList.iterator();
                while (iterator.hasNext())
                {
                    DoubleData doubleData2 = (DoubleData)iterator.next();
                    double[]   values2     = doubleData2.getValues();
                    ByteCodeHelper.arraycopy_primitive_8(values2, 0, array, num, values2.Length);
                    num += values2.Length;
                }
            }
            num = this.applyRaisedCosineWindow(array, i);
            this.overflowBuffer.reset();
            if (i - num > 0)
            {
                this.overflowBuffer.append(array, num, i - num);
            }
            if (data != null)
            {
                this.processUtteranceEnd();
                this.outputQueue.add(data);
            }
        }
Пример #2
0
        private void updateMeanSumBuffers()
        {
            double num = (double)1f / (double)this.numberFrame;

            ByteCodeHelper.arraycopy_primitive_8(this.sum, 0, this.currentMean, 0, this.sum.Length);
            LiveCMN.multiplyArray(this.currentMean, num);
            if (this.numberFrame >= this.cmnShiftWindow)
            {
                LiveCMN.multiplyArray(this.sum, num * (double)this.cmnWindow);
                this.numberFrame = this.cmnWindow;
            }
        }
Пример #3
0
        public int append(double[] array, int num, int num2)
        {
            if (this.occupancy + num2 > this.buffer.Length)
            {
                string text = "RaisedCosineWindower: overflow-buffer: attempting to fill buffer beyond its capacity.";

                throw new Error(text);
            }
            ByteCodeHelper.arraycopy_primitive_8(array, num, this.buffer, this.occupancy, num2);
            this.occupancy += num2;
            return(this.occupancy);
        }
Пример #4
0
        public override Data getData()
        {
            while (this.curInBufferSize < this.blockSizeSamples || this.curInBufferSize == 0)
            {
                Data data = this.getPredecessor().getData();
                if (data is DataStartSignal)
                {
                    this.sampleRate        = ((DataStartSignal)data).getSampleRate();
                    this.blockSizeSamples  = (int)Math.round((double)this.sampleRate * this.blockSizeMs / 1000.0);
                    this.curInBufferSize   = 0;
                    this.curFirstSamplePos = 0;
                    this.inBuffer.clear();
                }
                if (!(data is DoubleData))
                {
                    return(data);
                }
                DoubleData doubleData = (DoubleData)data;
                this.inBuffer.add(doubleData);
                this.curInBufferSize += doubleData.getValues().Length;
            }
            double[] array             = new double[this.blockSizeSamples];
            int      num               = 0;
            long     firstSampleNumber = ((DoubleData)this.inBuffer.get(0)).getFirstSampleNumber() + (long)this.curFirstSamplePos;

            while (!this.inBuffer.isEmpty())
            {
                DoubleData doubleData2 = (DoubleData)this.inBuffer.remove(0);
                double[]   values      = doubleData2.getValues();
                int        num2        = Math.min(this.blockSizeSamples - num, values.Length - this.curFirstSamplePos);
                ByteCodeHelper.arraycopy_primitive_8(values, this.curFirstSamplePos, array, num, num2);
                if (num2 < values.Length - this.curFirstSamplePos)
                {
                    if (!DataBlocker.assertionsDisabled && !this.inBuffer.isEmpty())
                    {
                        throw new AssertionError();
                    }
                    this.curFirstSamplePos += num2;
                    this.inBuffer.add(0, doubleData2);
                    break;
                }
                else
                {
                    num += num2;
                    this.curFirstSamplePos = 0;
                }
            }
            this.curInBufferSize = ((!this.inBuffer.isEmpty()) ? (((DoubleData)this.inBuffer.get(0)).getValues().Length - this.curFirstSamplePos) : 0);
            return(new DoubleData(array, this.sampleRate, firstSampleNumber));
        }
        private int applyRaisedCosineWindow(double[] array, int num)
        {
            int num2;

            if (num < this.cosineWindow.Length)
            {
                double[] array2 = new double[this.cosineWindow.Length];
                ByteCodeHelper.arraycopy_primitive_8(array, 0, array2, 0, num);
                array = array2;
                num2  = 1;
            }
            else
            {
                num2 = RaisedCosineWindower.getWindowCount(num, this.cosineWindow.Length, this.windowShift);
            }
            int num3 = num2;
            int num4 = this.cosineWindow.Length;

            int[] array3 = new int[2];
            int   num5   = num4;

            array3[1] = num5;
            num5      = num3;
            array3[0] = num5;
            double[][] array4 = (double[][])ByteCodeHelper.multianewarray(typeof(double[][]).TypeHandle, array3);
            int        num6   = 0;

            for (int i = 0; i < num2; i++)
            {
                double[] array5 = array4[i];
                int      j      = 0;
                int      num7   = num6;
                while (j < array5.Length)
                {
                    array5[j] = array[num7] * this.cosineWindow[j];
                    num7++;
                    j++;
                }
                this.outputQueue.add(new DoubleData(array5, this.sampleRate, this.currentFirstSampleNumber));
                this.currentFirstSampleNumber += (long)this.windowShift;
                num6 += this.windowShift;
            }
            return(num6);
        }