© Analog Devices Inc.
Application Notes | August 27, 2021
LTspice Audio WAV Files: Using Stereo and Encrypting Voice Messages
Question: Can you utilize stereo data and encrypt voice messages with LTspice audio WAV files?
Answer: If music be the food of love, simulate on.
This RAQ explains how to use LTspice® audio WAV files for the syntax of stereo (and higher channel count).
LTspice can be used to generate WAV files as an output of a circuit simulation as well as import WAV files to excite a circuit simulation. It is well documented that mono WAV files can be used as an input in LTspice, and LTspice can be used to produce a WAV output. This article details how to use LTspice audio WAV files for the less well-known syntax of stereo (and higher channel count).
LTspice has many superpowers, but its handling of audio files is one of its more impressive talents. While it is fascinating to see a circuit come to life on the computer screen, creating a sound file that can be played outside of LTspice enables engineers to use another sense to evaluate simulations. Using mono LTspice audio WAV files is well documented. This article expands the discussion to stereo (or more channels), and shows how to export stereo data from, and import it to, LTspice via WAV files. It also illustrates a few tips and tricks with WAV files that will enable the reader to further utilize WAV files.
Generating a Stereo WAV File
Let’s start by producing a stereo wave file from a mono signal. Figure 1 shows a circuit that generates a 1 V, 1 kHz sine wave and splits it into two channels, alternating the signal between them—the 1 kHz tone is switched in 2-second intervals between CH1 and CH2.
Figure 1. In this simulation, a 1 kHz sine wave is switched in two-second intervals between CH1 and CH2. The resulting two-channel signal is exported to an audio WAV file.
The command .wave “C:\export.wav” 16 44.1k V(CH1) V(CH2) digitizes each channel with 16-bit resolution, sampled at 44.1 kSPS, and stores the resultant audio in C:\export.wav. In the command above, each signal listed after the sample rate becomes its own channel in the WAV file. LTspice can store as many as 65,535 channels in a single LTspice audio WAV file—just append signals to the above command as desired.
Figure 2. The two stereo channels from export.wav are used to stimulate two independent circuits.
By default, LTspice’s .wave command saves the first listed channel as the left audio channel and the second as the right audio channel. In this case, when export.wav is played back through a media player, CH1 will be read as the left channel and CH2 will read as the right, regardless of the circuit node naming convention. Note that, by default, CH1 and CH2 are stored as chan 0 and chan 1, respectively, in the .wav file, which is important for reading the file discussed below.
This exported stereo audio file can be used to stimulate another circuit, shown in Figure 2, which uses the two channels from export.wav as signal inputs.
The voltage sources, V1 and V2, are placed as usual, then the voltage signals from export.wav are assigned by holding down the CTRL key and right clicking over each voltage source, revealing the Component Attribute Editor as shown in Figure 3.
Figure 3. Stereo signals from export.wav are used as inputs to the circuit of Figure 2. Here is the assignment for V1, with the value set to pull Channel 0 from export.wav.
As mentioned above, when the LTspice audio WAV file is first generated, as many as 65,535 channels can be digitized into one WAV file—simply append as many channels as desired onto the end of the .wave command.
Remember, by default, LTspice names the first channel Channel 0, the next one is named Channel 1, and so on. In this case, export.wav (generated by the simulation in Figure 1), stores the voltage V(CH1) as Channel 0 and V(CH2) as Channel 1. To play back these channels using a voltage source, specify the .wav file and channel in the value line of the voltage source.
In this case:
Figure 4. The left (yellow) channel shows about 30% feedthrough into the right (blue) channel when played on a laptop. / Figure 5. The mobile phone handset from the year 2000 showed no crosstalk, but distortion at full volume.
Playing export.wav through a laptop showed about 30% of the left channel appearing on the right channel when measured on an oscilloscope as shown in Figure 4.
Figure 6. A later generation handset showed significantly better performance for crosstalk, distortion, and amplitude.
Playing the same file on a mobile phone handset (circa 2000) gave a more separated result, showing no perceivable crosstalk, but a slight amount of distortion at full volume as shown in Figure 5.
Repeating the experiment on a later generation 2018 handset showed no perceivable crosstalk, a full 1 V peak signal, and very little distortion as shown in Figure 6. Note the oscilloscope plots were taken with a 500 mV/div sensitivity.
The same file was used across all three platforms, showing that LTspice is producing the WAV file with full separation, but resulting playback depends greatly on the quality of the player’s audio stage.
Voice Encryption
The circuit in Figure 7 shows a basic method of voice encryption whereby an audio signal is encrypted using a random number sequence, then decrypted.
Figure 7. Using a random voltage source to encrypt/decrypt an audio file.
The file voice.wav contains the original audio. An Excel spreadsheet is used to generate a random number sequence with a 100 µs change period. The results are copied into a text file called random.txt. An extract of random.txt is shown in Figure 8.
Figure 8. Random voltages generated using Excel and saved in a text file.
This file is used to generate a randomly changing voltage, V(RAND), using the piecewise linear (PWL) voltage source in LTspice.
V(RAND) is added to the voice signal using the behavioral voltage source B1. The output is then multiplied by V(RAND) and the result is sent to the encrypt.wav file. Listening to encrypt.wav showed that the original audio was barely perceivable.
Figure 9 shows the original voice, the encrypted voice, and the decrypted voice signals in the LTspice plot window.
A second behavioral voltage source was then used to decrypt the original audio signal and the result was sent to the file decrypt.wav.
Figure 9. Output of original, encrypted, and decrypted voice signals.
Producing a WAV File from a Differential Voltage Source
The syntax of the .wave command does not allow for the digitization of differenial voltages. However, this can easily be overcome by using a behavioral voltage source as shown in Figure 10.
Figure 10. Creating a WAV file from a differential voltage.
The behavioral voltage source outputs a voltage equal to V(OUT1) – V(OUT2) and this can be used in the .wave command in the usual way as shown.
Indeed, the variables inside the behavioral voltage source’s function can include any voltage or current in the circuit and these can be manipulated using any of the mathematic functions of LTspice. The net result can then be exported to an LTspice audio WAV file in the normal way.
LTspice is a powerful simulator, but its results do not have to be contained inside LTspice. Using the .wave command, LTspice can import, manipulate, and export audio files for playing on a media player.
About the Author: Simon Bramble graduated from Brunel University in London in 1991 with a degree in electrical engineering and electronics, specializing in analog electronics and power. He has spent his career in analog electronics and worked at Linear Technology (now part of © Analog Devices Inc.). He can be reached at simon.bramble@analog.com.



