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-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.mfbz.cn/a/437827.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

SAP PP学习笔记 - 豆知识08 - 如何修改价格

正常的品目修改用MM02。 新建一个品目之后&#xff0c;啥都没干&#xff0c;现在想修改一下价格&#xff0c;发现MM02 修改不了了。 1&#xff0c;MR21 这里注意 转记日付 要和会计期间一致。 比如我这里的会计期间是 2024/03 有关会计期间&#xff0c;可以参照如下文章&am…

项目经理如何应对多系统对接的项目?

对于项目经理来说&#xff0c;处理系统对接&#xff08;API对接&#xff09;的需求是一项既复杂又关键的任务。这项任务涉及到确保不同的系统能够高效、安全地共享数据&#xff0c;从而实现流畅的业务流程和提高整体的系统性能。下面是一个详细的指南&#xff0c;旨在帮助产品经…

部署zabbix6.0.27 执行 make install 报错

CentOS7 部署 zabbix6.0.27 执行 make install 报错 报错信息 [rootlocalhost zabbix-6.0.27]# make install /usr/bin/ld: warning: libssl.so.3, needed by /usr/local/mysql/lib/libmysqlclient.so, not found (try using -rpath or -rpath-link) /usr/bin/ld: warning: l…

论文阅读:SDXL Improving Latent Diffusion Models for High-Resolution Image Synthesis

SDXL Improving Latent Diffusion Models for High-Resolution Image Synthesis 论文链接 代码链接 介绍 背景&#xff1a;Stable Diffusion在合成高分辨率图片方面表现出色&#xff0c;但是仍然需要提高本文提出了SD XL&#xff0c;使用了更大的UNet网络&#xff0c;以及增…

Java定时调度范式定时操作

在 Java 中&#xff0c;我们可以使用各种方法来执行定时操作。这些操作包括执行任务、调度任务、执行重复任务等。下面将介绍几种常见的 Java 定时调度范式。 1. Timer 和 TimerTask Java 提供了 Timer 和 TimerTask 类&#xff0c;用于执行定时任务。 示例代码&#xff1a;…

【JavaEE初阶】 JVM简介

文章目录 &#x1f38d;前言&#x1f343;JVM发展史&#x1f6a9;Sun Classic VM&#x1f6a9;Exact VM&#x1f6a9;HotSpot VM&#x1f6a9;JRockit&#x1f6a9;J9 JVM&#x1f6a9;Taobao JVM&#xff08;国产研发&#xff09; &#x1f340;JVM 运行流程⭕总结 &#x1f3…

【Datawhale组队学习:Sora原理与技术实战】

Transformersdiffusion技术背景简介 Transformers diffusion背景 近期大火的OpenAI推出的Sora模型&#xff0c;其核心技术点之一&#xff0c;是将视觉数据转化为Patch的统一表示形式&#xff0c;并通过Transformers技术和扩散模型结合&#xff0c;展现了卓越的scale特性。 被…

成功实施自动化测试的优点

随着技术的发展&#xff0c;保证应用程序的质量变得越来越具有挑战性。由于敏捷开发和成本因素&#xff0c;导致了发现问题窗口时间有限&#xff0c;因此测试经常会忽略某些应该关注的地方。 测试工程师应该在发布产品之前发现其中存在的问题&#xff0c;但是任何软件都不可能…

SpringBoot项目如何添加全局接口上下文

1. 定义Spring Boot应用的路由 首先&#xff0c;确保您的Spring Boot应用有一个统一的路由前缀。例如&#xff0c;可以在application.properties或application.yml配置文件中使用server.servlet.context-path属性来定义所有请求的基础路径。 # application.properties server…

Ansible 基础入门

2&#xff09;Ansible 介绍 Ansible 基本概念 Ansible 是一种自动化运维工具&#xff0c;基于 Paramiko 开发的&#xff0c;并且基于模块化工作&#xff0c;Ansible 是一种集成 IT 系统的配置管理、应用部署、执行特定任务的开源平台&#xff0c;它是基于 Python 语言&#xf…

sudo command not found

