Changing Impulse Response AudioClip in Convolution Reverb Demo plugin of the Native Audio Plugin SDK
Where do I load my own impulse response (IR) into the demo convolution reverb plugin from the Native Audio Plugin SDK, please?
The C# code of the ConvolutionReverbUploadIR is:
using UnityEngine;
using System.Collections;
using System.Runtime.InteropServices;
public class ConvolutionReverbUploadIR : MonoBehaviour
{
[DllImport("AudioPluginDemo")]
private static extern bool ConvolutionReverb_UploadSample(int index, float[] data, int numsamples, int numchannels, int samplerate, [MarshalAs(UnmanagedType.LPStr)] string name);
public AudioClip[] impulse = new AudioClip[0];
public int index;
private bool[] uploaded = new bool [64];
private AudioClip[] currImpulse = new AudioClip [64];
void Start()
{
UploadChangedClips();
}
void Update()
{
UploadChangedClips();
}
void UploadChangedClips()
{
int currindex = index;
foreach (var s in impulse)
{
if (currImpulse[currindex] != s)
uploaded[currindex] = false;
// if s is not null and is loaded and uploaded/ uploading
if (s != null && s.loadState == AudioDataLoadState.Loaded && !uploaded[currindex])
{
// debug log state uploading impulse name
Debug.Log ("Uploading impulse response " + s.name + " to slot " + currindex);
float[] data = new float[s.samples];
s.GetData(data, 0);
ConvolutionReverb_UploadSample(currindex, data, data.Length / s.channels, s.channels, s.frequency, s.name);
uploaded[currindex] = true;
currImpulse[currindex] = s;
}
currindex++;
}
}
}
Any help would be appreciated, please.
Answer by MadWork · Aug 29, 2016 at 05:17 PM
I figured this out. In case anyone is wondering:
You can add your own impulse responses by adding audio clips to the audio array, "impulse". These are added to the "use sample" parameter of the "convolution reverb" mixer.
Answer by LookListen_Audio · Mar 30, 2017 at 11:20 AM
@MadWork Been searching around all over the place for a way to move forward with the convolution. i've found the Convolution Reverb Upload IR Script and added clips to the Impulse array. But when I manipulate the Use Sample value it doesn't read my new IRs.
Any extra steps you took? Any help would be much appreciated!
Your answer
Follow this Question
Related Questions
Audio Spatializer SDK. Source/Listener location matrix 0 Answers
Threading using Thread Ninja to use Adtapsy SDK 0 Answers
Is it possible to access rig joints in C#? 0 Answers
Native audio Plugin SDK channels question 1 Answer
Unity project build issue 0 Answers