Skip to content

Add audio sample count calculation function while maintain precision of the timestamp #9

@drunkenQCat

Description

@drunkenQCat

I am a programmer working on sound, my work always needs to transfer SMPTE timecode to time stamp, and times them to 44100 or 48000.
我是音频技术,对SMPTE时间码转时间戳有需求。日常工作中,时间戳的结果要乘以44100或者48000。

But after running code below, the result appears so wired.
但是下面这段代码得出了预料之外的结果:

from dftt_timecode import DfttTimecode

a = DfttTimecode('01:00:00:13', 'smpte', fps=24, drop_frame=False, strict=True)
print(f"the timestamp of 01:00:00:13 is :  {a.timestamp}")
print(f"the sample count at 44100 is :  { a.timestamp * 44100 }")
print(f"the sample count at 48000 is :  { a.timestamp * 48000 }")

print("================================================")

a = DfttTimecode('01:00:00:14', 'smpte', fps=24, drop_frame=False, strict=True)
print(f"the timestamp of 01:00:00:14 is :  {a.timestamp}")
print(f"the sample count at 44100 is :  { a.timestamp * 44100 }")
print(f"the sample count at 48000 is :  { a.timestamp * 48000 }")
the timestamp of 01:00:00:13 is :  3600.54167
the sample count at 44100 is :  158783887.647
the sample count at 48000 is :  172826000.16
================================================
the timestamp of 01:00:00:14 is :  3600.58333
the sample count at 44100 is :  158785724.853
the sample count at 48000 is :  172827999.84

I think the problem may happens in data type tranferring or something else, but I haven't inspect the source code yet. Or maybe the maintainer has any consideration on it?
我觉得可能是数据类型转换时候出了问题,不过我还没有查到是源代码哪部分。或者这是作者设计上的考量吗?

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions