在给定时间查找.wav的“音量" [英] Finding the 'volume' of a .wav at a given time

查看:89
本文介绍了在给定时间查找.wav的“音量"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我的第四年项目开发一个小示例应用程序(处理功能响应式编程).这个想法是创建一个简单的程序,该程序可以播放.wav文件,然后显示正在播放的歌曲当前音量的弹跳"动画(例如在录音软件中).我正在Scala中构建它,因此主要是在研究Java库和现有的解决方案.

目前,我已经设法轻松播放.wav文件,但似乎无法实现第二个目标.基本上有一种方法可以解码.wav文件,以便我可以通过某种方式访问 在任何给定时间的音量"?从数量上看,我认为我的意思是振幅,但我对此可能是错的-高等物理学是前一段时间....

很显然,我对此一无所知,所以如果有人能指出我正确的方向,那就太好了!

解决方案

在数字音频处理中,您通常指的是信号的瞬时峰值幅度(也称为

另一种测量模式是RMS,它是通过在特定时间窗口内积分而计算得出的(将平方采样值相加,除以窗口长度,然后求平方根,即均方根RMS).这样可以更好地理解信号的能量",其移动比峰值测量更平滑,但无法捕获观察到的最大值.有时也将此模式称为 VU表.您可以使用某种滞后(低通)滤波器对此进行近似,例如y[i] = y[i-1]*a + |x[i]|*(a-1),对于某些值0 < a < 1

您通常以对数形式显示值,即在分贝中显示,因为这更符合我们的看法信号强度,并且对于大多数信号,可以更规则地覆盖屏幕空间.

我参与的三个项目可能会为您提供帮助:

  • ScalaAudioFile ,可用于从AIFF或WAVE文件中读取示例帧
  • ScalaAudioWidgets 这是一个尚不完善的项目,只能在scala-上提供一些音频应用程序小部件,摆动,包括PPM视图-只需使用滑动窗口,并以固定的时间间隔设置窗口的当前峰值(以及可选的RMS),该视图将处理峰值保持时间和下降时间
  • ( ScalaCollider ,SuperCollider声音合成系统的客户端,您可以使用它来播放声音文件并实时测量峰值和RMS幅度,后者可能对您的项目来说是一个过大的杀伤力,如果您从未听说过SuperCollider,则可能会涉及一些严重的学习曲线,其优点是您无需担心将您的声音播放与仪表显示同步)

I am working on a small example application for my fourth year project (dealing with Functional Reactive Programming). The idea is to create a simple program that can play a .wav file and then shows a 'bouncing' animation of the current volume of the playing song (like in audio recording software). I'm building this in Scala so have mainly been looking at Java libraries and existing solutions.

Currently, I have managed to play a .wav file easily but I can't seem to achieve the second goal. Basically is there a way I can decode a .wav file so I can have someway of accessing the 'volume' at any given time? By volume I think I means its amplitude but I may be wrong about this - Higher Physics was a while ago....

Clearly, I don't know much about this at all so it would be great if someone could point me in the right direction!

解决方案

In digital audio processing you typically refer to the momentary peak amplitude of the signal (this is also called PPM -- peak programme metering). Depending on how accurate you want to be or if you wish to model some standardised metering or not, you could either

  • just use a sliding window of sample frames (find the maximum absolute value per window)
  • implement some sort of peak-hold mechanism that retains the last peak value for a given duration and then start to have the value 'fall' by a given amount of decibels per second.

The other measuring mode is RMS which is calculated by integrating over a certain time window (add the squared sample values, divide by the window length, and take the square-root, thus root-mean-square RMS). This gives a better idea of the 'energy' of the signal, moving smoother than peak measurements, but not capturing the maximum values observed. This mode is sometimes called VU meter as well. You can approximate this with a sort of lagging (lowpass) filter, e.g. y[i] = y[i-1]*a + |x[i]|*(a-1), for some value 0 < a < 1

You typically display the values logarithmically, i.e. in decibels, as this corresponds better with our perception of signal strength and also for most signals produces a more regular coverage of your screen space.

Three projects I'm involved with may help you:

  • ScalaAudioFile which you can use to read the sample frames from an AIFF or WAVE file
  • ScalaAudioWidgets which is a still young and incomplete project to provide some audio application widgets on top of scala-swing, including a PPM view -- just use a sliding window and set the window's current peak value (and optionally RMS) at a regular interval, and the view will take care of peak-hold and fall times
  • (ScalaCollider, a client for the SuperCollider sound synthesis system, which you might use to play back the sound file and measure the peak and RMS amplitudes in real time. The latter is probably an overkill for your project and would involve some serious learning curve if you have never heard of SuperCollider. The advantage would be that you don't need to worry about synchronising your sound playback with the meter display)

这篇关于在给定时间查找.wav的“音量"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