The Essence of Low-Level Systems Programming
In high-level languages like JavaScript or Python, memory allocation and hardware interfaces are abstracted away. But understanding computing at its foundational level requires mastering pointers, manual buffer boundaries, bitwise operations, cache-friendly data structures, and mathematical acoustics.
During my Computing IV coursework at UMass Lowell, I developed a suite of 7 systems engineering projects in C++17 utilizing SFML (Simple and Fast Multimedia Library), Boost Test & Regex, and Valgrind memory auditing.
To celebrate this body of work, I engineered an interactive, in-browser lab on torres.dev where you can play and experiment with these algorithms live:
š Launch the Interactive C++ Systems Lab
Core Architectural Breakthroughs
1. Karplus-Strong Physical Acoustic Modeling (StringSound)
The Karplus-Strong algorithm simulates the physics of plucked string acoustics without requiring computationally expensive partial differential equations.
At its core sits a custom generic Circular Buffer (Ring Buffer):
cpptemplate <typename T> class CircularBuffer { std::vector<T> m_buffer; size_t m_capacity; size_t m_first{0}, m_last{0}, m_size{0}; public: void enqueue(T item); T dequeue(); T peek() const; };
When a string of frequency $f$ is plucked:
- The buffer is filled with $N = \lceil \frac{44100}{f} \rceil$ samples of uniform white noise in $[-0.5, 0.5]$ representing an acoustic energy burst.
- At every audio sample tick, a low-pass averaging filter decays the frequency: $$y[t] = \alpha \times \frac{x[t] + x[t-1]}{2}$$ where $\alpha \approx 0.996$ represents string energy loss.
- This creates the authentic, warm harmonic resonance of a steel or nylon guitar string.
2. Sokoban Matrix Puzzle Engine (SFML & Kenney CC0)
The classic Sokoban warehouse puzzle was implemented with strict object-oriented design, dynamic template matrices, and operator overloading:
- Engineered a reusable
matrix<T>generic 2D grid container with bounds checking and 1D cache line mapping (map[r * cols + c]). - Overloaded
std::istream& operator>>(std::istream&, sokoban&)to stream custom warehouse blueprints (such aslevel1.txt) with symbols for walls (#), floors (.), crates (O), targets (*), and player start (@). - Inherited from
sf::Drawableand bound textures dynamically for multi-directional character movement and crate placement. - Artwork Credit: Warehouse pixel art, crates, and character directional sprites were created by Kenney Vleugels (Kenney.nl / @KenneyNL) under the Creative Commons Zero (CC0) Public Domain dedication.
3. Linear Feedback Shift Registers & Pixel XOR Encryption (PhotoMagic)
A Linear Feedback Shift Register (LFSR) generates deterministic pseudo-random sequences using bit shifts and tap XOR operations:
- A binary seed string is loaded into a bitset register.
- On each step, the leftmost bit is XORed with a designated tap bit and fed back into the rightmost position.
- Every pixel $(R, G, B)$ of an SFML image is transformed via
pixel.channel ^ lfsr.generate(8). - Because $A \oplus B \oplus B = A$, passing the identical key back through the algorithm decodes the image with zero cryptographic degradation.
4. Needleman-Wunsch Dynamic Programming DNA Alignment
Global pairwise sequence alignment finds the optimal edit distance between two genomic sequences of lengths $M$ and $N$:
- Constructs an $(M+1) \times (N+1)$ Dynamic Programming matrix.
- Recurrence relationship evaluates matches ($+0$), mismatches ($+1$), and insertion/deletion gaps ($+2$): $$opt[i][j] = \min \begin{cases} opt[i+1][j+1] + \text{cost}(x[i], y[j]) \ opt[i+1][j] + 2 \ opt[i][j+1] + 2 \end{cases}$$
- Backtracks from $(0, 0)$ to $(M, N)$ to reconstruct the exact optimal evolutionary alignment.
- Memory optimization: profiling identified that flattened contiguous 1D buffers outperform nested
std::vector<std::vector<int>>on large genomic payloads due to CPU cache line locality.
Key Engineering Lessons & Profiling with Valgrind
- Memory Profiling: Running workloads through
valgrind --leak-check=fulleliminated memory leaks in dynamic pointers and uncovered subtle off-by-one errors in circular buffer wrapping. - Data Structure Performance: Contiguous memory structures dramatically reduce cache misses compared to pointer-heavy tree models.
- Audio Physical Simulation: Discrete DSP (Digital Signal Processing) loops require rigorous float-to-int16 clamping to prevent speaker clipping.
Live Interactive Lab & Repository
- Interactive Lab: torres.dev/systems/cpp-portfolio
- Full Report (PDF): /CPP_Portfolio.pdf
- GitHub Repository: github.com/And3rsonTorres/CPP_Porfolio