低音增强

harmonic sound is said to have a missing fundamentalsuppressed fundamental, orphantom fundamental when its overtones suggest a fundamental frequency but the sound lacks a component at the fundamental frequency itself. The brain perceives the pitch of a tone not only by its fundamental frequency, but also by the periodicity implied by the relationship between the higher harmonics; we may perceive the same pitch (perhaps with a differenttimbre) even if the fundamental frequency is missing from a tone.

For example, when a note (that is not a pure tone) has a pitch of 100 Hz, it will consist of frequency components that are integer multiples of that value (e.g. 100, 200, 300, 400, 500.... Hz). However, smaller loudspeakers may not produce low frequencies, and so in our example, the 100 Hz component may be missing. Nevertheless, a pitch corresponding to the fundamental may still be heard.

1.衰减高频部分,有利于突出低音部分。

2.衰减弱分量,有利于增加对比度。

2.根据人理听觉心理学感知,即便基音丢失,增强频谱的主要谐波,达到低音增强的目的。

试听:http://pan.baidu.com/s/1ntNz5wd

原始音频

处理后的音频

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
以下是一个简单的动态低音增强算法的C代码示例: ```c #include <stdio.h> #include <stdlib.h> #include <math.h> #define MAX(x, y) ((x) > (y) ? (x) : (y)) // 简单的IIR滤波器 typedef struct { double b[3]; double a[3]; double x[2]; double y[2]; } iir_filter_t; void iir_filter_init(iir_filter_t* filter, double b0, double b1, double b2, double a1, double a2) { filter->b[0] = b0; filter->b[1] = b1; filter->b[2] = b2; filter->a[1] = a1; filter->a[2] = a2; filter->x[0] = 0.0; filter->x[1] = 0.0; filter->y[0] = 0.0; filter->y[1] = 0.0; } double iir_filter_apply(iir_filter_t* filter, double x) { double y = filter->b[0] * x + filter->b[1] * filter->x[0] + filter->b[2] * filter->x[1] - filter->a[1] * filter->y[0] - filter->a[2] * filter->y[1]; filter->x[1] = filter->x[0]; filter->x[0] = x; filter->y[1] = filter->y[0]; filter->y[0] = y; return y; } // 动态低音增强算法 void dynamic_bass_boost(double* audio, int n, int fs, double* audio_boosted) { // 设置滤波器参数 double f_cutoff = 100.0; // 截止频率为100Hz double Q = 1.0; // 值越大,带宽越窄 double w0 = 2.0 * M_PI * f_cutoff / fs; double alpha = sin(w0) / (2.0 * Q); double b0 = (1.0 - cos(w0)) / 2.0; double b1 = 1.0 - cos(w0); double b2 = (1.0 - cos(w0)) / 2.0; double a1 = -2.0 * cos(w0); double a2 = 1.0 - alpha; iir_filter_t filter; iir_filter_init(&filter, b0, b1, b2, a1, a2); // 计算音频信号的瞬时能量 int window_size = (int)(fs * 0.1); // 每100ms计算一次能量 double* energy = (double*)calloc(n, sizeof(double)); for (int i = window_size; i < n; i++) { for (int j = i - window_size; j < i; j++) { energy[i] += audio[j] * audio[j]; } } // 根据瞬时能量动态增强低音 double gain_max = 6.0; // 最大增益为6dB double threshold = 0.9 * energy[n-1]; // 能量的90%作为阈值 double* gain = (double*)calloc(n, sizeof(double)); for (int i = window_size; i < n; i++) { if (energy[i] > threshold) { double g = MAX(1.0, (energy[i] / threshold - 1.0) * (gain_max - 1.0) + 1.0); gain[i] = pow(10.0, g / 20.0); } } // 应用增益 for (int i = 0; i < n; i++) { double x = iir_filter_apply(&filter, audio[i]); audio_boosted[i] = x * gain[i]; } free(energy); free(gain); } ``` 这个算法的基本思路和Python代码实现相同,不同之处在于使用了C语言的结构体来实现滤波器,使用动态内存分配来分配能量和增益的数组。另外,注意在C语言中需要手动计算幂次,例如使用`pow()`函数来计算增益的幂次。
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值