5.4 C++ Play sound

#1
Hi! I have no idea how to do this. I was digging, but nothing.
Found this old topic https://www.cryengine.com/community_arc ... 4&t=116729
But sound system does not exist anymore. Only audio system, and it doesn't have PlaySound, but PlayFile, which I tried to use, but no effect.

Code: Select all

CryAudio::SPlayFileInfo info("Sounds/mySounds/mySound.ogg"); gEnv->pAudioSystem->PlayFile(info);
And yes. My file is valid, I just copied it from gameSDK, but it doesn't work at all. Any ideas?
Cryengine tutorial videos on my Youtube channel! Check it out !
https://www.youtube.com/user/MusicForLifePL20

Re: 5.4 C++ Play sound

#4
Maybe try to activate the audio system debugging with the CVar s_DrawAudioDebug. This should provide you with some basic information about he audio system. What does it say about the AudioTranslationLayer, are you really using SDL Mixer ? Where is your listener ? Do you see any events getting triggered by the audio system ?

Cheers,
Alex

Re: 5.4 C++ Play sound

#5
Ok I figured out. The reason was that I approached this topic completely wrong. I still keep forgetting about existance of components. Forgive me :) in the other topic you placed link to github repo with default components and suddenly i remembered about audio default component. Looked into that and based on it I created my own audio component that fits my needs :) I will share how to achieve that tomorrow and will edit this post . Thank you !
Cryengine tutorial videos on my Youtube channel! Check it out !
https://www.youtube.com/user/MusicForLifePL20

Re: 5.4 C++ Play sound

#7
Ok I figured out. The reason was that I approached this topic completely wrong. I still keep forgetting about existance of components. Forgive me :) in the other topic you placed link to github repo with default components and suddenly i remembered about audio default component. Looked into that and based on it I created my own audio component that fits my needs :) I will share how to achieve that tomorrow and will edit this post . Thank you !
Please share a small demonstrate code :) Thanks.
Small tips
How to add an image to a forum post
[C++] How to smoothly turn your character

Re: 5.4 C++ Play sound

#8
Any update or any other idea on that?

At the moment I just want to know how to play a sound when for example I press a button. Either define the sound from a file name or use a sound created in "Audio Controls Editor".
Tried to add a trigger component (I thought it works like in the sandbox) but no success. In the sandbox I can choose a sound in "PlayTrigger" field. Cannot find this in the component via c++.
Made a lot of tries but no result as well. I used the .ogg sound from the bullet, so file is ok.

Hope someone can give a hint to the right directions or a small solution.

Cheers
Charalampos :-)

Re: 5.4 C++ Play sound

#9
Hi,
Please clarify following things.
1. Which game project do you use? (custom, GameSDK, FP, TP and so on)
2. Which audio middleware do you use? (Fmod, SDL_mixer, Wwise)
3. Do you want to play the sound via code? (C++/C#)
4. Which exact "trigger component" are you referring to?

Re: 5.4 C++ Play sound

#10
Oh, at the moment I just want to play a sound when a press a button, either from a file or one created with the Audio Controls Editor. I thought I can use an engine function for that,

1. Last few times tried with the ISO template c++ (will the solution be different if I use the FP or TP template?!)
2. until yesterday I even really didn't know what a middleware is. But since I use the sound from the bullet the comes with the templates, it should be sdl_mixer. Have to look more on this topic, interesting!
3. Yes, I try this with c++
4. Cry::Audio::DefaultComponents::CTriggerComponent

Thanks for fast reply
Charalampos :-)

Who is online

Users browsing this forum: No registered users and 1 guest