<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Tech Notes - References and Fixes on Clayton Easley</title><link>https://claytoneasley.org/posts/notes/</link><description>Recent content in Tech Notes - References and Fixes on Clayton Easley</description><generator>Hugo -- gohugo.io</generator><language>en-us</language><lastBuildDate>Sun, 31 Aug 2025 00:00:00 +0000</lastBuildDate><atom:link href="https://claytoneasley.org/posts/notes/index.xml" rel="self" type="application/rss+xml"/><item><title>Send Sound Through Your Circuit Designs</title><link>https://claytoneasley.org/posts/notes/sound-through-lt-spice/</link><pubDate>Tue, 06 Jan 2026 14:29:39 -0500</pubDate><guid>https://claytoneasley.org/posts/notes/sound-through-lt-spice/</guid><description>Notes on how to send .wav files through simulated analog circuits in LTspice</description><content:encoded><![CDATA[<p>Wheather you&rsquo;re a student, professional, or hobbyist, you will eventually come across <a href="https://en.wikipedia.org/wiki/SPICE">SPICE Software</a> when desigining electronics projects. SPICE software, such as <a href="https://www.analog.com/en/resources/design-tools-and-calculators/ltspice-simulator.html">LTspice</a>, can be used to simulate your analog and digital designs without having to bust out a breadboard or soldering iron.</p>
<p>One of LTspice&rsquo;s features I have found incredibly useful is it&rsquo;s ability to process <code>.wav</code> files as a voltage input and the write the voltage output of the circuit to a new audo file.</p>
<h2 id="audio-settings">Audio Settings</h2>
<p>When working with audio in LTspice, it is important to ensure the correct audio format and encoding are used. The <code>.wav</code> file is just a container for uncompressed pulse-code modulation (PCM) data.
To process audio files in the <code>.wav</code> file format it is important to make sure the file is encoded corectly. The .wav file is a just a <a href="https://en.wikipedia.org/wiki/Container_format">container</a> for raw uncompressed <a href="https://en.wikipedia.org/wiki/Pulse-code_modulation">pulse-code modulation (PCM)</a> data.</p>
<p>So when importing your audio files into LTspice make sure you take note of the <span style="color:red"><strong>audio encoding</strong></span>, <span style="color:red"><strong>bit rate</strong></span>, <span style="color:red"><strong>sample rate</strong></span>, <span style="color:red"><strong>audio duration</strong></span> and make sure the audio channel is <span style="color:red"><strong>monophonic</strong></span></p>
<p>Most audio recording software has the option to export wavefiles in 8-bit to 32-bit  PCM format. In most cases, 16-bit should suffice.</p>

<details>
  <summary>See Audacity Export Example</summary>
  <hr>
<p>Download <a href="https://www.audacityteam.org/">Audacity</a> or <a href="https://github.com/audacity/audacity">Audacity github</a></p>
<p>Open a new Audacity project and navigate to <code>Tracks &gt; Add New &gt; Mono Track</code>. Click on the newly added track and then navigate to <code>Generate &gt; Pluck</code> to make a guitar plucking sound.</p>
<p>Take note that Audacity uses the <a href="https://studiocode.dev/resources/midi-middle-c/">MIDI pitch number</a> which is diffrent than the key number when generating the pluck sound.</p>
<figure>
    <img loading="lazy" src="/notes/audicty_wav_encoding_settings.webp"/> 
</figure>
</details>

<h2 id="ltspice-settings-and-circuit">LTspice Settings and Circuit</h2>
<p>Once you have your audio file you want to use, I would recommend moveing it into the root directory where your LTspice project is located. Otherwise, you will have to provide the <strong>full path</strong> to your audio file.</p>
<pre tabindex="0"><code>.
├── pluck.wav
└── project.asc
</code></pre><h3 id="add-audio-input">Add Audio Input</h3>
<p>Right click the value of your voltage source and put the folowing in the empty text box.</p>
<pre tabindex="0"><code>wavefile=path/to/your_audio.wav
</code></pre><p>This voltage source will now serve as your audio input in your circuit.</p>
<h3 id="simulation-settings">Simulation settings</h3>
<p>The next step is going to be to set up a <a href="https://ltwiki.org/LTspiceHelpXVII/LTspiceHelp/html/DotTran.htm">transient analysis</a> equal to the duration of your audio sample.</p>
<p>This can be done by adding the flowing directive by pressing <code>.</code> on your keyboard. You can also use the GUI by naviagiting to <code>Simulate &gt; Configure Analysis</code> and edit your settings in the <code>Transient</code> tab.</p>
<p>In my case my directive looks like the flowing but you may need to change the duration of analysis.</p>
<pre tabindex="0"><code>.tran 0 1s 0s 0.1s
</code></pre><h3 id="audio-output">Audio Output</h3>
<p>The next step is going to be to add the output newtork lable by pressing <code>n</code> on your keyboard. Keep note of the name of this node as it acts as a varable for the output data. In the example image this is <strong>V_Out</strong>.</p>

