funssun@hotmail.com
QQ:313482884
const
AudioFormatPCM1M8:tWAVEFORMATA =(wFormatTag:WAVE_FORMAT_1M08;nChannels:$0001;nSamplesPerSec:$00002B11;nAvgBytesPerSec:$00002B11;nBlockAlign:$0008;wBitsPerSample:$0008;cbSize:$0002;UserData
$40, $01, $00, $00,$00, $00, $00, $00,$00, $00, $00, $00,$00, $00, $00, $00,$00, $00, $00, $00,$00, $00, $74, $B4,$44, $00, $F8, $6C,$CD, $00, $44, $10)) ;
AudioFormatPCM1S8:tWAVEFORMATA =(wFormatTag:WAVE_FORMAT_1M08;nChannels:$0002;nSamplesPerSec:$00002B11;nAvgBytesPerSec:$00005622;nBlockAlign:$0008;wBitsPerSample:$0008;cbSize:$0002;UserData
$40, $01, $00, $00,$00, $00, $00, $00,$00, $00, $00, $00,$00, $00, $00, $00,$00, $00, $00, $00,$00, $00, $74, $B4,$44, $00, $F8, $6C,$CD, $00, $44, $10)) ;
AudioFormatPCM1M16:tWAVEFORMATA=(wFormatTag:WAVE_FORMAT_1M08;nChannels:$0001;nSamplesPerSec:$00002B11;nAvgBytesPerSec:$00005622;nBlockAlign:$0010;wBitsPerSample:$0010;cbSize:$0002;UserData
$40, $01, $00, $00,$00, $00, $00, $00,$00, $00, $00, $00,$00, $00, $00, $00,$00, $00, $00, $00,$00, $00, $74, $B4,$44, $00, $F8, $6C,$CD, $00, $44, $10)) ;
AudioFormatPCM1S16:tWAVEFORMATA=(wFormatTag:WAVE_FORMAT_1M08;nChannels:$0002;nSamplesPerSec:$00002B11;nAvgBytesPerSec:$0000AC44;nBlockAlign:$0010;wBitsPerSample:$0010;cbSize:$0002;UserData
$40, $01, $00, $00,$00, $00, $00, $00,$00, $00, $00, $00,$00, $00, $00, $00,$00, $00, $00, $00,$00, $00, $74, $B4,$44, $00, $F8, $6C,$CD, $00, $44, $10)) ;
function TACMDevice.GetFormat ;
begin
case FWaveFormat.wFormatTag of
GSM_FORMAT_610:Result := GSM610 ;
WAVE_INVALIDFORMAT:Result := 'invalid format' ;
WAVE_FORMAT_1M08:
case FWaveFormat.nChannels of
1 : case FWaveFormat.nAvgBytesPerSec of
8000 : Result := PCM8M8 ;
16000 : Result := PCM8M16 ;
else Result := PCM1M8 ;
end ;
2 : case FWaveFormat.nAvgBytesPerSec of
16000 : Result := PCM8S8 ;
32000 : Result := PCM8S16 ;
end ;
end ;
WAVE_FORMAT_1S08:Result := PCM1S8 ;
WAVE_FORMAT_1M16:Result := PCM1M16 ;
WAVE_FORMAT_1S16:Result := PCM1S16 ;
WAVE_FORMAT_2M08:Result := PCM2M8 ;
WAVE_FORMAT_2S08:Result := PCM2S8 ;
WAVE_FORMAT_2M16:Result := PCM2M16 ;
WAVE_FORMAT_2S16:Result := PCM2S16 ;
WAVE_FORMAT_4M08:Result := PCM4M8 ;
WAVE_FORMAT_4S08:Result := PCM4S8 ;
WAVE_FORMAT_4M16:Result := PCM4M16 ;
WAVE_FORMAT_4S16:Result := PCM4S16 ;
else Result := 'Unknown Wave Format.' ;
end ;
end ;
procedure TACMDevice.SetFormat ;
var
MaxSizeFormat : longint ;
procedure Change(Value:tWAVEFORMATA) ;
begin
FWaveFormat:= Value ;
Update ;
end ;
begin
Value := UpperCase(Value) ;
if Value=''
then begin
acmMetrics(0, ACM_METRIC_MAX_SIZE_FORMAT, MaxSizeFormat);
fc.cbStruct := sizeof(fc);
fc.cbWfx := MaxSizeFormat;
fc.pwfx := @FWaveFormat ;
fc.fdwStyle:=ACMFORMATCHOOSE_STYLEF_INITTOWFXSTRUCT; //use the pwfx(waveformatex structure) as default
//display the ACM dialog box
if acmFormatChoose(fc)=MMSYSERR_NOERROR then Update ;
end
else if Value=PCM8M8
then Change(AudioFormatPCM8M8)
else if Value=PCM8S8
then Change(AudioFormatPCM8S8)
else if Value=PCM8M16
then Change(AudioFormatPCM8M16)
else if Value=PCM8S16
then Change(AudioFormatPCM8S16)
else if Value=GSM610
then Change(AudioFormatGSM8K) ;
end ;