问题标签 [sample-rate]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
24 浏览

wav - wav 使用 avconv 时样本数不一致

我需要制作一些一致的音乐样本。具有 1 秒长波和 44100 采样率,我应该能够获得正好 44100 个样本的数组。不幸的是,这不是真的。

我的方法如下:

1) 产生 output.wav,1 秒长,采样率为 44100

2)我阅读文件并打印样本数量

对于 input.mp3 和起始位置的不同选择,我得到不同的数字:43776、43776、44928、43776、43776、44928

我的问题是,为什么会这样?以及如何更改第 1 步以生成一致的数据样本?

0 投票
1 回答
45 浏览

arduino - “读取模拟电压”采样率

在这个 arduino 示例中:

读取模拟电压

如果我在 MEGA 2560 上运行它,采样率会是多少?我应该怎么做才能将采样率设置为 6kHz?

谢谢你。

0 投票
1 回答
870 浏览

arduino - “读取模拟电压”采样率

我想确保我的代码看起来可以正常工作,因为明天我没有太多时间使用信号发生器,我想知道如何设置采样率。

我想用 Arduino MEGA 2560 以 6kHz 的采样率对 2kHz 信号进行采样。它不一定是实时的,所以我正在考虑填充一个缓冲区,然后通过串行连接发送这些信号。任何人都可以说如果这段代码绝对不能为此工作吗?我怎样才能将采样率设置为 6kHz?

谢谢你。

0 投票
1 回答
888 浏览

matlab - Matlab,fdesign,采样率

我正在使用fdesign.lowpassMatlab 中的函数,对以 8kHz 采样的信号。我正在为语音信号制作滤波器并想滤除高斯噪声,我找到了基本频率。使用 FFT 大约为 343Hz。

所以我在Matlab中使用命令:

我的采样率应该是 8000/2 吗?

0 投票
1 回答
5215 浏览

python - Python波音频采样率

我正在尝试将 javascript 前端、flask 服务器和微软的认知服务结合起来进行音频识别。

微软的服务器要求音频数据具有特定的参数,特别是要求 16000 帧率\频率。

但是从windows上的浏览器我只能得到41000。现在,我得到41000的音频,然后像这样保存:

音频通过 socketio 以 dict\json 数据的形式接收。如果我直接保存而不更改任何内容,那听起来不错。但是如果我将采样率更改为 16000,它显然听起来失真并且非常缓慢,因此几秒钟的音频会延长到一分钟左右。

如何正确更改音频速率而影响它在 Python 3.4 中的声音?

谢谢。

编辑: 这是工作代码:

这里的缺点是,即使我通过 json 从 mediaRecorder Api 获取音频数据,所以我将它保存在内存中......我把它写在磁盘上,然后再次打开它以便能够使用 wave 的函数获取采样率。但是如果不将其写入磁盘,我该怎么做呢?谢谢。如果我必须为此提出一个新问题,当然可以。

EDIT2: 哦,好的,回答我自己的后续问题 -io.BytesIO成功了。

0 投票
1 回答
1176 浏览

python - How to measure the sample rate in python when getting data from a ADC?

I am working in a project using Raspberry Pi 3 B where I get data from a IR sensor(Sharp GP2Y0A21YK0F) through a ADC MPC3008 and display it in real-time using PyQtgraph library.

However, it seems that I am getting very few samples and the graph is not "smooth" as I expect.

I am using the Adafruit Python MCP3008 Library and the function mcp.read_adc(0) to get the data.

Is there a way to measure the sample rate in Python?

Thank you

Hugo Oliveira

0 投票
0 回答
639 浏览

c# - 运行时的采样率转换

所以,我有一个绝妙的主意来写一些东西来解析 .MOD 文件。(跟踪器音乐)为了尝试播放它们作为我自己的 C# 练习练习。

现在我一路来实际播放它,但遇到了一个问题。我的引擎使用的音频缓冲区是半固定速率的。我相信44100hz。这个特定的模块文件,就像我认为的所有 .MOD 文件一样,具有 8287Hz 的采样率(我相信来自 atari/amiga 时代的东西?)

长话短说,听起来不太好。

