How do I get valuables from audioinfo

Hello everyone. I need help about auidoinfo. I want to use audioinfo valuables as veriables. For example I want to get BitsPerSample or NumChannels as veriable because I will make if else about that. For example I want to make 16 BitsPerSample if my file has 24 BitsPerSample or change samplerate. Thank you for helping.

Answers (1)

The audioinfo function returns a structure, so refer to its fields —
load handel.mat
filename = 'C:\Temp\handel.wav';
audiowrite(filename,y,Fs);
clear y Fs
info = audioinfo(filename);
BPS = info.BitsPerSample
BPS = 16
Consult the documentation for audiowrite to understand how to save the file with the chosen changed parameters.
(This code uses code from the audioinfo documentation page to create the file.)
.

Products

Release

R2015a

Asked:

on 23 Feb 2022

Answered:

on 23 Feb 2022

Community Treasure Hunt

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

Start Hunting!