- Live virtualised oscilloscope environment
- Visulise the effect of changing frequency and amplitude
- Create complex waveforms by summing simple sine waves
- Visulise the effect of phase coherence on the sum wave
- Introduction
- Installation
- User Settings
- Scientific Explanation
- Known Issues and Future Improvements
- Contact
- License
PyWaves Visualizer is a Python script that allows users to visualize sine waves with different frequencies and amplitudes. The script provides a graphical interface where users can adjust various parameters and see the live animation of the sine wave. The animation can be played, paused, and saved as a GIF.
- Reference Wave: Users can capture the current plot as a reference waveform by clicking the "Capture Reference" button. The reference wave is saved and displayed in red behind the animation.
- Sum Wave (Optional):
If the reference wave is captured, users can choose to show the sum between the live wave and the reference wave by clicking the "Show Sum" button. The sum wave is simply calculated as follows:
Sum(t) = LiveWave(t) + ReferenceWave(t)
and is displayed in green behind the animation.
By adjusting the frequncy and or amplitude of the wave, users can visulise the effect on the sum wave and investigate phase phenomena such as beating.
To setup PyWaves Visualizer, follow these steps:
- Clone this repository to your local machine or download the script directly.
- Ensure you have Python installed on your system (Python 3.6 or later recommended).
- Install the required libraries using pip:
pip install numpy matplotlib
- Run the
pywaves_visualizer.py
file. - The visualizer window will appear, and you can start experimenting with different sine waves.
In the script, there are several user-configurable settings:
wave_fidelity
: Number of points to plot in the sine wave.fps
: Frames per second of the animation (time between frames is 1/fps).initial_frequency
: Initial frequency value in Hz.initial_amplitude
: Initial amplitude value (normalized unitless).initial_time_length
: Initial plot window length in seconds.initial_amplitude_scale
: Initial amplitude scale value for y-axis.
Feel free to modify these settings according to your preferences.
The PyWaves Visualizer uses the following mathematical equations to generate the sine wave:
General sine wave equation:
y(t) = A * sin(2 * π * f * (t - δ))
Where:
A
is the amplitude of the wave.f
is the frequency of the wave in Hz.t
is time in seconds.π
is the mathematical constant pi (approximately 3.14159).δ
is the phase shift, which is set to 0 in this visualizer.
The script currently has the following known issues and possible future improvements:
- Consider decoupling the time base and animation frame rate to address potential issues with beating due to animation mismatch.
- Add other waveforms like square, triangle, and sawtooth.
- Allow users to input slider values via keyboard input for precision and ease of use.
- Allow users to easily change slider limits.
If you have any questions, feedback, or issues related to PyWaves, feel free to contact me, Adill Al-Ashgar, at adillwmaa@gmail.co.uk.
This project is licensed under the MIT License. You are free to use, modify, and distribute the code for personal and commercial purposes. Attribution to the original author, Adill Al-Ashgar, is appreciated.