Re: [AD] sound frequency?

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


At 07:54 AM 7/05/2004, you wrote:

When testing the digmid patch before.. I noticed something strange:
Allegro's ALSA driver would pitch my .mids slightly higher than the OSS
driver. I found out, the difference is due to the default frequency:
ALSA uses 44100, OSS 45454.

I have no idea how sound works.. but still, I'm wondering now. Why do
different frequency values change the pitch of a midi, and which value
should be used as default? Different values for OSS/ALSA as right now
probably is not the right thing.

Anyone can shed light on this?

44100 Hz is the correct frequency.


Ben Davis wrote:
The figure 45454 comes from the early Sound Blasters.  It wasn't possible to
specify a precise frequency

Just so you know, the SB16 was immune to this. I couldn't test it on any other Sound Blasters, but when I had an SB16, I modified the DOS SB16 driver, a long time ago durring me toying with code phase, so it used the exact frequency requested. I tried 44100, 22050, 16000, 11025, and even 8000, and they all sounded right on pitch next to their off-value counterparts (plus on my old 486 those few Hz really heklped performace with DIGMID :P). I'm not exactly sure what I did though, so I'm not sure I can do the same changes again.

(To Elias Pschernig)
On many soundcards, 44100 Hz is the base or natural frequency. The reason is that the analog electronics in the soundcard is designed to give good sound quality and accurate reproduction at 44100 Hz. When a different frequency is programmed, they reprocess the 44100 Hz digital sample to give, say, 22050 Hz. This means that oddball frequencies can't be programmed into the soundcard because they can't be divided into 44100 Hz. So 11025 Hz might be acceptable, 11000 Hz isn't. In my experience older soundcards like the sb16 could be programmed at almost any frequency as long as it was a multiple of 128 (I think it was 128). Modern soundcards however reprocess the sound card using a DSP and usually can't be programmed to use odd frequencies. When a sound recording program was taken from a Pentium sb16 and ported to a new Athlon XP system, the new crappy onboard sound chip wouldn't accept a frequency of 16384 Hz. This freq was selected because it was convenient for doing an FFT (FFT sample sizes must be a multiple of 2). This meant the recording freq had to be changed to 22050 Hz before the program would work.

Playing back a sound at a higher speed makes the pitch of the sound go up. Funnily enough, playing back a sound at a lower speed makes the pitch of the sound go down. The allegro\tests\akaitest.exe program uses this technique to play the same sound at different pitches. (On my computer under W98SE I have to run allegro\setup\setup.exe, copy the saved allegro.cfg to allegro\tests, change digi_card = AXA midi_card = -1.)

(Science lesson time) Doppler shift sound is actually done by an algorithm which increases or decreases the playback speed of a sound. It's the same sound, but if it is played back faster, it sounds like the object is coming nearer. Decreasing the playback speed makes the objects sound like it is moving away. If the objects if moving faster, the playback speed is increased even more. An example of a game with doppler shift is Battlezone II, approaching tanks have their engine sound doppler shifted for more realistic sound effects. Some games even go as far to make the doppler shifted sound move from the speaker to the other. Soundcards after EAX standard usually seem to have doppler shifting included.

If more info is needed, google for cd sampling rate and it will give lots of explanations about why various sound sampling frequencies are chosen.

Sig:
When people see a cow, some want milk and others want steak. One feeds a person for years, the other only a few weeks.







Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/