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

Hello Everybody, Hello Qorvo Team, Hello Mr. Engelhardt,

i cut myself short:
Will there ever be any WAV support, like we were used to in "xx"spice from ADI?
I point to inputs as well as outputs.

Thanks for considering any answer.
Sincerely,
Johannes Herrmann (a great fan of Mike Engelhardt)
Leipzig, Germany

1 Like

Hi, Johannes.

Will the WavIO Components on my GitHub repo do what you need?

–robert

1 Like

Hello Robert,
Thanks for your reply. Out of bad experiences with third party addons, i am refusing those. This is nothing against you or your efforts. Its just my bad experience with badware.

Generally, i do not understand, why Mike implemented WAV support natively in LTSpice, but didn’t do so with QSpice. Generally i am of the opinion, that such I/O Support should be essential part of the main program. I -personally- think, this is no thing for 3rd Party Plugins.

Again: Nothing against your work - your effort. I really appreciate your answer.
Again: Its just may bad experience with dirty 3rd party plugins.

Maybe i will reconsider at some point in time, but right now i think i stick with ADI and ADI-Spice.
Sorry.

1 Like

Hi Robert!
I really liked QSpice, I had a great desire to switch to this platform, but I ran into a limitation for using wav - it is 16 bit, 24 bit is required. Will it be possible to expand?

Hi, Denis.T.

The source is provided and should be easy to revise. If you do, please share.

If you’re asking if I’ll do it, I can take a look. There are lots of possible formats. Maybe you can share a small file encoded in the format that you’re looking for.

–robert

Hello Robert!
Unfortunately, I am not a programmer and cannot correct the program. Link to the file that is processed in Spice
https://drive.google.com/file/d/1UYC7Nrssu6z1zU2sfXqDQKAFly6S0Jid/view?usp=sharing

I’ll take a look at it.

Before I go too far down the rabbit hole, do you really need 24-bit precision? That is, could you not use Audacity to re-encode as 16-bit and use the existing component(s)?

24 bit minimum value

Question: Is there support for 48 k and 96 k frequencies?

Hi, Denis.T.

Per your request, I’ve made a fast pass at adding 24-bit PCM support to the WavSrc.cpp component code. In theory, the frequency in the WAV file determines the frequency that is produced in the simulation.

That said, the code is largely untested. You asked so I’m relying on you to thoroughly test and report back. (Fair is fair, right?)

You can find the code and compiled DLL in the WavIO folder in the dev branch of my QSpice GitHub repo.

–robert

Hello Robert! Thank you very much for your work, I am currently on a trip and will start testing in 2.5 weeks. I only have a Linux machine with me.

Hello Robert!
A friend tried it and was able to read wav 24 bit, how to save to file as wav?
It is necessary to save the result of the circuit in wav for subsequent analysis.

My friend used the WavIO_Demo scheme to get the resulting wav with recording to a file, the reference file is 24/48, in the scheme we can only specify samplerate (48kHz), but the bit depth in the recorded file is 16bit still. Is it possible to somehow specify the bit depth values?
And make a parameter indicating the number of channels at the output, otherwise when using mono at the input, a stereo file with one channel is formed.

Hi, Denis.T.

I’ve updated the WavOut component for 24-bit PCM. See the following post.

Please test thoroughly and let me know what problems you find.

–robert

2 Likes

Hello Robert!
We tested the latest iteration of your WavIO implementation. There are a lot of questions, so:

  • reads only 24-48 (our ref files in 16-44 and 16-48 are not recognized. see link below)
  • the output file is shorter, but this is not croping, look likes time stretching (the output format also 24-48)
  • Ref and Output files are not phase subtracted. There are artifacts in the output file in the form of noise.
    examples at the link:
    We operate with mono files. Please, add the ability to include 1 or 2 channels in settings. Now the default is 2 channels and my mono is just duplicated.
    Ideally, I would like to have no parameters at all, just get the same file format as output, including sampling frequency, bit depth, number of channels and length. regardless of the input format.
    https://drive.google.com/drive/folders/1-0YYq7fcTFX8y3ByySPSjlFQuR0z4X45

Hi, Denis.T.

I’m not seeing the problems that you are.

  • See the attached files for my test suite. Stereo*.wav are Audacity-generated inputs; out*,wav are outputs from WavIO_Demo.qsch. (Remove .txt extension for zip file.) I’m having no problems with any combination of 16/24 44100/48000. Did you download the updated files from the dev branch?

  • The output files are not shorter, they are longer by 4 bytes/6 bytes, 16-bit and 24-bit encoding respectively. This is due to the QSpice sample delay between a component input and an output. Therefore, the output file begins with an extra sample.

  • “Ref and output files are not phase subtracted… noise.” I’ve no idea what you’re seeing. The components do nothing with phase. There will be some difference between inputs and outputs due to rounding errors and QSpice handling the “analog connection” between the two components. Not sure what you’re expecting but please demonstrate the issue(s) more clearly.

  • You can post-process with Audacity to remove the second channel if that’s truly a problem for your project.

It is, of course, quite possible that the code could be made more accurate. I look forward to your findings.

–robert

wav_samples.zip.txt (12.0 KB)

I compared two files, the top one is the original one, the bottom one passed through QSpice, the negative half-wave shows the distortion of the sine and the time shift that is increasing. I attached the photo image_2024-05-09_21-22-29.png, it is located in the same link. In this folder there are two files 16-48.wav and 16-44.wav, which QSpice cannot read, the rest are readable.