How can I play sound files programmatically? [Solved]

Yes, you did it! :smiley:
The problem was not the pointer, but for not use a pointer in the SoundManager variable, when I do:

SoundManager sound_manager = game->GetSoundManager()

It creates a copy of the sound manager in the memory. But surely other code of GD, to update the sound manager and so, uses a pointer, the pointer to the original sound manager pointing to another memory block different than my variable. In other words, this sound_manager variable is useless.
To fix it, just save the pointer instead a copy:

SoundManager* sound_manager = &(game->GetSoundManager())

I hope I’m not saying a lot of trash, as I’m not a C++ developer, I’m just “learning” it for curiosity :stuck_out_tongue:

And instead:

sound_manager.PlaySoundOnChannel()

You have to do:

sound_manager->PlaySoundOnChannel()    // because sound_manager is a pointer

Makes my example to work, thanks