// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved.
#pragma once
#include "Types.h"
#include "Engine/Tools/AudioTool/AudioDecoder.h"
#include "Engine/Core/ISerializable.h"
#include "Engine/Audio/Config.h"
#if COMPILE_WITH_ASSETS_IMPORTER
///
/// Enable/disable caching audio import options
///
#define IMPORT_AUDIO_CACHE_OPTIONS 1
///
/// Importing audio utility
///
class ImportAudio
{
public:
///
/// Importing audio options
///
struct Options : public ISerializable
{
AudioFormat Format = AudioFormat::Vorbis;
bool DisableStreaming = false;
bool Is3D = false;
int32 BitDepth = 16;
float Quality = 0.4f;
String ToString() const;
// [ISerializable]
void Serialize(SerializeStream& stream, const void* otherObj) override;
void Deserialize(DeserializeStream& stream, ISerializeModifier* modifier) override;
};
public:
///
/// Tries the get audio import options from the target location asset.
///
/// The asset path.
/// The options.
/// True if success, otherwise false.
static bool TryGetImportOptions(const StringView& path, Options& options);
///
/// Imports the audio data (with given audio decoder).
///
/// The importing context.
/// The audio decoder.
/// Result.
static CreateAssetResult Import(CreateAssetContext& context, AudioDecoder& decoder);
///
/// Imports the .wav audio file.
///
/// The importing context.
/// Result.
static CreateAssetResult ImportWav(CreateAssetContext& context);
///
/// Imports the .mp3 audio file.
///
/// The importing context.
/// Result.
static CreateAssetResult ImportMp3(CreateAssetContext& context);
#if COMPILE_WITH_OGG_VORBIS
///
/// Imports the .ogg audio file.
///
/// The importing context.
/// Result.
static CreateAssetResult ImportOgg(CreateAssetContext& context);
#endif
};
#endif