1 2 #ifdef _MSC_EXTENSIONS 3 #pragma pack(push) 4 #pragma pack(1) 5 #endif 6 typedef struct { 7 int numOfSongs; 8 int defSong; // zero based index (0....numOfSongs-1) 9 char *commentBuffer; 10 } sapMUSICstrc; 11 #ifdef _MSC_EXTENSIONS 12 #pragma pack(pop) 13 #endif 14 15 sapMUSICstrc *sapLoadMusicFile( char *fname ); 16 void sapPlaySong( int numOfSong ); 17 void sapRenderBuffer( signed short *buffer, int number_of_samples ); 18 19 20 21 // don't delete sapMUSICstrc returned via sapLoadMusicFile!!! 22 // don't modify or delete commentBuffer pointed by this structure!!! 23 // if error occurs, then sapLoadMusicFile returns NULL. 24 // sapRenderBuffer, fills given buffer with n=(number_of_samples) mono 25 // 8bit unsigned samples. 26 // example: 27 // 28 // sapMUSICstrc *currentFile; 29 // unsigned char playBuffer[44100]; 30 // int currentSong; 31 // 32 // currentFile = sapLoadMusicFile( "music.sap" ); 33 // currentSong = currentFile->defSong; 34 // again: 35 // while(key) 36 // { 37 // sapRenderBuffer( &playBuffer, 44100 ); 38 // __play_buffer( ); 39 // } 40 // if( key==next_song ) 41 // { 42 // currentSong = (currentSong+1) % currentFile->numOfSongs; 43 // sapPlaySong( current_song ); 44 // goto again; 45 // } 46 // No data need to be deleted, bcoz SAP is using only static data 47 // and is able to play only one song at time 48 49