How can I generate audio tone?

30 Ansichten (letzte 30 Tage)
Osman osmanavci
Osman osmanavci am 2 Apr. 2020
Kommentiert: Walter Roberson am 3 Apr. 2020
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?

Antworten (1)

Walter Roberson
Walter Roberson am 2 Apr. 2020
Bearbeitet: Walter Roberson am 3 Apr. 2020
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 Kommentare
Osman osmanavci
Osman osmanavci am 3 Apr. 2020
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 am 3 Apr. 2020
sin(2*pi*Frequency*Time) . Time is 0:number_of_samples divided by sampling frequency.

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by