Defined in carb/audio/AudioUtils.h

inline SoundData *carb::audio::createSoundFromFile(const IAudioData *iface, const char *filename, bool streaming = false, size_t autoStream = 0, SampleFormat fmt = SampleFormat::eDefault, DataFlags flags = 0)

create a sound data object from a file on disk.

  • iface[in] The IAudioData interface to use.

  • filename[in] The name of the file on disk to create the new sound data object from. This may not be nullptr.

  • streaming[in] set to true to create a streaming sound. This will be decoded as it plays. Set to false to decode the sound immediately on load.

  • autoStream[in] The threshold in bytes at which the new sound data object will decide to stream instead of decode into memory. If the decoded size of the sound will be larger than this value, it will be streamed from its original source instead of decoded. Set this to 0 to disable auto-streaming.

  • fmt[in] The format the sound should be decoded into. By default, the decoder choose its preferred format.

  • flags[in] Optional flags to change the behavior. This can be any of: fDataFlagSkipMetaData, fDataFlagSkipEventPoints or fDataFlagCalcPeaks.


The new sound data if successfully created and loaded. This object must be released once it is no longer needed.


nullptr if the operation failed. This may include the file not being accessible, the file’s data not being the correct format, or a decoding error occurs.