[SUPPORT] AudioAnalyzer

Thought I’d try running this in 4.23 out of the box and try to fix any issues myself. However there’s an error I have no idea how to fix. Seems like an error in something in AudioAnalyzer.build.cs.

UnrealBuildTool : error : Unable to instantiate module ‘AudioAnalyzer’: System.InvalidProgramException: Common Language Runtime detected an invalid program.
1> at AudioAnalyzer…ctor(ReadOnlyTargetRules Target)
1> (referenced via default plugins → AudioAnalyzer.uplugin)

I sent the update for 4.23 on Friday, but I think we need to wait until Monday to obtain the Marketplace team result.

The cs file has been changed to be able to compile on 4.23 version.
Now we can’t use Target.Platform to define cases on a switch statement, all this cases must be replaced by nested if statements

Hi BYC!

I am enjoying the plugin a lot, and have it working in UE4.

Can you please provide some suggestions on modifying the linear array of NumBands? For example, how to curve the line of objects?

I see how to modify the spacing and scale of effect but not rotating each successive instance so the line forms an arc or circle. Thank you!

Do you want to make something like that?
Audio Analyzer plugin for UE4 [Ring Visualizer] - YouTube](Audio Analyzer plugin for UE4 [Ring Visualizer] - YouTube)

Some maths for that visualizer
To calculate the position of the cube you need to apply the cos/sen of the angle of the cube inside the circle. For example if we want 8 bands:
The first one will be in the 0 degrees position, the second in 45*, the third one in 90… Now with that angle use the cos to get the X position of the transform and the sin to take the Y position.

AngleOffset = 360/NumBands
RingSize = 1000

Foreach loop CubeId 0 -> Numbands CubeAngle = AngleOffset * CubeId
CubePosX = Cosd(CubeAngle) * RingSize
CubePosY = Sind(CubeAngle) * RingSize
Set Cube Transform
[INDENT=2]Location (CubePosX, CubePosY, 0)[/INDENT]
[INDENT=2]Rotator (0, 0, CubeAngle)[/INDENT]
[INDENT=2]Scale (1,1,1)[/INDENT]

The full project of this and other visualizers can be found in the patreon page.

Hi BYC!

I love this plugin - thank you!
Running into two edge cases when analyzing a windows audio loopback stream & wondering if you have any thoughts on them:

  • Users using an external audio interface like the Focusrite Scarlett get analysis data that’s dramatically reduced in amplitude from what it is if they run the audio through their internal audio hardware.
  • Users feeding audio through Oculus Rift onboard audio don’t get any loopback data at all. (HTC Vive users using Vive audio have no problems though.)

I know both of these are pretty distant edge cases from the norm but was curious whether you had any thoughts on how we could address them.

Thanks!

I’m using the WINAPI implementation to add this feature to the plugin. Unfortunately I can only test it on windows platform, but if you have a log file you can send it to support@parallelcube.com

Works flawlessly on android. But the plugin causes my game to crash in iOS. I did read it is experimental and mp3 doesn’t work in iOS, but it should atleast build and run in an iphone right ?

Can you send the log files to support@parallelcube.com?

Just shared the logs. Just in case, i am also sharing it here

The plugin crashes the project just by being enabled when deployed onto an ios device.
It seems “libSDL2.dylib” is not being loaded. Any idea for a quick fix on my end ?


Version:             0.515 (0.7)
Code Type:           ARM-64 (Native)
Role:                Foreground
Parent Process:      launchd [1]
Coalition:            [1605]


Date/Time:           2020-01-09 13:01:45.8371 +0530
Launch Time:         2020-01-09 13:01:45.8255 +0530
OS Version:          iPhone OS 13.3 (17C54)
Release Type:        User
Baseband Version:    4.01.02
Report Version:      104

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note:  EXC_CORPSE_NOTIFY
Termination Description: DYLD, dependent dylib '@rpath/libSDL2.dylib' not found for '/private/var/containers/Bundle/Application/C6152FFF-E11A-49EC-8DC8-4B0C43582BD2/BallDasher.app/BallDasher', tried but didn't find: '/private/var/containers/Bundle/Application/C6152FFF-E11A-49EC-8DC8-4B0C43582BD2/BallDasher.app/Frameworks/libSDL2.dylib' '@rpath/libSDL2.dylib' '/usr/local/lib/libSDL2.dylib' '/usr/lib/libSDL2.dylib'
Highlighted by Thread:  0

