Pixel Streaming 오디오 캡처
Pixel Streaming은 Unreal Engine의 플러그인으로, 렌더링된 프레임을 스트리밍하고 WebRTC를 통해 입출력을 동기화합니다. 애플리케이션은 서버 측에서 실행되며, 클라이언트 측은 렌더링 및 사용자 상호작용을 처리합니다. Pixel Streaming 및 설정에 대한 자세한 내용은 Pixel Streaming Documentation를 참조하세요.
호환성
이 솔루션은 다음과 호환됩니다:
- 공식 Pixel Streaming 인프라 (Epic Games 참조 구현)
- 타사 Pixel Streaming 제공업체 포함:
- Vagon.io
- Arcane Mirage
- Eagle 3D Streaming
- 다른 WebRTC 기반의 스트리밍 솔루션
- 운영 체제: Windows 및 Linux 서버
이 구현은 이러한 환경에서 테스트되었으며, 사용된 Pixel Streaming 호스팅 솔루션에 관계없이 올바르게 작동합니다.
확장 플러그인 설치
이 기능은 Runtime Audio Importer 플러그인의 확장으로 제공됩니다. 사용하려면 다음과 같이 해야 합니다:
- Runtime Audio Importer 플러그인이 프로젝트에 이미 설치되어 있는지 확인
- Google Drive에서 Pixel Streaming Audio Capture 플러그인 확장을 다운로드
- 다운로드한 아카이브에서 폴더를 추출하여 프로젝트의
Plugins
폴더에 넣기 (해당 폴더가 없으면 만듭니다) - 프로젝트를 리빌드하기 (이 확장은 C++ 프로젝트가 필요합니다)
- 이 확장은 소스 코드로 제공되며, C++ 프로젝트가 필요합니다
- 지원되는 Unreal Engine 버전: UE 5.2 이상
- 플러그인을 수동으로 빌드하는 방법에 대한 자세한 내용은 Building Plugins tutorial를 참조하세요
개요
Pixel Streaming Capturable Sound Wave는 표준 Capturable Sound Wave를 확장하여 Pixel Streaming 클라이언트의 마이크로부터 오디오를 직접 캡처할 수 있게합니다. 이 기능으로 다음을 할 수 있습니다:
- Pixel Streaming을 통해 연결된 브라우저에서 오디오 캡처
- 특정 플레이어/피어로부터 오디오 처리
- 음성 채팅, 음성 명령, 또는 원격 사용자로부터 오디오 녹음 구현
기본 사용법
Pixel Streaming Capturable Sound Wave 생성
우선, Pixel Streaming Capturable Sound Wave 객체를 생성해야 합니다:
- Blueprint
- C++
PixelStreamingSoundWave = UPixelStreamingCapturableSoundWave::CreatePixelStreamingCapturableSoundWave();
Pixel Streaming Capturable Sound Wave는 조기 소멸을 방지하기 위해 강력한 참조로 취급해야 합니다 (예: Blueprints에서 별도의 변수에 할당하거나 C++에서 UPROPERTY()
를 사용하는 방식).
캡처 시작 및 중지
간단한 함수 호출로 오디오 캡처를 시작하고 중지할 수 있습니다:
- Blueprint
- C++
// Assuming PixelStreamingSoundWave is a reference to a UPixelStreamingCapturableSoundWave object
// Start capturing audio (the device ID parameter is ignored for Pixel Streaming)
PixelStreamingSoundWave->StartCapture(0);
// Stop capturing audio
PixelStreamingSoundWave->StopCapture();
StartCapture
의 DeviceId
매개변수는 Pixel Streaming Capturable Sound Waves에 대해 무시되며, 캡처 소스는 자동으로 또는 설정한 플레이어 정보에 의해 결정됩니다.
캡처 상태 확인
사운드 웨이브가 현재 오디오를 캡처하고 있는지 확인할 수 있습니다:
- Blueprint
- C++
// Assuming PixelStreamingSoundWave is a reference to a UPixelStreamingCapturableSoundWave object
bool bIsCapturing = PixelStreamingSoundWave->IsCapturing();
Complete Example
여기서는 Pixel Streaming 오디오 캡처를 설정하는 완전한 예제를 소개합니다:
- Blueprint
- C++
이것은 Pixel Streaming 클라이언트로부터 오디오 데이터를 캡처하는 기본적인 코드 예제입니다.
이 예제는 EXAMPLEMODULE
모듈 내 UPixelStreamingAudioExample
클래스에 위치한 CapturePixelStreamingAudioExample
함수를 사용합니다.
예제를 성공적으로 실행하려면, .Build.cs 파일의 PublicDependencyModuleNames
또는 PrivateDependencyModuleNames
에 RuntimeAudioImporter
와 PixelStreaming
모듈을 추가하고, 프로젝트의 .uproject 파일에도 추가해야 합니다.
#pragma once
#include "CoreMinimal.h"
#include "UObject/Object.h"
#include "PixelStreamingAudioExample.generated.h"
UCLASS(BlueprintType)
class EXAMPLEMODULE_API UPixelStreamingAudioExample : public UObject
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintCallable)
void CapturePixelStreamingAudioExample();
private:
// Keep a strong reference to prevent garbage collection
UPROPERTY()
class UPixelStreamingCapturableSoundWave* PixelStreamingSoundWave;
};
#include "PixelStreamingAudioExample.h"
#include "Sound/PixelStreamingCapturableSoundWave.h"
#include "Kismet/GameplayStatics.h"
void UPixelStreamingAudioExample::CapturePixelStreamingAudioExample()
{
// Create a Pixel Streaming Capturable Sound Wave
PixelStreamingSoundWave = UPixelStreamingCapturableSoundWave::CreatePixelStreamingCapturableSoundWave();
// Start capturing audio
PixelStreamingSoundWave->StartCapture(0);
// Play the sound wave to hear the captured audio
UGameplayStatics::PlaySound2D(GetWorld(), PixelStreamingSoundWave);
// Set up a timer to stop capture after 30 seconds (just for demonstration)
FTimerHandle TimerHandle;
GetWorld()->GetTimerManager().SetTimer(TimerHandle, [this]()
{
PixelStreamingSoundWave->StopCapture();
}, 30.0f, false);
}
여러 Pixel Streaming 플레이어와 작업하기
여러 Pixel Streaming 클라이언트가 동시에 연결된 시나리오에서는 특정 플레이어의 오디오를 캡처해야 할 수 있습니다. 다음 기능들은 이를 관리하는 데 도움을 줍니다.
사용 가능한 Pixel Streaming 플레이어 가져오기
연결된 Pixel Streaming 플레이어를 식별하려면:
- Blueprint
- C++
UPixelStreamingCapturableSoundWave::GetAvailablePixelStreamingPlayers(FOnGetAvailablePixelStreamingPlayersResultNative::CreateWeakLambda(this, [](const TArray<FPixelStreamingPlayerInfo_RAI>& AvailablePlayers)
{
// Handle the list of available players
for (const FPixelStreamingPlayerInfo_RAI& PlayerInfo : AvailablePlayers)
{
UE_LOG(LogTemp, Log, TEXT("Available player: %s on streamer: %s"), *PlayerInfo.PlayerId, *PlayerInfo.StreamerId);
}
}));
특정 플레이어에서 캡처 설정하기
특정 플레이어에서 캡처해야 할 때:
- Blueprint
- C++
// Assuming PixelStreamingSoundWave is a reference to a UPixelStreamingCapturableSoundWave object
// and PlayerInfo is a FPixelStreamingPlayerInfo_RAI object from GetAvailablePixelStreamingPlayers
PixelStreamingSoundWave->SetPlayerToCaptureFrom(PlayerInfo);
플레이어 ID를 비워 두면 사운드 웨이브는 자동으로 연결된 첫 번째 이용 가능한 플레이어를 듣습니다. 이는 기본 동작으로, 싱글 플레이어 시나리오에 적합합니다.
일반 사용 사례
음성 채팅 구현
Pixel Streaming Capturable Sound Waves를 사용하여 원격 사용자와 로컬 플레이어 간의 음성 채팅을 구현할 수 있습니다:
- 각 연결된 플레이어에 대해 Pixel Streaming Capturable Sound Wave 생성
- 현재 말하고 있는 플레이어를 관리하는 시스템 설정
- 사용자가 언제 말하는지를 감지하기 위해 Voice Activity Detection 시스템 사용
- 필요에 따라 언리얼 엔진의 오디오 시스템을 사용하여 오디오를 공간화
음성 인식을 통한 음성 명령
Runtime Speech Recognizer 플러그인과 이 기능을 결합하여 원격 사용자를 위한 음성 명령 인식을 구현할 수 있습니다:
- Pixel Streaming Capturable Sound Wave를 사용하여 Pixel Streaming 클라이언트에서 오디오 캡처
- 캡처된 오디오를 Runtime Speech Recognizer에 직접 입력
- 게임 로직에서 인식된 텍스트 처리
Runtime Speech Recognizer 예제에서 표준 Capturable Sound Wave를 Pixel Streaming Capturable Sound Wave로 대체하면 Pixel Streaming 오디오 입력과 원활하게 작동합니다.
원격 사용자 오디오 녹음
나중에 재생하기 위해 원격 사용자의 오디오를 녹음할 수 있습니다:
- Pixel Streaming Capturable Sound Wave를 사용하여 오디오 캡처
- Export Audio를 사용하여 캡처된 오디오를 파일로 내보내기
- 나중에 사용하거나 분석하기 위해 파일 저장