Quote Originally Posted by DarknessX
The open_audio doesn't work with his method though... Open audio uses obtained.blah and and desired.blah which does not work in non-oop, while I was under the impression his example was non-oop.

EDIT: nevermind. I was thinking sdl_openaudio Now it works, sort of.

And, .mp3 files don't work The original SDL supported MP3's too... Is there anything specific I need to change to make it work with MP3's?
it only supports mp3 (and ogg format) if you use smpeg and Mixer_LoadMUS(), etc. instead of Mixer_LoadWAV().

like this:

Code:
Var
    bAudioOpen : Boolean;
    music      : PMix_Music;
Initialization
Code:
    bAudioOpen := False;
    Log('Initializing...');
    If SDL_Init&#40;SDL_INIT_AUDIO Or SDL_INIT_VIDEO Or SDL_INIT_JOYSTICK&#41; < 0 Then
    Begin
        Log&#40;'Could not initialize SDL'&#41;;
        Exit;
    End
I open the audio
Code:
        audio_rate     &#58;= 22050;//MIX_DEFAULT_FREQUENCY;
        audio_format   &#58;= AUDIO_S16SYS;
        audio_channels &#58;= MIX_DEFAULT_CHANNELS;
        audio_buffers  &#58;= 4096;
        // Open the audio device
        Log&#40;'Opening audio...'&#41;;
        If Mix_OpenAudio&#40;audio_rate, audio_format, audio_channels, audio_buffers&#41; < 0 Then
        Begin
            Log&#40;Format&#40;'Could not open audio&#58; %s', &#91;SDL_GetError&#93;&#41;&#41;;
            Exit;
        End

I then play the music if that went ok:
Code:
Procedure PlayMusic&#40;AFileName&#58; AnsiString; loops&#58; Integer&#41;;
Begin
    Log&#40;'Loading music...'&#41;;
    music &#58;= Mix_LoadMUS&#40;PChar&#40;AFileName&#41;&#41;;
    If &#40;music = Nil&#41; Then
    Begin
        Log&#40;Format&#40;'Could not load "%s"&#58; %s', &#91;AFileName, SDL_GetError&#40;&#41;&#93;&#41;&#41;;
        Exit;
    End;
    Log&#40;'Music loaded'&#41;;
    If loops <> -1 Then
    Begin
        Log&#40;Format&#40;'Playing&#58; "%s"&#40; looping &#41;',&#91;AFileName&#93;&#41;&#41;;
    End
    Else
        Log&#40;Format&#40;'Playing&#58; "%s"&#40; not looping &#41; ',&#91;AFileName&#93;&#41;&#41;;
    Mix_PlayMusic&#40;music, loops&#41;;
    Log&#40;'Playing'&#41;;
End;

After everything is finished I cleanup
Code:
Procedure Cleanup;
Begin
    If music <> Nil Then
    Begin
        Log&#40;'Freeing music...'&#41;;
        Mix_FreeMusic&#40;music&#41;;
        Log&#40;'Music freed'&#41;;
        music &#58;= Nil;
    End;
    If bAudioOpen Then
    Begin
        bAudioOpen &#58;= False;
        Log&#40;'Closing audio...'&#41;;
        Mix_CloseAudio;
        Log&#40;'Audio closed'&#41;;
    End;
    SDL_Quit;
End;
My complete example program (ignore gp2x bits) that works on windows.

Code:
Program gp2x_sdl_mixer;
&#123;$IFDEF fpc&#125;
&#123;$MODE Delphi&#125; &#123;$H+&#125;
&#123;$ENDIF&#125;

Uses
    sdl_mixer,
    sdl,
    SysUtils;

Var
    bAudioOpen &#58; Boolean;
    music      &#58; PMix_Music;
    screen     &#58; PSDL_Surface;

&#123;..............................................................................&#125;

&#123;..............................................................................&#125;
Procedure Log&#40;AString&#58; AnsiString&#41;;
Var
    FileName &#58; AnsiString;
    LogFile  &#58; Text;
Begin
    FileName &#58;= ExtractFilePath&#40;ParamStr&#40;0&#41;&#41; + 'LogFile.txt';
    AssignFile&#40;LogFile,FileName&#41;;
    If FileExists&#40;FileName&#41; Then
        Append&#40;LogFile&#41;
    Else
        Rewrite&#40;LogFile&#41;;
    WriteLn&#40;LogFile,AString&#41;;
    Flush&#40;LogFile&#41;;
    CloseFile&#40;LogFile&#41;;
End;
&#123;..............................................................................&#125;

&#123;..............................................................................&#125;
Function  Initialize&#58; Boolean;
Var
    audio_rate     &#58; integer;
    audio_format   &#58; Uint16;
    audio_channels &#58; integer;
    audio_buffers  &#58; integer;
Begin
    Result &#58;= False;
    bAudioOpen &#58;= False;
    Log&#40;'Initializing...'&#41;;
    If SDL_Init&#40;SDL_INIT_AUDIO Or SDL_INIT_VIDEO Or SDL_INIT_JOYSTICK&#41; < 0 Then
    Begin
        Log&#40;'Could not initialize SDL'&#41;;
        Exit;
    End
    Else
    Begin
        screen &#58;= SDL_SetVideoMode&#40;320,240,16,SDL_SWSURFACE&#41;;
        If screen = Nil Then
        Begin
            Log&#40;Format&#40;'Could not create window&#58; %s',&#91;SDL_GetError&#93;&#41;&#41;;
            Exit;
        End;
        Log&#40;'Window created'&#41;;
        SDL_ShowCursor&#40;0&#41;;
        audio_rate     &#58;= 22050;//MIX_DEFAULT_FREQUENCY;
        audio_format   &#58;= AUDIO_S16SYS;
        audio_channels &#58;= MIX_DEFAULT_CHANNELS;
