public override int GetHashCode() { int hash = 1; if (FloatData != 0F) { hash ^= FloatData.GetHashCode(); } if (DoubleData != 0D) { hash ^= DoubleData.GetHashCode(); } if (IntData != 0) { hash ^= IntData.GetHashCode(); } if (LongData != 0L) { hash ^= LongData.GetHashCode(); } if (BoolData != false) { hash ^= BoolData.GetHashCode(); } if (StringData.Length != 0) { hash ^= StringData.GetHashCode(); } hash ^= list_.GetHashCode(); return(hash); }
private DoubleData process(DoubleData doubleData) { double[] values = doubleData.getValues(); if (this.criticalBandFilter == null || this.sampleRate != doubleData.getSampleRate()) { this.numberFftPoints = values.Length - 1 << 1; this.sampleRate = doubleData.getSampleRate(); this.buildCriticalBandFilterbank(); this.buildEqualLoudnessScalingFactors(); } else if (values.Length != (this.numberFftPoints >> 1) + 1) { string text = new StringBuilder().append("Window size is incorrect: in.length == ").append(values.Length).append(", numberFftPoints == ").append((this.numberFftPoints >> 1) + 1).toString(); throw new IllegalArgumentException(text); } double[] array = new double[this.numberFilters]; for (int i = 0; i < this.numberFilters; i++) { array[i] = this.criticalBandFilter[i].filterOutput(values); double[] array2 = array; int num = i; double[] array3 = array2; array3[num] *= this.equalLoudnessScaling[i]; } return(new DoubleData(array, doubleData.getSampleRate(), doubleData.getFirstSampleNumber())); }
/// <summary> /// Process data, creating the PLP cepstrum from an input audio frame. /// </summary> /// <param name="input">A PLP Spectrum frame.</param> /// <returns>a PLP Data frame</returns> /// <exception cref="System.ArgumentException">PLPSpectrum size is incorrect: plpspectrum.length == + /// plpspectrum.Length + , numberPLPFilters == + /// _numberPlpFilters</exception> private IData Process(DoubleData input) { var plpspectrum = input.Values; if (plpspectrum.Length != _numberPlpFilters) { throw new ArgumentException ("PLPSpectrum size is incorrect: plpspectrum.length == " + plpspectrum.Length + ", numberPLPFilters == " + _numberPlpFilters); } // power law compress spectrum var compressedspectrum = PowerLawCompress(plpspectrum); // compute autocorrelation values var autocor = ApplyCosine(compressedspectrum); var LPC = new LinearPredictor(_lpcOrder); // Compute LPC Parameters LPC.GetARFilter(autocor); // Compute LPC Cepstra var cepstrumDouble = LPC.GetData(_cepstrumSize); var cepstrum = new DoubleData (cepstrumDouble, input.SampleRate, input.FirstSampleNumber); return(cepstrum); }
public override Data getData() { object obj = this.getPredecessor().getData(); if (((Data)obj) is DataStartSignal) { this.reset(); } if (((Data)obj) is DoubleData) { DoubleData audio = (DoubleData)((Data)obj); obj = this.classify(audio); } object obj2 = obj; Data result; if (obj2 != null) { if ((result = (obj2 as Data)) == null) { throw new IncompatibleClassChangeError(); } } else { result = null; } return(result); }
/// <summary> /// Process data, creating the mel cepstrum from an input spectrum frame. /// </summary> /// <param name="input">a MelSpectrum frame</param> /// <returns> mel Cepstrum frame</returns> private DoubleData Process(DoubleData input) { var melspectrum = input.Values; if (Melcosine == null) { NumberMelFilters = melspectrum.Length; ComputeMelCosine(); } else if (melspectrum.Length != NumberMelFilters) { throw new ArgumentException("MelSpectrum size is incorrect: melspectrum.length == " + melspectrum.Length + ", numberMelFilters == " + NumberMelFilters); } // first compute the log of the spectrum for (var i = 0; i < melspectrum.Length; ++i) { melspectrum[i] = Math.Log(melspectrum[i] + LogFloor); } double[] cepstrum; // create the cepstrum by apply the melcosine filter cepstrum = ApplyMelCosine(melspectrum); return(new DoubleData(cepstrum, input.SampleRate, input.FirstSampleNumber)); }
/// <summary> /// Process data, creating the power spectrum from an input audio frame. /// </summary> /// <param name="input">The input power spectrum.</param> /// <returns>power spectrum</returns> /// <exception cref="System.ArgumentException">Window size is incorrect: in.length == /// + values.Length /// + , numberFftPoints == /// + ((windowLength >> 1) + 1)</exception> private DoubleData Process(DoubleData input) { var values = input.Values; var windowLength = (values.Length - 1) << 1; if (_filters == null || _sampleRate != input.SampleRate) { _sampleRate = input.SampleRate; BuildFilterbank(windowLength, _numberFilters, _minFreq, _maxFreq); } else if (values.Length != ((windowLength >> 1) + 1)) { throw new ArgumentException("Window size is incorrect: in.length == " + values.Length + ", numberFftPoints == " + ((windowLength >> 1) + 1)); } var output = new double[_numberFilters]; for (var i = 0; i < _numberFilters; i++) { output[i] = _filters[i].Apply(values); } var outputMelSpectrum = new DoubleData(output, _sampleRate, input.FirstSampleNumber); return(outputMelSpectrum); }
public override Data getData() { object obj = this.getPredecessor().getData(); if (((Data)obj) is DoubleData && String.instancehelper_equals(this.convMode, "d2f")) { DoubleData doubleData = (DoubleData)((Data)obj); obj = new FloatData(MatrixUtils.double2float(doubleData.getValues()), doubleData.getSampleRate(), doubleData.getFirstSampleNumber()); } else if (((Data)obj) is FloatData && String.instancehelper_equals(this.convMode, "f2d")) { FloatData floatData = (FloatData)((Data)obj); obj = new DoubleData(MatrixUtils.float2double(floatData.getValues()), floatData.getSampleRate(), floatData.getFirstSampleNumber()); } object obj2 = obj; Data result; if (obj2 != null) { if ((result = (obj2 as Data)) == null) { throw new IncompatibleClassChangeError(); } } else { result = null; } return(result); }
/// <summary> /// Process data, creating the power spectrum from an input audio frame. /// </summary> /// <param name="input">input power spectrum</param> /// <returns>power spectrum</returns> private DoubleData Process(DoubleData input) { var _in = input.Values; if (_filter == null || _sampleRate != input.SampleRate) { _numberFftPoints = (_in.Length - 1) << 1; _sampleRate = input.SampleRate; BuildFilterbank(_numberFftPoints, _numberFilters, _minFreq, _maxFreq); } else if (_in.Length != ((_numberFftPoints >> 1) + 1)) { throw new ArgumentException( "Window size is incorrect: in.length == " + _in.Length + ", numberFftPoints == " + ((_numberFftPoints >> 1) + 1)); } var output = new double[_numberFilters]; /// Filter input power spectrum for (var i = 0; i < _numberFilters; i++) { output[i] = _filter[i].FilterOutput(_in); } var outputMelSpectrum = new DoubleData(output, _sampleRate, input.FirstSampleNumber); return(outputMelSpectrum); }
protected internal override Data computeNextFeature() { DoubleData doubleData = this.cepstraBuffer[this.currentPosition]; float[] array = new float[(this.window * 2 + 1) * doubleData.getValues().Length]; int num = 0; for (int i = -this.window; i <= this.window; i++) { int num2 = this.currentPosition + i + this.cepstraBufferSize; int cepstraBufferSize = this.cepstraBufferSize; int num3 = (cepstraBufferSize != -1) ? (num2 % cepstraBufferSize) : 0; double[] values = this.cepstraBuffer[num3].getValues(); double[] array2 = values; int num4 = array2.Length; for (int j = 0; j < num4; j++) { double num5 = array2[j]; float[] array3 = array; int num6 = num; num++; array3[num6] = (float)num5; } } int num7 = this.currentPosition + 1; int cepstraBufferSize2 = this.cepstraBufferSize; this.currentPosition = ((cepstraBufferSize2 != -1) ? (num7 % cepstraBufferSize2) : 0); return(new FloatData(array, doubleData.getSampleRate(), doubleData.getFirstSampleNumber())); }
public IData getData() { IData inputData = getPredecessor().getData(); int i; if (inputData is DataStartSignal) { power = null; noise = null; floor = null; peak = null; return(inputData); } if (!(inputData is DoubleData)) { return(inputData); } DoubleData inputDoubleData = (DoubleData)inputData; double[] input = inputDoubleData.getValues(); int length = input.Length; if (power == null) { initStatistics(input, length); } updatePower(input); estimateEnvelope(power, noise); double[] signal = new double[length]; for (i = 0; i < length; i++) { signal[i] = Math.Max(power[i] - noise[i], 0.0); } estimateEnvelope(signal, floor); tempMasking(signal); powerBoosting(signal); double[] gain = new double[length]; for (i = 0; i < length; i++) { gain[i] = signal[i] / (power[i] + EPS); gain[i] = Math.Min(Math.Max(gain[i], 1.0 / maxGain), maxGain); } double[] smoothGain = smooth(gain); for (i = 0; i < length; i++) { input[i] *= smoothGain[i]; } return(inputData); }
private void Compass_ReadingChanged(object sender, CompassChangedEventArgs e) { Xamarin.Essentials.CompassData reading = e.Reading; DoubleData data = Heading; data.TimeStamp = DateTime.UtcNow; data.Value = reading.HeadingMagneticNorth; data.SendNotification(); }
private void Barometer_ReadingChanged(object sender, BarometerChangedEventArgs e) { Xamarin.Essentials.BarometerData reading = e.Reading; DoubleData data = Pressure; data.TimeStamp = DateTime.UtcNow; data.Value = reading.PressureInHectopascals; data.SendNotification(); }
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); } }
/// <summary> /// 기본값을 씁니다. /// </summary> public void DefaultValue() { // 내부 데이터를 클리어 한다. ByteData.Clear(); BoolData.Clear(); IntData.Clear(); FloatData.Clear(); DoubleData.Clear(); StringData.Clear(); }
public override Data getData() { Data data = this.getPredecessor().getData(); if (data is DataStartSignal) { this.sampleRate = ((DataStartSignal)data).getSampleRate(); } if (data is DataStartSignal || (data is SpeechStartSignal && this.captureUtts)) { this.baos = new ByteArrayOutputStream(); this.dos = new DataOutputStream(this.baos); } if ((data is DataEndSignal && !this.captureUtts) || (data is SpeechEndSignal && this.captureUtts)) { string nextFreeIndex; if (this.isCompletePath) { nextFreeIndex = this.outFileNamePattern; } else { nextFreeIndex = WavWriter.getNextFreeIndex(this.outFileNamePattern); } this.writeFile(nextFreeIndex); this.isInSpeech = false; } if (data is SpeechStartSignal) { this.isInSpeech = true; } if ((data is DoubleData || data is FloatData) && (this.isInSpeech || !this.captureUtts)) { DoubleData doubleData = (!(data is DoubleData)) ? DataUtil.FloatData2DoubleData((FloatData)data) : ((DoubleData)data); double[] values = doubleData.getValues(); double[] array = values; int num = array.Length; int i = 0; while (i < num) { double num2 = array[i]; try { this.dos.writeShort((int)new Short((short)ByteCodeHelper.d2i(num2)).shortValue()); } catch (IOException ex) { Throwable.instancehelper_printStackTrace(ex); } i++; continue; } } return(data); }
/// <summary> /// Process data, creating the power spectrum from an input frame. /// </summary> /// <param name="input">the input frame</param> /// <returns>a DoubleData that is the power spectrum of the input frame</returns> private DoubleData Process(DoubleData input) { /// Create complex input sequence equivalent to the real /// input sequence. /// If the number of points is less than the window size, /// we incur in aliasing. If it's greater, we pad the input /// sequence with zeros. var _in = input.Values; if (_numberFftPoints < _in.Length) { var i = 0; for (; i < _numberFftPoints; i++) { _inputFrame[i] = new Complex(_in[i], 0.0f); } for (; i < _in.Length; i++) { _tempComplex = new Complex(_in[i], 0.0f); _inputFrame[i % _numberFftPoints] = Complex.Add (_inputFrame[i % _numberFftPoints], _tempComplex); } } else { var i = 0; for (; i < _in.Length; i++) { _inputFrame[i] = new Complex(_in[i], 0.0f); } for (; i < _numberFftPoints; i++) { _inputFrame[i] = new Complex(0.0d, 0.0d); } } // Create output sequence. var outputSpectrum = new double[(_numberFftPoints >> 1) + 1]; // Start Fast Fourier Transform recursion RecurseFft(_inputFrame, outputSpectrum, _numberFftPoints, _invert); /// Return the power spectrum var output = new DoubleData (outputSpectrum, input.SampleRate, input.FirstSampleNumber); return(output); }
//释放对象,清理内存 public void Clear() { _dash = null; _double = null; _magnet = null; _protect = null; _superMan = null; _startDash = null; _deadDash = null; _colliction = null; }
public override Data getData() { Data data; if (this.outputQueue.isEmpty()) { data = this.getPredecessor().getData(); if (data != null) { if (data is DoubleData) { DoubleData doubleData = (DoubleData)data; if (this.currentFirstSampleNumber == -1L) { this.currentFirstSampleNumber = doubleData.getFirstSampleNumber(); } this.createWindow(doubleData.getSampleRate()); this.process(doubleData); } else { if (data is DataStartSignal) { DataStartSignal dataStartSignal = (DataStartSignal)data; this.createWindow(dataStartSignal.getSampleRate()); Map props = dataStartSignal.getProps(); props.put("windowSize", Integer.valueOf(this.windowShift)); props.put("windowShift", Integer.valueOf(this.cosineWindow.Length)); this.currentFirstSampleNumber = -1L; } else if (data is SpeechStartSignal) { this.currentFirstSampleNumber = -1L; } else if (data is DataEndSignal || data is SpeechEndSignal) { this.processUtteranceEnd(); } this.outputQueue.add(data); } } } if (this.outputQueue.isEmpty()) { return(null); } data = (Data)this.outputQueue.remove(0); if (data is DoubleData && !RaisedCosineWindower.assertionsDisabled && ((DoubleData)data).getValues().Length != this.cosineWindow.Length) { throw new AssertionError(); } return(data); }
public static FloatData DoubleData2FloatData(DoubleData data) { int num = data.getValues().Length; float[] array = new float[num]; double[] values = data.getValues(); for (int i = 0; i < values.Length; i++) { array[i] = (float)values[i]; } return(new FloatData(array, data.getSampleRate(), data.getFirstSampleNumber())); }
private void addCepstrum(DoubleData doubleData) { DoubleData[] array = this.cepstraBuffer; int num = this.bufferPosition; int num2 = num; this.bufferPosition = num + 1; array[num2] = doubleData; int num3 = this.bufferPosition; int num4 = this.cepstraBufferSize; this.bufferPosition = ((num4 != -1) ? (num3 % num4) : 0); }
public DoubleData GetItem(int index) { if (index < value1s.Count && index < value2s.Count) { if (value1s[index] != null && value2s[index] != null) { DoubleData data = new DoubleData(value1s[index], value2s[index]); return(data); } } return(null); }
public override Data getData() { Data data = this.getPredecessor().getData(); if (data is DataStartSignal) { this.power = null; this.noise = null; this.floor = null; this.peak = null; return(data); } if (!(data is DoubleData)) { return(data); } DoubleData doubleData = (DoubleData)data; double[] values = doubleData.getValues(); int num = values.Length; if (this.power == null) { this.initStatistics(values, num); } this.updatePower(values); this.estimateEnvelope(this.power, this.noise); double[] array = new double[num]; for (int i = 0; i < num; i++) { array[i] = java.lang.Math.max(this.power[i] - this.noise[i], (double)0f); } this.estimateEnvelope(array, this.floor); this.tempMasking(array); this.powerBoosting(array); double[] array2 = new double[num]; for (int i = 0; i < num; i++) { array2[i] = array[i] / (this.power[i] + 1E-10); array2[i] = java.lang.Math.min(java.lang.Math.max(array2[i], (double)1f / this.maxGain), this.maxGain); } double[] array3 = this.smooth(array2); for (int i = 0; i < num; i++) { double[] array4 = values; int num2 = i; double[] array5 = array4; array5[num2] *= array3[i]; } return(data); }
/// <summary> /// perform the action /// </summary> /// <param name="">the data for the action</param> public override bool Act(object data) { DoubleData actionData = data as DoubleData; double duration = 0; if (actionData != null) { duration = actionData.Value; } Vibrate(duration); return(true); }
/// <summary> /// Converts FloatData object to DoubleData. /// </summary> public static FloatData DoubleData2FloatData(DoubleData data) { var numSamples = data.Values.Length; var floatData = new float[numSamples]; var values = data.Values; for (var i = 0; i < values.Length; i++) { floatData[i] = (float)values[i]; } return(new FloatData(floatData, data.SampleRate, data.FirstSampleNumber)); }
public void TryReadError(DoubleData data) { var culture = data.Culture; var style = data.Styles; var pos = 0; double expected; Assert.IsFalse(double.TryParse(data.Text, style, culture, out expected)); double actual; Assert.IsFalse(DoubleReader.TryRead(data.Text, ref pos, style, culture, out actual)); Assert.AreEqual(expected, actual); Assert.AreEqual(0, pos); }
/// <summary> /// Returns the amount of audio data in milliseconds in the given SpeechClassifiedData object. /// </summary> /// <param name="data">The SpeechClassifiedData object.</param> /// <returns>The amount of audio data in milliseconds.</returns> public int GetAudioTime(IData data) { if (data is DoubleData) { DoubleData audio = (DoubleData)data; return((int)((audio.Values.Length * 1000.0f / audio.SampleRate))); } else if (data is FloatData) { FloatData audio = (FloatData)data; return((int)((audio.Values.Length * 1000.0f / audio.SampleRate))); } Debug.Assert(false); return(-1); }
public void TryReadSuccess(DoubleData data) { var culture = data.Culture; var style = data.Styles; var pos = 0; double expected; Assert.IsTrue(double.TryParse(data.Text, style, culture, out expected)); double actual; Assert.IsTrue(DoubleReader.TryRead(data.Text, ref pos, style, culture, out actual)); Assert.AreEqual(expected, actual); var expectedEnd = data.Text.Length; Assert.AreEqual(expectedEnd, pos); }
/// <summary> /// Returns the next Data object. /// </summary> /// <returns> /// The next Data object, or null if none available. /// </returns> public override IData GetData() { IData audio = Predecessor.GetData(); if (audio is DataStartSignal) { Reset(); } if (audio is DoubleData) { DoubleData data = (DoubleData)audio; audio = Classify(data); } return(audio); }
private bool isAudioStreamContinuous(Data data) { if (data is DoubleData) { DoubleData doubleData = (DoubleData)data; if (this.lastSampleNum != -1L && this.lastSampleNum != doubleData.getFirstSampleNumber()) { return(false); } this.lastSampleNum = doubleData.getFirstSampleNumber() + (long)doubleData.getValues().Length; } else if (data is DataStartSignal) { this.lastSampleNum = -1L; } return(true); }
private Data process(DoubleData doubleData) { double[] values = doubleData.getValues(); if (values.Length != this.numberPLPFilters) { string text = new StringBuilder().append("PLPSpectrum size is incorrect: plpspectrum.length == ").append(values.Length).append(", numberPLPFilters == ").append(this.numberPLPFilters).toString(); throw new IllegalArgumentException(text); } double[] array = this.powerLawCompress(values); double[] autocor = this.applyCosine(array); LinearPredictor linearPredictor = new LinearPredictor(this.LPCOrder); linearPredictor.getARFilter(autocor); double[] data = linearPredictor.getData(this.cepstrumSize); return(new DoubleData(data, doubleData.getSampleRate(), doubleData.getFirstSampleNumber())); }