Results 1 to 10 of 27

Thread: Win/Linux/Mac OSX Sound API with no .DLL/.SO dependencies?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    If you convert the .mp3 to .ogg then I think more 3rd party sound libraries will be able to play the music. Also, .mp3 theoretically requires a license before you can play those

    cheers,
    Paul

  2. #2
    Problem is the app needs to be able to play MP3s because the user has to be able to use their own songs etc. I was hoping to use BASS but the delphi header requires windows.

    I found this which gave me hope

    ----
    Fairly straightforward in Objective Pascal using the ObjC AVAudioPlayer class:

    http://developer.apple.com/library/i.../AVAudioPlayer

    Here's example code:

    var
    snd : AVAudioPlayer;
    {Since sound is played asynchronously, can't release (or autorelease)
    until after sound is done playing, so declare and release somewhere
    outside PlaySound. Call snd.release to release.}

    procedure PlaySound(sndFileName : NSString);
    var
    path : NSString;
    url : NSURL;
    err : NSError;
    begin
    path := NSBundle.mainBundle.resourcePath.
    stringByAppendingPathComponent(sndFileName);

    url := NSURL.fileURLWithPath(path);

    snd := AVAudioPlayer.alloc.initWithContentsOfURL_error(ur l, @err);
    if Assigned(snd) then
    snd.play
    else
    NSLog(NSSTR('Error'));
    end;
    Call it like this:

    PlaySound(NSSTR('Cartoon Boing.mp3'));

    This file is included with iMovie. Just add your audio file(s) to your Xcode project and they'll be copied to your app bundle when you build the app.

    Now, the only thing you'll need is Pascal units for the parsed Foundation and AVFoundation frameworks. Check with Embarc for that.

    Thanks.

    -Phil

    -----

    However, use of the word straightforward was not as straightforward for me. I cannot find a pas file to add to uses that gives me access to the AVAudioPlayer
    The views expressed on this programme are bloody good ones. - Fred Dagg

  3. #3
    Actually he has just replied but I am still in the dark - I will have to read his parsing text and see I get any headway

    ==============
    You'll somehow have to parse the iOS AVFoundation framework on your Mac in order to get access to the Objective C AVAudioPlayer class that you can use in Pascal as in the example code.

    Note that you don't need the entire class, just the methods you need. See this explanation for how to "parse" those methods by hand for now until an updated parser is available:

    https://forums.embarcadero.com/threa...427&tstart=375

    Thanks.

    -Phil
    ===========

    I might have to put it into the too hard basket for a few weeks and come back to it
    The views expressed on this programme are bloody good ones. - Fred Dagg

  4. #4
    I had a weird idea one day, putting Delphis TMediaPlayer in a dll so it could be used with Lazarus for musics... That component never failed me with MP3's. Other than that i used to have OpenAL ogg player for Delphi but i haven't managed to get that working with Lazarus.

  5. #5
    I use OpenAL with FPC. No problems, except that Apple's OpenAL implementation seems less that satisfactory. I have seen reports of rather severe bugs.

  6. #6
    Thanks for the info Ingemar
    I don't know if I will be able to port my game to Mac OS X any time soon - I don't have any Mac hardware, and haven't been able to get OS X working in a virtual machine to test either

    That will have to wait for some future time

    On the upside, I have gotten it to work on Windows and now Linux (Ubuntu), Yay! This is thanks to me using SDL, OpenGL, and OpenAL

    cheers,
    Paul

  7. #7
    Didn't I hear someone mentioning that the problems with playing sounds in SDL was fixed? Maybe wishful thinking but there was a thread about sound libraries in the Mac game programming mailing list.

    I really don't want to use Core Audio. It is yet another platform dependent library, and a messy one for that matter.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •