Example #1
0
int main(int argc, char ** argv) {

	fatInitDefault();
	InitMaxmod();
	initGui();
	
	while(1) {

		scanKeys();
		touchRead(&touch);
		updateBrowser();

		if(playing) {
			mmStreamUpdate();
			updateProgress(&musik);
			if(needsClosing) {
				needsClosing = false;
				closeDecoder();
			}
		}
		glFlush(0);
		swiWaitForVBlank();
	}
}
Example #2
0
/**********************************************************************************
 * main
 *
 * Program Entry Point
 **********************************************************************************/
int main( void ) {
//---------------------------------------------------------------------------------

    //----------------------------------------------------------------
    // print out some stuff
    //----------------------------------------------------------------
    consoleDemoInit();
    iprintf( "\n    Maxmod Streaming Example   \n");

    //----------------------------------------------------------------
    // initialize maxmod without any soundbank (unusual setup)
    //----------------------------------------------------------------
    mm_ds_system sys;
    sys.mod_count 			= 0;
    sys.samp_count			= 0;
    sys.mem_bank			= 0;
    sys.fifo_channel		= FIFO_MAXMOD;
    mmInit( &sys );

    //----------------------------------------------------------------
    // open stream
    //----------------------------------------------------------------
    mm_stream mystream;
    mystream.sampling_rate	= 25000;					// sampling rate = 25khz
    mystream.buffer_length	= 1200;						// buffer length = 1200 samples
    mystream.callback		= on_stream_request;		// set callback function
    mystream.format			= MM_STREAM_16BIT_STEREO;	// format = stereo 16-bit
    mystream.timer			= MM_TIMER0;				// use hardware timer 0
    mystream.manual			= true;						// use manual filling
    mmStreamOpen( &mystream );

    //----------------------------------------------------------------
    // when using 'automatic' filling, your callback will be triggered
    // every time half of the wave buffer is processed.
    //
    // so:
    // 25000 (rate)
    // ----- = ~21 Hz for a full pass, and ~42hz for half pass
    // 1200  (length)
    //----------------------------------------------------------------
    // with 'manual' filling, you must call mmStreamUpdate
    // periodically (and often enough to avoid buffer underruns)
    //----------------------------------------------------------------

    SetYtrigger( 0 );
    irqEnable( IRQ_VCOUNT );

    while( 1 )
    {
        // wait until line 0
        swiIntrWait( 0, IRQ_VCOUNT);

        // update stream
        mmStreamUpdate();

        // restore backdrop (some lines were drawn with another colour to show cpu usage)
        BG_PALETTE_SUB[0] = bg_colour;

        // wait until next frame
        swiWaitForVBlank();

        // set backdrop to show cpu usage
        BG_PALETTE_SUB[0] = cpu_colour;
    }

    return 0;
}