Backtrace not available

Unknown thread crashed with ARM Thread State (64-bit):
    x0: 0x0000000000000006   x1: 0x0000000000000001   x2: 0x000000016dd8e070   x3: 0x0000000000000093
    x4: 0x000000016dd8dc70   x5: 0x0000000000000000   x6: 0x0000000000000000   x7: 0x0000000000000000
    x8: 0x0000000000000020   x9: 0x0000000000000009  x10: 0x2762696c79642e32  x11: 0x6c2f7273752f2720
   x12: 0x2f27202762696c79  x13: 0x2f62696c2f727375  x14: 0x2e324c445362696c  x15: 0x00202762696c7964
   x16: 0x0000000000000209  x17: 0x0000000000000000  x18: 0x0000000000000000  x19: 0x0000000000000000
   x20: 0x000000016dd8dc70  x21: 0x0000000000000093  x22: 0x000000016dd8e070  x23: 0x0000000000000001
   x24: 0x0000000000000006  x25: 0x0000000105748000  x26: 0x0000000000000000  x27: 0x0000000105748000
   x28: 0x0000000000000000   fp: 0x000000016dd8dc40   lr: 0x0000000105732498
    sp: 0x000000016dd8dc00   pc: 0x000000010572b5e4 cpsr: 0x00000000
   esr: 0x00000000  Address size fault

Binary images description not available

Error Formulating Crash Report:
Failed to create CSSymbolicatorRef - corpse still valid ¯\_(ツ)_/¯

EOF


Hi

The quick fix is to try to copy the dylib to one of the expected folders. You have the dylib in the Plugin folder \UE_4.24\Engine\Plugins\Marketplace\AudioAnalyzer\Source\Thirdparty\SDL2\Libraries\IOS, you will have to copy the libs for the rest of the decoders too. You can find that in \UE_4.24\Engine\Plugins\Marketplace\AudioAnalyzer\Source\Thirdparty[decoder]\Libraries\IOS

There is some bugs with the packaging UE4 process and thirdparty plugins. For example in Android platform you will have to copy the plugin folder to your project folder to be able to package it for arm64, With armv7 the packaging is correct. So you can try to copy the plugin folder inside your project before packaging to discard a packaging problem related to their bug. If the problem continues we can try to check more things with your help.

I can find the library files as you mentioned, but i have zero idea on where i need to copy-paste it. Can you guide me on the location to copy-paste it ?

You will need access to the root folder of your file system

The error log suggests one of this paths:
‘/private/var/containers/Bundle/Application/C6152FFF-E11A-49EC-8DC8-4B0C43582BD2/BallDasher.app/Frameworks/libSDL2.dylib’
@rpath/libSDL2.dylib’
‘/usr/local/lib/libSDL2.dylib’
‘/usr/lib/libSDL2.dylib’

The first one must be the correct path of a successfully packaging process but I think you can try anyway of that list.

I’m going to investigate why the thirdparty libraries are not packaged in the expected path.

If you want to compile the plugin sources you have a guidelines here:
https://www.parallelcube.com/content/docs/audioanalyzer/install.html#manual-installation-ue4-4-20-and-older-versions

You can see too this tutorial about how to link and use thirdparty libraries in UE4 projects

To define a custom range of the frequency analysis you must use the “Init Beat Tracking Config** WLimits”.** To define the limits or the bounds of a band you need to use the Make Array node
You can set the low and high frecuency bound of the analysis bands. You only have two rules to make this list: sorted and no overlap.

So an example of valid bounds array:
0-10
11-40
80-100

