MATLAB Answers

read all audio files in one directory

77 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?

  0 Comments

Sign in to comment.

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

Show 9 older comments
Cesar Lobo
Cesar Lobo on 30 Nov 2020
my data is a random song. the code is supposed to import a song from a folder and performe the fft. i want to see the graph
Image Analyst
Image Analyst on 30 Nov 2020
OK, so did you call audioread() followed by fft()? If not, why not?
Walter Roberson
Walter Roberson on 30 Nov 2020
see the first example in the fft documentation for information on plotting

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!