# stuck on the simplest possible thing

**URL:** <https://qa.fmod.com/t/stuck-on-the-simplest-possible-thing/12145>\
**Category:** FMOD Engine\
**Created:** [November 10, 2015, 6:55pm UTC](https://qa.fmod.com/t/stuck-on-the-simplest-possible-thing/12145 "2015-11-10T18:55:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon18131903](https://avatars.discourse-cdn.com/v4/letter/a/e9c0ed/32.png) [@anon18131903](https://qa.fmod.com/u/anon18131903)\
**Post date:** [November 10, 2015, 6:55pm UTC](https://qa.fmod.com/t/stuck-on-the-simplest-possible-thing/12145/1 "2015-11-10T18:55:20Z")

</div>

I am stuck on something so simple…  
I can’t get playSound to work. I’m writing an OpenGl program, and have been generating sine tones(DSP’s) based on events with great success. Now I want to play an audio file (to eventually analyze the spectrum of), and the program runs but the audio file doesn’t play…

I’ve tried:  
**- creating and playing the sound in my main function,**  
…  
FMOD::Channel\* sChannel;  
FMOD::Sound\* sound;  
Asystem-\>createSound(“jaguar.mp3”, FMOD\_DEFAULT, 0, &sound);  
Asystem-\>playSound(sound, 0, false, &sChannel);

```
            //and waiting for user input
std::cout << "Press return to quit." << std::endl;
std::cin.get();

```

…

**- creating a Sound class, a newSound function, and unpausing the sound’s channel in my glut Display func (called once per frame)**

class Sound {  
FMOD::Channel \*soundchannel;  
FMOD::DSP \*sounddsp;  
FMOD::Sound \*sound;

public:

```
FMOD::Channel* getChannel() {
    return soundchannel;
}

Sound(FMOD::Channel* sc, FMOD::DSP* sdsp, FMOD::Sound* sound):
soundchannel(sc), sounddsp(sdsp), sound(sound)
{};

```

};

std::vector soundVec;

void newSound(){  
FMOD\_RESULT result;  
FMOD::Channel\* sChannel;  
FMOD::DSP\* sDSP;  
FMOD::Sound\* sound;

```
result = Asystem->createDSPByType(
                                  FMOD_DSP_TYPE_OSCILLATOR,
                                  &sDSP
                                  );

Asystem->createSound("jaguar.mp3", FMOD_DEFAULT, 0, &sound);

Asystem->playSound(sound, 0, false, &sChannel);
sChannel->setVolume(.8);
Sound newSound = Sound(sChannel, sDSP, sound);
soundVec.push_back(newSound);

```

}

display(){  
…  
for (int i = 0; i \< soundVec.size(); i++){  
FMOD::Channel\* cchannel = soundVec[i].getChannel();

```
    cchannel->setPaused(false);
}

```

…  
Asystem-\> update();  
}

**and have also, in fear that I wasn’t specifying the filepath of the audio file, copied the .wav file (taken from the fmod examples) into the sub folder containing my project as well as it’s parent folder**

I’ve had no success, and am seriously bummed out that I’m stuck on what’s probably the simplest possible thing to do with FMOD.

I know there are more interesting questions to answer, but any help would really be so appreciated.

Jake

---

<div class="post-metadata">

**Author:** ![brett](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/brett/32/261_2.png) [@brett](https://qa.fmod.com/u/brett)\
**Post date:** [November 10, 2015, 9:42pm UTC](https://qa.fmod.com/t/stuck-on-the-simplest-possible-thing/12145/2 "2015-11-10T21:42:11Z")

</div>

Is that code stripped down or are you not checking any return codes anywhere? They would probably tell you what’s wrong.

---

<div class="post-metadata">

**Author:** ![anon18131903](https://avatars.discourse-cdn.com/v4/letter/a/e9c0ed/32.png) [@anon18131903](https://qa.fmod.com/u/anon18131903)\
**Post date:** [November 10, 2015, 10:37pm UTC](https://qa.fmod.com/t/stuck-on-the-simplest-possible-thing/12145/3 "2015-11-10T22:37:07Z")

</div>

> [@](#):
>
> Is that code stripped down or are you not checking any return codes anywhere? They would probably tell you what’s wrong.

Thanks for your response… I haven’t been error checking.  
I just did, and yup I get

FMOD error! (18) File not found.  
Program ended with exit code: 255

Does this mean I haven’t specified the file path correctly? I’ve added the file to my xcode project, the project folder and its parent folder. I’m just calling

Asystem-\>createSound(“jaguar.wav”, FMOD\_DEFAULT, 0, &sound);

Thanks for identifying the problem… could you suggest a fix? I’d really appreciate it.

---

<div class="post-metadata">

**Author:** ![brett](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/brett/32/261_2.png) [@brett](https://qa.fmod.com/u/brett)\
**Post date:** [November 10, 2015, 10:43pm UTC](https://qa.fmod.com/t/stuck-on-the-simplest-possible-thing/12145/4 "2015-11-10T22:43:08Z")

</div>

yes, the problem is probably that you haven’t got the path right. its the same as if fopen() returned a failure not being able to find your file.

---

<div class="post-metadata">

**Author:** ![anon18131903](https://avatars.discourse-cdn.com/v4/letter/a/e9c0ed/32.png) [@anon18131903](https://qa.fmod.com/u/anon18131903)\
**Post date:** [November 10, 2015, 11:02pm UTC](https://qa.fmod.com/t/stuck-on-the-simplest-possible-thing/12145/5 "2015-11-10T23:02:17Z")

</div>

it’s working. thanks so much for taking the time.
