Hi. I want to use USoundWaveStreaming to microphone input.
USoundWaveStreaming* soundStreaming;
soundStreaming = new USoundWaveStreaming();
soundStreaming->QueueAudio(sa, samples);
After compiling Editor has crashed
MachineId:79F1B448465D2FDADA62F4BCF29A15EE
EpicAccountId:1a02678b3f7144d7add17b16d2962395
Unknown exception - code 00000001 (first/second chance not available)
"Fatal error: [File:D:\BuildFarm\buildmachine_++depot+UE4-Releases+4.10\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectGlobals.cpp] [Line: 2082]
UObject(const FObjectInitializ
UE4Editor_Core!FDebug::AssertFailed() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\core\private\misc\outputdevice.cpp:374]
UE4Editor_CoreUObject!UObject::UObject() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\coreuobject\private\uobject\uobjectglobals.cpp:2083]
UE4Editor_Engine!USoundBase::USoundBase() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\engine\private\soundbase.cpp:10]
UE4Editor_Engine!USoundWave::USoundWave() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\engine\private\soundwave.cpp:59]
UE4Editor_Engine!USoundWaveProcedural::USoundWaveProcedural() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\engine\private\soundwaveprocedural.cpp:7]
UE4Editor_TrdCppVoiceTest_9393!ATrdCppVoiceTestCharacter::ATrdCppVoiceTestCharacter() [e:\unrealprojects\trdcppvoicetest\source\trdcppvoicetest\trdcppvoicetestcharacter.cpp:51]
UE4Editor_HotReload!FHotReloadClassReinstancer::ReconstructClassDefaultObject() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\developer\hotreload\private\hotreloadclassreinstancer.cpp:198]
UE4Editor_HotReload!FHotReloadClassReinstancer::RecreateCDOAndSetupOldClassReinstancing() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\developer\hotreload\private\hotreloadclassreinstancer.cpp:234]
I think USoundWaveStreaming need to be initialized, but I have no mind how to do it.
Thanks.
Moss
(Moss)
December 23, 2015, 7:07pm
2
You are using new
instead of NewObject
, in UE4 you can not use some vanilla C++ stuff like those operators, UObjects need their very own initialization. Try changing your code to:
USoundWaveProcedural* SoundStreaming = NewObject<USoundWaveProcedural>();
From 4.9 USoundWaveStreaming
is also deprecated and replaced by USoundWaveProcedural
.
If you a usage example check the CreateVoiceAudioComponent
in the engine source .
Its works, but now when I use QueueAudio I have another crash
Access violation - code c0000005 (first/second chance not available)
""
UE4Editor_Core!scalable_msize() [d:\depot\ue4\engine\source\thirdparty\inteltbb\inteltbb-4.0\src\tbbmalloc\frontend.cpp:2615]
UE4Editor_Core!FMallocTBB::Realloc() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\core\private\hal\malloctbb.cpp:70]
UE4Editor_Core!FHeapAllocator::ForAnyElementType::ResizeAllocation() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\core\public\containers\containerallocationpolicies.h:344]
UE4Editor_Engine!USoundWaveProcedural::QueueAudio() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\engine\private\soundwaveprocedural.cpp:19]
UE4Editor_TrdCppVoiceTest!ATrdCppVoiceTestCharacter::VoiceTest() [e:\unrealprojects\trdcppvoicetest\source\trdcppvoicetest\trdcppvoicetestcharacter.cpp:160]
My code:
TSharedPtr<class IVoiceCapture> VoiceCapture;
USoundWaveProcedural* SoundStreaming;
// Voice init
VoiceCapture = FVoiceModule::Get().CreateVoiceCapture();
VoiceCapture->Start();
SoundStreaming = NewObject<USoundWaveProcedural>();
SoundStreaming->SampleRate = 22050;
SoundStreaming->NumChannels = 1;
SoundStreaming->Duration = INDEFINITELY_LOOPING_DURATION;
SoundStreaming->SoundGroup = SOUNDGROUP_Voice;
SoundStreaming->bLooping = false;
uint32 bytesAvailable = 0;
EVoiceCaptureState::Type CaptureState = VoiceCapture->GetCaptureState(bytesAvailable);
if (CaptureState == EVoiceCaptureState::Ok && bytesAvailable > 0)
{
UE_LOG(LogTemp, Warning, TEXT("Mic working"));
uint32 const maxBytes = 1000000;
uint8 buf[maxBytes];
memset(buf, 0, maxBytes);
uint32 readBytes = 0;
VoiceCapture->GetVoiceData(buf, maxBytes, readBytes);
SoundStreaming->QueueAudio(buf, readBytes);
}
getarobo
(getarobo)
March 28, 2016, 7:37pm
4
/AntXXX18 Have you got this working? I am trying to do the exact samething. Playing mic input (virtual input from maxmsp). Let me know PLEASE!!!
Wufasa
(Wufasa)
September 29, 2016, 3:29am
5
For future googlers, in addition to what Moss mentioned, you’ll also need to attah the USoundWaveProcedural object to an audio component via MyAudioDevice->CreateComponent(MySoundWaveProceduralObject, ...)
to avoid the Access violation - code c0000005
Refer to CreateVoiceAudioComponent for an example