MATLAB Answers

read all audio files in one directory

123 views (last 30 days)
Hi, I want to remove a frequency from all my mp3 songs, my idea is to use the audioread and audioinfo functions to copy a song in my workspace, see if i can use the filter I created, with a sample rate of 44.1kHz and cut out the frequency (1kHz +/- 300Hz). With audiowrite I can create a .wav file without that frequency. But its a lot of work to do that for every song, is it possible to read the first song in one directory, filter it and generate a wav file in another directory and continue with the second song in the directory and so on? audioread expects the whole filename, I have no idea how to find out how many and which songs are in the directory, can anyone help me?

Accepted Answer

Azzi Abdelmalek
Azzi Abdelmalek on 17 Jul 2016
folder='C:\Users\malek\Documents\MATLAB'
audio_files=dir(fullfile(folder,'*.m'))
for k=1:numel(audio_files)
filename=audio_files(k).name
%Do what you want with filename
% create a new file name 'new_file' for example
folder_destination='C:\Users\malek\Documents' % for example
file_dest=fullfile(folder_destination,'new_file'
% .....
end
  12 Comments
Walter Roberson
Walter Roberson on 30 Nov 2020
see the first example in the fft documentation for information on plotting

Sign in to comment.

More Answers (1)

Image Analyst
Image Analyst on 17 Jul 2016
  2 Comments
Image Analyst
Image Analyst on 18 Feb 2021
AudioArray{k} = audioread(fullFileName);
maxaudio(k) = max(AudioArray{k});

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!