Dilma, все это я видел. Никогда не претендовал на знание всего HiAsm, так что меня и "участник" устраивает, за сим и претензий к аттачам не имею. А как файлами перекидываться всегда с инетом найдем способ.
[size=-2]------ Добавлено в 08:52
Вот послений код по работе с DirectX. Удален баг при повторном пуске после первог пуск-стоп .
Add(MainForm,9088580,35,28)
{ Left=20 Top=105 Width=554 } Add(InlineCode,3368900,259,182) { @Hint=#16:DXSoundProcessor| WorkPoints=#6:doOpen|7:doStart|6:doStop| EventPoints=#8:onStream| VarPoints=#4:ArrI|4:ArrO| DataPoints=#8:Channels|4:Freq|8:BuffSize|3:Bit|6:Handle| Code=#15:unit HiAsmUnit;|0:|9:interface|0:|68:uses kol,Share,Debug,mmsystem,Windows,Messages,{DirectSound}DirectX;|0:|4:type|28: THiAsmClass = class(TDebug)|0:|10: private|15: Arr:PArray;|16: Arr1:PArray;|0:|12: protected|0:|9: public|28: _prop_BuffSize:integer;|28: _prop_Channels:integer;|24: _prop_Freq:integer;|23: _prop_Bit:integer;|26: _prop_Handle:integer;|0:|51: Channels ,Freq,BuffSize,Bit,Handle: THI_Event;|24: onStream:THI_Event;|0:|49: procedure doOpen(var _Data:TData; Index:word);|50: procedure doStart(var _Data:TData; Index:word);|49: procedure doStop(var _Data:TData; Index:word);|47: procedure ArrI(var _Data:TData; Index:word);|47: procedure ArrO(var _Data:TData; Index:word);|27: function _Count:integer;|56: function _Get(Var Item:TData; var Val:TData):boolean;|49: procedure _Set(var Item:TData; var Val:TData);|50: procedure _Set1(var Item:TData; var Val:TData);|0:|5: end;|0:|14:implementation|30: const start:boolean = false;|34: var Evt:array [0..1] of THandle;|46: EVNT:array [0..1] of TDSBPositionNotify;|64: PBuff:array [0..10000] of smallint;//Буфер воспроизведения|55: RBuff:array [0..10000] of smallint;//Буфер записи|17: Fs:integer;|51: BLKSIZE,Bits:integer;//число выборок на буфер|26: CAPTURESIZE:integer;|25: CaptureBytes:DWord;|50: wf:TWaveFormatEx;//Арес структуры WAVEFORMAT|54: dscbd:TDSCBufferDesc;//Структура DSCaptureBuffer|25: dsbd:TDSBufferDesc;|25: dspb:TDSBufferDesc;|22: ds:IDirectSound;|30: dsc:IDirectSoundCapture;|37: dscb:IDirectSoundCaptureBuffer;|29: dsb:IDirectSoundBuffer;|31: dspb1:IDirectSoundBuffer;|29: dsn:IDirectSoundNotify;|16: X:integer;|27: inPtr,outPtr:integer;|17: Me:integer;|22: //start:boolean;|29: Ptr1,Ptr2,Temp:pointer;|60: procedure THiAsmClass.doOpen(var _Data:TData; Index:word);|19: var err:integer;|8: begin|53: DirectSoundCreate(Nil,ds,nil);//Создать объект DS|54: DirectSoundCaptureCreate(nil,dsc,nil);//Объект DCB|74: Me := ReadInteger(_Data,Handle,_prop_Handle);//Указатель главного окна|66: ds.SetCooperativeLevel(Me,DSSCL_PRIORITY);//Установить уровень|68: Fs := ReadInteger(_Data,Freq,_prop_Freq);//Частота дискретизации|82: BLKSIZE := ReadInteger(_Data,BuffSize,_prop_BuffSize);//число выборок на буфер|29: CAPTURESIZE := BLKSIZE*2;|45: Bits := ReadInteger(_Data,Bit,_prop_Bit);|50: wf.wFormatTag := WAVE_FORMAT_PCM;//Waveformex|64: wf.nChannels := ReadInteger(_Data,Channels,_prop_Channels);|29: wf.nSamplesPerSec := Fs;|31: wf.wBitsPerSample := Bits;|95: wf.nBlockAlign := wf.nChannels*(wf.wBitsPerSample div 8);//Размер буфера на семпл в байтах|60: wf.nAvgBytesPerSec := wf.nSamplesPerSec*wf.nBlockAlign;|19: wf.cbSize :=0;|32: //Структура DSCaptureBuffer|34: dscbd.dwSize :=SizeOf(dscbd);|45: dscbd.dwFlags := {0}DSCBCAPS_WAVEMAPPED;|55: dscbd.dwBufferBytes := wf.nBlockAlign*CAPTURESIZE;|76: CaptureBytes := dscbd.dwBufferBytes div 2;//Размер единичного подбуфера|30: dscbd.lpwfxFormat := @wf;|70: dsc.CreateCaptureBuffer(dscbd,dscb,nil); //Создание буфера записи|38: //Описание вторичного буфера PLAY|33: dsbd.dwSize := SizeOf(dsbd);|126: dsbd.dwFlags := DSBCAPS_GLOBALFOCUS or DSBCAPS_GETCURRENTPOSITION2 or DSBCAPS_CTRLPOSITIONNOTIFY or DSBCAPS_LOCSOFTWARE ;|47: dsbd.dwBufferBytes := dscbd.dwBufferBytes;|29: dsbd.lpwfxFormat := @wf;|27: //Буфер первичный PLAY|33: dspb.dwSize := SizeOf(dspb);|43: dspb.dwFlags := DSBCAPS_PRIMARYBUFFER;|51: dspb.dwBufferBytes := 0;//dscbd.dwBufferBytes;|35: dspb.lpwfxFormat := nil;//@wf;|50: ds.SetCooperativeLevel(Me,DSSCL_WRITEPRIMARY);|79: err:=ds.CreateSoundBuffer(dspb,dspb1,nil);//Создание первичного буфера PLAY|24: dspb1.SetFormat(wf);|46: ds.SetCooperativeLevel(Me,DSSCL_PRIORITY);|72: ds.CreateSoundBuffer(dsbd,dsb,nil);//Создание вторичного буфера PLAY|21: //QueryInterface(|59: err := dsb.QueryInterface(IID_IDirectSoundNotify, dsn);|20: //События записи|64: Evt[0]:= CreateEvent(nil,False,False,nil);//создание событий|46: Evt[1]:= CreateEvent(nil,False,False,nil);|25: with EVNT[0] do begin|28: hEventNotify := Evt[0];|47: dwOffset := (dscbd.dwBufferBytes div 2)-1;|8: end;|25: with EVNT[1] do begin|28: hEventNotify := Evt[1];|41: dwOffset := dscbd.dwBufferBytes - 1;|8: end;|48: err := dsn.SetNotificationPositions(2,EVNT);|34: dscb.Start(DSCBSTART_LOOPING);|36: dspb1.Play(0,0,DSBPLAY_LOOPING);|34: dsb.Play(0,0,DSBPLAY_LOOPING);|18: start := true;|28: _hi_OnEvent(onStream);|6: end;|0:|61: procedure THiAsmClass.doStart(var _Data:TData; Index:word);|12: Label M1;|22: const k:integer= 0;|19: var err:integer;|40: Offset1,Offset2,Byt1,Byt2: DWord;|8: begin|27: if start=true then begin|42: Offset1 := 0; Offset2 := CaptureBytes;|36: Byt2 := 0; Byt1 := CaptureBytes;|42: M1:WaitForSingleObject(Evt[0],INFINITE);|10: begin|60: dscb.Lock(Offset1,CaptureBytes,Ptr1,Byt1,Ptr2,Byt2,0);|37: move(Ptr1^,RBuff,CaptureBytes);|46: err := dscb.Unlock(Ptr1,Byt1,Ptr2,Byt2);|59: dsb.Lock(Offset1,CaptureBytes,Ptr1,Byt1,Ptr2,Byt2,0);|37: //Сюда можно воткнуть обработку|39: //move(RBuff,PBuff,CaptureBytes);|37: move(PBuff,Ptr1^,CaptureBytes);|45: err := dsb.Unlock(Ptr1,Byt1,Ptr2,Byt2);|32: _hi_OnEvent(onStream,err);|9: end;|41: WaitForSingleObject(Evt[1],INFINITE);|10: begin|60: dscb.Lock(Offset2,CaptureBytes,Ptr1,Byt1,Ptr2,Byt2,0);|37: move(Ptr1^,RBuff,CaptureBytes);|46: err := dscb.Unlock(Ptr1,Byt1,Ptr2,Byt2);|59: dsb.Lock(Offset2,CaptureBytes,Ptr1,Byt1,Ptr2,Byt2,0);|37: //Сюда можно воткнуть обработку|39: //move(RBuff,PBuff,CaptureBytes);|37: move(PBuff,Ptr1^,CaptureBytes);|45: err := dsb.Unlock(Ptr1,Byt1,Ptr2,Byt2);|28: _hi_OnEvent(onStream);|9: end;|12: Goto M1;|7: end;|7: end;|0:|61: procedure THiAsmClass.doStop(var _Data:TData; Index:word);|9: begin|28: if start=true then begin|20: start := false;|14: dsb.Stop;|15: dscb.Stop;|25: CloseHandle(Evt[0]);|25: CloseHandle(Evt[1]);|54: //ds.QueryInterface(IID_IDirectSoundBuffer, dsb);|42: //if Assigned(dsb) then dsb._Release;|18: dsn._Release;|23: pointer(dsn):=nil;|18: dsb._Release;|23: pointer(dsb):=nil;|20: dspb1._Release;|25: pointer(dspb1):=nil;|19: dscb._Release;|24: pointer(dscb):=nil;|18: dsc._Release;|23: pointer(dsc):=nil;|17: ds._Release;|22: pointer(ds):=nil;|8: end;|8: end;|0:|36:function THiAsmClass._Count:integer;|5:begin|26: Result := CaptureBytes;|4:end;|0:|65:function THiAsmClass._Get(Var Item:TData; var Val:TData):boolean;|16:var ind:integer;|5:begin|27: ind := ToIntIndex(Item);|29: Val.data_type := data_int;|27: Val.idata := RBuff[ind];|4:end;|0:|58:procedure THiAsmClass._Set(Var Item:TData; var Val:TData);|20:var ind,tb1:integer;|5:begin|27: ind := ToIntIndex(Item);|25: tb1 := ToInteger(Val);|21: PBuff[ind] := tb1;|4:end;|0:|59:procedure THiAsmClass._Set1(Var Item:TData; var Val:TData);|20:var ind,tb1:integer;|5:begin|27: ind := ToIntIndex(Item);|25: tb1 := ToInteger(Val);|21: RBuff[ind] := tb1;|4:end;|0:|56:procedure THiAsmClass.ArrI(var _Data:TData; Index:word);|5:begin|19: if Arr = nil then|45: Arr := CreateArray(_Set1,_Get,_Count,nil);|32: _data.data_type := data_array;|30: _data.idata := integer(Arr);|4:end;|0:|56:procedure THiAsmClass.ArrO(var _Data:TData; Index:word);|5:begin|20: if Arr1 = nil then|44: Arr1 := CreateArray(_Set,nil,_Count,nil);|32: _data.data_type := data_array;|31: _data.idata := integer(Arr1);|4:end;|0:|4:end.| link(onStream,7022377:doFor,[(309,188)(309,300)]) link(Channels,4517215:Value,[(265,160)(146,160)]) link(Freq,11719795:Value,[(272,142)(265,142)]) link(BuffSize,13976584:Value,[(279,142)(335,142)]) link(Bit,15429536:Value,[(286,158)(398,158)]) link(Handle,9088580:Handle,[(293,131)(41,131)]) } Add(Button,2647402,35,182) { Left=15 Top=20 Caption="START" link(onClick,12265634:doEvent1,[]) } Add(Memory,11719795,259,70) { Default=Integer(44100) } Add(Memory,4517215,140,77) { Default=Integer(2) } Add(Memory,13976584,329,70) { Default=Integer(4096) } Add(Memory,15429536,392,70) { Default=Integer(16) } Add(LED,6336510,385,182) { Left=210 Top=130 } Add(Hub,12265634,98,182) { link(onEvent1,3368900:doOpen,[]) link(onEvent2,11664451:doStart,[(159,195)(159,216)]) } Add(ListBox,2832319,448,175) { Left=385 Top=15 Width=100 Height=240 } Add(Button,9502863,35,252) { Left=15 Top=65 Caption="STOP" link(onClick,2714028:doEvent1,[]) } Add(Thread,11664451,182,210) { Delay=100 FastStop=0 Point(doStopFlag) link(onExec,3368900:doStart,[(231,216)(231,195)]) } Add(For,7022377,322,294) { End=8191 link(onEvent,1997322:doEvent1,[]) link(onStop,6336510:doChangeValue,[(369,307)(369,188)]) } Add(ArrayRW,1897685,469,294) { link(Array,3368900:ArrI,[(475,258)(265,258)]) link(Index,4912597:Data2,[(482,272)(425,272)(425,401)(335,401)]) } Add(GetData,4912597,322,350) { link(Data,7022377:Position,[]) } Add(Hub,1997322,385,294) { link(onEvent1,1897685:doRead,[]) link(onEvent2,1727254:doWrite,[(438,307)(438,377)]) } Add(ArrayRW,1727254,455,364) { link(Array,3368900:ArrO,[(461,337)(272,337)]) link(Index,4912597:Data1,[(468,354)(405,354)(405,392)(328,392)]) link(Value,1897685:Item,[]) } Add(Hub,2714028,84,252) { link(onEvent1,3368900:doStop,[(247,258)(247,202)]) link(onEvent2,11664451:doStop,[(156,265)(156,223)]) }
|