Jump to content

Skullcode

Members
  • Content Count

    35
  • Joined

  • Last visited

Everything posted by Skullcode

  1. 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
  2. Its really helpful And useful thank you very much
  3. 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
  4. 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?
  5. 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
  6. 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
  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. is this a correct way to check if the Twsocket client is connected ? if wsocket1 .State = wsConnected then //do something
  9. 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
  10. 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);
  11. 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));
  12. 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
  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

    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
  15. 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 ?
  16. i have created two Forms Form 1 Form 2 each form has TWebBrowser Control now i have a Gif that i call its name Foo.gif <img src="Foo.gif" border="0" /> when i load this image in form1 TWebBrowser its animated normally . when i load it in Form2 TWebBrowserit doesn't animated i am Adding this gif once at run Time To each form when form Created also i notice that this happened if the gif that i try to load to another TWebBrowser have the same name so if i load foo.gif in form1 it will animate in form1 hence when loaded to Form2 TWebBrowser and it got the same name of the previously loaded one it doesn't animate in Form2 TWebBrowser any idea why this behavior happened ?
  17. 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
  18. Skullcode

    TWebBrowser very Weird Behavior with Gif images

    Any one tested and get same results? Is it a bug with twebbrowser itself?
  19. Skullcode

    Tbutton Flashing

    can i have flashwindow effect to be applied on a VCL Tbutton Control ?
  20. Skullcode

    TWebBrowser very Weird Behavior with Gif images

    another example with Twebbrowser it cause same result the gif is included you can place it where the exe located webbrowser example.zip
  21. Skullcode

    TWebBrowser very Weird Behavior with Gif images

    this is a minimal example for better understanding webbrowser example.zip
  22. Skullcode

    check if App Minimized

    when i minimize My Vcl Application i do the following check in a Timer if WindowState = wsMinimized then begin //do some logging end; but this if condition doesn't detect whether the app is Minimized or not any idea how to detect if the app Minimized ?
  23. Skullcode

    Form border Style bsNone Covers taskbar

    i have a form with bsNone borderStyle when i execute WindowState := wsMaximized; the taskbar became totally covered how can i avoid that ?
  24. is there any way to read the microphone volume and sound output volume ? in windows 10 the microphone level property is a range from 0 To 100 also the sound level is a range from 0 to 100 how can i read that ?
  25. Skullcode

    Twsocket Tcp Client miss some packets

    i am using Twsocket as a TcpClient to communicate with a tcpserver the server sends a packet in loop that should be received by the connected Client but Twsocket doesnt read all packets that sent by the server it reads one and miss another and read again and miss one again . is it a normal behavior by Twsocket ? i tested with TidtcpClient and it reads all packets normally no matter what
×