作業六是聲波顯示,先來解釋圖片好了。
A圖是初始畫面,B圖是開啟檔案顯示聲波的畫面,但還是WAV檔案。
C圖是底下Toolbar的卷軸功能,用的是之前設計打磚塊的概念,每往右拉一點,影像就一直貼一直貼上去,就是覆蓋覆蓋。照片是在拉的那一瞬間拍的,我到現在還沒找到可以讓他一口氣就跑出來的方法,他還是用掃描的方式在跑,由左邊掃到右邊。
D圖跟E圖則是XY軸的大小。
程式碼是我找以前上課的筆記,以下是程式碼。但有些程式忘了意思....就照寫...忘記了當初判斷為什麼會那樣寫...考完是再來研就好了。
void show(void){
NeoSoundisplay->Refresh();
NeoSoundisplay->Canvas->TextOut(10,400,IntToStr(NeoSoundisplay->Srb->Position) );
divx=StrToInt(NeoSoundisplay->Edit1->Text);
divy=StrToInt(NeoSoundisplay->Edit2->Text);
NeoSoundisplay->Canvas->MoveTo(0+dx,-data[0]/divy+dy);
NeoSoundisplay->Canvas->Pen->Color=clBlue;
for(int i=1;(i<NeoSoundisplay->Width*divx)&&(i<(FileLen-dd)/2-1);i++)
NeoSoundisplay->Canvas->LineTo(i/divx+dx,-data[i+NeoSoundisplay->Srb->Position]/divy+dy);
}
//---------------------------------------------------------------------------
void __fastcall TNeoSoundisplay::FormCreate(TObject *Sender){
bool open_flag;
int handle;
if(open_flag==true) {
fclose(inf);
}
inf=fopen(file_name,"r");
open_flag=true;
handle=fileno(inf);
FileLen= filelength(handle);
if(feof(inf)) {
fclose(inf);
open_flag=false;
}
data = new short[(FileLen-dd)/2];
fseek(inf,dd,SEEK_SET);
fread(data,sizeof(short),(FileLen-dd)/2,inf);
MediaPlayer1->VisibleButtons=Mplayer::TButtonSet()<<btPlay<<btStop<<btPause;
MediaPlayer1->DeviceType=dtWaveAudio;
MediaPlayer1->FileName=file_name;
MediaPlayer1->Display=f14_4_2;
MediaPlayer1->Open();
if((FileLen-dd)-NeoSoundisplay->Width*divx<0)
Srb->Max=0;
else
Srb->Max=(FileLen-dd)/2-NeoSoundisplay->Width*divx;
}
//---------------------------------------------------------------------------
void __fastcall TNeoSoundisplay::MediaPlayer1Click(TObject *Sender,
TMPBtnType Button, bool &DoDefault){
if(!MediaPlayer1->AutoOpen)
MediaPlayer1->Play();
}
//---------------------------------------------------------------------------
void __fastcall TNeoSoundisplay::btnShowWaveClick(TObject *Sender){
show();
}
沒有留言:
張貼留言