15
If I create a sine wave:
x=0:0.1:6*pi;
is the range of the wavey=sin(x);
is the wave with amplitude 1f=440;
is the desired frequency
How to generate a sound from this data?
I tried to sound(y, f)
, but it doesn’t work.
How to proceed?
15
If I create a sine wave:
x=0:0.1:6*pi;
is the range of the wavey=sin(x);
is the wave with amplitude 1f=440;
is the desired frequency How to generate a sound from this data?
I tried to sound(y, f)
, but it doesn’t work.
How to proceed?
11
So much is missing, let’s split up!
x=0:0.1:6*pi;
I don’t know what you intended to do 6*pi
, it doesn’t make any sense, you must have confused things, calm that I get there...
Your x
begins from the value 0
and linearly spacing the values with 0.1
until 6*pi = 18.8496
To exemplify your x
is:
0 0.1000 0.2000 0.3000 0.4000 0.5000 0.6000 ..... 18.800
This will give you a vector x
size 189
, it seems to me to be a very short size to listen to anything and the values tbm do not reflect the periodicity that you want...
Your second line:
y=sin(x);
yes it will generate a size senoid 189
and in accordance with the values contained in x
, but you’ve already realized that the values of your x
is not exactly what you expected right ...
Third line:
f=440;
OK you want to generate a senoid at 440Hz
Fourth line:
sound(y, f)
Touch your senoid y
on the frequency of 440Hz you think this is ?? humm is not how it works... In function sound
the first parameter should really be the values of the senoid/sound/etc the second parameter says to play the sound at the sampling rate at which your vector was created.
Right way to go:
Define how many seconds of senoid you want and set a sample rate(44100, 8000, 2000) at any rate at which the theory of Nyquist does not interfere with the human range of audible perception, something between 20hz até 20Khz
in theory your sampling rate may be 924hz até 44100hz
(yes 924Hz = f*2.1
pq vc want to create a senoid at a frequency of 440Hz, anything below this sample rate will impact the theorem and you will have problems, audio can start to intermittent or complete silence).
But let’s appeal and use one taxa de amostragem = 44100
in theory (in practice tbm) will cover any frequency up to 22050Hz
or is all our audible spectrum is inside :-)
segundos=3
Fs=44100;
f=440;
tamanho=segundos*Fs
sinal=1*sin(2*pi*f/Fs*(1:tamanho)); % 1 * sin é a amp, poderia qualquer outro valor de amplitude só coloquei pra exemplificar
sound(sinal, Fs)
Look at the formula 2*pi*f/Fs
and soon after it is multiplied by the vector that is linearly plotted by 1
.
Then just use the sound
to listen to.
Very good answer! :)
Browser other questions tagged matlab áudio
You are not signed in. Login or sign up in order to post.
Does it not work at all, or is the sound signal that has been played sufficiently noticeable to the human ear? : ) Another thing you need to see is if the range is long enough (it seemed too short for an audio signal) and if the appropriate frequency was used. Incidentally, in the documentation there is an indication that the frequency should be above 1000 Hz.
– Luiz Vieira
Some more tips that may be useful for comparison: http:/homepages.udayton.edu/~hardierc/ece203/sound.htm (samples) signal in a previously defined interval (the sampling rate - more information here: https://www.youtube.com/watch?v=ie7iREcYBPU)
– Luiz Vieira
@Luizvieira this serves as an answer, no?
– Math
@Math Maybe the first comment. But I’m not absolutely sure what I suggested was actually the AP problem and I don’t even have a way to test it (because I no longer have Matlab installed here). :)
– Luiz Vieira