当前位置: 首页>>代码示例>>C#>>正文


C# Frame.ToArray方法代码示例

本文整理汇总了C#中Frame.ToArray方法的典型用法代码示例。如果您正苦于以下问题:C# Frame.ToArray方法的具体用法?C# Frame.ToArray怎么用?C# Frame.ToArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Frame的用法示例。


在下文中一共展示了Frame.ToArray方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Fft

		/**
		 * Calculates FFT of a signal frame using radix-2 algorithm.
		 *
		 * Input data is given as a pointer to Frame object.
		 * Output spectrum is written to the spectrum vector, which must be
		 * initialized prior to the call to fft(). The spectrum is
		 * normalized by N/2, wher N is input frame length (zero-padded).
		 * The method  returns maximum magnitude of the calculated spectrum,
		 * which can be used for example to scale a frequency plot.
		 *
		 * @param frame pointer to Frame object
		 * @param spectrum initialized complex vector of the same length as data
		 * @return maximum magnitude of the spectrum
		 * @since 2.0.1
		 */
		public double Fft(Frame frame, ref Complex[] spectrum)
		{
			// the vector is initialized to zero padded length,
			// what means that it contains default values of contained type
			// (0.0 in case of double); that allows us to loop
			// only to frame length without padding and
			// automatically have zeros at the end of data
			double[] data = new double[zeroPaddedLength];
			int length = frame.GetLength();
			
			short[] frameArray = frame.ToArray();
			
			// first sample does not need preemphasis
			data[0] = frameArray[0];

			double current = 0.0;
			double previous = data[0];
			
			// iterate over all samples of the frame
			// filter the data through preemphasis
			// and apply a chosen window function
			// The goal of pre-emphasis is to compensate the high-frequency part
			// that was suppressed during the sound production mechanism of humans.
			// Moreover, it can also amplify the importance of high-frequency formants.
			// It's not neccesary for only music, but important for speech
			// (Set to 0 if no pre-emphasis should be performed)
			for (int n = 1; n < length; n++)
			{
				current = frameArray[n];
				data[n] = (current - preemphasisFactor * previous) * Window.Apply(winType, n, length);
				previous = current;
			}
			
			return Fft(data, ref spectrum);
		}
开发者ID:khairy-mohamed,项目名称:FindSimilar,代码行数:50,代码来源:Transform.cs


注:本文中的Frame.ToArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。