然后我读了一些关于采样率转换的内容。和一些页面做了一个简单的对比。如果您没有多余的东西,请使用最近的邻居。所以我做了。这听起来像一匹垂死的马。喜欢它可怕的尖叫,不推荐。所以我尝试了下一个最好的事情。线性插值。我知道什么时候必须播放原始 8.3Khz 文件中的下一个最佳样本,并且到那时我必须填充的所有样本,我都会用原始文件中的最后一个样本进行插值。或者 0 否则我认为(这可能很糟糕,但有点不重要)

所以现在我有了它,它模糊地类似于真实的声音(盐粒),但听起来仍然很可怕。我做错了什么,还是 SRC 需要更多的时间才能从中得到一些不错的东西?我也听不到最近邻和线性插值之间的任何真正区别,有什么原因吗?

原文: http: //puu.sh/tkgWZ.wav

最近的:http: //puu.sh/tkh0L.ogg

线性插值: http: //puu.sh/tkgZ6.ogg

在运行时尝试这个而不是预处理每个样本然后使用它是否现实?

我已经看到高级库仅涵盖这一点。而且我不需要我的项目听起来像这样,但是有没有一个不错的选择,或者我只是在这里做错了吗?我真的很感激一些音频方面的见解,因为我对音频的工作原理并不十分了解。

欢迎任何建议!

0 投票
1 回答
95 浏览

algorithm - How to detect the precise sampling interval from samples stored in a database?

A hardware sensor is sampled precisely (precise period of sampling) using a real-time unit. However, the time value is not sent to the database together with the sampled value. Instead, time of insertion of the record to the database is stored for the sample in the database. The DATETIME type is used, and the GETDATE() function is used to get current time (Microsoft SQL Server).

How can I reconstruct the precise sampling times?

As the sampling interval is (should be) 60 seconds exactly, there was no need earlier for more precise solution. (This is an old solution, third party, with a lot of historical samples. This way it is not possible to fix the design.)

For processing of the samples, I need to reconstruct the correct time instances for the samples. There is no problem with shifting the time of the whole sequence (that is, it does not matter whether the start time is rather off, not absolute). On the other hand, the sampling interval should be detected as precisely as possible. I also cannot be sure, that the sampling interval was exactly 60 seconds (as mentioned above). I also cannot be sure, that the sampling interval was really constant (say, slight differences based on temperature of the device).

When processing the samples, I want to get:

  • start time
  • the sampling interval
  • the sequence o the sample values

When reconstructing the samples, I need to convert it back to tuples:

  • time of the sample
  • value of the sample

Because of that, for the sequence with n samples, the time of the last sample should be equal to start_time + sampling_interval * (n - 1), and it should be reasonably close to the original end time stored in the database.

Think in terms of the stored sample times slightly oscillate with respect to the real sample-times (the constant delay between the sampling and the insertion into the database is not a problem here).

I was thinking about calculating the mean value and the corrected standard deviation for the interval calculated from the previous and current sample times.

Discontinuity detection: If the calculated interval is greater than 3 sigma off the mean value, I would consider it a discontinuity of the sampled curve (say, the machine is switched off, or any outer event lead to missing samples. In the case, I want to start with processing a new sequence. (The sampling frequency could also be changed.)

Is there any well known approach to the problem. If yes, can you point me to the article(s)? Or can you give me the name or acronym of the algorithm?

0 投票
0 回答
96 浏览

numpy - 从频谱图中提取采样率

我有一组频谱图作为 numpy 数组。有什么办法可以找到他们的采样率?我没有任何其他信息,例如原始声音文件。

0 投票
0 回答
440 浏览

time-series - 选择采样率

我有一些原始加速度计数据,这些数据是在 200 到 220 Hz 的采样率下以不均匀的时间间隔收集的。我想使用固定方法分析数据,因此我对原始数据应用了 matlab 抗锯齿功能重新采样。这是我用于重采样的代码:

time_data = timeseries(mag, time) % mag 是幅度 sqrt(x^2 + y^2 + Z^2)

fs = 26; %频率

time_end = 50;

dt = 1 / fs;% 固定 dt = 1 / fs 的新时间向量

new_time = 1:dt:time_end;

time_datanew = resample(time_data, new_time);

我的问题是:如何选择频率 fs,即我应该为重采样数据选择哪个采样率?结束时间应该是多少,即这个窗口应该有多大才能检测到一些重要的特征?

希望我的问题有意义:)

非常感谢您的帮助。