Yay, another dsp thread. PROTIP for >>5: write to stdout, it's better. That way some of us can do | aplay instead of enabling OSS emulation. And your code becomes so much simpler.
Name:
Anonymous2008-05-24 14:07
Can someone be kind enough to explain the PCM format read by /dev/dsp? The meaning of this 8000hz, how endianness affects interpretation of sound, what does each byte (in 8bit pcm) mean, etc
>>10 The meaning of this 8000hz
Number of samples read per second. how endianness affects interpretation of sound
Each sample is one byte in this format, so it doesn't matter. what does each byte (in 8bit pcm) mean
Simply the attenuation, 127 is 0, 0 is negative maximum, and 255 maximum.
For a pure tone, use a sine wave scaled to 0-255. Figure out a way of calculating the frequency (it has to do with 8000Hz) and you can generate any tone.
Name:
Anonymous2008-05-24 14:12
* Not attenuation, damn it... hm, what is the term...
Name:
Anonymous2008-05-24 14:14
>>12
So each second is 8000 bytes, where each byte means something like the "volume" of the tone corresponding to that frequency? Am I enlightened?
Name:
Anonymous2008-05-24 14:17
>>14
Well, just use a sine wave and change the frequency of it. Longer waves for lower frequency sounds, and shorter waves for higher frequency (perhaps up to 8000Hz, or half of that). You might want to scale the amplitude down a bit though, as that seems to improve sound quality a bit.
>>22
Funny you should ask that; I had to rewrite some software that was running on one of our old AIX machines last week. And not only was it AIX, but it was an ungodly old version of AIX (5.2). It was funny finding out things like, hey, grep back then didn't support recursive searches.
> uname -a
AIX harper 2 5 000B423C4C00
As such, my advice is to take an axe to any monstrosity HP-UX/AIX machine you have the misfortune to come across.
Name:
Anonymous2008-05-25 22:50
I think I've finally understood[1] how basic sound works. It's like a digital raw description of actual analogic sound. But, damn, that imples that i must build the waves myself with sin(). What if i want to play two different tones simultaneously?
Does anyone know a good introduction to ``sound theory''? Because I'd prefer reading something myself than filling this thread with questions. Due to geographical conditions i'm unable to buy books, so links are preferred. But I don't know what to search.
>>28
Well, what happens if you were to set up two speakers in the same room playing two different tones? The instantaneous pressure from the two would be added together. If you want to mix two sound waves, you just need to add their amplitudes for that sample together.
Name:
Anonymous2008-05-25 23:23
>>30
You mean that adding up both lineally would work? Taking two parts of the wave from the od output above:
I'm not going to decipher your graph, but
Wave 1: 0 1 2 3 4 5 4 3 2 1 0 -1 -2
Wave 2: 0 2 4 2 0 -2 -4 -2 0 2 4 2 0
Combo : 0 3 6 5 4 3 0 1 2 3 4 1 -2
is how it works. The only thing to watch out for is that exceeding your maximum amplitude is very likely, and will result in distorted output. You can just let the numbers overflow if you want, or you can clip the waveform, what audio software usually dies. In my example, if the maximum amplitude is 5, that six needs to be made into a 5. This will also result in distorted output, but that's just how it is. If you're trying to produce nice sound, it's a matter of carefully picking levels that won't clip given the material you are mixing.
Name:
Anonymous2008-05-26 1:29
>>34
Corrections: I'm responding to >>31, "dies" should be "does".
>>34 exceeding your maximum amplitude is very likely, and will result in distorted output. [...] that six needs to be made into a 5. This will also result in distorted output, but that's just how it is.
God, you're a fucking emo. Crrrawwwwwling in my skiiiinnnnnnnn...
>>38
Is that even relevant to the topic, or is it just your way of saying ``I thought we were speaking of mainstream music for faggots''
Name:
Anonymous2008-05-27 1:00
>>39
Whatever you do, you'll get distorted output. You cannot win.
Name:
Anonymous2008-05-27 1:13
>>40
You just have to teach your computer to speak softly. Or you could technically program a compressor, but screw that. A little distortion adds life.
Name:
Anonymous2008-05-27 1:23
>>38
Is that just your way of saying,``I've read Linkin Park lyrics''?
Name:
Anonymous2009-03-06 8:55
Compile LISP in their laughter I began changeing the code that deals with the user input was correct return.