How to force the building of peaks when using ImportFile()?

phi-g wrote on 3/27/2020, 7:10 PM

Hi, I've put together a script that does everything I want it to do... except the rendered videos all lack audio. It imports pre-saved veg files, names the regions based on the file names and renders each region, naming the video from the region name (with a preset known to include audio). The only thing I've noticed is that the support files aren't created when the import runs (the .sfap0 file is but is always 0 bytes). If I drag veg files onto the timeline from Explorer, all of these secondary files are automatically created which makes me think maybe I need to kickstart an asynchronous process or something. I threw a WaitForIdle() in here and there, to no effect.

I don't see anything in the scripting API that might be useful (or similar to Rebuild Audio Peaks in the menu). Am I missing something? Should the lack of these files prevent audio from being "rendered" with the video? I always thought the peak file was just to visualise the waveforms for the audio.


phi-g wrote on 3/28/2020, 3:20 AM

Upon further testing it seems to create the peaks and whatnot if I don't run any code after the Import and just let it sit there. But if I so much as put a MessageBox.Show() in it will jump straight past the creation of the peaks, even with WaitForIdle() in every conceivable position in between.

In the API summary it says WaitForIdle() will "wait for asynchonous actions (such as building audio peaks) to complete."

foreach (String File in Files) {            

I've tried the WaitForIdle() in each of those positions and both together. If that's the end of the script, the peaks are then built after the MessageBox is closed but I don't want to see the MessageBox until the peaks have been built...