C# Mel-Spectrogram 梅尔频谱

目录

介绍

Main features

Philosophy of NWaves

效果 

项目

代码

下载


C# Mel-Spectrogram 梅尔频谱

介绍

利用NWaves实现Mel-Spectrogram 梅尔频谱

NWaves github 地址:https://github.com/ar1st0crat/NWaves

NWaves is a .NET DSP library with a lot of audio processing functions.

Main features

  •  major DSP transforms (FFT, DCT, MDCT, STFT, FWT, Hilbert, Hartley, Mellin, cepstral, Goertzel)
  •  signal builders (sine, white/pink/red/Perlin noise, awgn, triangle, sawtooth, square, pulse, ramp, ADSR, wavetable)
  •  basic LTI digital filters (moving average, comb, Savitzky-Golay, pre/de-emphasis, DC removal, RASTA)
  •  FIR/IIR filtering (offline and online), zero-phase filtering
  •  BiQuad filters (low-pass, high-pass, band-pass, notch, all-pass, peaking, shelving)
  •  1-pole filters (low-pass, high-pass)
  •  IIR filters (Bessel, Butterworth, Chebyshev I & II, Elliptic, Thiran)
  •  basic operations (convolution, cross-correlation, rectification, amplification, fade / crossfade)
  •  block convolution (overlap-add / overlap-save offline and online)
  •  basic filter design & analysis (group delay, zeros/poles, BP, BR, HP from/to LP, SOS, combining filters)
  •  state space representation of LTI filters
  •  FIR filter design: frequency sampling, window-sinc, equiripple (Remez / Parks-McClellan)
  •  IIR filter design: IirNotch / IirPeak / IirCombNotch / IirCombPeak
  •  non-linear filters (median filter, distortion effects, bit crusher)
  •  windowing functions (Hamming, Blackman, Hann, Gaussian, Kaiser, KBD, triangular, Lanczos, flat-top, Bartlett)
  •  periodograms (Welch / Lomb-Scargle)
  •  psychoacoustic filter banks (Mel, Bark, Critical Bands, ERB, octaves) and VTLN warping
  •  customizable feature extraction (time-domain, spectral, MFCC, PNCC/SPNCC, LPC, LPCC, PLP, AMS)
  •  preconfigured MFCC extractors: HTK (MFCC-FB24), Slaney (MFCC-FB40)
  •  LPC conversions: LPC<->cepstrum, LPC<->LSF
  •  feature post-processing (mean and variance normalization, adding deltas) and CSV serialization
  •  spectral features (centroid, spread, flatness, entropy, rolloff, contrast, crest, decrease, noiseness, MPEG7)
  •  harmonic features (harmonic centroid and spread, inharmonicity, tristimulus, odd-to-even ratio)
  •  time-domain characteristics (rms, energy, zero-crossing rate, entropy)
  •  pitch tracking (autocorrelation, YIN, ZCR + Schmitt trigger, HSS/HPS, cepstrum)
  •  chromagram (chroma feature extractor)
  •  time scale modification (phase vocoder, PV with identity phase locking, WSOLA, PaulStretch)
  •  simple resampling, interpolation, decimation
  •  bandlimited resampling
  •  wavelets: haar, db, symlet, coiflet
  •  polyphase filters
  •  noise reduction (spectral subtraction, sciPy-style Wiener filtering)
  •  sound effects (echo, tremolo, wahwah, phaser, chorus, vibrato, flanger, pitch shift, morphing, robotize, whisperize)
  •  3D/Stereo audio (stereo panning, stereo and ping-pong delay, ITD-ILD, binaural panning)
  •  envelope following
  •  dynamics processing (limiter / compressor / expander / noise gate)
  •  harmonic/percussive separation
  •  Griffin-Lim algorithm
  •  Karplus-Strong synthesis
  •  PADSynth synthesis
  •  adaptive filtering (LMS, NLMS, LMF, SignLMS, RLS)
  •  simple modulation/demodulation (AM, ring, FM, PM)
  •  simple audio playback and recording

Philosophy of NWaves

NWaves was initially intended for research, visualizing and teaching basics of DSP and sound programming.

Usually, DSP code is quite complicated and difficult to read, because it's full of optimizations (which is actually a very good thing). NWaves project aims in particular at achieving a tradeoff between good understandable code/design and satisfactory performance. Yet, the main purpose of this lib is to offer the DSP codebase that would be:

  • easy to read and understand
  • easy to incorporate into existing projects
  • easy to port to other programming languages and frameworks
  • even possibly treated as the DSP/audio textbook.

效果 

项目

代码

