Room Effects in UE with Resonance Audio - resonance-audio

I'm working on a VR game at the moment in UE AND FMOD. We're trying to implement the Room Effects, as has been done so neatly with the Unity plugin.
We've successfully managed to create a room within a collider which seems to work with the room effects, however, we're having trouble having more than one room in the same map/level so we can change the room effect as we walk through the level.
has anyone managed to get room effects working in UE before, as in unity?

At present, with the Resonance Audio FMOD plugin combined with UE, you can pass new 'RoomProperties' to the Listener plugin via a call to
setParameterData(int index, void *data, unsigned int length);
From C++.
You must, however, handle detection of movement between different "rooms" yourself.
As I believe you most likely already know, you should pass a pointer to an instance of the RoomProperties struct, found here: https://github.com/resonance-audio/resonance-audio-fmod-sdk/blob/master/Plugins/include/RoomProperties.h
cast to void pointer, with the index parameter set to 1 and the length parameter set to sizeof(RoomProperties)

You can create multiple Room Effect 'zones' using Unreal's Audio Volumes.
Add a new Audio Volume, go to its Details panel and open the Reverb tab. You should see a Reverb Plugin Effect drop-down list. Locate the Create New Asset section and select Resonance Audio Reverb Plugin Preset to create a new reverb preset.
Then, in your new Resonance Audio Reverb Plugin Presets you can select some unique room effect settings for the volume you've just created.
You then repeat the process for additional 'rooms'.
You can also add a Global Reverb Preset if you would like to use some 'default' room effects settings (for example, when the player is no longer in any of the Audio Volumes).
Please see: https://developers.google.com/resonance-audio/develop/unreal/developer-guide#using_the_resonance_audio_reverb_plugin for more info!

