manually creating my own audio file
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I followed the instructions in MATLAB website audiowrite, to create an audio wav file. https://www.mathworks.com/help/matlab/ref/audiowrite.html#btjqac7-4
I imported handel.mat etc., and played it back perfectly with, sound(y,Fs);
I then did the same thing for a short music wav file I have, a recording of an E tone simulation of a guitar string, and it played back perfectly as well.
So now I thought I could manually create an array that would create the same sound. I create a short program to create a 44100x2 array so that I would have one second of sound. I displayed the first few rows of the y array I created from the E tone.wav file, "([y,Fs] = audioread('E tone.wav');", used the first value in the array as my data value. This was 9.1553e-05. I alternated between - and + values for each row, as seen in the original wav file
So now I have a 44100x2 array of 9.1553e-05 and -9.1553e-05.
When I use "sound" to play it, I get no sound.
I've review many pages online trying to find out what's going on, but I can't figure out what I'm missing, not seeing.
A chose a different value within the working audio matrix and still nothing.
Does any see what I'm missing?
All help appreciated.
5 commentaires
Jan
le 26 Jan 2018
Modifié(e) : Jan
le 26 Jan 2018
@Williah: I've formatted your code. You can do this by your own, see http://www.mathworks.com/matlabcentral/answers/13205-tutorial-how-to-format-your-question-with-markup#answer_18099
You have posted the code of "thehardway", but call "thehardway3".
Réponses (1)
Jan
le 26 Jan 2018
Modifié(e) : Jan
le 26 Jan 2018
The code can be simplified:
function x = thehardway(y)
x = repmat(0.0001221, size(y));
x(2:2:end, :) = -x(2:2:end, :);
end
You could here this, if you increase the volume by the factor 1000:
sound(x * 1000);
2 commentaires
Jan
le 28 Jan 2018
Modifié(e) : Jan
le 28 Jan 2018
Williah's comment moved here (please post comments in the section for comments, not as an answer. Stephen has moved two other comments of you already):
Thanks for the code rewrite, much more efficient (and informative :) ).
Interesting result. When I used sound, multiplying by 1000, I hear 2 pops, like electric sparks. I'm going to play with the data values to see what I learn.
One more question. What does the data, 0.1221*e-03, represent? What is the unit of measurement of this data?
Jan
le 28 Jan 2018
@Williah: I have no idea, what 0.0001221 represents. I've taken it from your code example. There is no unit for these data. For data of type double, sounds use a range of [-1.0, +1.0]. For a physical meaning, you have to consider the amplifier and speakers.
Voir également
Catégories
En savoir plus sur Audio and Video Data dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!