-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add audio sample count calculation function while maintain precision of the timestamp #9
Comments
Hello! It's glad to know that this library is being used by the industry. The problem you encountered is caused by multiplying a 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 : {float(a.precise_timestamp * 44100):.2f}")
print(f"the sample count at 48000 is : {float(a.precise_timestamp * 48000):.2f}")
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 : {float(a.precise_timestamp * 44100):.2f}")
print(f"the sample count at 48000 is : {float(a.precise_timestamp * 48000):.2f}")
You can see that the code is giving the right result. 1 frame at 24 fps corresponds to 1837.5 samples at 44.1 kHz, or 2000 samples at 48 kHz. But still, this is not quite an elegant way of use. So I am considering of packing this function(give out the audio sample counts of a tc instance under certain sample rate) into a class method. Hope this resolves your problem! Best regards. |
@WheheoHu We should consider add a class method to make such operations easier. Maybe the implementation should like: # class method
get_audio_sample_counts(self, sample_rate):
return math.floor(self.__precise_time*sample_rate)
# floor to avoid 'ghost' sample |
Thank you for your response! I will use this method in my project moving forward. I look forward to seeing this package being applied more widely in the future. |
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.
但是下面这段代码得出了预料之外的结果:
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?
我觉得可能是数据类型转换时候出了问题,不过我还没有查到是源代码哪部分。或者这是作者设计上的考量吗?
The text was updated successfully, but these errors were encountered: