Giter VIP home page Giter VIP logo

Comments (11)

tdaede avatar tdaede commented on May 22, 2024 1

My first thought is that your buffer size of 4096 seems kind of small... with op_open_memory you're expected to give it the whole file.

from opus.

fredvs avatar fredvs commented on May 22, 2024

Hello.

Some more explanation:

===> The code (in Pascal):

PipeBufferSize := 4096;
Wantframes := 1024;
HandleOP := op_open_memory(Buffer_byte[0],PipeBufferSize, Err);
Outframes := op_read_float(HandleOP,@Buffer_float[0], Wantframes, nil);

The result:
===> Err = 0
===> Outframes = 0

(Part of) data of memory Buffer_byte:

OggS��s��T=����OpusHead����OggS�s����;����OpusTags�Encoded with GStreamer Opusenc��ALBUM=Summer 2016
ARTIST=Kungs DATE=2016�DESCRIPTION=Loop Guitar.
GENRE=Dance�TITLE=guit_kungs.opusOggS�C�s���粫,���������������������
��6.)'�"@����uR���׼�e�A��+���&j}�����h1P� ���d��F����Ȱ(�x3K�.�M9W���t����!����R��/��i5�h���DH�U54��%
�$cĶ4Z�e���K����l̾q�i�(5����e�E�+��b�z��=
�kɡ)ډf�{s������9U����y��QX.Y!�Āz(��^a�G-K���Xް�s����Rh3SeZ��������_Ce���a���H7�o��0���c<����X�" p��
rsC���l;X|���0a>-���p�4���m��r'���$�L��@�#�g���Y��\��F�f�E;D�C3u��'�t����o�4�uF�J�W/!-���FC�)V��%S}��fL�4�x��P�U�I�\k��
Z�$�=���
�!4�ǁa6�L���X�.ep��B}�y>�4\Щ8��da?���5���G����#wn�h-0p!;K� �8��d����a���t�u�S� (f;�t�����:ȝ�6������r~o=Ӭo�AMg��gO�T���������xfNO��v.�6h�&�ݖM���1��K����5�LZҥ8��R���\��+T���Č�һ"w\˛��׈��������3&k�^�s�G �Kl6n�'p�;LH5wwOO� 3*��KP�cdI/���n�IƤ"����x�MQ��Z��v�v+y�]�ۍ0������F�@��7BL�<����Y@����%�a��C�,6���N}�}��0�Ř ���n�϶�r�����������>�tj��gV���#s rh����~�#��v����K6��j�oi �[���L�G���6��������NM_@�C��9�lp+�%�����+ٞA.���;�n6��{�F��Z�t���F��a������L�5{���@�f �C������r������h���[�l��2�7w�����"���N��i;t��J빀���h?/�s@�ط��x��9�7�� فF;��Űle}xٝx� �E�� uТ.��!NQ�%�g�;�A3�(���zy���F���������?�T]��I�4�+v��G4ɚ������"҅zo�F��� ���mm݌^�ǀh��M2
��v�,&�Vm�"t�����W�O�����k
��M�CZC�����a��
�{(k�r��I�����4�U*�|WV����nn��O2k$�����"��������=��L�%
�VVu�[*74��ۊ�
9�������mu��������A�m��a�������q��Kk.��N�p��|��b0�� ��'�K�
*���,&����lC�%�\���̲Qq�or�F:�3pV.9G�J������������s�]t���� �̩��G7���#&��
�e������ɒŧ�a��>�T

Fre;D

from opus.

fredvs avatar fredvs commented on May 22, 2024

Hello and thanks to answer.

with op_open_memory you're expected to give it the whole file.

Ha, but for internet streaming, only a buffer will be given.
I have try with > 4k ==> same result : outframes = 0.

IMO, it seems that Buffer_byte entered in op_open_memory :

HandleOP := op_open_memory(Buffer_byte,PipeBufferSize, Err);

That Buffer_byte is not used in HandleOP:

outframes := op_read_float(HandleOP, at Buffer[0], Wantframes, nil);

Thanks.

Fre;D

from opus.

fredvs avatar fredvs commented on May 22, 2024

My first thought is that your buffer size of 4096 seems kind of small..

Ooops, wait, I try just now with buffer size of 32768 and... =>

Outframes = 960 => part of Buffer_float :

OUTPUT DATA AFTER ------------------------------
|1.497329258E-15|7.976823725E-16|1.053572953E-14|1.416983206E-14|4.160564173E-14|5.061418271E-14|1.145734169E-13|1.031588823E-13|2.113849731E-13|1.950407067E-13|3.359531891E-13|3.398339552E-13|4.791735585E-13|5.920528824E-13|6.257254372E-13|9.335471849E-13|7.733262815E-13|1.188091509E-12|9.587536928E-13|1.484348885E-12|1.224514088E-12|1.695904051E-12|1.727135795E-12|1.562433668E-12|2.427822917E-12|1.295814259E-12|2.721563643E-12|1.122110326E-12|2.970792232E-12|1.62301856E-12|3.838969073E-12|2.293267789E-12|4.843023985E-12|2.284443034E-12|5.548845671E-12|2.675828743E-12|6.294744673E-12|3.880955453E-12|8.067684541E-12|4.635028472E-12|1.00626044E-11|4.249789323E-12|1.125298726E-11|3.546743845E-12|1.26623009E-11

So, yes, there is some movement there ;-)

It is on the good way.

But why only 960 frames for buffer-in of 32768 bytes (maybe it is normal ?) ?

There is not yet sound, there is a arithmetic error with that buffer-out.

But there is great progress.

Of course, any comment is highly welcome.

@tdaede : many thanks, now I am full of hope to do Opus-web-streaming work for the Pascal community.

Fre;D

from opus.

rillian avatar rillian commented on May 22, 2024

Each call to op_read_*() will return one packet's worth of decoded data, 960 samples in this case. The API expects you to call op_read_float() in a loop so you can play the output, or do whatever else you want to as each piece of compressed data is decoded.

from opus.

fredvs avatar fredvs commented on May 22, 2024

Hello rillian.

Yep, yep, yep, I get (bad) sound but it will work, sure.

op_read_float() works like charm with op_open_file.

It will work also with op_open_memory.

OK, great, I begin to understand better how Opus work, now time to tune it.

Write you later with a perfect sound from a Opus-web_streamed file.

Fre;D

from opus.

fredvs avatar fredvs commented on May 22, 2024

Re-hello.

What is the ratio between ASize and length of BufferURL here ? :

HandleOP := op_open_memory(BufferURL, ASize , Err);

(if ASize = 100, length of BufferURL ⁼ ?)

And here, if ASize = 100, length of BufferFloat = ?, BSize = ?

op_read_float(HandleOP, BufferFloat, BSize, nil);

Many thanks.

Fre;D

from opus.

tdaede avatar tdaede commented on May 22, 2024

See documentation here: https://opus-codec.org/docs/opusfile_api-0.5/group__stream__open__close.html#gaffc5769a1e5977f186f77a1fb08cb248

It's the size of the file in bytes. It doesn't directly correlate with op_read_float, as the bitrate of the file may change.

If you want to do network streaming, you might want op_open_callbacks instead, which will call your application whenever you do an op_read_float but more input data is needed. Don't know how callbacks work with Pascal/Delphi, though. Also note that there's op_open_url, which will open and play from a HTTP stream for you.

from opus.

fredvs avatar fredvs commented on May 22, 2024

Hello.

I did try to use op_open_url but without success. Even adding methods for libopusurl.so (did not find h header with this). Also I prefer use my own code for streaming and have access to the pipe.

For op_open_callbacks, I try also but without luck, I will re-try.

Thanks for doc but I do not see the ratio between between ASize and length of BufferURL in

HandleOP := op_open_memory(BufferURL, ASize , Err);

Thanks.

Fre;D

from opus.

fredvs avatar fredvs commented on May 22, 2024

Hello.

Fixed !

The main problem was a ajustement of buffer size.

Perfect sound from https Opus file.

Many thanks.

Fre;D

from opus.

rillian avatar rillian commented on May 22, 2024

Glad you got it working!

from opus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.