文章目录 一句话Intro其他操作 一句话 sudo 某命令 改成 sudo -i 某命令 试试。 -i 会把当前用户的环境变量带过去&#xff0c;这样在sudo的时候&#xff0c;有更高的权限&#xff0c;有本用户的环境变量(下的程序命令)。 -i, --login run login shell as the target user; a …

I’m stuck!(CCF201312-5)解析(java实现)

代码 package test_201312;import java.util.Scanner;/** 201312-5 试题名称&#xff1a; I’m stuck! 时间限制&#xff1a; 1.0s 内存限制&#xff1a; 256.0MB 问题描述&#xff1a; 问题描述给定一个R行C列的地图&#xff0c;地图的每一个方格可能是#, , -, |, ., S, T七…

JS使用方式

JS是解释性语言&#xff0c;所以不需要搭建类似C#/Java之类的开发运行环境&#xff0c;因为他们是编译型语言。JS一般运行在浏览器中或者node环境中&#xff0c;这里都是JS引擎的功劳。 node环境使用 推荐使用nvm管理node版本&#xff0c;nrm管理代理地址。 安装node&#xf…

腾讯云服务器和阿里云服务器哪家更优惠?2024价格对比

2024年阿里云服务器和腾讯云服务器价格战已经打响&#xff0c;阿里云服务器优惠61元一年起&#xff0c;腾讯云服务器61元一年&#xff0c;2核2G3M、2核4G、4核8G、4核16G、8核16G、16核32G、16核64G等配置价格对比&#xff0c;阿腾云atengyun.com整理阿里云和腾讯云服务器详细配…

【蓝桥杯基础算法】dfs(上)组合数,全排列

刚接触算法&#xff0c;有没有被递归又循环的dfs吓到&#xff1f;没关系&#xff0c;几个例题就可以彻底掌握&#xff01; 1.全排列 1-n的全排列,如输入3&#xff0c;按顺序对1-3进行排列 //枚举 #include<iostream> #include<algorithm> #include<cstring>…

【Linux基础(二)】进程管理

学习分享 1、程序和进程1.1、程序1.2、进程和进程ID 2、Linux下的进程结构3、init进程4、获取进程标识5、fork系统调用5.1、fork函数实例分析 6、进程的特性7、在Linux下进程指令7.1、终止进程指令7.2、查看进程指令&#xff1a;7.3、以树状图列出进程 8、多进程运行异常情况8.…

【Spring云原生系列】Spring Cloud Stream:消息驱动架构(MDA)解析,实现异步处理与解耦合!

&#x1f389;&#x1f389;欢迎光临&#xff0c;终于等到你啦&#x1f389;&#x1f389; &#x1f3c5;我是苏泽&#xff0c;一位对技术充满热情的探索者和分享者。&#x1f680;&#x1f680; &#x1f31f;持续更新的专栏《Spring 狂野之旅&#xff1a;从入门到入魔》 &a…

2024年抖店新商家自学全套教程,完整版店铺操作流程,如下!

我是王路飞。 想做一个项目的话&#xff0c;就要先了解其完整的流程是怎样的。 做抖店也不例外&#xff0c;没开店的就先了解下抖店的基本信息和大概运营流程&#xff1b;开过店的就先让自己入门并把流程跑通&#xff0c;如此才有承接后续渠道和资源的能力。 今天这篇文章专…

计算机网络:应用层知识点汇总

文章目录 一、网络应用模型二、域名系统&#xff08;DNS&#xff09;三、文本传输协议&#xff08;FTP&#xff09;四、电子邮件五、万维网和HTTP协议 一、网络应用模型 p2p也就是对等模型 二、域名系统&#xff08;DNS&#xff09; 我们知道&#xff0c;随着人们建立一个网站…

【机器学习】【决策树】分类树|回归树学习笔记总结

决策树算法概述 基本概念 决策树&#xff1a;从根节点开始一步步走到叶子节点&#xff0c;每一步都是决策过程 对于判断的先后顺序把控特别严格 一旦将判断顺序进行变化则最终的结果将可能发生改变 往往将分类效果较佳的判断条件放在前面&#xff0c;即先初略分在进行细节分…