Register | Login
Views: 19364387
Main | Memberlist | Active users | ACS | Commons | Calendar | Online users
Ranks | FAQ | Color Chart | Photo album | IRC Chat
11-02-05 12:59 PM
0 user currently in Programming. | 3 guests
Acmlm's Board - I2 Archive - Programming - outputting sound. | |
Add to favorites | "RSS" Feed | Next newer thread | Next older thread
User Post
Sushi D
Newcomer
Level: 3

Posts: 2/2
EXP: 49
For next: 79

Since: 12-30-04

Since last post: 243 days
Last activity: 242 days
Posted on 03-04-05 02:23 AM Link | Quote
hmm..

basically i would like to ask for any information with regards to creating sounds and outputting them.

not stuff like playing an MP3 or WAV file.. but creating it in real time and then outputting it.


any information would be appreciated.

thank you in advance for your assistance.
Dish

Spiny
Level: 38

Posts: 291/596
EXP: 355646
For next: 14801

Since: 03-15-04
From: Disch

Since last post: 18 days
Last activity: 18 days
Posted on 03-04-05 04:34 AM Link | Quote
There's two parts to outputting sound that you should have to be familiar with:

1) Actually outputting the sound. This can be done by various methods. On windows... the simplest is probably through waveOut functions. DirectSound is another alternative which will give you a lower latency, but is a little more complicated to manage. It's probably best to get familiar with streaming sound before you work on generating it... I'd practice with streaming large .wav files or something similar before you go into the second part:

2) Generating the sound!

Sound is produced by vibrating waves. The volume of the wave it determined by it's amplitude or 'height', whereas the pitch is determined by its frequency (the number of times the wave repeats per second). For a visual example (please excuse the crudity):



The pitch of the tone is measured in frequencies measured in Hz. Hz = the number of repetitions per second. So to produce a 220 Hz tone, you could have a waveform repeat 220 times in one second. The higher the frequency, the higher the pitch.

And like I said before, the amplitude determines the volume of the sound. The "taller" the wave, the louder the sound.

Now... how do computers represent this wave? Computers break down the wave into "samples"... which are basically a list of points at regular intervals (like the green dots in this fugly example I made in paint!):



The number of samples that make up a second's worth of sound is known as the samplerate. A samplerate of 44100 Hz means there are 44100 samples for each 1 second's worth of sound. The higher the sampletate, the higher the quality. Audio CD's use 44100 Hz.

Each sample is merely a value containing the current position of the wave (you could think of it as the "Y position"... the height of the current position of the wave). The depth of this measurement is determined by the "bits per sample". 8-bit sound and 16-bit sound are the most common. 8-bit sound means that (you guessed it), each sample is represented by 1 byte! Whereas with 16-bit sound, each sample is represented with 2 bytes. A weird quirk with this, though... is that usually 8-bit sound is unsigned... meaning 128 is the "center line"... 0 is the bottom... and 255 is the top. However 16-bit sound is signed.... meaning 0 is the "center line"... -32768 is the bottom... and 32767 is the top.

Anyway... that's about the jist of it. If you have further questions (which I'm sure you do). Feel free to ask.
Parasyte

Bullet Bill
Level: 35

Posts: 334/514
EXP: 267348
For next: 12588

Since: 05-25-04

Since last post: 104 days
Last activity: 32 days
Posted on 03-05-05 11:01 AM Link | Quote
Here is a very nice document which explains digital audio: http://music.arts.uci.edu/dobrian/digitalaudio.htm
If Disch's post has you completely lost or if you just want to learn more, I highly recommend reading it.
Add to favorites | "RSS" Feed | Next newer thread | Next older thread
Acmlm's Board - I2 Archive - Programming - outputting sound. | |


ABII


AcmlmBoard vl.ol (11-01-05)
© 2000-2005 Acmlm, Emuz, et al



Page rendered in 0.021 seconds.