PortAudio / portaudio

PortAudio is a cross-platform, open-source C language library for real-time audio input and output.
Other
1.39k stars 291 forks source link

Implemented Int32_To_UInt8_Dither #841

Open ngoiyaeric opened 10 months ago

ngoiyaeric commented 10 months ago

Implemented a method to convert data from int32_To_UnInt8_Dither. Port audio did not offer 32bitTriangularDither so I used the available 16bitTriangularDither. Would like to know how to test this code and how to check if it is implemented correctly. The build for port audio works with these changes.

RossBencina commented 10 months ago

Thanks for this. I'm not sure that you have the dither scaling factor correct, could you provide a rationale please? Looking at the docs for PaUtil_Generate16BitTriangularDither we think maybe:

PaInt32 result = ((*src >> 1) +  (dither << 8));
result = (result >> 23) + 128;

But please could you check this for yourself.

The following tests are present, not sure whether they are sufficient:

ngoiyaeric commented 10 months ago

Hi, thanks for the corrections. I made the code changes you have suggested. What dynamic range code should I expect after running test/patest_converters for the i32 to ui8 conversions, what logic should I use to generalize this indicator across various conversion tests.

RossBencina commented 9 months ago

What dynamic range code should I expect after running test/patest_converters for the i32 to ui8 conversions

Same as other ui8 conversions I guess.

Could you paste the output of this test here please and we'll scratch our heads about it:

https://github.com/PortAudio/portaudio/blob/master/test/patest_converters.c

ngoiyaeric commented 9 months ago

What dynamic range code should I expect after running test/patest_converters for the i32 to ui8 conversions

Same as other ui8 conversions I guess.

Could you paste the output of this test here please and we'll scratch our heads about it:

https://github.com/PortAudio/portaudio/blob/master/test/patest_converters.c

Hi, When I run this command gcc -l/portaudio/src/common/ patest_converters.c -o your_output_executable -lm -lportaudio to test the module, I get this error. patest_converters.c:53:10: fatal error: 'pa_converters.h' file not found

include "pa_converters.h"

     ^~~~~~~~~~~~~~~~~

1 error generated.

Any Ideas how I could fix it?

dmitrykos commented 9 months ago

@ngoiyaeric it depends on how src/common folder is related to the path from which you are running GCC build command. If you are running GCC build from inside portaudio folder then it would be -Isrc/common, if from outside but portaudio folder is not in the root of the storage then -Iportaudio/src/common and so on.

ngoiyaeric commented 9 months ago

@ngoiyaeric it depends on how src/common folder is related to the path from which you are running GCC build command. If you are running GCC build from inside portaudio folder then it would be -Isrc/common, if from outside but portaudio folder is not in the root of the storage then -Iportaudio/src/common and so on.

hi, this does not remedy the issue, the same error is still thrown.

dmitrykos commented 9 months ago

@ngoiyaeric in any case GCC is struggling to locate pa_converters.h in your build configuration, it is the only reason. To avoid dealing with compiler configuration directly you could try building patest_converters via CMake generated build project.

dmitrykos commented 7 months ago

@ngoiyaeric have you managed to test your implementation? Also this commit (https://github.com/PortAudio/portaudio/pull/841/commits/273c99101954004ff01f93d5f50423b379c21bed) has to be removed from PR.