How can I generate 10kHz,5 second audio tone and it`s sampling frequency is equal to 44100 Hz? and How can I set the magnitude?

답변 (1개)

Walter Roberson
Walter Roberson 2020년 4월 2일
편집: Walter Roberson 2020년 4월 3일

1 개 추천

Create a vector of samples that is ((sampling frequency) times (number of seconds)) long. Then you can play it with audioplayer() or sound() .
When you use audioplayer() or sound(), what you would pass to it would typically be floating point data in the range -1 to +1 . That range of values corresponds to (potentially) full volume, according to whatever amplification is being done by devices that are (mostly) outside the control of MATLAB. (In some cases there are calls you can make to change the volume setting of your operating system.) Aside from amplification questions, the volume percieved by the user is going to relate to the range of motion: if you were to send data in the range 0 to +1 only, then the effect on loudness would be the same as if you were to send -1 to 0, and that in turn would be the same as if you sent -1/2 to +1/2; all three are half of the volume that could be achieved. The values you send are not directly volume numbers: they are how far in or out the speaker cone is to be from relaxed, and volume comes with motion, not with pure extension. sound(ones(14000), 4000) would be silent because there is no motion.
So, if you have a set of samples centered around 0, and you want to play it at (say) 25% of the maximum the hardware is configured for, then multiply the samples by 25%.
s=rand(1,4000);
sound(s,4000);
sound(s*0.25,4000)

댓글 수: 6

Osman osmanavci
Osman osmanavci 2020년 4월 3일
Is it valid given commands by you for my record setting as we see in ss?
Walter Roberson
Walter Roberson 2020년 4월 3일
That looks pretty good for writing to a file.
However, note this is not "generating" a tone, this is recording something. It is a common homework assignment to be required to generate a tone from a mix of specific frequencies of sine waves.
Osman osmanavci
Osman osmanavci 2020년 4월 3일
Of course, my commands in image records the voice, I know it. So, I must generate generate 5 seconds long 10 kHz audio tone. Its sampling frequency must be equal to my recorded voice’s sampling frequency and its magnitude can be 2 times of the maximum magnitude of voice data. Then ı must add tone signal to voice signal and obtain distorted signal. I mean, I ask only how can I generate tone signal?
Walter Roberson
Walter Roberson 2020년 4월 3일
What is the waveform of the tone you must generate? The code for generating the tone would be different for a triangle wave than for a sine wave.
Remember, sin(2*pi*Frequency*Time) completes Frequency cycles per second.
Osman osmanavci
Osman osmanavci 2020년 4월 3일
it can be sine form, I am going to use to design a filter to obtain original recording voice from distorted audio signal.
Walter Roberson
Walter Roberson 2020년 4월 3일
sin(2*pi*Frequency*Time) . Time is 0:number_of_samples divided by sampling frequency.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Measurements and Spatial Audio에 대해 자세히 알아보기

질문:

2020년 4월 2일

댓글:

2020년 4월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by