- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我使用knowles sph0645lm4h-b 麦克风获取数据,它是24 位PCM 格式,具有18 个数据精度。然后将 24 位 PCM 数据截断为 18 位数据,因为根据规范,最后 6 位始终为 0。之后,18 位数据存储为 32 位无符号整数。当 MSB 位为 0 时,表示为正整数,当 MSB 为 0 时,表示为负整数。
在那之后,我发现所有的数据都是正面的,不管我曾经测试过哪种声音。我用双频对其进行了测试,并进行了 FFT,然后我发现结果几乎是正确的,除了大约 0-100Hz 的较低频率更大。但我用数据重建了声音,用于 FFT 算法。重建的声音几乎是正确的,但有噪音。
我使用缓冲区来存储使用 DMA 传输的麦克风数据。缓冲区是
uint16_t fft_buffer[FFT_LENGTH*4]
DMA_InitStructure.DMA_Channel = DMA_Channel_0;
DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)&(SPI2->DR);
DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)fft_buffer;
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory;
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
DMA_InitStructure.DMA_PeripheralDataSize =DMA_PeripheralDataSize_HalfWord;
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;
DMA_InitStructure.DMA_BufferSize = FFT_LENGTH*4;
DMA_InitStructure.DMA_Mode = DMA_Mode_Normal;
DMA_InitStructure.DMA_Priority = DMA_Priority_VeryHigh;
DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable;
DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_Full;
DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single;
DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single;
int32_t fft_integer[FFT_LENGTH];
for (t=0;t<FFT_LENGTH*4;t=t+4){
uint8_t first_8_bits, second_8_bits, last_2_bits;
uint32_t store_int;
/* get the first 8 bits, middle 8 bits and last 2 bits, combine it to a new value */
first_8_bits = fft_buffer[t]>>8;
second_8_bits = fft_buffer[t]&0xFF;
last_2_bits = (fft_buffer[t+1]>>8)>>6;
store_int = ((first_8_bits <<10)+(second_8_bits <<2)+last_2_bits);
/* convert it to signed integer number according to the MSB of value
* if MSB is 1, then set all the bits before MSB to 1
*/
const uint8_t negative = ((store_int & (1 << 17)) != 0);
int32_t nativeInt;
if (negative)
nativeInt = store_int | ~((1 << 18) - 1);
else
nativeInt = store_int;
fft_integer[cnt] = nativeInt;
cnt++;
}
uint8_t a, b, c, d
for (t=0;t<FFT_LENGTH*4;t=t+4){
a = (fft_buffer[t]&0xFF00)>>8;
b = fft_buffer[t]&0x00FF;
c = (fft_buffer[t+1]&0xFF00)>>8;
/* set the tri-state to 0 */
d = fft_buffer[t+1]&0x0000;
printf("%.2x",a);
printf("%.2x",b);
printf("%.2x",c);
printf("%.2x\n",d);
}
0ec40000
0ec48000
0ec50000
0ec60000
0ec60000
0ec5c000
...
0cf28000
0cf20000
0cf10000
0cf04000
0cef8000
0cef0000
0cedc000
0ced4000
0cee4000
0ced8000
0cec4000
0cebc000
0ceb4000
....
0b554000
0b548000
0b538000
0b53c000
0b524000
0b50c000
0b50c000
...
c4 0e ff 00
c5 0e ff 40
...
52 0b ff c0
50 0b ff c0
最佳答案
原始数据中从DC开始的大低频分量是由于错误地将24位二进制补码样本转换为int32_t
造成的大DC偏移。 .直流偏移是听不见的,除非它导致发生削波或算术溢出。实际上没有任何高达 100Hz 的低频,这仅仅是 FFT 对强 DC (0Hz) 元素的响应的人工产物。这就是为什么你听不到任何低频的原因。
下面我已经尽可能清楚地陈述了一些假设,以便可以调整答案以匹配实际情况。
鉴于:
Raw data in Memory:
c4 0e ff 00
c5 0e ff 40
...
52 0b ff c0
50 0b ff c0I use it as little endian.
2 elements are used for data from one channel and 2 element is used for the other channel
fft_buffer[0] stores the higher 16 bits, fft_buffer[1] stores the lower 16 bits
c4 0e ff 00
fft_buffer[n] = 0x0ec4 ;
fft_buffer[n+1] = 0x00ff ;
0x00ff0ec4
fft_buffer
作为 32 位数组,交换 16 位字序,然后移位以将符号位移动到
int32_t
符号位位置和(可选)重新缩放,例如:
c4 0e ff 00 => 0x00ff0ec4
0x00ff0ec4<< 8 = 0xff0ec400
0xff0ec400/ 16384 = 0xffff0ec4(-61756)
// Reinterpret DMA buffer as 32bit samples
int32_t* fft_buffer32 = (int32_t*)fft_buffer ;
// For each even numbered DMA buffer sample...
for( t = 0; t < FFT_LENGTH * 2; t += 2 )
{
// ... swap 16 bit word order
int32_t sample = fft_buffer32 [t] << 16 |
fft_buffer32 [t] >> 16 ;
// ... from 24 to 32 bit 2's complement and rescale to
// maintain original magnitude. Copy to single channel
// fft_integer array.
fft_integer[t / 2] = (sample << 8) / 16384 ;
}
关于audio - 麦克风的低频分量过大,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44684556/
我想使用错误组件显示我的错误消息,但不想在 中加载组件对于经过身份验证的用户,导航菜单也不应显示。 我有这样的应用程序组件.. 我有错误处理程序,它使用 router.navigate 路由
我正在尝试获取 RGB 图像,将其转换为 LAB(又名 CIE L* a* b*)色彩空间,然后提取 L* 分量。 这是我的代码: from skimage import io, color from
我在我的一个模型中定义了以下常量。 export const NEWS_TYPE_TEXT = { News: 'News', Interview: 'Intervie
我有一个Electron(6)/Angular(8)应用程序。 在正面( Angular ),我通过IPCRenderer向背面发送一条消息。 在背面,IPCMain接收消息并执行所需的操作,例如,获
我正在尝试在我的应用程序中创建一个可重用的 quickView 模式,以使用 ng-bootstrap modal library 动态加载任何组件。 就我加载文档中所示的相同示例组件而言,它工作正常
我需要将一个名为“photos”的数组从我的 component.ts 传递到 component.html。这是我的 component.ts 文件 export class PhotosCompo
我有一个按钮,单击该按钮会转到新路线并打开附加到该路线的另一个组件。 有没有一种方法可以从 DOM 中删除我们单击以转到不同组件的组件?示例:当单击“单击我返回主页”按钮时,它会打开另一个组件。在这种
这个问题在这里已经有了答案: Detect click outside Angular component (12 个答案) 5天前关闭。 我知道这方面有无数的问题,我尝试了每一个解决方案,但没有一个
我想将显示值的格式传递给 Angular 分量。 例如: format="'(utc, offset) location (tz)'" === '(UTC -04:00) New York (EDT)
我正在使用 Angular 组件将动态图表加载到我的小部件中: 这是我的组件的示例: angular.module("generalApp").component("chartPie", { temp
假设我有一个组件在被点击时发出一个事件,即 @Component({ selector: 'component-checkout-payment', template:
我有一个问题。 我正在处理另一个人的代码,有一个 JFrame 有很多 JSeparators(他用它们作为“面板”的边框)现在我将它们替换为 JBorderedPanel 类,该类遵循与整体相同的边
所以我在这里想做的是制作一个 Angular 组件并将其注入(inject)到我的 Angular 应用程序中。这是 Angular 分量的代码: (function(angular) { 'use
关闭。这个问题需要多问focused 。目前不接受答案。 想要改进此问题吗?更新问题,使其仅关注一个问题 editing this post . 已关闭 4 年前。 Improve this ques
我正在创建一个像这样的可重用组件: submit 我想在属性 isDisabled 为 true 时禁用点击事件,我尝试了类似的操作,但它不起作用。 packages/component/my-b
一种简单的说法是,当 RGB 分量相等时,它们形成灰色。然而,这还不是全部,因为如果它们只有细微的差别,它们看起来仍然是灰色的。 假设观看者具有健康的色彩视觉,我如何确定给定值是否会被视为灰色(大概具
您好我正在尝试使用带 Angular Electron 构建桌面应用程序,主要问题是在用户登录后我找不到正确加载主要组件的方法。正如您在 main.js 中看到的,这是我创建两个窗口(1 个用于登录的
new AngularJS 1.5 中似乎没有“替换”选项组件概念(就像指令一样)。 如果我想要表格行,你有什么建议元素作为组件?就有效的 HTML 而言是不可能的吗? 真实示例:mailBox组件内
我有颜色=#12FFFF。这是这种格式的颜色,其中 12FFFF 是十六进制数。现在我想获取每个独立的 R、G、B 分量的十进制。我该如何在java中做到这一点? 最佳答案 目前尚不清楚你的问题是什么
我需要一些关于 Java 的 ImageIO API 的帮助。我似乎迷失在 ComponentColorModel 类中。我需要逐像素检查 *.png 文件来检测它是灰度图像还是彩色图像。但是,我不知
我是一名优秀的程序员,十分优秀!