gtreshchev / AudioAnalysisTools

Audio Analysis Tools plugin for Unreal Engine. Provides a variety of functions for analyzing audio data. Works in conjunction with the Runtime Audio Importer plugin.
MIT License
103 stars 17 forks source link

Is it possible to use this with Audio Capture for live input? #13

Open BorisKourt opened 1 year ago

BorisKourt commented 1 year ago

Not an issue, just wondering if this setup is supported?

Instead of:

Import sound wave -> Play sound wave -> Analyze audio data as the sound wave plays

Do:

Audio Capture -> Analyze audio data as the sound wave comes in
gtreshchev commented 1 year ago

Yes, it is possible. Instead of binding to OnGeneratePCMData, which is used during sound wave playback, you should bind to OnPopulateAudioData, which is broadcasted each time audio population occurs. This way, the audio data will be analyzed during the capturing process itself.

BorisKourt commented 1 year ago

Thanks for the quick reply! I am having trouble adapting this part of the wiki based on your recommendation: https://github.com/gtreshchev/AudioAnalysisTools/wiki#example-of-detecting-a-beat-as-a-sound-wave-is-played

It appears that I still need an imported sound wave in order to make everything connect properly?

Is there any documentation on OnPopulateAudioData?

BorisKourt commented 1 year ago
Screenshot 2023-07-07 at 02 24 06

Is this an appropriate direction? This is in a blueprint with just one Audio Capture in it.

gtreshchev commented 1 year ago

The documentation regarding the OnPopulateAudioData including is here: https://github.com/gtreshchev/RuntimeAudioImporter/wiki/Utilities

Yes, this looks proper. Since streaming and capturable sound waves are inherited from imported sound wave, they support the same functionality and leverage the same internal logic for accumulating and outputting the audio data. If you encounter too many beats occurring, you can take a look at the IsBeatRange function, for example.

BorisKourt commented 1 year ago

Thanks for the replies.

Is there a way to specify the input device by name? Or does this always default to Unreal's system default detection?

I am able to read out the names of available input devices, and see their ids. But it appears that only one of the devices works at a time, none of the device IDs except for that one work. (This is on macos)

gtreshchev commented 1 year ago

I'm not entirely sure, but there might be platform-specific behavior that prevents using multiple input devices simultaneously. Although that's just my assumption, I haven't explored the workflow of capturing with multiple devices at the same time. As for identifying the input device, yes, I believe the only way is to take the ID integer into account when calling StartCapture and specifying the ID.