<details>
  <summary>See Example Low Pass Filter Schmatic</summary>
  <hr>
<figure>
    <img loading="lazy" src="/notes/lowpass_schematic.webp"/> 
</figure>
<p><a href="https://www.electronics-tutorials.ws/filter/filter_2.html">click here if you want to know more about RC filters</a></p>
<p>Here is a simple low pass filter example with a cut off frequency of  $ \approx 10061 $ Hz which is the closest I could get using standard components.</p>
<p><strong>Remember</strong></p>
<p>$$ f_c = {1 \over 2\pi RC} $$</p>
</details>

<br>
<p>Once you have your circuits input, output, and simulation settings configured we need to use the <a href="https://ltwiki.org/LTspiceHelp/LTspiceHelp/_WAVE_Write_selected_nodes_to_a_wav_file_.htm">.wave directive</a> to output your audio file the circuit.</p>
<pre tabindex="0"><code>.wave &lt;output.wav&gt; &lt;bit rate&gt; &lt;sample rate&gt; V(&lt;output node&gt;)
</code></pre><p>Given my audio settings.</p>
<pre tabindex="0"><code>.wave pluck_out.wav 16 44100 V(V_Out)
</code></pre><h2 id="example-audio">Example Audio</h2>
<p>Listen carefully, the original audio should sound sharper than the outputted file. Looking at LTspice output image (right) you can see the <a href="https://en.wikipedia.org/wiki/Attenuation">attenuation</a> from the right of the red line onward compared to the original audio (left).</p>
<table>
  <thead>
      <tr>
          <th>Original</th>
          <th>LTspice output</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><audio controls src="/notes/pluck.wav"></audio></td>
          <td><audio controls src="/notes/pluck_out.wav"></audio></td>
      </tr>
      <tr>
          <td><figure>
    <img loading="lazy" src="/notes/peak_fft.webp"/> 
</figure>
</td>
          <td><figure>
    <img loading="lazy" src="/notes/peak_out_fft.webp"/> 
</figure>
</td>
      </tr>
  </tbody>
</table>
]]></content:encoded></item><item><title>My Simple CMake Setup</title><link>https://claytoneasley.org/posts/notes/cmake/</link><pubDate>Mon, 01 Sep 2025 16:51:28 -0400</pubDate><guid>https://claytoneasley.org/posts/notes/cmake/</guid><description>simple CMake project template</description><content:encoded><![CDATA[<figure>
    <img loading="lazy" src="/img/cmake_logo_dark.png"
         alt="CMake logo"/> 
</figure>

<p>In my summer semester of 2025 I decided to take a C programming class to sharpen my coding skills. But, as my assignments became more complex, they required multiple header and implementation files. This is where tools known as <a href="https://en.wikipedia.org/wiki/Build_system_(software_development)">build systems</a> come into handy, such <a href="https://www.gnu.org/software/make/">as GNU Make</a>. The problem with C build systems is that there are arguably too many of them, and on top of this, there are what are known as meta <a href="https://en.wikipedia.org/wiki/Build_system_(software_development)">build systems</a>. Meta build systems are tools that create build scripts for other build systems.</p>
<p>After reviewing the laundry list of compiler tools, I settled on <a href="https://cmake.org/">CMake</a>. CMake is a meta build system that can generates <code>makefiles</code> tailored for a specific platform and compiler, allowing you to easily <a href="https://en.wikipedia.org/wiki/Cross_compiler">cross-compile</a> for different target architectures.</p>
<p>With all this out of the way lets set up a simple C project with CMake!</p>
<p>CMake has many features that I will not be covering here so you many want to <a href="https://cmake.org/documentation/">refer to the CMake documentation</a></p>
<h2 id="installation">Installation</h2>
<p>I would recommend following the <a href="https://cmake.org/getting-started/">official CMake installation</a> guide as this may become out of date! On top of this, I have not tested my CMakeLists.txt file on Windows and recommend using <a href="https://learn.microsoft.com/en-us/windows/wsl/install">Windows Subsystem for Linux (WSL)</a> unless you are devloping applications specificly for Windows.</p>

<details>
  <summary>Click for Linux instructions</summary>
  <hr>
