Stereo Audio Generation with Phase-Differentiated Channels

The code is designed to generate and play a stereo audio signal with a specific frequency and phase difference, like circularly polarized.
6 Downloads
Updated 16 Aug 2023

View License

The code is designed to generate and play a stereo audio signal with a specific frequency and phase difference, simulating a situation similar to circularly polarized signals. Here's a breakdown:
1. **Setup and Initialization**:
- The code sets up a sample rate of `44.1 kHz`, which is a common sample rate used for audio CDs.
- A time vector (`t`) is then generated to represent a duration of `2` seconds, given the sample rate.
2. **Tone Generation**:
- The desired frequency for the audio tone is defined as `440 Hz`, which corresponds to the A4 note on a piano or musical keyboard.
- Using this frequency and the time vector, a sinusoidal waveform (`signal1`) is generated using the sine function.
- Simultaneously, another sinusoidal waveform (`signal2`) is created which is phase-shifted by `90` degrees from the first signal. This is achieved using the cosine function, which inherently has a `90` degree phase difference from the sine function.
3. **Stereo Signal Creation**:
- Both the sinusoidal signals are combined into a stereo signal. The first signal (`signal1`) is directed to the left channel, while the second signal (`signal2`) is directed to the right channel. This creates a stereo audio signal with distinct content in the left and right channels.
4. **Audio Playback**:
- An audio player object is created using the MATLAB `audioplayer` function, which takes the stereo signal and the sample rate as inputs.
- The audio is then played using the `play` function, allowing the user to hear the generated tone with the specified frequency and phase difference between the left and right channels.
Overall, this code provides an illustrative example of how one can create and play a stereo audio signal in MATLAB, with control over the frequency and phase properties of the signal. This can be particularly useful in audio signal processing experiments, simulations, or educational demonstrations.

Cite As

Mrutyunjaya Hiremath (2024). Stereo Audio Generation with Phase-Differentiated Channels (https://www.mathworks.com/matlabcentral/fileexchange/133937-stereo-audio-generation-with-phase-differentiated-channels), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2023a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.0.0