&#123;$IFDEF gp2x&#125;
        audio_buffers  &#58;= 512;
&#123;$ELSE&#125;
        audio_buffers  &#58;= 4096;
&#123;$ENDIF&#125;
        // Open the audio device
        Log&#40;'Opening audio...'&#41;;
        If Mix_OpenAudio&#40;audio_rate, audio_format, audio_channels, audio_buffers&#41; <0> 1&#41; Then
                Log&#40;Format&#40;'Opened audio at %d Hz %d bit %s', &#91;audio_rate,
                        &#40;audio_format and $FF&#41;, 'stereo'&#93;&#41;&#41;
            Else
                Log&#40;Format&#40;'Opened audio at %d Hz %d bit %s', &#91;audio_rate,
                        &#40;audio_format and $FF&#41;, 'mono'&#93;&#41;&#41;;
        End;
    End;
    Result &#58;= True;
    bAudioOpen &#58;= True;
    Log&#40;'Initialized'&#41;;
End;
&#123;..............................................................................&#125;

&#123;..............................................................................&#125;
Procedure PlayMusic&#40;AFileName&#58; AnsiString; loops&#58; Integer&#41;;
Begin
    Log&#40;'Loading music...'&#41;;
    music &#58;= Mix_LoadMUS&#40;PChar&#40;AFileName&#41;&#41;;
    If &#40;music = Nil&#41; Then
    Begin
        Log&#40;Format&#40;'Could not load "%s"&#58; %s', &#91;AFileName, SDL_GetError&#40;&#41;&#93;&#41;&#41;;
        Exit;
    End;
    Log&#40;'Music loaded'&#41;;
    If loops <> -1 Then
    Begin
        Log&#40;Format&#40;'Playing&#58; "%s"&#40; looping &#41;',&#91;AFileName&#93;&#41;&#41;;
    End
    Else
        Log&#40;Format&#40;'Playing&#58; "%s"&#40; not looping &#41; ',&#91;AFileName&#93;&#41;&#41;;
    Mix_PlayMusic&#40;music, loops&#41;;
    Log&#40;'Playing'&#41;;
End;
&#123;..............................................................................&#125;

&#123;..............................................................................&#125;
Procedure Cleanup;
Begin
    If music <> Nil Then
    Begin
        Log&#40;'Freeing music...'&#41;;
        Mix_FreeMusic&#40;music&#41;;
        Log&#40;'Music freed'&#41;;
        music &#58;= Nil;
    End;
    If bAudioOpen Then
    Begin
        bAudioOpen &#58;= False;
        Log&#40;'Closing audio...'&#41;;
        Mix_CloseAudio;
        Log&#40;'Audio closed'&#41;;
    End;
&#123;$IFNDEF gp2x&#125;
    SDL_Quit;
&#123;$ELSE&#125;
    chdir         &#40;'/usr/gp2x'&#41;;
    ExecuteProcess&#40;'/usr/gp2x/gp2xmenu',&#91;'/usr/gp2x/gp2xmenu'&#93;&#41;;
&#123;$ENDIF&#125;
End;
&#123;..............................................................................&#125;

&#123;..............................................................................&#125;
Procedure WaitForKeyUp&#40;AKey&#58; Uint32&#41;;
Var
    event &#58; TSDL_Event;
    done  &#58; Boolean;
Begin
    done &#58;= False;

    While Not done Do
    Begin
        SDL_Delay&#40;1&#41;;
        While SDL_PollEvent&#40;@event&#41; = 1 Do
        Begin
            If event.type_ = SDL_KEYUP Then
                If event.key.keysym.sym = AKey Then done &#58;= True;
        End;
    End;
End;
&#123;..............................................................................&#125;

&#123;..............................................................................&#125;
Procedure WaitForJoystickButtonUp&#40;AButton&#58; Uint32&#41;;
Var
    event &#58; TSDL_Event;
    done  &#58; Boolean;
Begin
    done &#58;= False;

    While Not done Do
    Begin
        SDL_Delay&#40;1&#41;;
        While SDL_PollEvent&#40;@event&#41; = 1 Do
        Begin
            If event.type_ = SDL_JOYBUTTONUP Then
                If event.jbutton.button = AButton Then done &#58;= True;
        End;
    End;
End;
&#123;..............................................................................&#125;

&#123;..............................................................................&#125;
Begin
    Try
        DeleteFile&#40;ExtractFilePath&#40;ParamStr&#40;0&#41;&#41; + 'LogFile.txt'&#41;;
        If Initialize Then
        Begin
            PlayMusic&#40;ExtractFilePath&#40;ParamStr&#40;0&#41;&#41; + 'Pet Shop Boys - 02 - West End Girls.mp3',0&#41;;
&#123;$IFNDEF gp2x&#125;
            WaitForKeyUp&#40;SDLK_Escape&#41;;
&#123;$ELSE&#125;
            WaitForJoystickButtonUp&#40;SDLK_GP2X_START&#41;;
&#123;$ENDIF&#125;
        End
        Else
            Log&#40;'Initializing failed.'&#41;;
    Except
        On E&#58;Exception Do Log&#40;E.Message&#41;;
    End;
    Log&#40;'closing...'&#41;;
    Cleanup;
End.
I hope this helps
cheers,
Paul.