• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

SOLVED External .ogg audio file not playing

Sn4pi

Member
Hey guys!
I guess this is the first time, I don't know what to do and am so desperate to ask other people what I'm doing wrong.


So the idea:
I want to load music from my computer, get it into my project and play the audio

To do so, I use the nsfs extension of yellow afterlife so I don't have any problems with the Sandbox system of GM.
With the help of the extension, I easily find the music folder, copy the folder into the working_directory and use audio_create_stream() to create a stream of the audio file.

After that I try playing it with audio_play_sound() but nothing happens and the console says: (0): ov_open error -132
I already used a bunch of debug messages to help me and it seems that everything works fine up to the point where it tries to play the sound. Of course I googled the error - which is not fatal btw - and found out that it has to do with .ogg in some way, though I don't understand the issue :confused:

Much help is appreciated!
 

Sn4pi

Member
Ofc here's the code so you can comfortably analyze my problem:

GML:
/// @description Take audio file and play it
var musicPath = "C:/Users/Danilo/Music";
if directory_exists_ns(musicPath) {
    directory_copy_ns(musicPath, working_directory + "/Music");
    musicPath = working_directory + "/Music";
    var file = file_find_first_ns(musicPath + "/*.ogg");
    if (file != "") {
        if (activeSong != -1) audio_destroy_stream(activeSong);        //Destroy old stream for more space
        else show_debug_message("This is your first audio stream!");
        
        show_debug_message(file);        //Only shows the title of the song (e.g. "Aloha.ogg")
        activeSong = audio_create_stream(musicPath + "/" + file);
        show_debug_message(string(activeSong));
    }
    
    else show_debug_message("Directory is empty");
}

else show_debug_message("Directory doesn't exist");


//Play audio
if (activeSong != -1 && !audio_is_playing(activeSong)) {
    show_debug_message("Audio exists");
    audio_play_sound(activeSong, 0, false);
    show_debug_message("Playing Audio");
    audio_sound_gain(activeSong, 0.1, 1000);
}

And here's the stuff of the console:
This is your first audio stream!
How_Do_I_Let_Go.ogg
create stream 300000
300000
Audio exists
Playing Audio
(0): ov_open error -132
 

TailBit

Member
it is the audio gain that you feed the wrong thing..


GML:
    var snd = audio_play_sound(activeSong, 0, false);
    show_debug_message("Playing Audio");
    audio_sound_gain(snd, 0.1, 1000);
 

TailBit

Member
So if you load the music the sandbox way, you don't get any error?


Code:
Return Values
- 0 for success

- less than zero for failure:
OV_EREAD - A read from media returned an error.
OV_ENOTVORBIS - Bitstream does not contain any Vorbis data.
OV_EVERSION - Vorbis version mismatch.
OV_EBADHEADER - Invalid Vorbis bitstream header.
OV_EFAULT - Internal logic fault; indicates a bug or heap/stack corruption.
So, there is a few possible errors it could be:

.. the first and last doesn't sound like something you can control, but if you can load it the normal way using the sandbox, then it might be the extension?

.. the other 3 is just problem with reading the file, try some other files .. do some of them work? If so then try edit and re-save the file?

But yeah, wasn't easy to find much on that one :/
 

Sn4pi

Member
I don't think it has to do with the extension but I'll try other audio files to check. Thanks for the reply though!
 

Sn4pi

Member
Okay it seems like the formation of my .ogg file just wasn't right. I converted it with a higher bitrate and it works perfectly now!


So in this case the ISSUE is the .ogg file itself having a wrong format/kbps etc. so you have to convert it again.
 
Top