so the peak meter is a lil bit ahead of time?
BotB Academy n00b s0z
Level 5 Playa
post #147163 :: 2021.09.24 9:59pm :: edit 2021.09.25 3:36am
the audio device asks for some samples from the program, then the peak meter examines them in a buffer, then the samples are played by the device ...

am i right?

or, the peak meter will be rendered later, and the delay time depends on the frame rate and other things, plus, audio playing is async. so it's hard to say the peak meter's response to the sound will show earlier or later than the sound arrives?? does the time gap mainly depend on video frame rate and (sample number in buffer / playback frequency)?
Level 9 Playa
post #147170 :: 2021.09.25 5:31am
Hello, Yakuman!

I think that I could use more information to reply at inquiries of yours in this thread, and by, I am feel desire to ask you back the next two questions:

If the inquiries of yours in this thread are specific to a system, platform, or format:
Which system, platform, or format they are?

Do you by peak meter mean the visual representation of audio data volume amplitude in a particular software? If otherwise: What is you do mean by peak meter?

Cheers, Yakuman!
Level 5 Playa
post #147178 :: 2021.09.25 8:30am :: edit 2021.09.25 8:41am
  damifortune liēkd this
Thanks for your reply.

The "peak meter" I meant is exactly the visual representation of audio data volume amplitude which shows the instantaneous level of an audio signal, and with a peak(clip) indicator in it.

I'm not sure that the question is about a specific system/platform/format. I think that lots of systems work in the similar way. Of course, I was talking about digital stuff, not analog.

I'm working on cramming a peak meter in my small, simple and naive SDL2 tracker project. In the program, when the audio device has no further data to playback, it calls a callback funtion to get a certain number of new samples. So the audio device calls the function over and over again, while the video runs at a certain FPS. So the video and the audio work at different paces. Suppose that the sound which is generated by the program is very loud and we want to use the peak meter to show the clips, I wonder that the moment the meter shows a clip is precisely the moment that the sound pops.

For example, the playback frequency is 44100 Hz, and the sample buffer contains 8192 samples(let's assume it is mono). After producing 8192 samples, the program finds a clip in them, then shows the alert on the peak meter while rendering it. At that time, the audio device maybe has just played 1000 samples. Thus, the pop sound will arrive 7192 / 44100 = about 0.16s later since the peak meter shows it. A delay of 0.16s is easy to perceive.

I want to know if I'm wrong. If I'm not wrong, does the problem have a solution?

Cheers, Oli!

LOGIN or REGISTER to add your own comments!