As a base I took the broadcaster and receiver samples.
Initially the LiveAudioRecorderData procedure just sends the buffer that is supplied.
I modified it as below.
targetformat is simply a TWaveStorage which has the GSM sample loaded.
- Code: Select all
procedure TMainForm.LiveAudioRecorderData(Sender: TObject;
const Buffer: Pointer; BufferSize: Cardinal; var FreeIt: Boolean);
var
I: Integer;
SrcFormat: TWaveFormatEx;
Data: Pointer;
DataSize: DWORD;
Data2: Pointer;
DataSize2: DWORD;
begin
FreeIt := True;
SetPCMAudioFormatS(@SrcFormat, LiveAudioRecorder.PCMFormat);
if ConvertWaveFormat(@srcFormat, Buffer, BufferSize,
targetformat.Wave.WaveFormat, Data, DataSize)
then edit4.text := 'yes'
else edit4.text := 'no';
if ConvertWaveFormat(targetformat.Wave.WaveFormat, Data, DataSize,
@srcFormat, Data2, DataSize2)
then edit5.text := 'yes'
else edit5.text := 'no';
edit6.Text := inttostr(DataSize);
edit7.Text := inttostr(DataSize2);
for I := tcpServer.Socket.ActiveConnections - 1 downto 0 do
with tcpServer.Socket.Connections[I] do
if Data = Self then // the client is ready
SendBuf(Data^, DataSize);
// SendBuf(Buffer^, BufferSize);
end;
When I select PCM 22Khz 8bit mono or 16 bit mono I see that the conversion goes well, edit 4 displays "yes".
Also converting it back works fine because edit5 will also display yes.
On the receiver sample I have also put a TWaveStorage with the exact same GSM sample wave file loaded.
However, using ConvertWaveFormat already returns false.
I did check the size of the data and the broadcaster send 455 bytes of data and that is also the amount I receive.
Is ConvertWaveFormat the best way to convert the buffer to GSM and back to PCM?
PS: I did read the README over and over, and I actually went through all 31 pages on this forum to look for answers.
Some people must have succeeded in this, the FRN client is the proof of that, but I can't figure out how to do it.
Can you give me some directions about correctly converting the buffer to GSM and back?
Thanks,
Mark.