# Low Level API on Unity

**URL:** <https://qa.fmod.com/t/low-level-api-on-unity/15899>\
**Category:** Unity\
**Created:** [June 18, 2020, 1:55pm UTC](https://qa.fmod.com/t/low-level-api-on-unity/15899 "2020-06-18T13:55:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alco6](https://avatars.discourse-cdn.com/v4/letter/a/e480ec/32.png) [@Alco6](https://qa.fmod.com/u/Alco6)\
**Post date:** [June 18, 2020, 1:55pm UTC](https://qa.fmod.com/t/low-level-api-on-unity/15899/1 "2020-06-18T13:55:18Z")

</div>

Hi,  
I am trying to use the Low Level API on Unity. However when I play there is no sound at all.

- I have disabled Unity Audio in Project Sett

> private void InitFMODLowLevel()  
> {  
> FMOD.Factory.System\_Create(out FMODsystem);  
> FMODsystem.setOutput(FMOD.OUTPUTTYPE.WASAPI);  
> FMODsystem.init(512, FMOD.INITFLAGS.NORMAL, System.IntPtr.Zero);  
> }

> ```
> void PlaySoundLowLevel(float noteFreq, float duration )
> {
> 
> FMOD.CREATESOUNDEXINFO sInfo = new FMOD.CREATESOUNDEXINFO();
> sInfo.length = (uint)duration; //sound.Length
> sInfo.format = FMOD.SOUND_FORMAT.PCMFLOAT;
> sInfo.defaultfrequency = 44100;
> sInfo.numchannels = 1;
> sInfo.cbsize = Marshal.SizeOf(typeof(FMOD.CREATESOUNDEXINFO));
> 
> FMOD.Sound FMODSound;
> byte[] Signal= CreateSound( noteFreq, duration);
> FMODsystem.createSound(Signal, FMOD.MODE.DEFAULT,ref sInfo,out FMODSound);
> 
> FMOD.ChannelGroup masterChannelGroup;
> FMODsystem.getMasterChannelGroup(out masterChannelGroup);
> 
> FMODsystem.playSound(FMODSound, masterChannelGroup, false, out FMODChannel);
>      
> }
> 
> ```

Could you please tell me where could be the problem? I receive no error on the console but there is no sound.

---

<div class="post-metadata">

**Author:** ![mathew](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/mathew/32/431_2.png) [@mathew](https://qa.fmod.com/u/mathew)\
**Post date:** [June 18, 2020, 10:35pm UTC](https://qa.fmod.com/t/low-level-api-on-unity/15899/2 "2020-06-18T22:35:18Z")

</div>

Firstly, I’d recommend you check the error codes returned from each FMOD function, that should give you an idea where your error is.

Looking at your sample, I’d say createSound is failing because you need to pass in [FMOD.MODE.OPEN\_MEMORY](https://fmod.com/resources/documentation-api?version=2.0&page=core-api-common.html#fmod_openmemory).

---

<div class="post-metadata">

**Author:** ![Alco6](https://avatars.discourse-cdn.com/v4/letter/a/e480ec/32.png) [@Alco6](https://qa.fmod.com/u/Alco6)\
**Post date:** [June 19, 2020, 8:57am UTC](https://qa.fmod.com/t/low-level-api-on-unity/15899/3 "2020-06-19T08:57:34Z")

</div>

I tried OPEN\_MEMORY and OPENUSER, I get errors with all different combinations from createSound

FmodERRCheck(FMODsystem.createSound(Signal, (FMOD.MODE.OPENUSER| FMOD.MODE.OPENMEMORY), ref sInfo, out FMODSound));

Signal is a byte[] generated sinewave.

```
void PlaySoundLowLevel(float noteFreq, float duration )
    {

        FMOD.CREATESOUNDEXINFO sInfo = new FMOD.CREATESOUNDEXINFO();
        sInfo.length = (uint)duration; //sound.Length
        sInfo.format = FMOD.SOUND_FORMAT.PCMFLOAT;
        sInfo.defaultfrequency = 44100;
        sInfo.numchannels = 1;
        sInfo.cbsize = Marshal.SizeOf(typeof(FMOD.CREATESOUNDEXINFO));

        FMOD.Sound FMODSound;
        byte[] Signal= CreateSoundSignal( noteFreq, duration);

        FmodERRCheck(FMODsystem.createSound(Signal, (FMOD.MODE.OPENUSER| FMOD.MODE.OPENMEMORY), ref sInfo, out FMODSound));

        ///Channel configuration
        FMOD.ChannelGroup masterChannelGroup;
        FmodERRCheck(FMODsystem.getMasterChannelGroup(out masterChannelGroup));
        

        FMOD.Channel FMODChannel; 
        FmodERRCheck(FMODsystem.playSound(FMODSound, masterChannelGroup, false, out FMODChannel));

    }

    public static byte[] CreateSoundSignal(float noteFreq, float time)
    {
        int sampleFreq = 44100;
        int sampleTime = Mathf.RoundToInt(sampleFreq * time);

        float[] samples = new float[sampleTime];
        for (int i = 0; i < samples.Length; i++)
        {
            samples[i] = Mathf.Sin(Mathf.PI * 2 * i * noteFreq / sampleFreq);
        }
        byte[] byteSamples = new byte[samples.Length * sizeof(float)];

        Buffer.BlockCopy(samples, 0, byteSamples, 0, byteSamples.Length);

        return byteSamples;
    }
```

---

<div class="post-metadata">

**Author:** ![mathew](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/mathew/32/431_2.png) [@mathew](https://qa.fmod.com/u/mathew)\
**Post date:** [June 21, 2020, 11:00pm UTC](https://qa.fmod.com/t/low-level-api-on-unity/15899/4 "2020-06-21T23:00:19Z")

</div>

Instead of OPENUSER, try OPENRAW.  
So FMOD.MODE.OPENRAW | FMOD.MODE.OPENMEMORY