i have been unable to get the audio volume resonance reverbs to work with stock UE4 (4.19.1, with resonance 1.0 that doesn't require a custom build). i can get the master reverb to work, but not just for the audio volumes. any advice on this?
this issue is also posted here:
https://forums.unrealengine.com/development-discussion/audio/1472284-reverb-plugin-of-google-resonance-for-ue4-doesn-t-work

Related

Changing audio renderer endpoint while playing

I'm writing an audio player using Microsoft Media Foundation.
I wonder is it possible to change the playback device without re-creating the session?
IMFActivate *m_p_sink_activate;
...
m_p_sink_activate->SetString(MF_AUDIO_RENDERER_ATTRIBUTE_ENDPOINT_ID, name_device);
This doesn't take effect if the audio is already being played.
Btw, the media player provided by Microsoft.Windows.SDK.Contracts (Windows.Media.Playback.MediaPlayer) does it perfectly.
When I change m_mediaPlayer.AudioDevice, the audio stream is redirected to the assigned device immediately. So I wonder if this is also possible for MSMF.
So far I have a way could do this job,
Create a new topology which cloned from previous one.
Create new audio renderer using MFCreateAudioRendererActivate and using set string with the new audio endpoint ID add it to a topologynode;
Add the new node to new topology;
Using IMFMediaSession::SetTopology() do set new topology to play.
You could refer to MS sample TopoEdit for detail.
One side effect is that each time SetTopology cause huge memory growth.

Set audio endpoint devices application specific (programmatically)

Link to the bug report on 'Feedback Hub'
An audio endpoint device, from here on referred to as 'endpoint', is a physical or virtual audio output or input device.
With the Windows 10 April Update 1803 the long overdue 'App volume and device preferences' have been introduced. These settings allow more control over audio stream management as it is now possible to set different endpoints for different applications, no matter whether that particular application comes with an endpoint selection or not.
However, there is an issue where the audio of a program, whose endpoint is non-default, is streamed through the default endpoint (or not at all) after it has been closed and launched again, although the endpoint is displayed correctly in the settings:
As far as I know the issue can be recreated on a Windows 10 machine (version 1803 or higher) with any virtual or physical endpoint and an affected program. I used 'VLC Media Player' in this example (disregarding the fact that it comes with an endpoint selection) as it is well known and widely accessible, which should make it easier to recreate the issue.
What I'm searching for...
... is a programmatically solution to switch between endpoints, which ideally can be launched in form of a script to set the correct endpoint with an application launch.
For my purpose it would be enough to have to adjust the device instance path manually, as the device would be always the same, but I'm not going to complain about a solution which retrieves the device instance path from the registry, too.
Defined endpoints and the device instance path of the device they are using can be retrieved from the subkeys of the key HKEY_USERS\# YOUR SID #\Software\Microsoft\Multimedia\Audio\DefaultEndpoint. I don't know how windows generates the name of the subkeys or where they can be found. If I had to take a wild guess, I'd say these are Application IDs (feel free to correct me if I'm wrong).
The device instance path itself can be found in the Device Manager (under 'Audio inputs and outputs' double click the desired device, navigate to the tab 'Details' and select 'Device instance path' from the 'Property' drop-down menu).
Additionally the entry about Audio Endpoint Devices and Stream Management in the Microsoft Docs might be helpful, but that is way above my head.
A possible but impractical workaround...
... would be, to manually set another endpoint for the application and switch back to desired endpoint at every launch of said application (as shown above).
But not just takes this at least 10 seconds at each and every launch, you might even forget to do this as the audio might just get streamed through the default endpoint *¹.
The alternative to the latter is, that no audio will be streamed at all *² or in some cases it actually works *³.
*¹ e.g.: VLC Media Player, Tom Clancy's Rainbow Six Siege (although the audio will be streamed correctly during the splash screens)
*² e.g.: Call of Duty 4: Modern Warfare, Call of Duty: Modern Warfare 2, Call of Duty: Modern Warfare 3
*³ e.g.: Window Media Player, Microsoft Edge, Firefox
Observations
VLC Media Player comes with an endpoint selection, but so does TeamSpeak 3 and, unlike VLC, it skips the Windows settings completely.
Call of Duty not streaming any audio most likely is connected to the engine as I didn't encounter any other application doing something similar.
Windows Media Player, Microsoft Edge and Firefox are the only programs (I tested so far) which work fine. They have no endpoint selection (I'd know of) and will use the correct endpoint after closing and launching it again. It should be noted, however, that Firefox and Microsoft Edge will show multiple instances in the "App volume and device preferences" when adjusting the endpoint.
Disclaimer
I already tried two 3rd party softwares: 'Audio Router', which didn't work at all and 'CheVolume', which doesn't solve the issue and constantly crashes while doing so.
This question is based on one I asked over at Super User (here), where I didn't get an answer I was able to work with due to my lack of knowledge regarding actual programming (I'm only somewhat familiar with Batch and PowerShell). I'm well aware that neither Stack Overflow nor Super User are script writing services, however, the issue is not being fixed with the Windows 10 October Update 1809 and I see this as a problem which is affecting not just me and with that would be helpful for multiple people after me. Feel free to write a comment or propose an edit if you see this differently.
I'm also not sure whether the tags 'audio-streaming' and 'endpoint' should be used in this context, please propose an edit if they shouldn't or you can think of any better.
Edit - 05/11/18
Using the 3rd party software 'EarTrumpet' I was able to overcome the issue with the 'Call of Duty' games (no audio at all after restarting), however, 'VLC Media Player' would not restart after I assigned a non-default endpoint with 'EarTrumpet' until I closed 'EarTrumpet' again and the issue with 'Tom Clancy's Rainbow Six Siege' remains the same.
Edit - 18/01/19
Added link to a bug report I created on the 'Feedback Hub' 2 month ago.
Edit - 20/01/19
After doing some testing again it should be noted that having 'EarTrumpet' run in the background will keep a non-default endpoint for 'VLC Media Player' across restarts, however, 'VLC Media Player' will only (reliably) restart when the non-default endpoint was set in the 'App volume and device preferences'.
I do not have any solution regarding a programming language to handle such events.
But I can recommend EarTrumpet app to handle this change more quickly https://www.theverge.com/2018/6/13/17457778/eartrumpet-windows-10-audio-app
(Windows store: https://www.microsoft.com/en-us/p/eartrumpet/9nblggh516xp?ranMID=24542&ranEAID=nOD%2FrLJHOac&ranSiteID=nOD_rLJHOac-hUn6PgKuMKwQLdrzRqnPTA&epi=nOD_rLJHOac-hUn6PgKuMKwQLdrzRqnPTA&irgwc=1&OCID=AID681541_aff_7593_1243925&tduid=%28ir__qwqlg6jd0jba3y9hpnbvikaite2xk6kuyv9udtr100%29%287593%29%281243925%29%28nOD_rLJHOac-hUn6PgKuMKwQLdrzRqnPTA%29%28%29&irclickid=_qwqlg6jd0jba3y9hpnbvikaite2xk6kuyv9udtr100&activetab=pivot:overviewtab )
I will update the answer if I find a easy way to script/program a change of output on each app.

Changin mp3 speed in Qt and C++ [QMediaPlayer]

I'm trying to develop a little application in which you can load a mp3 file and play it in variable speeds! (I know it already exists :-) )
I'm using Qt and C++. I already have the basic player but I'm stuck with the rate thing, because I want to change the rate smoothly (like in Mixxx) without stopping the playback! The QMediaPlayer always stops if I change the value and creates a gap in the sound. Also I don't want the pitch to change!
I already found something called "SoundTouch" but now I'm completely clueless what to do with it, how to process my mp3 data and how to get it to the player! The "SoundTouch" Library is capable of doing what I want, i got that from the samples on the homepage.
How do I have to import the mp3 file, so I can process it with the SoundTouch functions
How can I play the output from the SoundTouch function? (Perhaps QMediaPlayer can do the job?)
How is that stuff done live? I have to do some kind of stream I guess? So I can change the speed during play and keep on playing without gaps. Graphicaly in my head it has to be something that sits between the data and the player, where all data has to go through live, with a small buffer (20-50 ms or so) behind to avoid gaps during processing future data.
Any help appreciated! I'm also open to any another solution then "SoundTouch" as long as I can stay with Qt/C++!
(Second thing: I want to view a waveform overview aswell as moving part of it (around actual position of the song), so I could also use hints on how to get the waveform data)
Thanks in advance!
As of now (Qt 5.5) this is impossible to do with QMediaPlayer only. You need to do the following:
Decode the audio using GStreamer, FFMpeg or (new) QAudioDecoder: http://doc.qt.io/qt-5/qaudiodecoder.html - this will give you raw PCM stream;
Apply SoundTouch or some other library to this raw data to change the pitch. If GPL is ok, take a look at http://nsound.sourceforge.net/examples/index.html, if you develop proprietary stuff, STK might be a better choice: https://ccrma.stanford.edu/software/stk/
Output the modified data into audio device by using QAudioOutput.
This strategy uses Qt as much as possible, and brings you the best platform coverage (you still lose Android though as it does not support QAudioOutput)

Adjust volume / mute from my Qt C++ programm

Under Windows (7,8) I can mute / adjust volume as per application and per output device.
I wonder how I can set / query these values from my C++ Qt application. Basically I need to figure out / accomplish (use cases):
Is the global mute set (per device)? Set global mute from my application.
Is the application's mixer mute set? Set mixer mute.
Set mixer volume, set global volume.
Query mixer volume, set mixer volume?
Wherever possible I am looking for the Qt-ish way to accomplish things, keeping code as platform independent as possible. I can imagine to query the global mute via an OS-independent API, but using a Windows only class for the mixer.
From the C# question Get Master Sound Volume in c# I understand IAudioMeterInformation, IMMDeviceCollection, IMMDevice are the MSDN documentation entry points for Windows specific handling.
How do I tell if the master volume is muted? shows how commands can be send via WM_APPCOMMAND . Again, windows specific, also not allowing to query values but only to set them.
Is there something for Qt encapsulating these things? Is it Phonon I need to use? Checking Phonon briefly I did not see any methods for what I need, but I might have missed it.

Strategy for accessing native camera events on Google Glass using a Service

Background:
I have a google glass, and I am thinking on an app that can grab any/all images a user takes using the native camera, and passing those images to an online service (e.g. Twitter or Google+). Kind of like a life-blogging style application.
In my first prototype, I implemented a FileObserver Service that watches for new files in the directory that glass stores its camera preview thumbnails (sdcard/google_cached_files/). The preview files always started with t_, so once I saw a new file there, I uploaded it to my webservice. This was working very well, but in Glass XE11 this cache file was moved out of my reach (/data/private-cache).
So now, I am watching the folder sdcard/DCIM/Camera/ for new .jpg files. This works ok, but the camera is storing the full size image there, so I have to wait 5-8 sec before the image is available for upload.
The Question:
Should it be possible to have background service running on glass that can intercept the camera event, and grab the thumbnail or the full image as a byte array from the Bundle so that I don't have to wait for it to write to disk before accessing it?
I have been reading up more on android development, and I suspect the answer involves implementing a BroadcastReciever in my service, but I wanted to check with the experts before going down the wrong path.
Many thanks in advance
Richie
Yes. Implement a PreviewCallback. Same way it worked for phones, example here: http://www.dynamsoft.com/blog/webcam/how-to-implement-a-simple-barcode-scan-application-on-android/
I tested it on Google Glass and it works. In this post ( http://datawillconfess.blogspot.com.es/2013/11/google-glass-gdk.html ) I list the parameters (below the video) which the camera returns after doing:
Camera m_camera = Camera.open(0);
m_params = m_camera.getParameters();
m_params.setPreviewFormat(ImageFormat.NV21);
m_camera.setParameters(m_params);
m_params = m_camera.getParameters();
m_params.setPreviewSize(320,240);
m_params.set("focus-mode",(String)"infinity");
m_params.set("autofocus", "false");
m_params.set("whitebalance",(String)"daylight");
m_params.set("auto-whitebalance-lock",(String)"true");
m_camera.setParameters(m_params);
String s = m_params.flatten();
Log.i("CAMERA PARAMETERS", "="+s);