Notes to self
This is what mame uses to determine how many samples it needs to emit for any given AVI fame
Language: cpp
length = framenum_to_samplenum(framenum + 1 + m_soundbuf_frames) - framenum_to_samplenum(framenum + m_soundbuf_frames);
And here's the body
Language: cpp
inline std::uint32_t avi_file_impl::framenum_to_samplenum(std::uint32_t framenum) const
{
return (std::uint64_t(m_info.audio_samplerate) * std::uint64_t(framenum) * std::uint64_t(m_info.video_sampletime) + m_info.video_timescale - 1) / std::uint64_t(m_info.video_timescale);
}
Great times.
If I replicate this in hawk, hopefully av will sync.
m_soundbuf_frames is a semi-arbitrary number of extra frames to prepare samples in advance for, 0.57 of a second, something around 45 frames of safety buffer. I hope I won't need it.
framenum is current actual frame.
Also I don't think I cleared the sound buffer when loading states lol. It just kept appending irrelevant samples.