# ERR\_INVALID\_PARAM when converting AudioClip to FMOD.Sound

**URL:** <https://qa.fmod.com/t/err-invalid-param-when-converting-audioclip-to-fmod-sound/11776>\
**Category:** Unity\
**Created:** [January 1, 2015, 9:18pm UTC](https://qa.fmod.com/t/err-invalid-param-when-converting-audioclip-to-fmod-sound/11776 "2015-01-01T21:18:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Footch](https://avatars.discourse-cdn.com/v4/letter/f/77aa72/32.png) [@Footch](https://qa.fmod.com/u/Footch)\
**Post date:** [January 1, 2015, 9:18pm UTC](https://qa.fmod.com/t/err-invalid-param-when-converting-audioclip-to-fmod-sound/11776/1 "2015-01-01T21:18:52Z")

</div>

I’m trying to convert a Unity AudioClip to an FMOD.Sound and I followed that post:  
[http://52.88.2.202/questions/question/load-an-audioclip-as-fmod-sound](http://52.88.2.202/questions/question/load-an-audioclip-as-fmod-sound)

I have a single FMODSystem object that I use to create various sounds and play them:

```
FMOD.RESULT result;
FMOD.Factory.System_Create(ref fmodSystem);
result = fmodSystem.init(4, FMOD.INITFLAG.NORMAL, System.IntPtr.Zero); 

```

And I have this method here for converting AudioClips into FMOD.Sounds:

```
private FMOD.Sound ConvertAudioClip(AudioClip clip){
	float[] samples = new float[clip.samples * clip.channels];
	clip.GetData(samples, 0);
	uint lenbytes = (uint)(clip.samples * clip.channels * sizeof(float));
	
	FMOD.CREATESOUNDEXINFO soundinfo = new FMOD.CREATESOUNDEXINFO();
	soundinfo.length = lenbytes;
	soundinfo.format = FMOD.SOUND_FORMAT.PCMFLOAT;
	soundinfo.defaultfrequency = clip.frequency;
	soundinfo.numchannels = clip.channels;

	FMOD.RESULT result;
	FMOD.Sound sound = new FMOD.Sound();
	result = fmodSystem.createSound("", FMOD.MODE.OPENUSER, ref soundinfo, ref sound);
	Debug.Log(result);
	System.IntPtr ptr1 = System.IntPtr.Zero, ptr2 = System.IntPtr.Zero;
	uint len1 = (uint)0, len2 = (uint)0;
	result = sound.@lock(0, lenbytes, ref ptr1, ref ptr2, ref len1, ref len2);
	Marshal.Copy(samples, 0, ptr1, (int)(len1 / sizeof(float)));
	if (len2 > 0)
	{
		Marshal.Copy(samples, (int)(len1 / sizeof(float)), ptr2, (int)(len2 / sizeof(float)));
	}
	result = sound.unlock(ptr1, ptr2, len1, len2);
	result = sound.setMode(FMOD.MODE.LOOP_NORMAL);
	return sound;
}

```

However, when I log the result from creating the sound I get an ERR\_INVALID\_PARAM error. What could be causing this ?

Thanks!

---

<div class="post-metadata">

**Author:** ![nick1](https://avatars.discourse-cdn.com/v4/letter/n/47e85d/32.png) [@nick1](https://qa.fmod.com/u/nick1)\
**Post date:** [January 5, 2015, 6:15am UTC](https://qa.fmod.com/t/err-invalid-param-when-converting-audioclip-to-fmod-sound/11776/2 "2015-01-05T06:15:09Z")

</div>

Have you modified the wrapper? Because that code you sent won’t compile.

Check to make sure that frequency and channels are greater than zero.

---

<div class="post-metadata">

**Author:** ![Footch](https://avatars.discourse-cdn.com/v4/letter/f/77aa72/32.png) [@Footch](https://qa.fmod.com/u/Footch)\
**Post date:** [January 5, 2015, 3:35pm UTC](https://qa.fmod.com/t/err-invalid-param-when-converting-audioclip-to-fmod-sound/11776/3 "2015-01-05T15:35:28Z")

</div>

> [@](#):
>
> Have you modified the wrapper? Because that code you sent won’t compile.
> 
> Check to make sure that frequency and channels are greater than zero.

Thanks for the answer! I haven’t modified the wrapper. I’m using SquareTangle’s integration [http://www.squaretangle.com/FMODUnity.html](http://www.squaretangle.com/FMODUnity.html)  
A debug of the frequency and channels (Debug.Log(clip.frequency + " " + clip.channels)😉 returns 48000 2 so they are not zero.

---

<div class="post-metadata">

**Author:** ![nick1](https://avatars.discourse-cdn.com/v4/letter/n/47e85d/32.png) [@nick1](https://qa.fmod.com/u/nick1)\
**Post date:** [January 5, 2015, 10:46pm UTC](https://qa.fmod.com/t/err-invalid-param-when-converting-audioclip-to-fmod-sound/11776/4 "2015-01-05T22:46:46Z")

</div>

We do not provide support for the Squaretangle wrapper. You could switch to our official Unity integration.

---

<div class="post-metadata">

**Author:** ![Footch](https://avatars.discourse-cdn.com/v4/letter/f/77aa72/32.png) [@Footch](https://qa.fmod.com/u/Footch)\
**Post date:** [January 6, 2015, 2:20pm UTC](https://qa.fmod.com/t/err-invalid-param-when-converting-audioclip-to-fmod-sound/11776/5 "2015-01-06T14:20:44Z")

</div>

> [@](#):
>
> We do not provide support for the Squaretangle wrapper. You could switch to our official Unity integration.

I understand. Thank you, I will switch to your official integration.
