• WANTED: Happy members who like to discuss audio and other topics related to our interest. Desire to learn and share knowledge of science required. There are many reviews of audio hardware and expert members to help answer your questions. Click here to have your audio equipment measured for free!

The 1 euro HDMI input solution for your next DIY DAC

phofman

Addicted to Fun and Learning
Joined
Apr 13, 2021
Messages
502
Likes
326
I am afraid I got lost in your commands.

Ad sox: the -n parameter is used when either input source (device or file)or output sink (device or file) is missing, like when generating a signal (-n instead of input) or when generating spectrum/stats of the signal (-n instead of the output specs). Your commands seem to mix -n into existing input/output chain.

If you play a pre-generated wav, there is no need to put trim 0.0 100.0 dcshift 0.0. I used that for generating the dc-shifted constants which produce a constant pattern of bits in every sample in the I2S data stream.
 
  • Like
Reactions: MCH
OP
M

MCH

Major Contributor
Joined
Apr 10, 2021
Messages
2,658
Likes
2,266
I am afraid I got lost in your commands.

Ad sox: the -n parameter is used when either input source (device or file)or output sink (device or file) is missing, like when generating a signal (-n instead of input) or when generating spectrum/stats of the signal (-n instead of the output specs). Your commands seem to mix -n into existing input/output chain.

If you play a pre-generated wav, there is no need to put trim 0.0 100.0 dcshift 0.0. I used that for generating the dc-shifted constants which produce a constant pattern of bits in every sample in the I2S data stream.
thanks for the indications. Was my first time using sox, just copied your example and adapted it to my needs. I repeated the captures changing what was wrong. The captures of the i2s signal are identical when playing the tones (indicating 24 bits i guess). The outcome of sox now is the following:

marcosch@raspcamilla2:~$ sox ~/1kHz192kHz32bstereo.wav -V -r 192000 -c 2 -b 32 -t alsa hdmi:vc4hdmi0 gain -160
sox: SoX v14.4.2
sox INFO formats: detected file format type `wav'

Input File : '/home/marcosch/1kHz192kHz32bstereo.wav'
Channels : 2
Sample Rate : 192000
Precision : 32-bit
Duration : 00:01:00.00 = 11520000 samples ~ 4500 CDDA sectors
File Size : 92.2M
Bit Rate : 12.3M
Sample Encoding: 32-bit Signed Integer PCM
Endian Type : little
Reverse Nibbles: no
Reverse Bits : no


Output File : 'hdmi:vc4hdmi0' (alsa)
Channels : 2
Sample Rate : 192000
Precision : 32-bit
Duration : 00:01:00.00 = 11520000 samples ~ 4500 CDDA sectors
Sample Encoding: 32-bit Signed Integer PCM
Endian Type : little
Reverse Nibbles: no
Reverse Bits : no

sox INFO sox: effects chain: input 192000Hz 2 channels
sox INFO sox: effects chain: gain 192000Hz 2 channels
sox INFO sox: effects chain: output 192000Hz 2 channels
In:100% 00:01:00.00 [00:00:00.00] Out:11.5M [ | ] Clip:0
Done.
 

gordoste

Member
Joined
Nov 19, 2023
Messages
32
Likes
25
Just reading the thread, it seems possible that it's not actually I2S data - perhaps a different format or something else entirely. I would recommend using a chip with a datasheet...
 

phofman

Addicted to Fun and Learning
Joined
Apr 13, 2021
Messages
502
Likes
326
@MCH :

You command "sox ~/1kHz192kHz32bstereo.wav -V -r 192000 -c 2 -b 32 -t alsa hdmi:vc4hdmi0 gain -160" means some wav gets attenuated by 160dB. But I do not know what that wav actually contains.

IMO better way would be generating the signal directly, having equal value in each sample so that you can see params of your transmission channel right away in your scope/analyzer

Like:
sox -V -r 192000 -c 1 -n -c 2 -b 32 -t alsa hdmi:vc4hdmi0 trim 0 1000 dcshift 1 gain -186

This makes sox generate from start 1000 seconds of zeros (trim 0 1000), dcshifted to 1 (i.e. all samples ffff), then attenuated down to the 32nd bit. Your scope/analyzer would show one bit every sample, if your transmission is 32-bit wide.

For checking the bits limit just leave out the gain and check how many ones are there in each sample (should be 24 instead of 32). Or change the dcshift to generate only the 24th LSB (it's easier to calculate the dcshift value (1/ 2^23) than the required gain dbs which have some imprecision caused by the logs calculation):

sox -V -r 192000 -c 1 -n -c 2 -b 32 -t alsa hdmi:vc4hdmi0 trim 0 1000 dcshift 0.0000001192


1704715369079.png


In all cases you should get stable I2S data values, every sample in both channels identical.
 
OP
M

MCH

Major Contributor
Joined
Apr 10, 2021
Messages
2,658
Likes
2,266
@MCH :

You command "sox ~/1kHz192kHz32bstereo.wav -V -r 192000 -c 2 -b 32 -t alsa hdmi:vc4hdmi0 gain -160" means some wav gets attenuated by 160dB. But I do not know what that wav actually contains.

IMO better way would be generating the signal directly, having equal value in each sample so that you can see params of your transmission channel right away in your scope/analyzer

Like:
sox -V -r 192000 -c 1 -n -c 2 -b 32 -t alsa hdmi:vc4hdmi0 trim 0 1000 dcshift 1 gain -186

This makes sox generate from start 1000 seconds of zeros (trim 0 1000), dcshifted to 1 (i.e. all samples ffff), then attenuated down to the 32nd bit. Your scope/analyzer would show one bit every sample, if your transmission is 32-bit wide.

For checking the bits limit just leave out the gain and check how many ones are there in each sample (should be 24 instead of 32). Or change the dcshift to generate only the 24th LSB (it's easier to calculate the dcshift value (1/ 2^23) than the required gain dbs which have some imprecision caused by the logs calculation):

sox -V -r 192000 -c 1 -n -c 2 -b 32 -t alsa hdmi:vc4hdmi0 trim 0 1000 dcshift 0.0000001192
Ok all good, i will try to do that when i have some time. Fyi, the wav i was using contain tones (1 kHz and the last one 3 kHz) generated in Audacity

In all cases you should get stable I2S data values, every sample in both channels identical.
This has been the case so far in the tests i have done (see for instance the first capture in post #19).

Additionally, now that i already soldered two cables to the pins, i plan to solder the remaining two and the spdif out and try to capture with a soundcard and check in REW if it provides a clean signal. It will take me some time now the holidays are over.

thanks a lot for all the help.
 
Top Bottom