Help with Shannon-Nyquist Reconstruction Artifacts in Interactive DSP Tool

Hello DSPrelated community,
I'm developing an interactive web application for learning DSP concepts as part of a university project (project overview: https://thierrydutoit.github.io/iDSP/). My component focuses on visually illustrating the impact of sampling rate and related parameters on reconstructed signal quality. I'm using Streamlit to create a dynamic interface (deployed demo: https://sampling-and-reconstruction.streamlit.app/).
I'm struggling with significant artifacts in my sinc() reconstructed signals, which suggests a flaw in my Shannon-Nyquist theorem implementation. The output signal is far from accurate.
The source code is accessible on the project's GitHub repository. I'm seeking advice on diagnosing the source of these artifacts and potential strategies to improve my reconstruction process. Any help in identifying errors in my code or suggesting alternative approaches would be highly valued.
Thank you for your expertise.

Here is perhaps the simplest possible Matlab model of a DAC zero-order hold. The sample rate of the DAC output signal is 8x that of the DAC input.
% function y= dac_model(x) 10/30/23 Neil Robertson % Model the zero-order hold (ZOH) function of a DAC % % x = DAC model input sequence % y = DAC model output sequence % sample rate of y is 8 times sample rate of x. % function y= dac_model(x) N= length(x); x_up= zeros(1,8*N); x_up(1:8:end)= 8*x; % upsample x by 8 b= ones(1,8)/8; % 8-tap boxcar filter y= conv(b,x_up); % filter x_up using b
For impulse input x = [1 0 0 0], the output sequence is as shown in the top plot. The spectrum of the output is shown in red in the bottom plot, along with the exact output spectrum. The model can accept any input sequence x. I discussed DAC zero order hold models in a post here.
regards,
Neil

I don't have the answers, Just one notice:
In the time domain plots, the base signal and shannon reconstructed version seem identical, yet the fft shows spread in shannon plot. I suspect your fft is misleading.
By the way your base signal is digital. isn't it? so you are reconstructing digital signal into digital signal...

To my humble opinion, using windowing will enhance significantly the display of your spectrums. (please see a demo file at :https://drive.mathworks.com/sharing/.../sampling_and_reconstruction.m ; change the windowing variable to true to see the difference)
Regarding the artifacts, you can see also in my demo file that the resampling created some spurs for the sampled signal. In Matlab, resample does a "lot" of things (upsampling, interpolating, downsampling). If one uses arbitrary fractional coefficients for the sampling frequencies (simulator step and sampler), I guess those spurs are likely to appear if no additional care is taken.
(I could not find your source code for the signal processing behind your application so it is difficult to say where do the spurs come.)