- To instruct V1 to replay Figure 1’s V(CH1): wavefile=“C:\export.wav” chan=0
- To instruct V2 to replay Figure 1’s V(CH2): wavefile=“C:\export.wav” chan=1






New Welsh multi-million innovation hub "open for business"
Cardiff-based Translational Research Hub - home to research institutes such as the Institute for Compound Semiconductors - is said to bring industrial partners alongside researchers to design, develop and test new cleaner, greener products and processes.
Fraunhofer IAF expands semiconductor research infrastructure
Two new research buildings provide researchers at the Fraunhofer Institute for Applied Solid State Physics IAF with facilities to continue developing technologies based on compound semiconductors.
Research facility to help UK take the lead in semi R&D
University of Sheffield announces a "major research facility" that will support the UK in its position as a "world-leader" in semiconductor R&D.
AI chipmaker Hailo collaborates with Renesas
The collaboration is said to result in a powerful and energy-efficient processing solution enabling advanced driver-assistance (ADAS) functions and automated driving (AD) systems in motor vehicles.
Mediatek to open design center at U.S. university
Fabless chipmaker Mediatek announces commitment to support its first Midwest semiconductor chip design center in West Lafayette, Indiana.
Japan’s next chip challenge: finding engineers
Japan, along with a number of companies, has invested a lot to build up the country’s domestic chip industry. The next challenge is to find a multitude of engineers to run and operate it.
Dexerials and SemsoTec to set up an optical solution center
Dexerials Corporation, a provider of leading-edge technologies, materials, and devices for smartphones, automobiles, and other products, and German automobile design house SemsoTec Group, will jointly establish an Optical Solution Center for leading-edge In-Vehicle HMIs in Cham, Germany.
90,000 square metres – Arrows new Dutch distribution centre
Arrow recently opened its new primary distribution centre (PDC) in Venlo, the Netherlands. The new centre is one of the company’s largest warehouses globally and replaces the existing facilities in the region and also provides increased capacity for future growth.
Sivers Semiconductors completes the integration of MixComm
Swedish Sivers Semiconductors says it has completed the integration of MixComm, creating a challenger in 5G, SATCOM and radar.
Inventronics to acquire ams Osram digital systems business
Inventronics has entered into an agreement to acquire the Digital Systems business in Europe and Asia from ams Osram, a global leader in optical solutions.
Allied Motion Technologies acquires Airex
Allied Motion Technologies, a designer and manufacturer of precision and specialty controlled motion products, has acquired Airex, LLC, a privately-owned company providing high precision electromagnetic components and solutions.
Arrow opens new distribution centre in the Netherlands
Arrow Electronics has opened a new primary distribution centre (PDC) in Venlo, the Netherlands. The PDC will function as a key hub serving all customers of Arrow’s electronics components business in Europe.
Smith adds 30,000 square feet of space in Houston
The distributor of electronic components has officially opened its new global services hub in Houston, Texas. The new location adds 30,000 square feet of space for the company’s services.
Samsung invests in Israeli AI systems & semiconductor company
Samsung Ventures has made an investment in NeuReality, an Israeli AI systems and semiconductor company.
Swedes develop new method for manufacturing semiconductor components
AlixLabs from Lund, Sweden, has developed a new method for manufacturing semiconductor components with a high degree of packing, eliminating several steps in the manufacturing process - Atomic Layer Etch Pitch Splitting (APS).
Kinetic closes asset purchase agreement with Gain Semiconductor
Analog and mixed-signal semiconductor company, Kinetic Technologies, has completed the acquisition of certain assets of Gain Semiconductor Incorporated.
Socionext relocation of its US HQ to Milpitas
Fabless SoC supplier, Socionext America Inc. (SNA), has relocated its US headquarters to a34,000 square foot single floor building in the City of Milpitas.
TF-AMD expands with new manufacturing site in Malaysia
TF-AMD Microelectronics plans to expand its manufacturing facility in Penang with the construction of a second site at Batu Kawan Industrial Park, Penang. A move set to create more than 3,000 new jobs.
Ericsson boosts distribution center in Malaysia
Swedish telecom company, Ericsson, has commissioned a new facility at the Kuala Lumpur International Airport (KLIA) that will expand its regional distribution capacity and role of Malaysia in the company.
Applied Materials acquires of Finland-based Picosun
Applied Materials has acquired Finnish atomic layer deposition (ALD) technology specialist Picosun Oy.
Melexis adds new manufacturing and R&D space in Bulgarian
In an update on LinkedIn the company states that it has officially opened ints new “high-tech” building in Sofia, Bulgaria. Melexis says that this new facility will contribute to Bulgaria's presence in areas such as microelectronic, automotive, and innovation.
Arduino finds backing among giants
Open-source company, Arduino, plans to expand its portfolio of hardware, software, connectivity and developer tools for professionals. To reach its goals the company launched a Series B financing round, raising USD 32 million from the likes of Bosch, Renesas and ARM.
Farnell expands Toshiba portfolio to support design engineers
The global distributor says that it has strengthened its global partnership with Toshiba Electronics Europe GmbH (Toshiba), resulting in a significant product line expansion and increased stock holding.
Load more news