How to plot the amplitude of audio file with c++?

狂风中的少年 提交于 2021-02-08 08:53:16

问题


I'm trying to create a program, using Qt (c++), which can plot the amplitude Signal (plot like audacity but dynamic waveform) when I playback an audio file (.wav, .mp3) using QAudiooutput and QIODevice.

What I've done:
with QAudioouput I can play the any audio file, with qwtplot I can plot any signal in 2D, in this case, x-axis will be time and y-axis will be the amplitude.

Now, my problem is how to get the amplitude for each second (time)?

Any help would be appreciated.


回答1:


The normal, uncompressed representation of audio is just its amplitude as a function of time. .wav files are ordinarily uncompressed, so a mono .WAV file is really the simplest of audio files: just a header followed by a series of amplitudes.

Note that digital audio has a sampling rate. E.g. a 32 kHz sample rate means that your WAV file has 32000 amplitudes per second. If it only had one, you couldn't hear it ! (<20 Hz). You can see this in Audacity; you can zoom in quite a bit on the waveform.



来源:https://stackoverflow.com/questions/24993808/how-to-plot-the-amplitude-of-audio-file-with-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!