Reading a text file and then loop load audio files

2 Ansichten (letzte 30 Tage)
I’m a bit confused, i want to read a text file data.txt and then in a loop load some wav-files.
  2 Kommentare
Mathieu NOE
Mathieu NOE am 11 Okt. 2021
hello
this is a bit vague.. what is the txt file for ? does it contains a list of the wav files names ?
Mohammed Babangida Ibrahim
Mohammed Babangida Ibrahim am 11 Okt. 2021
Yes, it contains the names of the wav-files. They go together. Each audio wav-file is accompanied with a text file

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Mathieu NOE
Mathieu NOE am 11 Okt. 2021
hello again
so this script will read the txt file where you have a list of wav file names
then the loop will open the associated wav files and display the data
hope it helps
clc
clearvars
folder = pwd; % current folder
fullfnames = readcell('wav.txt'); % read txt files and store filenames in cells
nFiles=numel(fullfnames);
for iFile = 1:nFiles
fullfname = char(fullfnames(iFile));
[signal,fs]=audioread(fullfile(folder,fullfname)); %read in wav
h = plot(signal); %
hold on
end
  3 Kommentare
Mathieu NOE
Mathieu NOE am 11 Okt. 2021
hello again
fullfile is used to create an absolute complete path to the files
I you work only on the current folder , this may be overkill but it's a safer method to create the path to your wav files
see more info on : help fullfile
Mathieu NOE
Mathieu NOE am 12 Okt. 2021
Hi
if my contribution has helped you, do you mind accepting it ?
tx

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by