如何在给定指定分贝级别的情况下在 R 中创建波形声音?

发布于 2024-12-19 03:00:44 字数 374 浏览 8 评论 0原文

IR,借助库 sound,我们能够创建正弦波:

s1 <- Sine(650, 1, 44100, 16, 2)

绘制波形,我们获得如下图像:

plot(s1[1:100])

waveform

波形在 [-1, +1] 区间移动。如果我播放它,它对应于多少分贝?

如何生成具有指定分贝级别的波浪声(具有相同的参数)(即波浪声,频率650Hz,持续时间1秒,采样率44100,16位,2通道,55dB)?

提前致谢!

I R, thanks to the library sound, we are able to create a sine wave:

s1 <- Sine(650, 1, 44100, 16, 2)

Plotting the waveform we obtain an image like this:

plot(s1[1:100])

waveform

The waveform moves in the interval [-1, +1]. If I play it, to what deciBel does it correspond?

How to generate a wave sound (with the same parameters), with a specified deciBel level (i.e. a wave sound, frequency 650Hz, duration 1 sec, sampling rate 44100, 16 bits, 2 channels, 55dB)?

Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你怎么敢 2024-12-26 03:00:44

所以我猜你想改变幅度,对吗?没有直接的方法可以按照您想要的方式改变声音的幅度,因为它是非常基本的包。尝试 tuneRseewave 软件包提供更高级的选项和控制(例如 afilter in seewave 可能是一个很好的解决方案,但是不幸的是我无法在 R 2.14 中运行它 - 不兼容)。

您可以用一种简单的方式做的是使用 normalize 来更改音量,但它不适用于 sound 包中的“默认”幅度。例如,如果您产生这个正弦波

 s1 <- .6*Sine(650, 1, 44100, 16, 2)  

,您可以通过以下方式对其进行归一化

 s2 <- normalize(s1) 

您可以听到(并在绘图上看到)s2 声音更大。

So I guess you want to change the amplitude right? There is no straightforward way to change amplitude in sound the way you want, because it's very basic package. Try tuneR or seewave packages for much more advanced options and control (for example afilter in seewave could be a good solution, but unfortunately I couldn't run it in R 2.14 - not compatible).

What you could do in a simple way is to use normalize to change the volume, but it doesn't work for the 'default' amplitude in sound package. For example, if you produce this sine wave

 s1 <- .6*Sine(650, 1, 44100, 16, 2)  

you can normalize it by

 s2 <- normalize(s1) 

And you can hear (and see on the plot) that the s2 is louder.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文