Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Free Pascal Non-OOP sound

  1. #1

    Free Pascal Non-OOP sound

    Well, I've been trying BASS, and FMOD, but I couldn't make either work (due to my lack of knowledge). Is there a sound system designed SPECIFICALLY for FPC or atleast non-OOP pascal? FMOD would probably work; but the problem lies that the help file shows how to initialize and use only for C/C++ (AFAIK).

    So, is there a sound system for FPC thats non-oop? I need to do one thing:
    Play .mp3 files from a specific directory, no matter the length/size.

    I really don't need much more functionality than that.
    --MagicRPG--

  2. #2

    Free Pascal Non-OOP sound

    openal is not oop, look in my sig - a wrapper for openal which still stays non-oop.
    This is my game project - Top Down City:
    http://www.pascalgamedevelopment.com...y-Topic-Reboot

    My OpenAL audio wrapper with Intelligent Source Manager to use unlimited:
    http://www.pascalgamedevelopment.com...source+manager

  3. #3

    Free Pascal Non-OOP sound

    Is there help files available anywhere? If not, I need either an alternative or else instructions on how to use it.
    --MagicRPG--

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

    Free Pascal Non-OOP sound

    You can try Noeska's OpenAL site. He has his own set of headers, but he also has a bunch of Tutorials as well.

    http://www.noeska.com/doal/
    Jason McMillen
    Pascal Game Development
    Co-Founder





  5. #5

    Free Pascal Non-OOP sound

    Well, on an inspection of OpenAL, it is either oop, or delphi. Either way, I don't understand it. My program doesn't have graphics to have a 'form' or 'button', which the OpenAL tutorials have in them. I can compile fine, but the program does not run. (I simply put it in a new procedure and changed the .wav file.) When called, it just simply doesn't do anything. I had a repeat-until going, so it should of worked, or at the minimum play the sound atleast once. But it didn't... So... I'm confused.

    Edit: 2D sound works too... All I'm using it for (for now) is playing sounds.

    Edit: Or maybe I need to learn classes?
    --MagicRPG--

  6. #6

    Free Pascal Non-OOP sound

    my little openal wrapper is pretty easy to figure out, it's pretty trivial - you load wav files with it and playback them as sources. it comes with an example too.
    This is my game project - Top Down City:
    http://www.pascalgamedevelopment.com...y-Topic-Reboot

    My OpenAL audio wrapper with Intelligent Source Manager to use unlimited:
    http://www.pascalgamedevelopment.com...source+manager

  7. #7

    Free Pascal Non-OOP sound

    I can't compile it though... I'm not using Lazarus or Delphi.. Just plain old FPC. And FPC doesn't have the units for forms, dialogs, buttons, etc...

    Plus I have no clue what implementation is, so that doesn't help. None of the example is commented, either. Maybe if you could comment it for me?
    --MagicRPG--

  8. #8

    Free Pascal Non-OOP sound

    http://www.pascalgamedevelopment.com...?p=33161#33161

    The main thing is only in AL_Lib.pas and VirtualOpenAL.pas, and those VCL units used are easily replaced by whatever you use in FPC.
    This is my game project - Top Down City:
    http://www.pascalgamedevelopment.com...y-Topic-Reboot

    My OpenAL audio wrapper with Intelligent Source Manager to use unlimited:
    http://www.pascalgamedevelopment.com...source+manager

  9. #9

    Free Pascal Non-OOP sound

    Just curious.

    What is your os.

    Do you have the openal runtime installed.

    Are you using fpc or delphi.

    The examples on my site are for delphi, but should also work with fpc. Just leave out the forms stuff.

    E.g. i have had an working example with fpc under linux and openal.

    Take a look at: http://www.noeska.com/doal/lesson13.aspx this has an fpc example project. It should provide info on your soundcard.


    Code:
    program fpcopenaldemo;
    
    //compile with fpc -Sd fpcopenaldemo.pas
    
    uses openal;
    
    var
      buffer : TALuint;
      source : TALuint;
      sourcepos: array [0..2] of TALfloat= ( 0.0, 0.0, 0.0 );
      sourcevel: array [0..2] of TALfloat= ( 0.0, 0.0, 0.0 );
      listenerpos: array [0..2] of TALfloat= ( 0.0, 0.0, 0.0);
      listenervel: array [0..2] of TALfloat= ( 0.0, 0.0, 0.0);
      listenerori: array [0..5] of TALfloat= ( 0.0, 0.0, -1.0, 0.0, 1.0, 0.0);
      Context: PALCcontext;
      Device: PALCdevice;
    
      data : Array[0..1000] OF Byte;
      loop : Integer;
    
    begin
      writeln('hello world!');
    
      //init openal library under windows you should use InitOpenAL()
      if InitOpenAL('libopenal.so') then
        writeln('OpenAl lib found')
      else
        begin
          writeln('Oops OpenAL not found')
          //halt;
        end;
    
      //Open (selected) device
      Device := alcOpenDevice(nil); // this is supposed to select the "preferred device"
    
      writeln('Open Device');
    
      //Create context(s)
      Context := alcCreateContext(Device,nil);
    
      //Set active context
      alcMakeContextCurrent(Context);
    
      //Clear Error Code
      //alGetError();
    
      writeln('init done');
    
      //Create Buffers
      AlGenBuffers(1, @buffer);
      For Loop:=0 to 1000 do
        data[loop] := Round(50*sin(loop*(5*pi)/50.0)+128);
      alBufferData(buffer, AL_FORMAT_MONO8, @data, 1001, 11024);
    
      //Create Sources
      AlGenSources(1, @source);
      AlSourcei ( source, AL_BUFFER, buffer);
      AlSourcef ( source, AL_PITCH, 1.0 );
      AlSourcef ( source, AL_GAIN, 1.0 );
      AlSourcefv ( source, AL_POSITION, @sourcepos);
      AlSourcefv ( source, AL_VELOCITY, @sourcevel);
      AlSourcei ( source, AL_LOOPING, AL_TRUE);
    
      //Create Listener
      AlListenerfv ( AL_POSITION, @listenerpos);
      AlListenerfv ( AL_VELOCITY, @listenervel);
      AlListenerfv ( AL_ORIENTATION, @listenerori);
    
      //start playing sound
      AlSourcePlay(source);
    
      //wait
      Writeln('Press [ENTER] to stop playing sound');
      Readln;
    
      //stop playing sound
      AlSourceStop(source);
    
      //exit
      AlDeleteBuffers(1, @buffer);
      AlDeleteSources(1, @source);
    
      //Free Context and Device
    
      //Get active context
      Context:=alcGetCurrentContext();
      //Get device for active context
      Device:=alcGetContextsDevice(Context);
      //Release context(s)
      alcDestroyContext(Context);
      //Close device
      alcCloseDevice(Device);
    
    end.
    http://3das.noeska.com - create adventure games without programming

  10. #10

    Free Pascal Non-OOP sound

    Windows,
    FPC,
    No openal runtime (didn't realize I needed it).

    I will take a look at your example, thanks.
    I'm new to any type of audio/graphical programming... so thats why I'm so stuck. I'm a noob Must fix that
    --MagicRPG--

Page 1 of 2 12 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
  •