WAV-Files //-// Input/Output Support

I don’t know what happened, but in the new project there is no distortion in the negative wave. Another problem was discovered: when reading in QSpice, values ​​​​float and create noise, they can be seen in the pictures when zoomed in and heard when listening to a file recorded with QSpice, there is no such problem in LTspice. This is quite a big problem, because… noises are introduced that are not there. I don’t know where the problem is in the reader module or in QSpice itself. Project WavIO_readable.zip in the same link.

A friend gave corrections, it works without artifacts.

There is no explicit management of buffers in the code, which can lead to data loss or corruption when reading or writing. Each time a different number of samples is read and, accordingly, written. As a result, the output file with sample loss becomes shorter and visually appears to be compressed in time, but the problem is the cumulative effect of sample loss. My wav file is 190 second length, I ended up missing 3373 samples. but each time the number of recorded samples is different, and therefore the losses are different, but they are significant.

Hi, Denis.T.

I’ve uploaded revised source and *.dll’s to the dev branch of the GitHub repository.

  • Changed the normalization factor from 0x7fffff to 0x800000. (I’m not convinced that this is correct but we’ll see.)
  • Fixed the sign-extension issue for 24-bit samples.
  • Corrected issues in WavSrc sample timing. This should fix “dropped samples” and noise beyond single-bit rounding/conversion errors.
  • Added more detail to the information in the QSpice Output window.

The WavIO_Demo.qsch output file will have an extra sample prepended in the WAV data. That is expected and we’ll deal with that later after other issues, if any remain, are resolved.

The last bit about “no explicit management of buffers in the code.” I think this a misunderstanding related to C-Block components and is fixed in the third bullet above.

Anyway, please give it another thorough testing.


1 Like

Hello Robert!
The artifacts remained, but the number of lost samples increased.

Well, I need to be able to reproduce what you’re seeing. Does the problem occur with my sample *.wav files? With the WavIO_Demo.qsch?

If not, I need copies of your *.qsch and *.wav and details about exactly how to produce your results.


All files and the project are located in the link that I gave, you need to run the project for a time equal to the time of the input file, then compare the sizes of the output and input files accurate to the sample.

A gentle reminder: When seeking assistance, it’s generally beneficial to follow a general approach to problem resolution. This involves clearly describing the issue, providing step-by-step instructions to replicate the problem, and including only the necessary files for replication. Overwhelming someone with a folder containing all files can make it challenging for those who are eager to offer support, as it requires a significant amount of time to fully comprehend the situation.

Additionally, it’s worth noting that Robert, much like the rest of us, is simply a community member who graciously volunteers their time and expertise to assist others out of their own passion for supporting the community.


All information has already been provided in earlier messages. Input a 24-bit 48 kHz file with any signal, even a sine wave lasting a couple of minutes, and compare the number of samples at the end, there should be no differences. At this rate, finding out the cause will take several months.

OK, Denis.T, I’ve investigated further.

  • Your wavin_2448.wav file is approximately 25.205 seconds long.
  • Your WavIO_Test.qsch shows that you are running the sim for 26s.
  • I ran the current version of the code (as posted on the repo) for 26s.
  • The QSpice output window reported the following:
WavOut v0.3 (@237) Creating WAV file "./wav_samples/wavout_2448.wav" with 24 bits/sample and 48000 samples/second.
WavSrc v0.3 (@211) Reading WAV file "./wav_samples/wavin_2448.wav", loops=1, gain=1.000000
WavSrc v0.3 (@354) WAV Metadata: # of Channels=1, Bit Depth=24, Sample Rate=48000Hz, # of Samples=1209818

Total elapsed time: 8.05392 seconds.
WavOut v0.3 (@286) Closing WAV file.  1248001 samples written.
WavSrc v0.3 (@193) Closing WAV file.

I’ve not done a byte-by-byte comparison of the files so there may, indeed, be “rounding errors” in amplitude. However, I have looked at your input file and the WavIO output file in Audacity. They appear to be identical to me other than a one-sample delay at the start and trailing samples at the end.

Gee, Denis.T, I’m sorry that this free software development isn’t moving fast enough for you. If you give me the details that I’ve asked for – the specific problems in a reproducible fashion – it will go faster.

I look forward to those details.


nam_2448.wav is 3 minutes 12 seconds long, use it.
There is a very big difference in the latest version.

OK, Denis.T. I think that I’ve found an issue. Working on it…


1 Like


I’ve completely reworked the components to work around a possible QSpice issue. Please download the code/DLLs from the dev branch again and verify that we’re getting closer.

Note that there is a sample-time-shift between input and output and amplitudes may differ by +/-one bit due to rounding. But you should no longer see the lost sample issue.


1 Like

Thanks Robert!
Now it works fine, but there is a shift by 2 samples, maybe it will be possible to do it programmatically in the next adjustment? And I would like to make a parameter for the number of channels in the output file 1 or 2.