C++Builder Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
C++빌더 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
메신저 프로젝트
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C++빌더 Q&A
C++Builder Programming Q&A
[18239] 메모리에 로드한 wave를 play 할려고 하는데요...
김유미 [] 1074 읽음    2002-05-07 18:52
화일을 읽어서 메모리에 전부 로드한후 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());
}

+ -

관련 글 리스트
18239 메모리에 로드한 wave를 play 할려고 하는데요... 김유미 1074 2002/05/07
18315     Re:메모리에 로드한 wave를 play 할려고 하는데요... 이종빈 953 2002/05/09
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.