|
화일을 읽어서 메모리에 전부 로드한후 Play 하려고 하는데 잘안되서요
이 화일은 Windows type이 아니라서 1thByte와 2thByte를 바꾸는 기능도 있고
또 앞부분에 헤더가 없어요
소스를 보시고 부탁좀 드릴께요
void __fastcall TWavePlayerMainForm::FileRead(char *SourceFileName)
{
int ret;
int Signal; //음량이 조정된 값이 저장될 변수
long SeekPosition; //Read Data 위치
char Buffer[10]; //Wave를 2Byte읽어 저장할 변수
struct stat statbuf;
stat(SourceFileName, &statbuf);
SeekPosition = 0;
FILE *in; //Source Wave File Device
CGauge1->MaxValue = statbuf.st_size;
in = fopen(SourceFileName, "rb");
memset(WaveForm->PlayBuf.Data[0], 0x00, sizeof(WaveForm->PlayBuf.Data[0]));
while(1)
{
//진행률 보이기
CGauge1->Progress = SeekPosition;
//원본화일에서 실재 Data를 읽기위해 읽을 위치로 이동
fseek(in, SeekPosition, SEEK_SET);
//2 Byte를 읽어 Buffer에 정수로 저장
memset(Buffer, 0x00, sizeof(Buffer));
ret = fread(Buffer,3,1,in);
if (ret == NULL) break;
WaveForm->PlayBuf.Data[0][SeekPosition] = Buffer[1];
WaveForm->PlayBuf.Data[0][SeekPosition+1] = Buffer[0];
SeekPosition = SeekPosition + 2;
Application->ProcessMessages();
}
fclose(in);
}
void __fastcall TWavePlayerMainForm::Button1Click(TObject *Sender)
{
Label12->Caption = DateToStr(Date()) + " " + TimeToStr(Time());
WaveForm->InitPriamy(WavePlayerMainForm->Handle);
WaveForm->InitSecond();
CGauge2->MaxValue = WaveFileCount;
for(int i=0; i<WaveFileCount; i++)
{
Label3->Caption = WaveFileListStringGrid->Cells[1][i];
CGauge2->Progress = i;
FileRead(Label3->Caption.c_str());
Label9->Caption = WaveFileCount - i;
WaveForm->PlaySound();
WaveFileListStringGrid->Cells[0][i] = WaveFileListStringGrid->Cells[0][i+1];
WaveFileListStringGrid->Cells[1][i] = WaveFileListStringGrid->Cells[1][i+1];
Refresh();
Application->ProcessMessages();
Sleep(500);
}
Label13->Caption = DateToStr(Date()) + " " + TimeToStr(Time());
}
|