# dsp.getParameterData return ERR\_INVALID\_PARAM

**URL:** https://qa.fmod.com/t/dsp-getparameterdata-return-err-invalid-param/13376
**Category:** FMOD Engine
**Created:** [August 24, 2017, 12:49am UTC](https://qa.fmod.com/t/dsp-getparameterdata-return-err-invalid-param/13376 "2017-08-24T00:49:23Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![r\_emak\_e](https://avatars.discourse-cdn.com/v4/letter/r/e274bd/32.png) [@r\_emak\_e](https://qa.fmod.com/u/r_emak_e)
#### Post date: [August 24, 2017, 12:49am UTC](https://qa.fmod.com/t/dsp-getparameterdata-return-err-invalid-param/13376/1 "2017-08-24T00:49:23Z")

</div>

```
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

using AudioSpectrumStudy.Fmod;
using System.Runtime.InteropServices;

namespace AudioSpectrumStudy
{
    public partial class Form1 : Form
    {
        Fmod.System system;
        Fmod.Channel channel;
        Fmod.Sound sound;
        Fmod.ChannelGroup channelGroup;
        Fmod.DSP dsp;
        Fmod.DSP_DESCRIPTION description;
        Timer timer;

        public Form1()
        {
            InitializeComponent();
            textBox1.MouseDoubleClick += textBox1_MouseDoubleClick;

            system = new Fmod.System(IntPtr.Zero);
            system.init(32, INITFLAGS.NORMAL, IntPtr.Zero);
            channel = new Channel(IntPtr.Zero);
            sound = new Sound(IntPtr.Zero);

            sound.setMusicSpeed(1.0f);
            sound.setMode(MODE._2D);

            description = new DSP_DESCRIPTION();
            system.createDSP(ref description, out dsp);

            channel.getChannelGroup(out channelGroup);
            timer = new Timer();
            timer.Tick += timer_Tick;
        }

        void textBox1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "File|*.*";
            ofd.ShowDialog();

            textBox1.Text = ofd.FileName;
        }

        void timer_Tick(object sender, EventArgs e)
        {
            system.update();

            UpdateSpectrum();

            progressBar1.Value = (int)_spectrum[0] > 100 ? 100 : (int)_spectrum[0];
        }

        private void Form1_Load(object sender, EventArgs e)
        {
        }

        private const int SPECTRUM_SIZE = 512;
        private float[][] _spectrumInfo;
        public float[] _spectrum;

        private void UpdateSpectrum()
        {
            if (_spectrum == null || _spectrumInfo == null)
            {
                if(_spectrum == null)
                    _spectrum = new float[SPECTRUM_SIZE];

                if (_spectrumInfo == null)
                {
                    _spectrumInfo = new float[2][];
                    _spectrumInfo[0] = new float[SPECTRUM_SIZE];
                    _spectrumInfo[1] = new float[SPECTRUM_SIZE];
                }
            }

            System.IntPtr data = IntPtr.Zero;
            uint length = 0;

            dsp.getParameterData(3, out data, out length);
            //Fmod.DSP_PARAMETER_FFT spectrumBuffer = new DSP_PARAMETER_FFT();
            
            var spectrumBuffer = (Fmod.DSP_PARAMETER_FFT)Marshal.PtrToStructure(data, typeof(Fmod.DSP_PARAMETER_FFT));

            _spectrumInfo = spectrumBuffer.spectrum;

            for (int i = 0; i < SPECTRUM_SIZE; i++)
            {
                _spectrum[i] = (_spectrumInfo[0][i] + _spectrumInfo[1][i]) / 2f;
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            system.createSound(textBox1.Text, MODE._2D, out sound);
            system.playSound(sound, channelGroup, false, out channel);
            system.playDSP(dsp, channelGroup, false, out channel);

            system.release();
            system.close();

            timer.Start();
        }
    }
}

```

this is my code  
var spectrumBuffer = (Fmod.DSP\_PARAMETER\_FFT)Marshal.PtrToStructure(data, typeof(Fmod.DSP\_PARAMETER\_FFT));  
this code raise exception ‘ArgumentNullException’ so, I traced with debug why the exception raise.  
I found dsp.getParameterData() method was returned ‘ERR\_INVALID\_PARAM’  
why working like that?

---

<div class="post-metadata">

### Author: ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)
#### Post date: [August 24, 2017, 4:31am UTC](https://qa.fmod.com/t/dsp-getparameterdata-return-err-invalid-param/13376/2 "2017-08-24T04:31:02Z")

</div>

It looks like you aren’t adding your dsp to anything.  
You will need to use Channel/ChannelGroup::[addDSP()](https://www.fmod.org/docs/content/generated/FMOD_Channel_AddDSP.html).

Also a good idea to make sure the sound is playing before using getParameterData, otherwise you will just get back meaningless data.

---

<div class="post-metadata">

### Author: ![r\_emak\_e](https://avatars.discourse-cdn.com/v4/letter/r/e274bd/32.png) [@r\_emak\_e](https://qa.fmod.com/u/r_emak_e)
#### Post date: [August 24, 2017, 4:48am UTC](https://qa.fmod.com/t/dsp-getparameterdata-return-err-invalid-param/13376/3 "2017-08-24T04:48:29Z")

</div>

> [@](#):
>
> It looks like you aren’t adding your dsp to anything.  
> You will need to use Channel/ChannelGroup::[addDSP()](https://www.fmod.org/docs/content/generated/FMOD_Channel_AddDSP.html).
> 
> Also a good idea to make sure the sound is playing before using getParameterData, otherwise you will just get back meaningless data.

truly music was not played…  
playSound Method also returned ERR\_INVALID\_PARAM too.  
I’m so confused about use this api now 😑

---

<div class="post-metadata">

### Author: ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)
#### Post date: [August 24, 2017, 5:47am UTC](https://qa.fmod.com/t/dsp-getparameterdata-return-err-invalid-param/13376/4 "2017-08-24T05:47:42Z")

</div>

The channelgroup may not be valid, you are calling getChannelGroup on the channel before it has been assigned (in the playSound method). You don’t have to use a channelgroup when creating a sound, you can pass in null or even the master group using System::getMasterChannelGroup.

Also when creating the dsp, you need to specify the description going in to create it. Otherwise you can use createDSPByType(FMOD.DSP\_TYPE.FFT, out dsp).

---

<div class="post-metadata">

### Author: ![r\_emak\_e](https://avatars.discourse-cdn.com/v4/letter/r/e274bd/32.png) [@r\_emak\_e](https://qa.fmod.com/u/r_emak_e)
#### Post date: [August 24, 2017, 6:55am UTC](https://qa.fmod.com/t/dsp-getparameterdata-return-err-invalid-param/13376/5 "2017-08-24T06:55:30Z")

</div>

thx at all, I turned the other solution.

now have new issue  
private void FmodERRCheck(Fmod.RESULT result){  
if (result != RESULT.OK)  
{  
MessageBox.Show(Fmod.Error.String(result));  
}  
}

```
    private void InitFmodSystems()
    {
        Fmod.Factory.System_Create(out system);
        system = new Fmod.System(IntPtr.Zero);
        system.init(3, INITFLAGS.NORMAL, IntPtr.Zero);

        channelGroup = new ChannelGroup(IntPtr.Zero);

        FmodERRCheck(system.createChannelGroup("", out channelGroup));
    }

```

I fixed my code right that  
FmodERRCheck(system.createChannelGroup("", out channelGroup));  
this line message to me ERR\_INVALID\_PARAM again.  
welp. I think that could be working 😕
