fmod:如何使用FMOD_OUTPUTTYPE_WAVWRITER_NRT?

发布于 2024-12-29 19:30:38 字数 1042 浏览 1 评论 0原文

这是我之前的问题的后续: 渲染一些声音数据到一个新的声音数据中?

我正在创建一个程序,该程序将处理一个包含声音库和时间偏移的文件,以标记何时必须播放声音并从中生成波形文件。

所以我认为 FMOD_OUTPUTTYPE_WAVWRITER 非常适合这项工作。

对于声音库,想象一下文件中的类似内容:

0 kick.wav
1 hit.wav
2 flute.wav

左侧的数字描述右侧声音文件名的声音 ID, 时间偏移量:

1000 0
2000 1
3000 2

左边的数字告诉程序何时必须以毫秒为单位播放声音,右边的数字是声音 ID。

因此,当我启动程序时,FMOD将生成一个波形文件,其中第一秒包含踢脚(来自kick.wav),第二秒包含打击,第三秒包含长笛,我将不得不等待至少 3 秒才能完成任务。

但是,如果我想渲染更长的音乐,比如 5 分钟,那么我必须等待至少 5 分钟才能完成任务,因为我让它依赖于系统计时器以指定的偏移量播放声音在文件中和 while(true) 循环来更新 FMOD::System。我认为必须有一种方法可以更快地渲染,而无需等待程序在指定时间实际渲染声音,因为我在 DAW 程序中看到,例如索尼 ACID,可以非常快地渲染曲目。

然后我看了一下API参考,有FMOD_OUTPUTTYPE_WAVWRITER_NRT,然后我想这可能是解决方案,所以我尝试立即更改输出设备而不修改其他任何内容,生成的波形文件听起来很混乱!我听到很多重复的声音,长时间的延迟等等。

那么,如何正确使用非实时版本呢?在我的情况下使用 NRT 时更新 fmod 系统的正确方法是什么?

我在 fmod 文档本身中找不到有关 NRT 输出类型使用的明确解释。

无论如何,我在Windows环境下使用C++。

谢谢。

this is a follow up to my earlier question: Rendering some sound data into one new sound data?

I'm creating a program that will process a file containing a sound bank and time offsets to mark when the sound must be played and generate a wave file from it.

So I suppose FMOD_OUTPUTTYPE_WAVWRITER is perfect for the job.

For the sound bank, imagine something like this in a file:

0 kick.wav
1 hit.wav
2 flute.wav

where the number on the left describes the sound ID of the sound file name on the right,
and the time offsets:

1000 0
2000 1
3000 2

where the number on the left tells the program when the sound must be played in milliseconds, and number on the right is the sound ID.

Therefore, when I start the program, FMOD will generate a wave file which contains a kick (from kick.wav) in the first second, a hit in the second second, and a flute in the third second, and I will have to wait for at least 3 seconds for the task to complete.

However, if I want to render a longer music, say, 5 minutes, then I must have to wait for at least 5 minutes for the task to complete, since I make it depend on the system timer to play the sound at the specified offset in the file and a while(true) loop to update FMOD::System. I think there must be a way to render faster without waiting for the program to actually render the sound at the specified time, since I saw in a DAW program like, say, Sony ACID, can render the tracks really fast.

Then I take a bit look into the API reference, there's FMOD_OUTPUTTYPE_WAVWRITER_NRT, then I thought this maybe the solution, so I tried changing the output device right away without modifying anything else, and the generated wave file sounds messed up! I hear many repetitive sound, long delays, etc.

So, how to use the non-realtime version properly? What is the correct way to update the fmod system when using NRT in my case?

I couldn't find a clear explanation about the usage of NRT ouput type in the fmod documentation itself.

Anyway, I use C++ in a Windows environment.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

假装爱人 2025-01-05 19:30:38

FMOD_OUTPUTTYPE_WAVEWRITER_NRT 的工作方式是每次调用 System::update 时都会生成音频。每次“更新”生成的数据量由 System::setDSPBufferSize 的 bufferlength 参数控制。

因此,调用 System::update 的速度越快,生成数据的速度就越快。现在,您工作的重要部分是将“x”次对 System::update 的调用转换为可以与您的时间线匹配的内容。

默认情况下,FMOD 的运行采样率为每秒 48000 个样本(可通过 System::setSoftwareFormat 配置)。因此,如果将 'bufferlength' 设置为 1024,则每次调用 System::update 都会生成 1024 个样本(写入 wav 文件)。所以...
1024 / 48000 = 0.021333 秒 ~ 21.3 毫秒每次调用生成数据。现在您可以计算需要调用 System::update 多少次才能获得您拥有的时间戳。

The way FMOD_OUTPUTTYPE_WAVEWRITER_NRT works is it generates audio every time System::update is called. The amount of data generated per 'update' is governed by the bufferlength parameter of System::setDSPBufferSize.

So the faster you call System::update the faster the data is generated. Now the important part for your job is to convert 'x' number of calls to System::update into something you can match to your timeline.

By default FMOD operates at a sample rate of 48000 samples per second (configurable via System::setSoftwareFormat). So if you set 'bufferlength' to 1024, each time you call System::update 1024 samples will be generated (written to the wav file). So...
1024 / 48000 = 0.021333 seconds ~ 21.3 milliseconds of data is generated per call. Now you can calculate how many times you need to call System::update to get to the timestamps you have.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文