And an example of invalid bounds array:

0-10
10-40 (overlap frequency 10Hz)

0-10
5-40 (overlap frequencies 5-10Hz)

In this image I have created 3 bands, the first one takes the accumulative result of frequencies from 0 Hz to 10 Hz and the second one from 11 Hz to 40 Hz…
You can override the **threshold **value for all the bands at this point too. The concept of the beat tracking analysis and this parameter can be found in this tutorial

InitBT.png
The output of Get Beat Tracking will be an array of 3 elements, one for each band.

BetBT.png

You can override one threshold value for each band using the **WThreshold **node

GetBTT.png

The plugin is focused in real time analysis so there is no node to do a full beat tracking analysis without playing. But if you only want the analysis in real time without audio output you can set the Volume of the Audio Manager to 0 using Set Playback Volume node.

For example, an audiosurf style game. If you want to generate the track in front of the player before they reach that point you need to audio managers, one to play the song with volume 0 and make the analysis, and the second one start playing the same song but with a delay of 3-5 seconds (the time of the track generated in front of the player) and without analysis.

Question:
All the listed formats (mp3, wav, ogg) can be open at runtime and played inside the game ? Can get the soudwave file ?
From some replies I notice you’re using SDL2, you’re using the base or Mixer ? And in the case you’re using SDL2 base why aren’t you using the inclued SDL2 in the engine ?

I’m using the audio module of SDL2 library to play the sounds, and taking the raw data during the playback. It’s and audio system independient of the UE4 audio, but can be used inside the ue4 projects. You can load the audio and play from the original file at runtime. I have not been able to extract the audio from the soundwave class so you can’t take the audio from a soundwave and use it in the plugin.

I’m using the base library. On plugin release the version of the sdl2 included by the engine was outdated, I don’t know the current version included with the engine, I prefer to use the last version, for example that version included performance improvements on Android platform and some fixes than the UE4 version didn’t have, at that time.

Hi BYC

I am running into a problem when using your Plugin. I want to create a project (as basic as possible) that uses frequency ranges of a selected audio device input/output to drive different parameters of objects.

I’m not an expert on blueprints, so I took your AA_StarterProject and changed it into a “loopback-version”. Well maybe you can create a short guide for a very simple setup, but with the current changed up starter project, there’s a problem with the frequency range defined as array index 1.

The array indexes (frequency ranges) 0, 2 & 3 return the correct values, but index 1 stays at 0.

Thanks! And let me know if you need any further information.

The problem is the size of the range in position 1 with that time window.

For a 0.02s window with a 44100 sample rate audio the minimal frequency bucket is:
Num_samples = 44100 * 0.02 = 882 (now we search for a window size power 2 to fit that number samples (1024), this is the size of our FFT analysis)
So each FFT result position represent a band of 44100 / 1024 = 43.0660 hz

Now you have a band of 120 - 90 = 30 Hz, that value falls below the band size of the FFT
If you request a range under that minimal you obtain a 0.

With a timewindow of 0.03 you can reduce the minimal size to work with your bounds.
44100 * 0.03 =1323 -> next power 2 value 2048
44100 / 2048 = 21.53 hz
So you can increase the time window by 0.03 sec to reduce the minimal range and obtain a value for all your curent bands (or you can increase the size of that band over 43)

Thanks for the quick answer! I had to read this a couple of times to understand it, but it makes sense!

I changed the range to 90 - 140. I will create sliders to directly adjust the values in the gamepreview later, so that I have direct feedback for how it looks. Then it will come in handy that I understand the problem with the timewindow :slight_smile:

I managed to get the libraries imported into the final ipa file, and the game no longer crashes in my iphone at startup. But no music plays. Do you know why it might not play in iOS ? There is simply no reaction, while building the same game for windows works like a charm. I really need to get it work in iphone somehow. Is it properly tested in iOS though ?

All the necessary .dylib files are successfully packaged in the framework folder.

@BYC Hi is there any pitch or slow down method… How can I slow down music for a while?