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

Thread: KOS sound streaming

                  
   
  1. #1
    DCEmu Coder GPF's Avatar
    Join Date
    Apr 2004
    Location
    Texas
    Age
    52
    Posts
    796
    Rep Power
    78

    Default KOS sound streaming

    I am currently also trying to figure out how to convert SDL sound to KOS sound streaming but don't know where to start. Is there any examples anywhere? All the kos examples are for sndvorbis and mp3/wav playback.

    My code has the stereo sound in a buffer and then dac sound effects in another buffer, and its using

    SDL_BuildAudioCVT(&acvt, AUDIO_U8, 1, 8000, DEFAULT_FORMAT,DEFAULT_CHANNELS, samplerate)

    and
    SDL_ConvertAudio(&acvt)

    then its mixing the both streams into one

    SDL_MixAudio(sound_buffer+sound_frame_write, dac_data, bpf, SDL_MIX_MAXVOLUME);

    how would I replace this with KOS calls? use multiple channels? Any examples or help is appreciated.

    Thanks,

    Troy

  2. #2
    DCEmu Coder
    Join Date
    Nov 2004
    Location
    Portland, OR, USA
    Posts
    54
    Rep Power
    0

    Default Re: KOS sound streaming

    Actually you kinda answered your own question. Take a look at the liboggvorbisplay/libtremor examples and it shows how to set up and use the streaming. In SVN KOS you can have as many streaming channels as you want, in addition to mono or stereo.

    Oh also I guess you meant you need sound effects. That's done with the snd_sfx_* calls.

    kernel/arch/dreamcast/include/dc/sound/sfxmgr.h
    Cryptic Allusion Games / Cryptic Allusion, LLC
    http://www.cagames.com/

  3. #3
    DCEmu Coder GPF's Avatar
    Join Date
    Apr 2004
    Location
    Texas
    Age
    52
    Posts
    796
    Rep Power
    78

    Default Re: KOS sound streaming

    oops I forgot to mention it was for an emulator port, so there are no sound files to load.

    I was looking for an example that used the sound callback and sound polling. Closest example I could find was the Modplug example, but still don't understand how I use it

    here is a simple psuedo code of what I am trying to do.

    initbuffers(1 buffer is stereo sound, and 2nd buffer is mono sound effectsl) and start sound streaming - how do I set up the multiple channels? do I need multiple callbacks?

    emulator calls a sound_update function with a number of frames of sound to play, that then calls 2 different core functions to get sound data into the 2 buffers.
    do I add snd_stream_poll(...); to this section?

    when does the callback function get called and what actually should be in the function.

    Thanks I am new to sound other the loading a file and letting the arm play it.

    Troy




  4. #4
    DCEmu Coder JMD's Avatar
    Join Date
    Apr 2004
    Location
    France
    Age
    49
    Posts
    83
    Rep Power
    0

    Default Re: KOS sound streaming

    If found an exemple of emulator sound streaming in the stef genPlus source he posted on this topic.

    I'm still working on the implementation of the sound streaming in my own project with this exemple + the KOS oggvorbis exemple.
    My code already does something : it crash ....
    That's a (good ?) begining.




  5. #5
    Dream Coder
    Join Date
    Apr 2004
    Location
    Miami, FL
    Age
    37
    Posts
    4,675
    Rep Power
    50

    Default Re: KOS sound streaming

    i'm having a similar problem. Trying to replace this code:

    Code:
    int init_sdl_audio(void) 
    { 
    
       if(SDL_InitSubSystem(SDL_INIT_AUDIO)) {    fprintf(stderr,"Couldn't Start Sound.\n");  } 
    
      desired.freq = SAMPLE_RATE; 
      desired.samples = NB_SAMPLES; 
      desired.format = AUDIO_S16; 
      desired.channels = 2; 
      desired.callback = update_sdl_stream; 
      desired.userdata = NULL; 
      SDL_OpenAudio(&desired, NULL); 
      streams_sh_start(); 
      YM2610_sh_start(); 
      SDL_PauseAudio(0); 
      
      return 1; 
    }
    I tried replacing it with this:
    Code:
    int init_sdl_audio(void) 
    { 
    
         snd_stream_init(update_sdl_stream); 
      snd_stream_queue_enable(); 
      snd_stream_start(SAMPLE_RATE, 1); 
    //hangs here ^^^ 
         streams_sh_start(); 
      YM2610_sh_start(); 
         return 1; 
    }
    but it hangs at the point where I marked, within the init function, not between the two. Maybe I have to fill my buffers first? Of course, my effort is not aided by the fact that the original SDL code gives no sound on the Dreamcast either =\ (works fine on PC).
    If anyone is looking to buy, sell, trade games and support a developer directly at the same time, consider joining Goozex. Enjoy!

  6. #6
    DCEmu Coder
    Join Date
    Nov 2004
    Location
    Portland, OR, USA
    Posts
    54
    Rep Power
    0

    Default Re: KOS sound streaming

    I think maybe you misunderstand what the "queue" functions do. When you enable queueing it fills up all the buffers, loads it into SPU RAM, and generally gets ready to hit the ground running. When you tell it to go, sound starts coming out instantly. I did that for the timing in FoF.

    I'd recommend removing the queue calls to see if that makes it go for now.

    Also I'm sure you've realized this, but the function decl for the SDL callback is almost assuredly different than the KOS one, so you will have to change that too.
    Cryptic Allusion Games / Cryptic Allusion, LLC
    http://www.cagames.com/

  7. #7
    Dream Coder
    Join Date
    Apr 2004
    Location
    Miami, FL
    Age
    37
    Posts
    4,675
    Rep Power
    50

    Default Re: KOS sound streaming

    the queue functions i added later, it didnt work without them either. Ill look at the callback, thanks. (from what i looked at it seemed the same).

    edit: WOW, i cant believe i missed that =P. the two callbacks send and ask for the same things but the orders are different, so maybe it will work now, thanks =). [now to fix the random crashing first...]
    If anyone is looking to buy, sell, trade games and support a developer directly at the same time, consider joining Goozex. Enjoy!

  8. #8
    Dream Coder
    Join Date
    Apr 2004
    Location
    Miami, FL
    Age
    37
    Posts
    4,675
    Rep Power
    50

    Default Re: KOS sound streaming

    hrm, no matter what i do it seems to hang after printing the following:
    snd_init(): loading 3408 bytes into SPU RAM
    and just... hangs. Any helpful hint as to what i may be doing wrong?
    If anyone is looking to buy, sell, trade games and support a developer directly at the same time, consider joining Goozex. Enjoy!

  9. #9
    DCEmu Coder
    Join Date
    Nov 2004
    Location
    Portland, OR, USA
    Posts
    54
    Rep Power
    0

    Default Re: KOS sound streaming

    This is about the time I start throwing printf's in the code
    Cryptic Allusion Games / Cryptic Allusion, LLC
    http://www.cagames.com/

  10. #10
    Dream Coder
    Join Date
    Apr 2004
    Location
    Miami, FL
    Age
    37
    Posts
    4,675
    Rep Power
    50

    Default Re: KOS sound streaming

    [quote author=Dan Potter link=board=Dev;num=1102054491;start=0#8 date=12/03/04 at 20:51:07]This is about the time I start throwing printf's in the code
    [/quote]


    poo. that means having to recompile kos over and over, something i dont like doing =P. oh well, thanks anyways, ill just try that. (i thought there might be something specific i didnt do).
    If anyone is looking to buy, sell, trade games and support a developer directly at the same time, consider joining Goozex. Enjoy!

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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
  •