C# Mel-Spectrogram 梅尔频谱

news2024/10/22 20:22:43

目录

介绍

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-Spectrogram
            var 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.coloradmin.cn/o/1498546.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Springboot 的几种配置文件形式

方式一&#xff1a;多个yml文件 步骤1&#xff1a;创建多个配置文件 application.yml #主配置文件 application-dev.yml #开发环境的配置 application-prod.yml #生产环境的配置 application-test.yml #测试环境的配置步骤2&#xff1a;applicaiton.yml中指定配置 在a…

H3C BGP 基本配置实验

H3C BGP 基本配置实验 实验拓扑 ​​ 实验需求 按照图示配置 IP 地址&#xff0c;R1 和 R5 上使用环回口模拟业务网段&#xff0c;R2&#xff0c;R3&#xff0c;R4 的环回口用于配置 Router-id 和建立 IBGP 邻居AS 200 运行 OSPF 实现内部网络互通R1&#xff0c;R2&#xf…

Python 中实现 CDF 累积分布图的两种方法

什么是累积分布 累积分布函数&#xff0c;又叫分布函数&#xff0c;是概率密度函数的积分&#xff0c;能完整描述一个实随机变量X的概率分布。一般以大写“CDF”&#xff08;Cumulative Distribution Function&#xff09;标记。 《百度百科》 累积分布函数&#xff0c;又叫分…

LeetCode 刷题 [C++] 第300题.最长递增子序列

题目描述 给你一个整数数组 nums &#xff0c;找到其中最长严格递增子序列的长度。 子序列 是由数组派生而来的序列&#xff0c;删除&#xff08;或不删除&#xff09;数组中的元素而不改变其余元素的顺序。例如&#xff0c;[3,6,2,7] 是数组 [0,3,1,6,2,2,7] 的子序列。 题目…

【Linux】Linux原生异步IO(一):libaio-介绍

1、IO模型 1.1 简述 相信大家在搜索的时候,都会看到下面这张图,IO的使用场景:同步、异步、阻塞、非阻塞,可以组合成四种情况: 同步阻塞I/O: 用户进程进行I/O操作,一直阻塞到I/O操作完成为止。同步非阻塞I/O: 用户程序可以通过设置文件描述符的属性O_NONBLOCK,I/O操作可…

什么样的项目适合Web自动化测试

&#x1f525; 交流讨论&#xff1a;欢迎加入我们一起学习&#xff01; &#x1f525; 资源分享&#xff1a;耗时200小时精选的「软件测试」资料包 &#x1f525; 教程推荐&#xff1a;火遍全网的《软件测试》教程 &#x1f4e2;欢迎点赞 &#x1f44d; 收藏 ⭐留言 &#x1…

共用体union

一、共用体的特性 共用体又叫做联合体&#xff0c;共用体的特性如下&#xff1a; 1.共用体的所有成员共用一段内存空间&#xff0c;且所有成员的起始位置是一致的 2.共用体的值由最后赋值的成员决定 3.共用体的内存大小 共用体的内存必须大于或等于其他成员变量中最大数据类型…

专题1 - 双指针 - leetcode 15. 三数之和 - 中等难度

leetcode 15. 三数之和 - 点击直达 leetcode 15. 三数之和 中等难度 双指针1. 题目详情1. 原题链接2. 基础框架 2. 解题思路1. 题目分析2. 算法原理3. 时间复杂度 3. 代码实现4. 知识与收获 leetcode 15. 三数之和 中等难度 双指针 1. 题目详情 给你一个整数数组 nums &#…

SQL 替换某一列中所有数据的特定字符

UPDATE product SET spec REPLACE(spec, ,, ) 把product表的spec字段内容中的逗号替换为

性能问题分析排查思路之机器(3)

本文是性能问题分析排查思路的展开内容之一&#xff0c;第2篇&#xff0c;主要分为日志1期&#xff0c;机器4期、环境2期共7篇系列文章&#xff0c;本期是第三篇&#xff0c;讲机器&#xff08;硬件&#xff09;的网络方面的排查方法和最佳实践。 主要内容如图所示&#xff1a…

Java请求时间耗时长分析

