音波のプロパティ
サウンドウェーブから直接、全体のPCMバッファを取得できます。
- Blueprint
- C++
// Assuming ImportedSoundWave is a UE reference to a UImportedSoundWave object
TArray<float> PCMBuffer = ImportedSoundWave->GetPCMBufferCopy();
取得したPCMデータをバイトに変換する必要がある場合は、こちらを参照してください。
シームレスなオーディオループを作成するには、ループを設定してサウンドウェーブの再生時間を自動的にゼロに巻き戻し、再生終了後に再び再生できるようにします。
- 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 を選択すると、無音の間も音波の再生を継続できます。これは、サウンド減衰を使用している場合に特に便利です。
- Blueprint
- 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);