I want to have a mif file from the sound signal of a for example mp3 file. How can I do it using MATLAB?
Thanks,
BooMZ!
As result, I couldn't find any solution to convert a MP3 file to mif. But I could convert wav file to mif. It's the instructions:
First you must drag and drop your wav file to MatLab. MatLab will make a array from wav file. Finally, you must write the data array to a file with mif format. (you can do it by fprintf)
Related
How can I convert *.pcm audio file to *.wav audio File in MATLAB-Code?
I just need to insert a header, but how it is work?
Thank you very much!
Since you didn't specify it, I'm assuming you are using Matlab 2018b, so I will point you to the most recent documentation about audioread:
As you can see, PCM is not on the supported format list.
You should try to look if you can parameter your AudioRecorder to record your audio to another format within the ones in the supported list: .wav, .ogg, .flac, .au, .aif, .aifc, mp3, .mp4...
An alternative option, without using audioread, would be to import pcm data like any other data file, then convert it to 16 bit wav. I assume sample rate is 44100 Hz.
fid = fopen('audioFile.pcm'); % Open raw pcm file
audio = int16(fread(fid, Inf, 'int16')); % Convert data into 16 bit
fclose(fid); % Close pcm file
audiowrite('audioFile.wav', audio, 44100,'BitsPerSample', 16); % Write wav
I have to convert 'Yale' dataset whose format is .pgm to .mat file, I searched about this issue but couldn't find anything.
I appreciate any help.
Images can be saved in .mat format by using the save() function offered by MATLAB.
Let us suppose the name of your image is xyz.pgm that has to be saved as xyz.mat. Following steps should do so :
im = imread('xyz.pgm')
save('xyz.mat','im')
You can look into save() function to learn more about it.
Instead if you just want to convert it into other image formats, you should look up imwrite().
I have speech data, which I segment into some parts. I am trying to create a .wav file for each segmented data and play this .wav file.
For example, suppose the speech data is an 1x1000 array called data. I segment this data into 4 parts using the indices of seg_data.
seg_data
1 250
251 500
501 750
751 1000
Code:
for i=1:size(seg_data(:,1))
w(i)=data(seg_data(i,1): seg_data(i,2));
wavwrite(w(i),'file_%d \n ',i);
end
First thing I need to create one folder in which the .wav file that is created in every iteration is stored. Then, I can read the stored file one by one and can play it.
If you don't know the sampling frequency Fs, you have to use the signature wavwrite(y,filename) as presented in the reference site.
for i=1:size(seg_data(:,1))
w(i,:)=data(seg_data(i,1): seg_data(i,2));
wavwrite(w(i,:),['file_',num2str(i)]);
end
BTW, the documentation suggests to use audiowrite instead.
I have a wav file generating function and want to save the output of a loop containing this function to a folder as wav files.
What you need is the function wavwrite (http://www.mathworks.de/de/help/matlab/ref/wavwrite.html) ;-) I hope that helps you and makes it possible for you to save your files.
I want to import a .raw file into MATLAB as a matrix (frames x spatial x spectral). Is there a built-in function to do this?
If you're referring to a raw image file from a camera, I would check out the submission RAW Camera File Reader from Bryan White on the MathWorks File Exchange.
You can also read the file directly. But you'll need to convert it to DNG first. See this:
http://blogs.mathworks.com/steve/2011/03/08/tips-for-reading-a-camera-raw-file-into-matlab/