This project is a Waveform Generator that supports both Sine Waves and Square Waves. Users can input parameters such as frequency, amplitude, and phase shift to generate and save waveforms in CSV format. The generated waveform can be visualized using Gnuplot.
- Generate Sine Wave or Square Wave data.
- Save waveform data as a CSV file.
- Plot the generated waveform using Gnuplot.
- Works on both Windows and Linux operating systems.
- MinGW or any compatible GCC compiler for C++.
- Gnuplot for Windows (Download from Gnuplot official site).
- Ensure
Gnuplotis added to the system'sPATH.
- GCC or Clang (usually pre-installed).
- Gnuplot (Install via package manager:
sudo apt-get install gnuplot).
-
Install MinGW:
- Download from MinGW.
- During installation, ensure G++ and make are selected.
- Add the MinGW
binfolder (e.g.,C:\MinGW\bin) to the system's PATH.
-
Install Gnuplot:
- Download and install Gnuplot for Windows.
- Add Gnuplot's
binfolder to the system's PATH.
-
Verify Installation:
gnuplot --versiong++ --version -
Compile the Program: Open a terminal (PowerShell or Command Prompt) in the project directory:
g++ main.cpp -I include -L lib -lwaves -o waveform_generator.exe
-
Install GCC and Gnuplot:
sudo apt update sudo apt install g++ gnuplot
-
Verify Installation:
gnuplot --versiong++ --version -
Compile the Program: Open a terminal in the project directory
g++ main.cpp -I include -L lib -lwaves -o waveform_generator.exe
- Open a terminal (Command Prompt or PowerShell) and navigate to the project directory:
cd path\to\dynasas_asg_part2_cpp
- Run the program:
waveform_generator.exe
- Follow the prompts to select a waveform type and input parameters
- The generated waveform will be saved to waveform_output.csv & Gnuplot will automatically open to display the plot.
- Open a terminal (Command Prompt or PowerShell) and navigate to the project directory:
cd path\to\dynasas_asg_part2_cpp
- Run the program:
./waveform_generator.out
- Follow the prompts to select a waveform type and input parameters
- The generated waveform will be saved to waveform_output.csv & Gnuplot will automatically open to display the plot.
Enter waveform type (sine/square): sine
Enter frequency (Hz): 5
Enter amplitude: 2
Enter phase shift (radians, optional - default 0): 0.5
Waveform saved to waveform_output.csv
Enter waveform type (sine/square): square
Enter frequency (Hz): 2
Enter amplitude: 2
Enter phase shift (radians, optional - default 0): 0.1
Waveform saved to waveform_output.csv
- Frequency refers to the number of cycles a waveform completes per second, measured in Hertz (Hz).
- It determines the pitch of a sound wave (in audio applications).
- Amplitude is the maximum height or strength of the waveform from its equilibrium position.
- It represents the intensity or energy of the wave (e.g., loudness in sound).
- Phase refers to the initial angle of the waveform at the starting time (usually measured in radians).
- It determines the horizontal shift or displacement of the wave from its standard position.
- The time period is the time taken for one complete cycle of the wave.
- It is the inverse of frequency
- A sine wave is a smooth, continuous waveform representing periodic oscillations.
- Sine waves are common in natural phenomena such as sound waves and electrical signals.
- A square wave alternates between two levels (high and low) with an abrupt transition.
- It is commonly used in digital electronics and clock signals.
- Unlike sine waves, square waves are non-smooth and have sharp edges.

