#include #include #include #include #include #include #include #include #include #include #include "cmedia.h" typedef unsigned int MENU_ITEM; #define FUNCTION_PREVIOUS 1 #define FUNCTION_NEXT 2 #define FUNCTION_PLAY 3 #define FUNCTION_PAUSE 4 #define FUNCTION_STOP 5 #define FUNCTION_FORWARD 6 #define FUNCTION_BACKWARD 7 #define FUNCTION_EXIT 8 #define MAX_LIST_NO 250 FILE *SourceFile; char buffer[256]; unsigned char PlayList[MAX_LIST_NO][_MAX_PATH]; CWAVEFORMAT PCMFormat; MP3FORMAT MP3Format; CHIPINFO ChipInformation; int FileCount=0, CurrentFile=0; unsigned int MasterVolume=0; BOOL bExit=FALSE, bPlaying=FALSE, bPause=FALSE; DWORD TotalPlaybackLength=0; unsigned int LeftPeakmeter=0, RightPeakmeter=0; BOOL bRearSpeakerEnabled=FALSE, bSPDIFOutEnabled=FALSE; float EQBandRatio[2][32]; int CurrentMP3Equalizer=0; enum FILETYPE { WAVE_FILE, MP3_FILE }; FILETYPE FileType; void ShowMenuItem(MENU_ITEM Item, BOOL bActive); void ShowSourceFileInformation(char *FileName); void Previous(); void Next(); void main(int argc, char **argv) { short oldfgd; long oldbgd; struct _rccoord oldpos; int ch,i; MENU_ITEM CurrentFunction; BOOL bExit; int iVenderID=0, iDeviceID=0, iIOBaseAddress=0, iIRQ=0, iIRQInterrupt=0; if (argc < 2) { printf("Play8738 V1.02 Beta Copyright (c) 2000 C-Media Electronic Inc.\n\n" ); printf("This program is used for CMI8338 and CMI8738 PCI audio chips.\n" ); printf("If you have any suggestions, please send feedback to beta_test@cmedia.com.tw.\n"); printf("For more informations, welcome to visit HTTP:\\\\WWW.CMEDIA.COM.TW.\n\n" ); printf("Usage: Play8738 filename\n\n" ); printf("filename: The full path of playback file.\n" ); printf(" It must be .wav, .mp3 or .m3u file type.\n\n" ); printf("Example:\n" ); printf(" Play8738 C:\\Window\\Ding.wav\n" ); printf(" Play8738 C:\\MP3\\MyMP3.mp3\n" ); printf(" Play8738 PlayList.m3u\n\n\n" ); printf("M3U file is a text file which includes a list of all .wav/.mp3 files.\n" ); printf("For example:\n" ); printf(" CMedia\\Sound\\MP3\\EYES_ON.MP3\n" ); printf(" CMedia\\Sound\\MP3\\HERO.MP3\n" ); exit(0); } CMIRESULT Result=InitialCMedia(ChipInformation); if (Result != CMI_NOERROR) { switch(Result) { case CMI_NOPCIBIOS: printf("No PCI BIOS interface present."); exit(Result); case CMI_NOAUDIOCHIP: printf("Can not find out the CMI8338 or CMI8738 PCI audio chip.\n"); exit(0); case CMI_IRQNOTSUPPORT: printf("This Interrupt Request Line is not supported.\n"); exit(0); case CMI_CANNOTALLOCATE: printf("Memory allocation error.\n"); exit(0); }; } MasterVolume = GetMasterVolume(); EnableSPDIFOut(FALSE); EnableRearSpeaker(FALSE); for(i=0; i<2; i++) for(int j=0; j<32; j++) EQBandRatio[i][j] = 1.0; SetMP3EqualizerBand(EQBandRatio); /* Process the arguments and display the current file format. */ SourceFile = NULL; if ((SourceFile=fopen(argv[1], "rb")) != NULL) { if (strchr(argv[1], '.')) strupr( strchr(argv[1], '.') ); else strupr( argv[1] ); if (strstr(argv[1], ".WAV")) // WAV FILE { if (!GetWaveFileInformation(SourceFile, PCMFormat)) { fseek(SourceFile, 0, SEEK_SET); if (!GetMP3FileInformation(SourceFile, PCMFormat, MP3Format)) { printf("The file format of %s is not supported!", argv[1] ); fclose(SourceFile); exit(0); } else FileType = MP3_FILE; } else FileType = WAVE_FILE; CurrentFile = 0; FileCount = 1; strcpy((char *)PlayList[0], argv[1]); } else if (strstr(argv[1], ".MP3")) // MP3 FILE { if (!GetMP3FileInformation(SourceFile, PCMFormat, MP3Format)) { printf("The file format of %s is not supported!", argv[1] ); fclose(SourceFile); exit(0); } else FileType = MP3_FILE; CurrentFile = 0; FileCount = 1; strcpy((char *)PlayList[0], argv[1]); } else if (strstr(argv[1], ".M3U")) // M3U FILE { char FileName[_MAX_PATH], SourcePath[_MAX_PATH], Temp[_MAX_PATH]; for(int i=strlen(argv[1])-1; i >= 0 && argv[1][i] != '\\'; i--) {} argv[1][i+1]='\0'; if (argv[1][1] != ':') { /* Get the current working directory: */ if( _getcwd( buffer, _MAX_DIR ) != NULL ) { int len = strlen(buffer); if (buffer[len-1] != '\\') { buffer[len] = '\\'; buffer[len+1] = '\0'; } strcpy(SourcePath, buffer); strcat(SourcePath, argv[1]); } } else { strcpy(SourcePath, argv[1]); } while(FileCount <= MAX_LIST_NO && !feof(SourceFile)) { fgets(Temp, _MAX_PATH, SourceFile); if (Temp[0] != '#') { char *p = strchr(Temp, 0x0d); if (p) *p = '\0'; p = strchr(Temp, 0x0a); if (p) *p = '\0'; strcpy(FileName, SourcePath); strcat(FileName, Temp); strcpy((char *)PlayList[FileCount], FileName); FileCount++; } Temp[0] = '#'; } fclose(SourceFile); if (FileCount != 0) { BOOL bFind=FALSE; for(int i=0; i 21) Volume=21; memset(buffer, '|', Volume); memset(buffer+Volume, ' ', 21-Volume); buffer[21] = '\0'; _settextposition(19,58); _outtext( buffer ); CurrentFunction = FUNCTION_PLAY; ShowMenuItem(CurrentFunction, TRUE); ShowSourceFileInformation((char *)PlayList[CurrentFile]); bExit = bPlaying = FALSE; _displaycursor(_GCURSOROFF); do { ch = 0; if (_kbhit()) { // Process the keystroke ch = _getch(); if (ch == 0x09) // Tab { ShowMenuItem(CurrentFunction, FALSE); if (CurrentFunction == FUNCTION_EXIT) CurrentFunction = FUNCTION_PREVIOUS; else CurrentFunction = CurrentFunction+1; ShowMenuItem(CurrentFunction, TRUE); } else if (ch == 0x0d) // Enter { if (CurrentFunction == FUNCTION_EXIT) bExit = TRUE; else if (CurrentFunction == FUNCTION_PLAY && !bPlaying) { Playback(); bPlaying=TRUE; } else if (CurrentFunction == FUNCTION_PLAY && bPlaying && bPause) { Pause(); bPause = FALSE; } else if (CurrentFunction == FUNCTION_STOP && bPlaying) { StopPlayback(); _setbkcolor( 1 ); _settextcolor( 14 ); _settextposition(24,57); _outtext( "0 min. 0.0 sec. " ); _settextposition(25,1); memset(buffer, ' ', 79); buffer[79] = '\0'; _outtext( buffer ); _settextcolor( 4 ); _settextposition(20,58); _outtext( " " ); _settextposition(21,58); _outtext( " " ); bPlaying = bPause = FALSE; } else if (CurrentFunction == FUNCTION_FORWARD && bPlaying) { if (!Forward()) { if (CurrentFile+1 == FileCount) { StopPlayback(); bPlaying = bPause = FALSE; } else Next(); } } else if (CurrentFunction == FUNCTION_BACKWARD && bPlaying) Backward(); else if (CurrentFunction == FUNCTION_PAUSE && bPlaying) { Pause(); bPause = !bPause; } else if (CurrentFunction == FUNCTION_PREVIOUS) Previous(); else if (CurrentFunction == FUNCTION_NEXT) Next(); } else if (ch == 0x1b) // ESC { bExit = TRUE; } else if (ch == 0x2b) // + { if (MasterVolume < 15) { MasterVolume++; SetMasterVolume(MasterVolume); } _settextcolor( 4 ); unsigned int Volume= MasterVolume*21/15; if (Volume > 21) Volume=21; memset(buffer, '|', Volume); memset(buffer+Volume, ' ', 21-Volume); buffer[21] = '\0'; _settextposition(19,58); _outtext( buffer ); } else if (ch == 0x2d) // - { if (MasterVolume > 0) { MasterVolume--; SetMasterVolume(MasterVolume); } _settextcolor( 4 ); unsigned int Volume= MasterVolume*21/15; if (Volume > 21) Volume=21; memset(buffer, '|', Volume); memset(buffer+Volume, ' ', 21-Volume); buffer[21] = '\0'; _settextposition(19,58); _outtext( buffer ); } else if (ch == 0) { ch = _getch(); switch(ch) { case 0x3b: // F1 if (!bPlaying) { Playback(); bPlaying = TRUE; } else if (bPlaying && bPause) { Pause(); bPause = FALSE; } break; case 0x3c: // F2 if (bPlaying) { Pause(); bPause = !bPause; } break; case 0x3d: // F3 if (bPlaying) { StopPlayback(); bPlaying = bPause = FALSE; } break; case 0x3e: // F4 if (bPlaying) Forward(); break; case 0x3f: // F5 if (bPlaying) Backward(); break; case 0x40: // F6 bSPDIFOutEnabled = !bSPDIFOutEnabled; EnableSPDIFOut(bSPDIFOutEnabled); break; case 0x41: // F7 bRearSpeakerEnabled = !bRearSpeakerEnabled; EnableRearSpeaker(bRearSpeakerEnabled); break; case 0x42: // F8 { CurrentMP3Equalizer++; CurrentMP3Equalizer %= 4; switch(CurrentMP3Equalizer) { case 0: // Flat { for(int i=0; i<2; i++) for(int j=0; j<32; j++) EQBandRatio[i][j] = 1.0; SetMP3EqualizerBand(EQBandRatio); } break; case 1: // Rock { EQBandRatio[0][0] = 1.8; EQBandRatio[0][ 8] = 0.9; EQBandRatio[0][16] = 2.0; EQBandRatio[0][24] = 1.9; EQBandRatio[0][1] = 1.4; EQBandRatio[0][ 9] = 1.2; EQBandRatio[0][17] = 2.0; EQBandRatio[0][25] = 1.8; EQBandRatio[0][2] = 0.9; EQBandRatio[0][10] = 1.2; EQBandRatio[0][18] = 2.0; EQBandRatio[0][26] = 1.8; EQBandRatio[0][3] = 0.7; EQBandRatio[0][11] = 1.4; EQBandRatio[0][19] = 2.0; EQBandRatio[0][27] = 1.8; EQBandRatio[0][4] = 0.6; EQBandRatio[0][12] = 1.4; EQBandRatio[0][20] = 2.0; EQBandRatio[0][28] = 1.4; EQBandRatio[0][5] = 0.7; EQBandRatio[0][13] = 1.4; EQBandRatio[0][21] = 1.9; EQBandRatio[0][29] = 1.4; EQBandRatio[0][6] = 0.8; EQBandRatio[0][14] = 1.7; EQBandRatio[0][22] = 1.9; EQBandRatio[0][30] = 1.4; EQBandRatio[0][7] = 0.8; EQBandRatio[0][15] = 1.7; EQBandRatio[0][23] = 1.9; EQBandRatio[0][31] = 1.4; for(int j=0; j<32; j++) EQBandRatio[1][j] = EQBandRatio[0][j]; SetMP3EqualizerBand(EQBandRatio); } break; case 2: // Jazz { EQBandRatio[0][0] = 1.8; EQBandRatio[0][ 8] = 1.4; EQBandRatio[0][16] = 0.7; EQBandRatio[0][24] = 0.9; EQBandRatio[0][1] = 1.4; EQBandRatio[0][ 9] = 1.3; EQBandRatio[0][17] = 0.7; EQBandRatio[0][25] = 0.9; EQBandRatio[0][2] = 0.9; EQBandRatio[0][10] = 1.3; EQBandRatio[0][18] = 0.7; EQBandRatio[0][26] = 0.9; EQBandRatio[0][3] = 0.8; EQBandRatio[0][11] = 1.1; EQBandRatio[0][19] = 0.7; EQBandRatio[0][27] = 0.9; EQBandRatio[0][4] = 0.7; EQBandRatio[0][12] = 1.1; EQBandRatio[0][20] = 0.8; EQBandRatio[0][28] = 1.3; EQBandRatio[0][5] = 0.7; EQBandRatio[0][13] = 1.1; EQBandRatio[0][21] = 0.8; EQBandRatio[0][29] = 1.3; EQBandRatio[0][6] = 1.0; EQBandRatio[0][14] = 0.9; EQBandRatio[0][22] = 0.8; EQBandRatio[0][30] = 1.3; EQBandRatio[0][7] = 1.0; EQBandRatio[0][15] = 0.9; EQBandRatio[0][23] = 0.8; EQBandRatio[0][31] = 1.3; for(int j=0; j<32; j++) EQBandRatio[1][j] = EQBandRatio[0][j]; SetMP3EqualizerBand(EQBandRatio); } break; case 3: // Classic { EQBandRatio[0][0] = 1.3; EQBandRatio[0][ 8] = 0.5; EQBandRatio[0][16] = 1.1; EQBandRatio[0][24] = 1.3; EQBandRatio[0][1] = 1.6; EQBandRatio[0][ 9] = 0.6; EQBandRatio[0][17] = 1.1; EQBandRatio[0][25] = 1.4; EQBandRatio[0][2] = 1.1; EQBandRatio[0][10] = 0.6; EQBandRatio[0][18] = 1.1; EQBandRatio[0][26] = 1.4; EQBandRatio[0][3] = 0.9; EQBandRatio[0][11] = 0.7; EQBandRatio[0][19] = 1.1; EQBandRatio[0][27] = 1.4; EQBandRatio[0][4] = 0.6; EQBandRatio[0][12] = 0.7; EQBandRatio[0][20] = 1.1; EQBandRatio[0][28] = 1.4; EQBandRatio[0][5] = 0.5; EQBandRatio[0][13] = 0.7; EQBandRatio[0][21] = 1.3; EQBandRatio[0][29] = 0.9; EQBandRatio[0][6] = 0.5; EQBandRatio[0][14] = 0.9; EQBandRatio[0][22] = 1.3; EQBandRatio[0][30] = 0.9; EQBandRatio[0][7] = 0.5; EQBandRatio[0][15] = 0.9; EQBandRatio[0][23] = 1.3; EQBandRatio[0][31] = 0.9; for(int j=0; j<32; j++) EQBandRatio[1][j] = EQBandRatio[0][j]; SetMP3EqualizerBand(EQBandRatio); } break; }; } break; case 0x4d: // Right ShowMenuItem(CurrentFunction, FALSE); if (CurrentFunction == FUNCTION_EXIT) CurrentFunction = FUNCTION_PREVIOUS; else CurrentFunction = CurrentFunction+1; ShowMenuItem(CurrentFunction, TRUE); break; case 0x4b: // Left ShowMenuItem(CurrentFunction, FALSE); if (CurrentFunction == FUNCTION_PREVIOUS) CurrentFunction = FUNCTION_EXIT; else CurrentFunction = CurrentFunction-1; ShowMenuItem(CurrentFunction, TRUE); break; case 0x48: // Up Previous(); break; case 0x50: // Down Next(); break; } } } else { if (bPlaying) { if (IsPlaybackEnd()) { if (CurrentFile+1 == FileCount) { StopPlayback(); bPlaying = bPause = FALSE; } else Next(); } else FillPlaybackData(); TotalPlaybackLength = GetPlaybackLength(); if (TotalPlaybackLength >= PCMFormat.nDataLength) TotalPlaybackLength = PCMFormat.nDataLength; float TotalTime1=TotalPlaybackLength*1.f/PCMFormat.nAvgBytesPerSec; int Minute = int(TotalTime1/60.f); int Second = int(TotalTime1)%60; int PercentSec = int((TotalTime1-floor(TotalTime1))*100.f); _setbkcolor( 1 ); _settextcolor( 14 ); _settextposition(24,57); sprintf( buffer, "%d min. %d.%d sec. \0", Minute, Second, PercentSec); _outtext( buffer ); float TotalTime2=PCMFormat.nDataLength*1.f/PCMFormat.nAvgBytesPerSec; int Progress = (int)(TotalTime1*79.0/TotalTime2); _settextposition(25,1); _setbkcolor( 14 ); _settextcolor( 1 ); memset(buffer, ' ', Progress); buffer[Progress] = '\0'; _outtext( buffer ); _settextposition(25,Progress+1); _setbkcolor( 1 ); _settextcolor( 14 ); memset(buffer, ' ', 79-Progress); buffer[79-Progress] = '\0'; _outtext( buffer ); // Show Volume Peakmeter and Master Volume _settextcolor( 4 ); unsigned int LeftChannelPeakmeter, RightChannelPeakmeter; GetPeakmeter(LeftChannelPeakmeter, RightChannelPeakmeter); LeftPeakmeter = LeftChannelPeakmeter*21/100; if (LeftPeakmeter > 21) LeftPeakmeter=21; memset(buffer, '|', LeftPeakmeter); memset(buffer+LeftPeakmeter, ' ', 21-LeftPeakmeter); buffer[21] = '\0'; _settextposition(20,58); _outtext( buffer ); RightPeakmeter = RightChannelPeakmeter*21/100; if (RightPeakmeter > 21) RightPeakmeter=21; memset(buffer, '|', RightPeakmeter); memset(buffer+RightPeakmeter, ' ', 21-RightPeakmeter); buffer[21] = '\0'; _settextposition(21,58); _outtext( buffer ); } } // The End if (bExit) { if (bPlaying) { StopPlayback(); bPlaying = bPause = FALSE; } if (SourceFile) { fclose(SourceFile); SourceFile = NULL; } ExitCMedia(); } } while (!bExit); /* Restore original foreground, background, and text position. */ _settextcolor( oldfgd ); _setbkcolor( oldbgd ); _clearscreen( _GCLEARSCREEN ); _settextposition( oldpos.row, oldpos.col ); _displaycursor(_GCURSORON); } void ShowMenuItem(MENU_ITEM Item, BOOL bActive) { if (bActive) { _setbkcolor( 7 ); _settextcolor( 1 ); } else { _setbkcolor( 1 ); _settextcolor( 7 ); } // 1 2 3 4 5 6 7 8 // 12345678901234567890123456789012345678901234567890123456789012345678901234567890 //" Previous Next Play Pause Stop Forward Backward Exit" switch(Item) { case FUNCTION_PREVIOUS: _settextposition(3,5); _outtext( "Previous" ); break; case FUNCTION_NEXT: _settextposition(3,17); _outtext( "Next" ); break; case FUNCTION_PLAY: _settextposition(3,25); _outtext( "Play" ); break; case FUNCTION_PAUSE: _settextposition(3,33); _outtext( "Pause" ); break; case FUNCTION_STOP: _settextposition(3,42); _outtext( "Stop" ); break; case FUNCTION_FORWARD: _settextposition(3,50); _outtext( "Forward" ); break; case FUNCTION_BACKWARD: _settextposition(3,61); _outtext( "Backward" ); break; case FUNCTION_EXIT: _settextposition(3,73); _outtext( "Exit" ); break; } } void ShowSourceFileInformation(char *FileName) { /* Show the source file information. */ _setbkcolor( 1 ); _settextcolor( 14 ); _settextposition(23,15); memset(buffer, ' ', 64); buffer[64]='\0'; _outtext( buffer ); _settextposition(23,15); _outtext( FileName ); float TotalTime=PCMFormat.nDataLength*1.f/PCMFormat.nAvgBytesPerSec; int Minute = int(TotalTime/60.f); int Second = int(TotalTime)%60; int PercentSec = int((TotalTime-floor(TotalTime))*100.f); _settextposition(24,15); sprintf( buffer, "%d min. %d.%d sec. \0", Minute, Second, PercentSec); _outtext( buffer ); _settextposition(24,57); _outtext( "0 min. 0.0 sec. " ); // Show Wave Formation Information _settextcolor( 9 ); if (FileType = WAVE_FILE) { _settextposition(7,17); _outtext( "Format Type: PCM (Wave)" ); _settextposition(8,17); sprintf( buffer, "Channels: %d \0", PCMFormat.nChannels); _outtext( buffer ); _settextposition(9,17); sprintf( buffer, "Samples/Sec.: %lu \0", PCMFormat.nSamplesPerSec); _outtext( buffer ); _settextposition(10,17); sprintf( buffer, "Bytes/Sec.: %lu \0", PCMFormat.nAvgBytesPerSec); _outtext( buffer ); _settextposition(11,17); sprintf( buffer, "Bits/Sample: %d \0", PCMFormat.wBitsPerSample); _outtext( buffer ); for(int i=13; i <=20; i++) { _settextposition(i,17); _outtext( " " ); } } else if (FileType = MP3_FILE) { _settextposition(7,17); _outtext( "Format Type: PCM (MP3) " ); _settextposition(8,17); sprintf( buffer, "Channels: %d \0", PCMFormat.nChannels); _outtext( buffer ); _settextposition(9,17); sprintf( buffer, "Samples/Sec.: %lu \0", PCMFormat.nSamplesPerSec); _outtext( buffer ); _settextposition(10,17); sprintf( buffer, "Bytes/Sec.: %lu \0", PCMFormat.nAvgBytesPerSec); _outtext( buffer ); _settextposition(11,17); sprintf( buffer, "Bits/Sample: %d \0", PCMFormat.wBitsPerSample); _outtext( buffer ); _settextposition(13,17); if (MP3Format.h_version == MPEG1) sprintf(buffer,"MPEG-1 Layer %d \0",MP3Format.h_layer); else sprintf(buffer,"MPEG2_LSF Layer %d \0",MP3Format.h_layer); _outtext( buffer ); _settextposition(14,17); sprintf(buffer,"%d kbps, ",abs((int)(MP3Format.h_bitrate/1000))); _outtext( buffer ); _settextposition(15,17); strcpy(buffer, ""); if (MP3Format.h_mode == stereo) strcpy(buffer, "Stereo "); else if (MP3Format.h_mode == joint_stereo) strcpy(buffer, "Joint Stereo "); else if (MP3Format.h_mode == dual_channel) strcpy(buffer, "Dual Channel "); else if (MP3Format.h_mode == single_channel) strcpy(buffer, "Single Channel"); _outtext( buffer ); _settextposition(16,17); if (MP3Format.h_private) strcpy(buffer, "Private : Yes"); else strcpy(buffer, "Private : No "); _outtext( buffer ); _settextposition(17,17); if (MP3Format.h_protection_bit == 0) strcpy(buffer, "CRCs : Yes"); else strcpy(buffer, "CRCs : No "); _outtext( buffer ); _settextposition(18,17); if (MP3Format.h_copyright) strcpy(buffer, "Copyrighted : Yes"); else strcpy(buffer, "Copyrighted : No "); _outtext( buffer ); _settextposition(19,17); if (MP3Format.h_original) strcpy(buffer, "Original : Yes"); else strcpy(buffer, "Original : No "); _outtext( buffer ); _settextposition(20,17); if (MP3Format.h_emphasis == none) strcpy(buffer, "Emphasis : None "); else if (MP3Format.h_emphasis == ms50_15) strcpy(buffer, "Emphasis : 50/15 ms "); else if (MP3Format.h_emphasis == reserved) strcpy(buffer, "Emphasis : Reserved "); else if (MP3Format.h_emphasis == CCITTJ17) strcpy(buffer, "Emphasis : CCITT J.17"); _outtext( buffer ); } // Show file list _setbkcolor( 1 ); _settextcolor( 2 ); char Temp[15]; int StartPos=((int)(CurrentFile/15))*15; for(int i=StartPos; i=0 && PlayList[i][j] != '\\'; j--) {} if (i==CurrentFile) { _setbkcolor( 2 ); _settextcolor( 1 ); Temp[0] = '>'; strcpy(Temp+1, (char *)PlayList[i]+j+1); _outtext( Temp ); _setbkcolor( 1 ); _settextcolor( 2 ); } else { Temp[0] = ' '; strcpy(Temp+1, (char *)PlayList[i]+j+1); _outtext( Temp ); } } } } void Previous() { if (FileCount > 1) { if (CurrentFile == 0) CurrentFile=FileCount; BOOL NeedPlay = bPlaying; if (bPlaying) StopPlayback(); fclose(SourceFile); SourceFile=NULL; while (!SourceFile) { BOOL bFind=FALSE; for(int i=CurrentFile-1; i >= 0 && !bFind; i--) { CurrentFile = i; SourceFile = NULL; if ((SourceFile=fopen((char *)PlayList[i], "rb")) != NULL) { if (strchr((char *)PlayList[i], '.')) strupr( strchr((char *)PlayList[i], '.') ); else strupr( (char *)PlayList[i] ); if (strstr((char *)PlayList[i], ".WAV")) // WAV FILE { if (!GetWaveFileInformation(SourceFile, PCMFormat)) { fseek(SourceFile, 0, SEEK_SET); if (GetMP3FileInformation(SourceFile, PCMFormat, MP3Format)) bFind = TRUE; } else bFind = TRUE; } else if (strstr((char *)PlayList[i], ".MP3")) // MP3 FILE { if (GetMP3FileInformation(SourceFile, PCMFormat, MP3Format)) bFind = TRUE; } if (!bFind) fclose(SourceFile); } if (i == 0 && !bFind) i=FileCount; } } ShowSourceFileInformation((char *)PlayList[CurrentFile]); if (NeedPlay) Playback(); } } void Next() { if (FileCount > 1) { if (CurrentFile+1 == FileCount) CurrentFile=-1; BOOL NeedPlay = bPlaying; if (bPlaying) StopPlayback(); fclose(SourceFile); SourceFile=NULL; while (!SourceFile) { BOOL bFind=FALSE; for(int i=CurrentFile+1; i