# iOS   have a problem, need help!

**URL:** <https://qa.fmod.com/t/ios-have-a-problem-need-help/13820>\
**Category:** FMOD Engine\
**Created:** [April 13, 2018, 4:31am UTC](https://qa.fmod.com/t/ios-have-a-problem-need-help/13820 "2018-04-13T04:31:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![vicczhang](https://avatars.discourse-cdn.com/v4/letter/v/e480ec/32.png) [@vicczhang](https://qa.fmod.com/u/vicczhang)\
**Post date:** [April 13, 2018, 4:31am UTC](https://qa.fmod.com/t/ios-have-a-problem-need-help/13820/1 "2018-04-13T04:31:37Z")

</div>

hi,  
I have a problem，  
in Android use this code can get a music file,but in iOS this never get a file,I need help.

code:

void compoundmain(const char\* recordPath, const char\* outputPath){  
FMOD::System \*system;  
FMOD::Sound \*sound;  
FMOD::Channel \*channel;  
FMOD\_RESULT result;

```
result = FMOD::System_Create(&system);
ERRCHECK(result);
system->setOutput(FMOD_OUTPUTTYPE_COREAUDIO);

result = system->init(32, FMOD_INIT_STREAM_FROM_UPDATE, &outputPath);
ERRCHECK(result);

system->createSound(recordPath, FMOD_DEFAULT, NULL, &sound);
system->playSound(sound, 0, false, &channel);

channel->setPitch(1.5);

```

// FMOD::DSP \*dsp = 0;  
unsigned int length = 0;  
sound-\>getLength(&length, FMOD\_TIMEUNIT\_MS);  
unsigned int position = 0;  
do{  
system-\>update();  
channel-\>getPosition(&position, FMOD\_TIMEUNIT\_MS);  
}while (position \< length);  
sound-\>release();  
system-\>close();  
system-\>release();  
}

---

<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:** [April 17, 2018, 11:57pm UTC](https://qa.fmod.com/t/ios-have-a-problem-need-help/13820/2 "2018-04-17T23:57:17Z")

</div>

Have you made sure to set the AudioSession Category for recording?

This information can be found in our Getting started guide in the iOS API docs.

> Recording ---------
> 
> Much like lock screen and background audio, recording requires a particular AudioSession category to be active at the time of System::recordStart (and must remain active until the recording finishes). The required category is called ‘play and record’ and can be read about in the audio session basics documentation. Note that FMOD is always ‘playing’ audio (even silence) so it is not sufficient to simply use the ‘recording’ category unless you are running the ‘No Sound’ or ‘Wav Writer’ output mode.
> 
> Some devices may take some time to switch AudioSession category so it is recommended to set this category at application start time to avoid any hiccups in audio playback.

---

<div class="post-metadata">

**Author:** ![vicczhang](https://avatars.discourse-cdn.com/v4/letter/v/e480ec/32.png) [@vicczhang](https://qa.fmod.com/u/vicczhang)\
**Post date:** [April 20, 2018, 10:52am UTC](https://qa.fmod.com/t/ios-have-a-problem-need-help/13820/3 "2018-04-20T10:52:23Z")

</div>

> [@](#):
>
> Have you made sure to set the AudioSession Category for recording?
> 
> This information can be found in our Getting started guide in the iOS API docs.
> 
> > Recording ---------
> > 
> > Much like lock screen and background audio, recording requires a particular AudioSession category to be active at the time of System::recordStart (and must remain active until the recording finishes). The required category is called ‘play and record’ and can be read about in the audio session basics documentation. Note that FMOD is always ‘playing’ audio (even silence) so it is not sufficient to simply use the ‘recording’ category unless you are running the ‘No Sound’ or ‘Wav Writer’ output mode.
> > 
> > Some devices may take some time to switch AudioSession category so it is recommended to set this category at application start time to avoid any hiccups in audio playback.

I Have been set AudioSession category 。 These days I find the problem。

the problem code is:  
result = system-\>init(32, FMOD\_INIT\_STREAM\_FROM\_UPDATE, &outputPath);  
ERRCHECK(result);

the outputPath is pointer,The right is ‘char path’ not pointer path。now it can output wav file。

---

<div class="post-metadata">

**Author:** ![vicczhang](https://avatars.discourse-cdn.com/v4/letter/v/e480ec/32.png) [@vicczhang](https://qa.fmod.com/u/vicczhang)\
**Post date:** [April 20, 2018, 10:41am UTC](https://qa.fmod.com/t/ios-have-a-problem-need-help/13820/4 "2018-04-20T10:41:53Z")

</div>

I Have been set AudioSession category 。 These days I find the problem。

the problem code is:  
result = system-\>init(32, FMOD\_INIT\_STREAM\_FROM\_UPDATE, &outputPath);  
ERRCHECK(result);

the outputPath is pointer,The right is ‘char path’ not pointer path。now it can output wav file。

---

<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:** [April 23, 2018, 1:55am UTC](https://qa.fmod.com/t/ios-have-a-problem-need-help/13820/5 "2018-04-23T01:55:48Z")

</div>

> [@](#):
>
> I Have been set AudioSession category 。 These days I find the problem。
> 
> the problem code is:  
> result = system-\>init(32, FMOD\_INIT\_STREAM\_FROM\_UPDATE, &outputPath);  
> ERRCHECK(result);
> 
> the outputPath is pointer,The right is ‘char path’ not pointer path。now it can output wav file。

Please refer to [http://www.fmod.org/questions/question/non-realtime-wav-writer/](http://www.fmod.org/questions/question/non-realtime-wav-writer/)
