Hello guys
I’m trying to add sound in my game, but I’m receiving this error:
Pls help me. What does it mean and how can I deal with it?
P.S.
All my sounds in .wav and under 44100
britzl
February 18, 2021, 9:44pm
2
Ok, let’s look at the code. The error comes from this line in comp_sound.cpp (the sound component):
return dmGameObject::PROPERTY_RESULT_NOT_FOUND;
}
Sound* sound = component->m_Resource;
uint32_t size = world->m_Entries.Size();
for (uint32_t i = 0; i < size; ++i)
{
PlayEntry& entry = world->m_Entries[i];
if (entry.m_SoundInstance != 0 && entry.m_Sound == sound && entry.m_Instance == instance)
{
float v = value;
switch(type) {
case dmSound::PARAMETER_GAIN: v *= entry.m_Sound->m_Gain; break;
case dmSound::PARAMETER_PAN: v += entry.m_Sound->m_Pan; break;
case dmSound::PARAMETER_SPEED: v *= entry.m_Sound->m_Speed; break;
default:
return dmGameObject::PROPERTY_RESULT_NOT_FOUND;
}
dmSound::Result r = dmSound::SetParameter(entry.m_SoundInstance, type, dmVMath::Vector4(v, 0, 0, 0));
if (r != dmSound::RESULT_OK)
The result/error codes are defined in sound.h:
};
enum Result
{
RESULT_OK = 0, //!< RESULT_OK
RESULT_PARTIAL_DATA = 1, //!< RESULT_PARTIAL_DATA
RESULT_OUT_OF_SOURCES = -1, //!< RESULT_OUT_OF_SOURCES
RESULT_EFFECT_NOT_FOUND = -2, //!< RESULT_EFFECT_NOT_FOUND
RESULT_OUT_OF_INSTANCES = -3, //!< RESULT_OUT_OF_INSTANCES
RESULT_RESOURCE_LEAK = -4, //!< RESULT_RESOURCE_LEAK
RESULT_OUT_OF_BUFFERS = -5, //!< RESULT_OUT_OF_BUFFERS
RESULT_INVALID_PROPERTY = -6, //!< RESULT_INVALID_PROPERTY
RESULT_UNKNOWN_SOUND_TYPE = -7, //!< RESULT_UNKNOWN_SOUND_TYPE
RESULT_INVALID_STREAM_DATA= -8, //!< RESULT_INVALID_STREAM_DATA
RESULT_OUT_OF_MEMORY = -9, //!< RESULT_OUT_OF_MEMORY
RESULT_UNSUPPORTED = -10, //!< RESULT_UNSUPPORTED
RESULT_DEVICE_NOT_FOUND = -11, //!< RESULT_DEVICE_NOT_FOUND
RESULT_OUT_OF_GROUPS = -12, //!< RESULT_OUT_OF_GROUPS
RESULT_NO_SUCH_GROUP = -13, //!< RESULT_NO_SUCH_GROUP
RESULT_NOTHING_TO_PLAY = -14, //!< RESULT_NOTHING_TO_PLAY
RESULT_INIT_ERROR = -15, //!< RESULT_INIT_ERROR
-8 is RESULT_INVALID_STREAM_DATA and it happens when trying to decode the sound:
This finally leads us to “Failed to decode sound (-2)” with the -2 being an error code of dmSoundCodec::Result
which we find here:
* Sound decoding support
*/
namespace dmSoundCodec
{
/// Codec context handle
typedef struct CodecContext* HCodecContext;
/// Decoder handle
typedef struct Decoder* HDecoder;
/**
* Result codes
*/
enum Result
{
RESULT_OK = 0, //!< RESULT_OK
RESULT_OUT_OF_RESOURCES = -1,//!< RESULT_OUT_OF_RESOURCES
RESULT_INVALID_FORMAT = -2, //!< RESULT_INVALID_FORMAT
RESULT_DECODE_ERROR = -3, //!< RESULT_DECODE_ERROR
RESULT_UNSUPPORTED = -4, //!< RESULT_UNSUPPORTED
RESULT_END_OF_STREAM = -5, //!< RESULT_END_OF_STREAM
RESULT_UNKNOWN_ERROR = -1000,//!< RESULT_UNKNOWN_ERROR
-2 is RESULT_INVALID_FORMAT so there is definitely something wrong with your sounds! Perhaps you can share one of the wav files here?
4 Likes
Oh sorry
For real, after decreasing my sounds to 44100hz went something wrong and they stoped playing…
Sorry again, i had to check it before posting the question
1 Like