using NWaves.Audio;
using NWaves.FeatureExtractors;
using NWaves.FeatureExtractors.Options;
using NWaves.Filters.Fda;
using NWaves.Signals;
using NWaves.Windows;
using System;
using System.IO;
using System.Text;
using System.Windows.Forms;namespace C__Mel_Spectrogram_梅尔频谱
{public partial class Form1 : Form{public Form1(){InitializeComponent();}WaveFile waveContainer;StringBuilder sb = new StringBuilder();private void button1_Click(object sender, EventArgs e){using (var stream = new FileStream("你好.wav", FileMode.Open)){waveContainer = new WaveFile(stream);}DiscreteSignal left = waveContainer[Channels.Left];//DiscreteSignal right = waveContainer[Channels.Right];//Mel-Spectrogramvar fftSize = 1024;var hopSize = 512;var melCount = 16;int samplingRate = left.SamplingRate;var mfccExtractor = new FilterbankExtractor(new FilterbankOptions{SamplingRate = samplingRate,FrameSize = fftSize,FftSize = fftSize,HopSize = hopSize,Window = WindowType.Hann,FilterBank = FilterBanks.Triangular(fftSize, samplingRate, FilterBanks.MelBands(melCount, samplingRate)),// if power = 1.0// SpectrumType = SpectrumType.Magnitude});var mfccVectors = mfccExtractor.ParallelComputeFrom(left);sb.Clear();foreach (var item in mfccVectors){sb.AppendLine(String.Join(",", item));}textBox1.Text = sb.ToString();}}
}

下载

源码下载

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/520093.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Postman 接口自动化测试教程:入门介绍和从 0 到 1 搭建 Postman 接口自动化测试项目

关于Postman接口自动化测试的导引&#xff0c;全面介绍入门基础和从零开始搭建项目的步骤。学习如何有效地使用Postman进行API测试&#xff0c;了解项目搭建的基础结构、环境设置和测试用例的编写。无论您是新手还是经验丰富的测试人员&#xff0c;这篇教程都将为您提供清晰的指…

代码第二十四天-寻找旋转排序数组中的最小值Ⅱ

寻找旋转排序数组中的最小值Ⅱ 题目要求 解题思路 二分法 当遇到两个left、right两个位置值相同时候&#xff0c;可以选择将 right right-1 代码 class Solution:def findMin(self, nums: List[int]) -> int:left,right0,len(nums)-1while left<right:mid(leftright…

基于session注册JAva篇springboot

springboot3全家桶&#xff0c;数据库 &#xff1a;redis&#xff0c;mysql 背景环境&#xff1a;邮箱验证码&#xff0c;验证注册 流程&#xff1a;先通过邮箱验证&#xff0c;发送验证码&#xff0c;将获取到的session和验证码&#xff0c;存入redis里&#xff08;发送邮箱…

社区店运营方案分享:从推广到盈利的实战经验

对于想要开实体店或创业的朋友们&#xff0c;社区店是一个具有很大发展潜力的选择。 作为一名鲜奶吧5年的创业者&#xff0c;我将分享一些从推广到盈利的实战经验&#xff0c;希望能给大家提供有价值的参考。 1、市场调研&#xff1a; 在开店之前&#xff0c;深入了解社区的…

python 基础知识点(蓝桥杯python科目个人复习计划59)

今日复习内容&#xff1a;做题 例题1&#xff1a;建造房屋 问题描述&#xff1a; 小蓝和小桥是两位年轻的建筑师&#xff0c;他们正在设计一座新的城市。 在这个城市中&#xff0c;有N条街道&#xff0c;每条街道上有M个位置可以建造房屋&#xff08;一个位置只能建造一个房…

王道机试C++第 3 章 排序与查找:排序问题 Day28(含二分查找)

查找 查找是另一类必须掌握的基础算法&#xff0c;它不仅会在机试中直接考查&#xff0c;而且是其他某些算法的基础。之所以将查找和排序放在一起讲&#xff0c;是因为二者有较强的联系。排序的重要意义之一便是帮助人们更加方便地进行查找。如果不对数据进行排序&#xff0c;…

线性代数笔记13--正交向量和正交子空间

0. 四个子空间 1. 正交向量 两向量点乘为0&#xff0c;向量正交。 A ⊤ B 0 A^{\top}B0 A⊤B0 勾股定理 ∣ ∣ x ∣ ∣ 2 ∣ ∣ y 2 ∣ ∣ ∣ ∣ x y ∣ ∣ 2 ||x||^2||y^2||||xy||^2 ∣∣x∣∣2∣∣y2∣∣∣∣xy∣∣2 验证正交条件 ∣ ∣ x ∣ ∣ 2 x ⊤ x x x ⊤ ∣…

Qt ini配置文件

ini文件用于保存用户的设置操作&#xff0c;下列以背景颜色设置为例子 暂时默认设置为白色背景 这段代码放置在主窗口的构造函数中&#xff0c;用于初始化读取ini文件 QString color;QSettings *set new QSettings("color.ini",QSettings::IniFormat);set->begi…

Python语言基础与应用-北京大学-陈斌-P32-31-计算和控制流-上机练习:创建并调用函数-字符集合的并集-上机代码

Python语言基础与应用-北京大学-陈斌-P32-31-计算和控制流-上机练习&#xff1a;创建并调用函数-字符集合的并集-上机代码 本文环境&#xff1a; win10 Thonny4.1.4 # 函数训练字符集合的并集 def my_union(str1,str2):list1 []list2 []i 0 while i < len(str1):lis…

OpenAI官方发文:对于马斯克起诉Opanai的看法

双方立场 马斯克的观点&#xff1a;投入资金将OpenAi并入特斯拉&#xff0c;实现从非盈利组织到盈利组织的转变。 OpenAi的观点&#xff1a;OpenAI 的使命是确保 AGI 惠及全人类&#xff0c;需要筹集资金搞研发&#xff0c;以非盈利组织模式运营&#xff0c;不急于实现盈利。盈…

钉钉群内自定义机器人发送消息功能实现

文章目录 钉钉群内自定义机器人发送消息功能实现1、设置webhook自定义机器人2、查看官方文档&#xff0c;使用open api3、编写业务代码4、发送成功结果如下 钉钉群内自定义机器人发送消息功能实现 1、设置webhook自定义机器人 设置关键词 添加完成后&#xff0c;获得改机器人的…

为什么 JavaScript 中的 0.1 + 0.2 不等于 0.3

本文作者为 360 奇舞团前端开发工程师 在使用 JavaScript 处理运算时&#xff0c;有时会碰到数字运算结果不符合预期的情况&#xff0c;比如经典的 0.1 0.2 不等于 0.3。当然这种问题不只存在于 JavaScript&#xff0c;不过编程语言的一些原理大致相通&#xff0c;我以 JavaSc…