Audio transkodieren
Transcoding-Formate
Sie können Audio von einem RAW- oder codierten Format in ein anderes umwandeln, indem Sie die entsprechenden Funktionen verwenden.
- Blueprint
- C++

// From encoded file to encoded file
URuntimeAudioTranscoder::TranscodeEncodedDataFromFile(TEXT("C:/Folder/AudioFrom.mp3"), ERuntimeAudioFormat::Auto,
TEXT("C:/Folder/AudioTo.ogg"), ERuntimeAudioFormat::OggVorbis,
100, FRuntimeAudioExportOverrideOptions(),
FOnEncodedDataTranscodeFromFileResultNative::CreateWeakLambda(this, [](bool bSucceeded)
{
// Handle the result
}));
// From encoded buffer to encoded buffer
TArray64<uint8> EncodedDataFrom;
URuntimeAudioTranscoder::TranscodeEncodedDataFromBuffer(EncodedDataFrom, ERuntimeAudioFormat::Auto,
ERuntimeAudioFormat::Wav,
100, FRuntimeAudioExportOverrideOptions(),
FOnEncodedDataTranscodeFromBufferResultNative::CreateWeakLambda(this, [](bool bSucceeded, const TArray64<uint8>& EncodedData)
{
// Handle the result
}));
// From RAW file to RAW file
URuntimeAudioTranscoder::TranscodeRAWDataFromFile(TEXT("C:/Folder/AudioFrom.raw"), ERuntimeRAWAudioFormat::Int16,
TEXT("C:/Folder/AudioTo.raw"), ERuntimeRAWAudioFormat::Float32,
FOnRAWDataTranscodeFromFileResultNative::CreateWeakLambda(this, [](bool bSucceeded)
{
// Handle the result
}));
// From RAW buffer to RAW buffer
TArray64<uint8> RAWDataFrom;
URuntimeAudioTranscoder::TranscodeRAWDataFromBuffer(RAWDataFrom, ERuntimeRAWAudioFormat::Int8,
ERuntimeRAWAudioFormat::Int32,
FOnRAWDataTranscodeFromBufferResultNative::CreateWeakLambda(this, [](bool bSucceeded, const TArray64<uint8>& RAWData)
{
// Handle the result
}));
Float-Array in Bytes umwandeln
Sie können ein Float-Array (z. B. 32-Bit-Float-PCM-Daten) in ein Byte-Array umwandeln. Dies ist nützlich, wenn Ihre Audiodaten in Bytes vorliegen müssen, etwa für die Netzwerkübertragung oder bestimmte Verarbeitungssysteme. Diese Umwandlung ist häufig erforderlich, wenn Sie Delegaten wie OnGeneratePCMData oder OnPopulateAudioData verwenden, da diese Float-PCM-Daten ausgeben.
- Blueprint
- C++

// Assuming FloatArray is an array of floats (such as 32-bit float PCM data)
TArray<float> FloatArray;
// Synchronous
TArray<uint8> ByteArray = URuntimeAudioUtilities::ConvertFloatArrayToBytes(FloatArray);
// Asynchronous
URuntimeAudioUtilities::ConvertFloatArrayToBytesAsync(FloatArray,
FOnConvertFloatArrayToBytesResultNative::CreateWeakLambda(this, [this](const TArray<uint8>& ByteArray)
{
// Handle the result
}));