Bug 1639 - I2S decoder wav file output issues
Summary: I2S decoder wav file output issues
Status: CONFIRMED
Alias: None
Product: libsigrokdecode
Classification: Unclassified
Component: PD: i2s (show other bugs)
Version: unreleased development snapshot
Hardware: All All
: Normal major
Target Milestone: ---
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-11-15 18:45 CET by Barabas Raffai
Modified: 2020-11-15 18:45 CET (History)
0 users



Attachments
pulseview session file, example exports (old is without patch, new is with), patch files (8.08 KB, application/zip)
2020-11-15 18:45 CET, Barabas Raffai
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Barabas Raffai 2020-11-15 18:45:03 CET
Created attachment 700 [details]
pulseview session file, example exports (old is without patch, new is with), patch files

There are a couple of issues with the wav files output by the I2S decoder. Patch, example outputs and pulseview session are attached.

The signals in the session are 24-bits per sample, the DAC and ADC signals are similar, with silence on the left channel, and a (low quality) sine wave on the right.


The number of samples on the left and right channels can be off by one, which causes the following python code to fail:

import scipy.io.wavfile as wav
import matplotlib.pyplot as plt

rate, data = wav.read("minimal_old.wav")


ffmpeg also complains about the file when running e.g.:
ffmpeg -i minimal_old.wav -acodec pcm_f32le test.wav

This is fixed by waiting for a pair of samples before outputting anything.

Another issue is that the decoder doesn't handle data that is less than 32-bit properly. The MSBs are always 0. When opening the output in any program, the data will be completely wrong, because the sign bit of the original samples is now sitting in the middle of the 32-bit output, with 0s in front of it. This can be fixed by left-shifting the decoded data.