<p>If you are on a unix/linx system you can install CMake using your systems package manager.</p>
<p><strong>For Example:</strong></p>
<pre tabindex="0"><code>sudo apt install cmake
</code></pre><p>Once installed you can check with</p>
<pre tabindex="0"><code>cmake --version
</code></pre></details>

<p><br><br></p>

<details>
  <summary>Click for Winows instructions</summary>
  <hr>
<p>Windows now has a package manager similar to what is found on UNIX systems. <a href="https://github.com/microsoft/winget-cli">Windows Package Manager (winget)</a> can be used to install CMake just like <code>apt</code> with the lovely UAC prompt.</p>
<p><strong>In a PowerShell terminal run:</strong></p>
<pre tabindex="0"><code>winget install cmake
</code></pre><p><strong>NOTE:</strong> CMake is not a compiler and if you are on Windows you will need to install a C/C++ compiler such as <a href="https://visualstudio.microsoft.com/downloads/">MSVC</a></p>
</details>

<h2 id="project-structure">Project Structure</h2>
<p>I am not sure if there is a formal name for this type of project structure, but this is what I have seen used out in the wild most often for C and C++ projects and what I prefer to use.</p>
<pre tabindex="0"><code>Project Name
├── README
├── LICENCE	
├── CMakeLists.txt    // simple CMakeLists.txt
├── build             // Where your build files go
├── include           // header files
├── lib               // external libraries (.so or .dll)
└── src               // source code 
    └── main.c
</code></pre><h2 id="config">Basic CMakeLists</h2>
<p>Here is a basic simple CMakeLists.txt to get a C or C++ project started. In your projects root directory copy this into your <code>CMakeLists.txt</code> file.</p>
<p>Make sure to replace anything you see in <code>&lt;&gt;</code> such as <code>&lt;Name&gt;</code> without the brackets.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-CMake" data-lang="CMake"><span style="display:flex;"><span>cmake_minimum_required(<span style="color:#e6db74">VERSION</span> <span style="color:#e6db74">3.24</span>)<span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010"></span>set(<span style="color:#e6db74">PROJECT_NAME</span> <span style="color:#e6db74">&lt;Name&gt;</span>)<span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010"></span>project(<span style="color:#f92672">${</span>PROJECT_NAME<span style="color:#f92672">}</span>)<span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010"></span>set(<span style="color:#e6db74">CMAKE_C_STANDARD</span> <span style="color:#e6db74">23</span>) <span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010"></span>set(<span style="color:#e6db74">CMAKE_C_STANDARD_REQUIRED</span> <span style="color:#e6db74">ON</span>) <span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010"></span><span style="color:#75715e"># list of c files to compile
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>set(<span style="color:#e6db74">SOURCES</span>
</span></span><span style="display:flex;"><span>  <span style="color:#75715e"># Source files go here
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>  <span style="color:#75715e"># src/main.c
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>  <span style="color:#e6db74">&lt;add</span> <span style="color:#e6db74">files</span> <span style="color:#e6db74">here&gt;</span>
</span></span><span style="display:flex;"><span>)<span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010"></span><span style="color:#75715e"># gcc compile options (Optional)
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"># add_compile_options(-Wall -Wextra -save-temps)
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span><span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010"></span>add_executable(<span style="color:#f92672">${</span>PROJECT_NAME<span style="color:#f92672">}</span> <span style="color:#f92672">${</span>SOURCES<span style="color:#f92672">}</span>)<span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010"></span>target_include_directories(<span style="color:#f92672">${</span>PROJECT_NAME<span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">PRIVATE</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">${</span>PROJECT_SOURCE_DIR<span style="color:#f92672">}</span><span style="color:#e6db74">/include</span>
</span></span><span style="display:flex;"><span>)<span style="color:#960050;background-color:#1e0010">
</span></span></span></code></pre></div><h2 id="build-and-run">Build and Run</h2>
<p>Once you have copied and edited your <code>CMakeLists.txt</code> you need to run <code>cmake</code> to generate the lower level build scripts for your project.</p>
<p>In your <code>build</code> directory run:</p>
<pre tabindex="0"><code>cmake ..
</code></pre><p>Running this command will generate a <code>Makefile</code> in your project&rsquo;s <code>build</code> directory.</p>
<p>Once your build scripts are generated run <code>make</code> in the <code>build</code> directory to compile your project.</p>
<pre tabindex="0"><code>make
</code></pre><p>Doing so will create a compiled binary in your <code>build</code> directory that you run using <code>./&lt;project-name&gt;</code></p>
]]></content:encoded></item></channel></rss>