#Sound Issue in MacOS

63 messages · Page 1 of 1 (latest)

vivid crest
#

Hi, thanks for your time on this post.

I am new to raylib, and I am unable to hear sound when I run the Unix Executable File. I tried to run the same script on my windows machine, I can hear sound on that machine

I am using a M2 clip macbook with MacOS 14.0.

This is the code

#include <raylib.h>

using namespace std;

int main()
{
    const int screenWidth = 800;
    const int screenHeight = 600;

    InitWindow(screenWidth, screenHeight, "My first RAYLIB program!");
    SetTargetFPS(60);
    InitAudioDevice();

    Sound sound = LoadSound("eating-sound.mp3");
    SetSoundVolume(sound, 1.0f);
    PlaySound(sound);

    while (WindowShouldClose() == false)
    {
        BeginDrawing();
        ClearBackground(BLACK);

        EndDrawing();
    }

    UnloadSound(sound);
    CloseAudioDevice();

    CloseWindow();
    return 0;
}```

I have attached the log I got when I run ```./main```

The file seems to loaded successfully, yet nothing can be heard.

I have also tried to run the audio example on my local machine https://www.raylib.com/examples/audio/loader.html?name=audio_sound_loading. I also cannot hear anything (I have downloaded the audio files to my local as well).

Thank you so much for your help!
languid wasp
#

did you build raylib from source or use a package?

vivid crest
#

@languid wasp Let's continue our discussion here, so that other facing similar issue can be benefit from it🤝 .

I install raylib via homebrew and you suggest me to build it myself

languid wasp
#

yeah, packages suck

#

building raylib is trivial

#

get the sources and just run make in the src folder

#

then it'll actually build for your system

vivid crest
#

These are your suggestions, let me forward it here for other's reference

#

Got it, let me try now and let you know the result. Thank you so much!!👏

#

I am just build the raylib from source. I am now trying to compile the project. But I do not know where the library is.

g++ -std=c++11 -o main main.cpp -l raylib -I/Users/leonchan/WorkSpace/raylib/src -L'PATH/TO/RAYLIBLIBRARY'

Could you please help? @languid wasp

languid wasp
#

you have to compile raylib first

#

cd to the src dir

#

and just run make

vivid crest
#

I have compiled it

languid wasp
#

that will build the lib

#

so do you have a .a file in the src folder?

vivid crest
#

yes, I have a libraylib.a in src folder now

languid wasp
#

yeah, that's the lib

#

also it's -lraylib (no space)

vivid crest
#

So should the whole command be g++ -std=c++11 -o main main.cpp -lraylib -I/Users/leonchan/WorkSpace/raylib/src -L/Users/leonchan/WorkSpace/raylib/src ?

languid wasp
#

well you need more than that

#

did you read over the wiki page for MacOS?

#

you also need some frameworks
-framework CoreVideo -framework IOKit -framework Cocoa -framework GLUT -framework OpenGL

vivid crest
languid wasp
#

yes

#

there is a section near the bottom about building yourself

#

your game needs more than just raylib

#

it needs opengl and iokit and stuff

#

though i don't think you need GLUT actually

vivid crest
#

I have followed the steps and encountered such issue

main.cpp:2:10: fatal error: 'raylib.h' file not found
#include <raylib.h>
         ^~~~~~~~~~```

I have already copied libraylib.a to the project root folder what am I missing?
languid wasp
#

no, you still need all the stuff from your other command line

#

it needs to know the include dir

#

and where the lib

#

do you have much experience building with C or C++?

#

just add the frameworks to your old command line

#
g++ -std=c++11 -o main main.cpp -lraylib -I/Users/leonchan/WorkSpace/raylib/src -L/Users/leonchan/WorkSpace/raylib/src -framework CoreVideo -framework IOKit -framework Cocoa -framework OpenGL
#

that should work

#

I think

vivid crest
#

Thanks! I am able to run it now. Yet I still cannot hear the sound

languid wasp
#

I don't use a mac

#

did you get rid of your homebrew version?

vivid crest
#

yes I did

languid wasp
#

then I dunno

#

Apple is a strange platform

#

but I know people are using raylib on it

#

it's less of 'raylib has good support for mac' and more about how much the mac supports the things raylib uses.

#

there is not a lot of apple specific code in raylib

#

all the real heavy lifing is done by GLFW, OpenGL, and MiniAudio

#

OpenGL is deprecated by apple, so they won't ever be fixing any of the many OpenGL bugs that exist in apple drivers

#

as for audio, who knows. they may change an API and that could break things

#

other people may have more info, usually building your own lib works

#

Apple really wants games to use Metal and other platform specific APIs, not cross platform things

vivid crest
#

Got it🤝 Thank you so much for your help!

#

it is more of a operating system problem instead of hardware level problem right? Coz I am considering if I should use parallel desktop to continue on windows or install linux

languid wasp
#

Yeah I doubt it’s hardware

#

It should work

#

And I know it works for several macOS users

vivid crest
#

Update: I managed to play sound on apple silicon mac device!

But what I am trying to do is to use the raylib C# binding instead of the original c++ one.

languid wasp
#

that just means it's using a dynamic library

vivid crest
#

@fringe minnow I use c# binding for raylib. Yet I discovered another problem with it: I cannot load texture from image. I tried to set breakpoint and went through the script line by line. The program terminal without any error once it hit the line that try to load texture from image. Do you still want to know how to set up a C# with raylib?

fringe minnow
languid wasp
#

if the C# bindings work then that would mean the C ones would work with a dynamic library link