Hello Mike & QSpice Team.
I’m really liking QSpice so far. The ability to insert native C/C++ code is a brilliant feature.
I’m thinking to add a unit to allow using a WAV file (or likely any audio format) as a source. Other than finding a library to open/parse the audio file, it seems simple enough. (Famous last words that I’ve regretted often.)
As a first pass, I simply created a block with an input port (clock) and output port (the voltage corresponding to the sample voltage at that clock cycle). However, this approach will require hardcoding the source file name and sample bitrate. I’d like to make those bits more flexible.
So, I have questions:
(1) Can a string parameter (in a .param statement or as an attribute) be passed to the C DLL at runtime (i.e., the user-supplied audio filename)?
(2) Same for an integer value (i.e., the user-supplied bitrate)?
At this point, I have the clock input driven by a pulse source at (twice) the bitrate. I’m assuming – perhaps incorrectly – that the DLL code will be called at least at every clock transition.
It might be better to have the DLL get the bitrate from the file parsing library. How could I pass that back to QSpice and have that used by the clock source?
Or is there a better way, maybe using the min/max time block that is available in the advanced settings when generating the code template? If so, does the DLL have access to the elapsed simulation time when called?
Thanks again for making such a promising tool.