Page 1 of 3 123 LastLast
Results 1 to 10 of 30

Thread: JEDI-SDL Audio

  1. #1

    JEDI-SDL Audio

    Hey, well, I just setup Free Pascal (pure, not lazarus, etc) to work with Jedi-SDL. It's working fine, compiles, can initiate and exit Jedi-SDL's audio using:
    Code:
    Program testsdl;
    
    uses sdl;
    
    begin
    sdl_init(SDL_INIT_AUDIO);
    
    sdl_quit;
    end.
    But I don't know how to load an audio file, then play/pause/stop it. Any help? Some example code, without using graphical windows? I'm going to be doing all my code via text-based, so all the 'forms' and such don't help me

    Also, I can't find the demo programs... I'm using the v1 beta, and I've looked (AFAIK) everywhere.
    --MagicRPG--

  2. #2

    JEDI-SDL Audio

    Go to here http://jedi-sdl.cvs.sourceforge.net/...Demos/WavTest/

    and you will find a SDL_Mixer demo...is this what you were looking for?

    cheers,
    Paul.
    Games:
    Seafox


    Pages:
    Syntax Error Software itch.io page

    Online Chess
    http://gameknot.com/#paul_nicholls

  3. #3

    JEDI-SDL Audio

    You may also want to check out this thread

    which discusses an sdl_mixer audio manager class I wrote a while a go.
    <br /><br />There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.<br />-= Paulo Coelho =-

  4. #4

    JEDI-SDL Audio

    I believe thats what I was looking for, paul_nicholls. But I need it to play mp3's too
    --MagicRPG--

  5. #5

    JEDI-SDL Audio

    SDL Mixer plays MP3 and OGG Vorbis among others, you just need to make sure you have the correct dlls and units referenced. smpeg I think.

    The JEDI-SDL examples in the JEDI-SDL folder will help a lot.

    I got a lot of info for using SDL from the book Programming Linux Games by NoStarch press..http://www.nostarch.com/frameset.php?startat=plg

    But there's nothing in there you can't glean from the SDL documentation on the libSDL site. http://www.libsdl.org/cgi/docwiki.cgi/SDL_5fmixer

    OK, so it's all in C but it's easy to read.

  6. #6
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25

    JEDI-SDL Audio

    [size=9px]Sorry, I know this is only slightly relevant, but because it was brought up. Even the C examples for things like SDL, OpenGL, etc are super useful because the function names are the same and the values that you pump into them are the same.[/size]

    The SDL Audio mixer is pretty decent for cross platform. I don't know of any other way to get the same kind of audio on all 3 major OSes, except for OpenAL. [size=9px](which isn't too bad/hard either tbh)[/size]

    One thing to note however the SDL_Mixer does not playback at 44100 Hz on Windows very well. For whatever reason. :scratch: On Linux it's perfectly fine, but for Windows it just gives you a really distorted output. You best bet for Win32/64 would be to playback at 22050 Hz instead.

    Oh and before I forget, do look for the included documentation with the latest release. It should have full listing of all the functions you'd need.
    Jason McMillen
    Pascal Game Development
    Co-Founder





  7. #7

    JEDI-SDL Audio

    I couldn't find the examples in the Jedi-SDL folder... I looked. Nothing there

    I don't know C, and can't understand enough to be able to figure out the values.
    --MagicRPG--

  8. #8
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25

    JEDI-SDL Audio

    I've recently done a major reconstruction of the new JEDI-SDL site. You can find online documentation there.

    EDIT: Sorry forgot to post the link in case you don't know it: jedi-sdl.pascalgamedevelopment.com
    Jason McMillen
    Pascal Game Development
    Co-Founder





  9. #9

    JEDI-SDL Audio

    Well, I'm overly confused. I have no clue how to initialize and play audio. I've been going through examples, code, tutorials, everything I can find, and I'm lost
    --MagicRPG--

  10. #10
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25

    JEDI-SDL Audio

    You're looking for a Demo in the JEDI-SDL 1.0 BETA release. it's located under the path JEDI-SDLv1.0\SDL_Mixer\Demos\WavTest There, albeit sort of hidden.

    [size=9px]Psst... Dom, you you need someone to make FPC/Lazarus demos for ya? These are kind of useless to a non-Delphi guy. [/size]


    --- Please note that this demo is not very straightforward and could probably be vastly improved. ---


    Since you are not using Delphi (or Kylix) you will not be able to just run and test it. So open up the Main.pas file and you'll see all the code you'll need.

    Considering that this code is pretty poor to make reference to I'll just cut out all the junk and post what you'll need from it. But don't let that stop you from actually going to check out the demo it's self!

    Don't forget to add the DLLs to the game folder!

    [pascal]uses
    sdl,
    sdl_mixer;

    // initialization
    var
    audio_rate: integer;
    audio_format: Uint16;
    audio_channels: integer;
    audio_buffers : integer;
    loops: integer;

    loops := 0;
    if ((SDL_Init(SDL_INIT_AUDIO) < 0)) then
    begin
    // Could not initialize SDL Audio
    SDL_Quit;
    exit;
    end
    else
    begin
    audio_rate := StrToInt(seAudioRate.Text);
    audio_format := StrToInt(seAudioFormat.Text);
    audio_channels := StrToInt(seAudioChannels.Text);
    audio_buffers := StrToInt(seAudioBuffers.Text);
    // Open the audio device
    if ( Mix_OpenAudio( audio_rate, audio_format, audio_channels, audio_buffers ) <0> 1) then
    // Memo.Lines.Add(Format('Opened audio at %d Hz %d bit %s', [audio_rate, (audio_format and $FF), 'stereo']))
    else
    // Memo.Lines.Add(Format('Opened audio at %d Hz %d bit %s', [audio_rate, (audio_format and $FF), 'mono']));


    // Load the requested wave file * /
    wave := Mix_LoadWAV(PChar(Edit1.Text)); // Edit1.Text is the WAV file path string
    if (wave = nil) then
    exit;

    // Play and then exit * /
    Mix_PlayChannel(0, wave, loops);
    while ( Mix_Playing(0) = 0 ) do
    SDL_Delay(100);
    end;

    // now we closing everything

    if ( wave <> nil ) then
    begin
    Mix_FreeChunk(wave);
    wave := nil;
    end;
    if ( bAudioOpen ) then // bAudioOpen is just some flag that was used to keep track if the audio device was opened.
    begin
    Mix_CloseAudio;
    end;
    SDL_Quit;

    // Done![/pascal]

    If you want more in depth information about all the other functions: Read
    Jason McMillen
    Pascal Game Development
    Co-Founder





Page 1 of 3 123 LastLast

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
  •