Jump to content


  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Its really helpful And useful thank you very much
  2. the component that i used to capture the microphone is http://www.lakeofsoft.com/ well try to create the encoder and the decoder outside of capture event usually i should use the encoder outside of the capture event the code i posted just to demonstrate how i use the wrapper
  3. i use this wrapper to encode/decode https://github.com/DelphiForAudio/delphi-opus-wrapper/blob/master/uLibOpus.pas here is what i am doing uses uLibOpus; const cFRAME_SIZE = 640; cSAMPLE_RATE = 16000; cCHANNELS = 1; cAPPLICATION = OPUS_APPLICATION_VOIP; cBITRATE = 500; cMAX_PACKET_SIZE = 1280; procedure TForm1.recDataAvailable(sender: unavclInOutPipe; data: Pointer; len: Cardinal); var encoder: TOpusEncoder; decoder: TOpusDecoder; OpusEncoded : Tbytes; OpusDecoded : Tbytes; frame_size : integer; nbBytes : integer; begin if (data <> nil) and (len > 0) then begin //// Opus Encode encoder := opus_encoder_create(cSAMPLE_RATE, cCHANNELS, cAPPLICATION, encoderError); try SetLength(OpusEncoded, cMAX_PACKET_SIZE); nbBytes := opus_encode(encoder, data^, cFRAME_SIZE, Pointer(OpusEncoded)^, cMAX_PACKET_SIZE); if nbBytes > 0 then begin SetLength(OpusEncoded, nbBytes); //udRecive.Send(OpusEncoded, Length(OpusEncoded)); end; finally opus_encoder_destroy(encoder); end; //// End encoder Opus ////decoder opus decoder := opus_decoder_create(cSAMPLE_RATE, cCHANNELS, encoderError); try SetLength(OpusDecoded, cMAX_PACKET_SIZE); frame_size := opus_decode(decoder, Pointer(OpusEncoded)^, Length(OpusEncoded), Pointer(OpusDecoded)^, cFRAME_SIZE, 0); SetLength(OpusDecoded, frame_size); ply.write(OpusDecoded, length(OpusDecoded)); finally opus_decoder_destroy(decoder); end; /// End decoder Opus end; the decoded sound is very noisy and choppy i think i am missing something or doing something wrong
  4. Skullcode

    Twsocket udp how to get the exact buffersize that received ? ?

    I am coming from a Java/Kotlin background using a UDP client in those platforms are different that's why I was really confused about receiving the event, the socket demo of ICS is very unorganized, for someone who doesn't have solid knowledge in Delphi As me, in other platforms a UDP client have a parameter in the receiving event That holds the bytes received and ready to use. I am reading each reply and I am trying to digest to understand better
  5. Skullcode

    Twsocket udp how to get the exact buffersize that received ? ?

    Thank you very much for clarification i do something like this now var OUR_MAX_UDP_BUFFER : integer; MBytes: TBytes; BytesReceived : integer; begin OUR_MAX_UDP_BUFFER := 4 * 1024; setLength(MBytes, OUR_MAX_UDP_BUFFER); BytesReceived := udRecive.Receive(MBytes, length(MBytes)); if BytesReceived > 0 then begin setLength(MBytes, BytesReceived); //use the Mbytes as it needed it is working but is what I am doing is correct? i am trying to handle it in a best way possible
  6. I am trying to receive some bytes that I have sent. but I am not able to specify the length of the byte since I do not know how to get the size of received bytes. currently, I do procedure TForm1.udReciveDataAvailable(Sender: TObject; ErrCode: Word); var MBytes: TBytes; begin setLength(MBytes, 0); udRecive.Receive(MBytes, length(MBytes)); but it always returns 0 length because I do set the length to 0 since I don't know how to set it to the exact length of the received Packet how do I know the exact length of the received packet to set it to the Mbytes variable?
  7. Skullcode

    how to use this wrapper of opus ?

    I have found this wrapper for opus encoding and decoding https://github.com/DelphiForAudio/delphi-opus-wrapper but I am confused on how to use it to encode/decode PCM audio data here is my PCM data coming from procedure TForm1.recDataAvailable(sender: unavclInOutPipe; data: Pointer; len: Cardinal); begin // I am not sure how to encode the data and its length using that wrapper // the example shows encoding decoding to wave files not directly to TBytes end;
  8. i use Twsocket as udp Client that is communicating with udpserver the server sends data in Bytes and the client should Receive This Data in Bytes as well i have tried the following based on what i see in the Demo Sample of OverbyteIcsUdpLstn Demo procedure TMainForm.WSocketDataAvailable(Sender: TObject; Error: Word); var aBytes : Tbytes; begin wsocket.Receive(aBytes, length(aBytes)); //... end; but this freezes the application and immediately crashed
  9. Skullcode

    converting this TidBytes code To Tbytes

    in my example i am stuck in sending those Bytes i am using Twsocket UDP that's what i do var ABytes: TBytes; EncodedBytes: TBytes; bytesHead : TBytes; baseaudio : string; begin baseaudio := 'Audio1'; SetLength(ABytes, len); Move(data^, ABytes[0], len); EncodedBytes := Encodeaudio(ABytes); SetLength(bytesHead, 6 + Length(EncodedBytes)); TEncoding.UTF8.GetBytes(baseaudio, 1, 6, bytesHead, 0); Move(EncodedBytes, bytesHead[6], Length(EncodedBytes)); wsocketudp.Send(bytesHead, Length(bytesHead)) when i send the data without adding header it sent just fine what is my Mistake ? the exception raised First chance exception at $004072A3. Exception class $C0000005 with message 'access violation at 0x004072a3: read of address 0x0bd600d8'. Process room.exe (5680) at this Line Move(EncodedBytes, bytesHead[6], Length(EncodedBytes));
  10. Skullcode

    converting this TidBytes code To Tbytes

    i already Converted the RawToBytes To Tbytes as i posted up there var Bytes: TBytes; SetLength(Bytes, len); Move(data^, Bytes[0], len); i am confused to do the copying line CopyTIdString('Audio1', Bytes, 0); CopyTIdBytes(RawToBytes(Buffer^, Buffersize), 0, Bytes, 6, Buffersize); CopyTidstring requires TidBytes
  11. Skullcode

    converting this TidBytes code To Tbytes

    i found this code in another forum var Bytes: TidBytes; Bytes := RawToBytes(data^, len); SetLength(Bytes, 6 + Buffersize); CopyTIdString('Audio1', Bytes, 0); CopyTIdBytes(RawToBytes(Buffer^, Buffersize), 0, Bytes, 6, Buffersize); any idea how to convert it To TBytes i am not sure how to assign the Pointer data and do the exact same things with copying string using Tbytes var Bytes: TBytes; SetLength(Bytes, len); Move(data^, Bytes[0], len);
  12. Skullcode

    this regex function gets unexpected results at some cases

    From where this dots came up it is no in the string i posted very weird
  13. i use this Regex function to check if the string have a Characters that I specify in the pattern on not Function CheckCharsinString(const astr: string):Boolean; var Regexs : TRegEx; i : integer; svalue : string; Allowed : string; begin svalue := Trim(astr); if Regexs.IsMatch(svalue, '^[ء-يA-Za-z0-9٠-٩⁰-⁹$™®©¤?@~<>«»✿❢•°،‘♔ہ¹ے;✧¢¯☆⊱٭✰❥¨.,’^*()%!\s-]+$') then begin Result := True; end else begin Result := False; end; end; when i check the following string CheckCharsinString('✿شـ❢ـوكـ❢ـ‏‏ Dan✿') it always Return False. it should return True sense all that chars i use is in regex pattern . what is my Mistake ?
  14. Skullcode

    Opus codec

    i am trying to build a voice communication app by sending a data from microphone to a Tcpserver and send it back to connected Clients i am looking for a component that can get a micrpohone audio input in bytes using opus codec in order to be able to send this data in real time . is there any known library in delphi VCL that can capture audio input data that encoded to opus codec ?
  15. Skullcode

    TWebBrowser very Weird Behavior with Gif images

    Yes its very weird i guess its a bug with twebbrowser on reading similar gif names in multiple instances