R
R
robertono2015-07-25 22:33:40
Programming
robertono, 2015-07-25 22:33:40

What is sound? How to generate it?

What is computer sound? One second from some music, for example.
Let's take the same video. It consists of video and sound. Video is, in turn, pictures that change after some time (ala number of frames per second). The picture is in turn a list of pixels (location + color).
And what does sound consist of? How often does it change? (transition to another sound, what does it depend on? For video, this is frames per second).

Answer the question

In order to leave comments, you need to log in

5 answer(s)
M
Moskus, 2015-07-26
@Moskus

Sound in some medium (air, water or solid) is pressure fluctuations, that is, sequences of higher and lower pressure drops propagating in space from a source.
Sound in a computer is a conditionally (that is, from maximum to minimum) encoded sequence of positions of a part of a sound-reproducing device, for example, a speaker membrane. The amount of deviation from the zero position is the amplitude, the number of intermediate positions per second is the sampling rate.
When they say that the sound on a CD is encoded in the format "16 bit 44 kHz", this means that the position of the speaker membrane is encoded 44 thousand times per second and between the extreme positions - 2 ^ 16, that is, 65535 positions.
When playing sound, each such value from 0 to 65535 is converted by the digital-to-analog converter of the sound card into a voltage value supplied to the speakers. And the speakers regularly create pressure fluctuations in the air.
A tone is indeed a frequency of oscillation, but a pure tone, when the sound is pure sinusoidal oscillations, is a rarity. In fact, the sine is a rarity. Open any audio recording in some sound editor, look at the maximum magnification at the waveform. Here, in general, it somehow looks like this.

V
Vasily, 2015-07-25
@Applez

Sound is frequency (Hz) and duration, otherwise everything is the same.
Here is a good article on the topic.

V
Vladimir Martyanov, 2015-07-25
@vilgeforce

Sound is a longitudinal wave in some medium. It is formed by vibration of some body, in the case of a computer - a membrane under the influence of an electric current. The current generates an alternating magnetic field in the winding, it interacts with a constant one and oscillations occur.

X
xmoonlight, 2015-07-25
@xmoonlight

Sound (or sound wave) is the wave vibrations of an air mass caused by vibrations of a solid body placed inside this air mass.
Electronic sound synthesis (synthesizer, electronic sound) - a sinusoidal change in voltage for subsequent electromagnetic-mechanical transformation, for example, vibrations of the speaker membrane of an acoustic column or earphone, over time.
Loudness - the amplitude of oscillations.
Tone is the frequency of oscillation.

R
Roman Mirilaczvili, 2015-07-26
@2ord

If about the theory of digital sound synthesis, then you should read Wikipedia: Audio Information Coding .
To practice sound programming, it is worth looking for examples for the PortAudio library. There is an introductory article to it: How to play continuous audio data?
When it comes to programming games, they usually play the previously recorded sound. The sound can be played as an audio stream, as well as by a MIDI synthesizer as commands for a set of musical instruments.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question