Clear Filters
Clear Filters

As a university assignment, I will compare audio files by compressing them with different algorithms. I need suggestion.

4 views (last 30 days)
As a university assignment, I will compare audio files by compressing them with different algorithms. I have made advances for the LPC and CELP algorithms. However, if I wanted to add it to my 3rd algorithm, I am not sure which algorithm I would add. If you have a 3rd algorithm suggestion that has plenty of resources and could be useful to me, I would like you to help. It would be much more useful to me if the codes are ready.

Answers (1)

Hassaan
Hassaan on 15 Jan 2024
Some of the commonly supported audio compression formats include:
  1. WAV (Waveform Audio File Format): MATLAB can read and write WAV files, which are typically uncompressed audio files. While WAV files are not compressed, they can be used as a reference for comparing compression algorithms.
  2. AAC (Advanced Audio Coding): MATLAB can encode and decode AAC audio files, which is a widely used lossy compression format known for its high-quality compression. You can use the audiowrite and audioread functions with the 'm4a' file format option for AAC.
  3. OGG (Ogg Vorbis): MATLAB supports Ogg Vorbis audio compression, a popular open-source lossy compression format. You can use the audiowrite and audioread functions with the 'ogg' file format option for Ogg Vorbis.
  4. FLAC (Free Lossless Audio Codec): FLAC is a lossless audio compression format supported by MATLAB. You can use the audiowrite and audioread functions with the 'flac' file format option for FLAC.
  5. MP3 (MPEG-1 Audio Layer III): MATLAB does not have built-in support for encoding MP3 files directly due to licensing restrictions. However, you can use third-party libraries or tools, as mentioned earlier, to work with MP3 compression.
  6. ALAC (Apple Lossless Audio Codec): MATLAB supports ALAC audio files, a lossless compression format developed by Apple. You can use the audiowrite and audioread functions with the 'alac' file format option for ALAC.
  7. AIFF (Audio Interchange File Format): MATLAB can read and write AIFF files, which are uncompressed audio files commonly used on Macintosh systems.
  8. AC3 (Audio Codec 3): MATLAB supports AC3 encoding and decoding for audio compression, which is often used in video files.
MATLAB code that demonstrates how to use the audioread and audiowrite functions to compress an audio file using AAC format and then decompress it:
% Load the input audio file (replace 'input.wav' with your audio file)
[y, fs] = audioread('input.wav');
% Set the output AAC file name
outputAACFile = 'output.aac';
% Compress the audio to AAC format with a specific bit rate (adjust as needed)
bitrate = 128; % Bitrate in kbps
audiowrite(outputAACFile, y, fs, 'BitRate', bitrate, 'Format', 'm4a');
% Read the compressed AAC audio file
compressedAudio = audioread(outputAACFile);
% Play the original and compressed audio for comparison (optional)
sound(y, fs);
pause(length(y)/fs); % Wait for the original audio to finish
sound(compressedAudio, fs);
  1. Replace 'input.wav' with the path to your input audio file.
  2. Set the outputAACFile variable to the desired name of the compressed AAC audio file.
  3. Adjust the bitrate variable to control the compression quality. Higher bitrates typically result in better audio quality but larger file sizes.
  4. The code uses audiowrite to compress the input audio to AAC format with the specified bitrate.
  5. It then reads the compressed AAC audio file using audioread.
  6. Optionally, it plays both the original and compressed audio files for comparison.
This code will allow you to compress an audio file to AAC format and save it. You can adjust the bitrate to control the compression quality to suit your needs.
------------------------------------------------------------------------------------------------------------------------------------------------
If you find the solution helpful and it resolves your issue, it would be greatly appreciated if you could accept the answer. Also, leaving an upvote and a comment are also wonderful ways to provide feedback.
Professional Interests
  • Technical Services and Consulting
  • Embedded Systems | Firmware Developement | Simulations
  • Electrical and Electronics Engineering
Feel free to contact me.

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!