推断是java.lang.OutOfMemoryError: Metaspace&#xff0c;元空间不够&#xff0c;频繁垃圾收集 这个过程中程序卡住一直不响应&#xff0c;应该是触发FGC有关系。 YGC&#xff1a;451->453 FGC&#xff1a;198->289 FGCT&#xff1a;52.246->76.291 但是堆内存的空间…

简易网络聊天室:2024/3/7

思维导图 基于UDP的简易网络聊天室 服务器&#xff1a; #include <myhead.h>#define SER_PORT 8888struct msgTyp //存储消息的结构体 {char type; //消息类型char name[30]; //用户姓名char text[1024]; //消息正文 };//创建链表存储客户端信息 typedef stru…

【计算机考研】考408,还是不考408性价比高?

首先综合考虑&#xff0c;如果其他科目并不是很优秀&#xff0c;需要我们花一定的时间去复习&#xff0c;408的性价比就不高&#xff0c;各个科目的时间互相挤压&#xff0c;如果备考时间不充裕&#xff0c;考虑其他专业课也未尝不可。 复习408本来就是费力不讨好的事情 不同…

SAP MM学习笔记44 - 特殊调达流程 - Blanket购买发注(汇总采购)

上一章学习了 支付计划&#xff0c;本章继续学习 Blanket购买发注&#xff08;汇总采购&#xff09;。 SAP MM学习笔记43 - 特殊调达流程 - 支付计划-CSDN博客 1&#xff0c;Blanket购买发注 概要 其实就是订好一个大致数额&#xff0c;然后让随便买&#xff0c;只要不超这个…

网络调试助手使用MQTT协议与Mosquitto通信(3)

一、连接报文 一开始设备需要连接到mqtt服务器&#xff0c;连接时的数据包内需要携带对应的设备ID&#xff0c;以及用户名和密码。这使用默认的用户名和密码。设备ID每一个设备都需要设置为不同的&#xff0c;两个相同的ID只能允许一台设备在线&#xff0c;另一个相同的ID的设备…

2024年最新阿里云服务器地域选择方法,以及可用区说明

阿里云服务器地域和可用区怎么选择&#xff1f;地域是指云服务器所在物理数据中心的位置&#xff0c;地域选择就近选择&#xff0c;访客距离地域所在城市越近网络延迟越低&#xff0c;速度就越快&#xff1b;可用区是指同一个地域下&#xff0c;网络和电力相互独立的区域&#…

实操keepalived(高可用)+Nginx(四层代理+七层代理),实现高可用、负载均衡以及动静分离

一 vrrp技术 VRRP 相关术语 VRRP能够在不改变组网的情况下&#xff0c;将多台路由器虚拟成一个虚拟路由器&#xff0c;i通过配置虚拟路由器的IP地址为默认网关&#xff0c;实现网关的备份。 协议版本: VRRPv2 (常用) 和VRRPv3:0 VRRPv2仅适用于IPv4网络&#xff0c;VRRPv3适用…

好物周刊#46:在线工具箱

https://github.com/cunyu1943 村雨遥的好物周刊&#xff0c;记录每周看到的有价值的信息&#xff0c;主要针对计算机领域&#xff0c;每周五发布。 一、项目 1. twelvet 一款基于 Spring Cloud Alibaba 的权限管理系统&#xff0c;集成市面上流行库&#xff0c;可以作用为快…

数字孪生10个技术栈:数据采集的八种方式

大家好&#xff0c;我是贝格前端工场&#xff0c;上期讲了数字孪生10个技术栈&#xff08;总括&#xff09;:概念扫盲和总体介绍&#xff0c;获得了大家的热捧&#xff0c;本期继续分享技术栈&#xff0c;大家如有数字孪生或者数据可视化的需求&#xff0c;可以联络我们。 一、…

文件包含漏洞初识

一、基础知识介绍 在web后台开发的时候&#xff0c;我们会使用PHP&#xff0c;Java这种代码&#xff0c;而在使用的过程中&#xff0c;我们经常会使用包含函数&#xff08;也就是调用&#xff09;&#xff0c;而很多时候&#xff0c;前端用户在选择浏览时会调用包含的文件这无…