View unanswered posts | View active topics It is currently Sat Nov 17, 2018 7:55 pm



Reply to topic  [ 27 posts ]  Go to page Previous  1, 2, 3
 stream sound[solved] 
Author Message

Joined: Sat Dec 06, 2008 6:07 pm
Posts: 65
buffer_length = 4096 should be fine.

Did you remember to call mmStreamUpdate periodically?


Fri Jun 26, 2009 6:47 pm
Profile WWW

Joined: Thu Jan 08, 2009 9:15 pm
Posts: 82
i call it every vbl, is this wrong :oops: or this one(this is the problem i think)?

sys.samp_count = 0;

if thatś the problem, i can solve it so easy 8)


Fri Jun 26, 2009 6:50 pm
Profile

Joined: Sat Dec 06, 2008 6:07 pm
Posts: 65
Calling the update every frame is ideal.

Code:
sys.samp_count = 0;


I'm not sure what this is...


Fri Jun 26, 2009 7:05 pm
Profile WWW

Joined: Thu Jan 08, 2009 9:15 pm
Posts: 82
yay it works now! but.. for a half :cry: , there are some parts with some noise, what i did was this:

change the wile in mm_word on_stream_request to if, i can explain it but it wasn't very logic to me


Fri Jun 26, 2009 7:11 pm
Profile

Joined: Sat Dec 06, 2008 6:07 pm
Posts: 65
Oh, no that's something unrelated to this. Are you sure your OGG decoding stuff is progressing through the file rather than just decoding the beginning over and over?

edit: (oops this was targetted for that other post)


Fri Jun 26, 2009 7:30 pm
Profile WWW

Joined: Thu Jan 08, 2009 9:15 pm
Posts: 82
tested it with some other samples, i'm just almost there! still the same effect but the sampples ARE recognisable(the effect is like this: part good sound, part nothing/bit noise and so on until end of file). i'll pm you my main, maybe you can see whatś wrong :P


for other the rom, to hear the effect, its on my site: https://sites.google.com/site/tomdevsndshomebrew


edit: ok i've found a problem i think: i thought that when you did:

Code:
s16 * test;
test++;


the pointer would point one byte furhter but that isn true. sound is better now. the only i can think off is that i don't update fast enough. ok here's the main i'm now using:

Code:
#include <nds.h>
#include <filesystem.h>
#include <fat.h>
#include <stdio.h>
#include <stdlib.h>
#include "ivorbiscodec.h"
#include "ivorbisfile.h"
#include <maxmod9.h>

#define OGG_BUFFER_GROOTTE (4096)


OggVorbis_File vf;
u8 channels;
u32 gelezen;
u32 samplecount;
mm_stream mystream;

void Update_OGG_Stream(OggVorbis_File * vf, void * buffer){

int current_section;
gelezen = 0;// we hebben immers nog niks gelezen in deze update

  while(gelezen<OGG_BUFFER_GROOTTE){// zolang het gelezen minder is dan de
  //buffer grootte
 
    long ret = ov_read(vf,buffer,(OGG_BUFFER_GROOTTE -gelezen), &current_section);

   if(ret == 0){// EOF
   iprintf("eind van de file, kies een andere\n");
   ov_clear(vf); // close the ogg file
   mmStreamClose(); // colse the stream
   break;
   }

          if (ret < 0) {// there's an error with decoding
      iprintf("fout tijdens decoden");
      break;
      }
         else {
         buffer +=ret;
              gelezen +=ret;
             }

        }

}

mm_word on_stream_request( mm_word length, mm_addr dest, mm_stream_formats format )
{

   int filled = 0;
   u8 *target = (u8*)dest;

   while( length >= 1024 ) {

      length -= 1024;
      filled += 1024;
      Update_OGG_Stream(&vf, target);
      target+=4096 // because it's an u8 pointer now instead of a s16
   }

   return filled;
}


int main(int argc, char **argv){

fatInitDefault();

FILE * pfile;
pfile = fopen("liedje.ogg", "rb");

consoleDemoInit();

mm_ds_system sys;
sys.mod_count          = 0;
sys.samp_count         = 0;
sys.mem_bank         = 0;
sys.fifo_channel      = FIFO_MAXMOD;
mmInit( &sys );
   
mm_stream mystream;
mystream.sampling_rate      = 44100;
mystream.buffer_length      = 4096;      
mystream.callback       = on_stream_request;      
mystream.format         = MM_STREAM_16BIT_STEREO;   
mystream.timer         = MM_TIMER0;            
mystream.manual         = true;

Open_OGG_File(pfile, &vf);

mmStreamOpen(&mystream );

   
while(1){

   mmStreamUpdate(); // update the ogg stream

       swiWaitForVBlank();

}         
  return(0);
}


Fri Jun 26, 2009 7:32 pm
Profile

Joined: Thu Nov 25, 2010 10:27 pm
Posts: 3
I´m trying to do this but I have problems. Nobody can help me? :|


Thu Nov 24, 2011 7:18 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 27 posts ]  Go to page Previous  1, 2, 3

Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
  Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software.
Get devkitPro at SourceForge.net. Fast, secure and Free Open Source software downloads