Results 1 to 3 of 3

Thread: Trying to play OGG music

  1. #1
    Squire
    Join Date
    Oct 2009
    Posts
    16

    Question Trying to play OGG music

    Hello. I am trying to make my first small game and I am just learning ClanLib 2.0.4. At clanlib.org I could not find a tutorial for how to play ogg music. Could someone please either point me to the tutorial or help me understand my mistakes? I tried to figure this out from the reference documentation, but when I run the game with the new code I immediately get a segfault.

    Code:
    #include <ClanLib-2.0/ClanLib/core.h>
    #include <ClanLib-2.0/ClanLib/display.h>
    #include <ClanLib-2.0/ClanLib/gl.h>
    #include <ClanLib-2.0/ClanLib/application.h>
    #include <ClanLib-2.0/ClanLib/sound.h>
    #include <ClanLib-2.0/ClanLib/vorbis.h>
    
    // ...other code...
    
      CL_SetupSound::CL_SetupSound();
      CL_SetupVorbis::CL_SetupVorbis();
      CL_String * track_name = new CL_String("../data/le_chant_des_sirenes_part_ii.ogg");
      CL_VirtualDirectory * virtualdirectory = new CL_VirtualDirectory; // what is this for?                                                       
      CL_SoundProvider_Vorbis * track = new CL_SoundProvider_Vorbis(*track_name, *virtualdirectory);
      CL_SoundBuffer * soundbuffer = new CL_SoundBuffer(track);
      soundbuffer->prepare();
      soundbuffer->play();
    
    // ...other code...
    I originally wrote the above without using so many pointers but that didn't work either. (I remember back when I dabbled in 0.8 that for some reason some things worked better with pointers...) I have a tiny bit of experience with 0.8 but never tried audio.

    I am running on a Gentoo Linux amd64 system with ClanLib 2.0.4 installed.

  2. #2
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    Instead try:
    Code:
    	CL_SetupSound setup_sound;
    	CL_SetupVorbis setup_vorbis;
    
    	CL_SoundOutput sound_output(44100);
    	CL_SoundBuffer sample("../data/le_chant_des_sirenes_part_ii.ogg");
    	CL_SoundBuffer_Session playback(sample.prepare());
    	playback.play();
    (Your code did not call CL_SoundOutput, so it did not allocate a sound card)

    You could modify the shadowofthebeast example to play vorbis by replacing "CL_SetupMikMod setup_mikmod;" with "CL_SetupVorbis setup_vorbis;" and changing "resources/b-title.mod" to an ogg file

    However, 2.0.4 sound is a bit buggy in places. It has improved in 2.1.0
    It is worth upgrading, as the API is nearly identical. (See http://www.rtsoft.com/forums/showthread.php?p=11666 )

    The sound example is a bit more stable in 2.1.0 - however the example is still incomplete in places

  3. #3
    Squire
    Join Date
    Oct 2009
    Posts
    16

    Talking

    You are so awesome! Thanks a lot!

Similar Threads

  1. Feature Request: Online play?
    By DarthDie in forum Novashell Game Creation System
    Replies: 6
    Last Post: 06-05-2007, 10:52 AM
  2. did you play both 2 dink games
    By madgamer in forum RTsoft Tavern
    Replies: 4
    Last Post: 01-06-2005, 01:54 AM
  3. Dink runs too fast to play
    By in forum Dink Smallwood HD
    Replies: 0
    Last Post: 09-30-2003, 03:51 PM
  4. anyone able to play on BYG today?
    By jimbobbucky in forum Funeral Quest
    Replies: 2
    Last Post: 07-26-2003, 02:14 PM
  5. Game play and dynamics
    By jjohn in forum Funeral Quest
    Replies: 16
    Last Post: 10-16-2002, 09:12 PM

Bookmarks

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
  •