manually creating my own audio file

4 visualizaciones (últimos 30 días)
Williah
Williah el 26 de En. de 2018
Editada: Walter Roberson el 28 de En. de 2018
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 comentarios
Jan
Jan el 26 de En. de 2018
Editada: Jan el 26 de En. de 2018
You have posted the code of "thehardway", but call "thehardway3".
Williah
Williah el 27 de En. de 2018
Thanks for the formatting. I saved the file thehardway3.m, so accessing is fine. I just named it wrong within. Corrected.

Iniciar sesión para comentar.

Respuestas (1)

Jan
Jan el 26 de En. de 2018
Editada: Jan el 26 de En. de 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 comentarios
Jan
Jan el 28 de En. de 2018
Editada: Jan el 28 de En. de 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
Jan el 28 de En. de 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.

Iniciar sesión para comentar.

Community Treasure Hunt

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

Start Hunting!

Translated by