To add special playback logics to an AudioComponent contained in a AAmbientSound actor, I tried to subclass AmbientSound through Unreal Editor’s Add Code to Project, however the editor complains that “Failed to add class . Failed to automatically compile module.” If its not possible, why?
I’m not sure why - it could have something to do with the “MinimalAPI” specifier in the code.
Anyway AmbientSound is a really thin wrapper around AudioComponent: it’ll be easier and more flexible for you to create an Actor Blueprint from scratch, add it an AudioComponent and control it from the actor graph.
Thanks but in code, is there a way I could get a reference to the AmbientSound actor which is manually added to UWorld? then I could dynamically add and delete audiocomponent from it.
You have different ways to do this:
- When you’re spawning the actor from the code, keep a reference to it
- Use the actor iterator to find yours
- You could create events in the code, and use those in your actor blueprint to add and remove audio component in blueprint
…and probably a lot more. What are you trying to achieve?
The ultimate goal is to access the raw data from a MediaSoundWave. My inital plan was to create an AmbientSound actor to host an audio component, which can load a MediaSoundWave as a SoundWave to access FByteBulkData RawData.