音波の特性
音波から直接、全てのPCMバッファを取得することができます。
- Blueprint
- C++
// Assuming ImportedSoundWave is a UE reference to a UImportedSoundWave object
TArray<float> PCMBuffer = ImportedSoundWave->GetPCMBufferCopy();
シームレスなオーディオループを作成するには、ループ再生を設定して音波の再生時間を自動でゼロに巻き戻し、再生終了後に再生します。
- Blueprint
- C++
// Assuming ImportedSoundWave is a UE reference to a UImportedSoundWave object
ImportedSoundWave->SetLooping(false);
再生されている音のボリュームをニーズに合わせて調整できます。
- Blueprint
- C++
// Assuming ImportedSoundWave is a UE reference to a UImportedSoundWave object
ImportedSoundWave->SetVolume(1.0f);
再生される音のピッチをお好みに合わせて変更することもできます。
- Blueprint
- C++
// Assuming ImportedSoundWave is a UE reference to a UImportedSoundWave object
ImportedSoundWave->SetPitch(1.0f);
字幕を設定することができます。具体的には、表示するテキストとその表示タイミングを定義します。
- Blueprint
- C++
// Assuming ImportedSoundWave is a UE reference to a UImportedSoundWave object
TArray<FEditableSubtitleCue> Subtitles;
FEditableSubtitleCue Subtitle;
Subtitle.Text = FText::FromString("Example");
Subtitle.Time = 2.0f;
Subtitles.Add(Subtitle);
ImportedSoundWave->SetSubtitles(Subtitles);
仮想化モードを設定できます。例えば、Play When Silent というモードでは、無音状態でも音波の再生を続けることができます。これは、音の減衰を使用する場合に特に役立ちます。
- ブループリント
- C++
// Assuming ImportedSoundWave is a UE reference to a UImportedSoundWave object
ImportedSoundWave->SetVirtualizationMode(EVirtualizationMode::PlayWhenSilent);
インポートされた音波のサンプルレートやチャンネル数を変更する必要がある場合は、適切な関数を使用してオーディオデータをリサンプルし、ミックスすることができます。これにより、音波データ全体が変更され、OnGeneratePCMData
および OnPopulateAudioData
デリゲートからの出力に影響を与えます。
- Blueprint
- C++
// Assuming ImportedSoundWave is a UE reference to a UImportedSoundWave object
ImportedSoundWave->ResampleSoundWave(44100);
ImportedSoundWave->MixSoundWaveChannels(2);
または、指定された希望のサンプルレートとチャンネル数に合わせて自動的にリサンプルとミックスを行いたい場合は、次の関数を使用できます(これにより、OnGeneratePCMData
およびOnPopulateAudioData
デリゲートの出力にも影響します)。
- Blueprint
- C++
// Assuming ImportedSoundWave is a UE reference to a UImportedSoundWave object
ImportedSoundWave->SetInitialDesiredSampleRate(44100);
ImportedSoundWave->SetInitialDesiredNumOfChannels(2);