Sound Using Pc Speaker 
Author Message
 Sound Using Pc Speaker

  I was playing with the sound procedure included in the Crt unit and
found a strange problem that I havent seen an answer to solving in the
manuals.
  I used an equation I found in a old math book that allowed me to
find notes based on the fact middle a s 440 hz. The equation is the
frequency wanted is = 440 * 12root\/2^n     where n is number of notes
above or below a. Using this formula I was able to get my programs to
play scales, etc.. The problem is that as the frequency increase the
duration decreases. So if I had a program play mid c to high c like
the following

playNote( note : integer; duration : integer);
  begin
        figure out freq.
        sound(freq);
        delay(duration);
        nosound;
   end;

 playnote(midc,200);
 playnote(midd,200);
 playnote(mide,200);
 ......
 ......
 playnore(highc,200);      <--- By the time I get here the duration
                                has just about halfed!?

  Is there a way to get around this? Why is this occuring? Is there a
equation that can compensate for difference in duration based on
frequency?

any answers or pointers appreciated,


=Brent Hostetler ============================
================== www.kaiwan.com/~brenth ===
+===========================================+



Tue, 08 Sep 1998 03:00:00 GMT  
 Sound Using Pc Speaker

: ..........
:
: playNote( note : integer; duration : integer);
:   begin
:       figure out freq.
:       sound(freq);
:       delay(duration);
:       nosound;
:    end;

:  playnote(midc,200);
:  playnote(midd,200);
:  playnote(mide,200);
:  ......
:  ......
:  playnore(highc,200);      <--- By the time I get here the duration
:                               has just about halfed!?

:   Is there a way to get around this? Why is this occuring? Is there a
: equation that can compensate for difference in duration based on
: frequency?

I have used such programs in the past with no problem at all!

I suggest you pre-calculate the frequencies of the notes, so that you
have the music played "smoothly", without "pauses for calculations".

In case you calculate the frequency in procedure PlayNote, the time
taken to calculate may seem as part of the previous note, so you have
the impression that the duration is not the same.

But, even if it sounds logical, I don't think a 386+ would need many
milliseconds to calculate the frequency inside procedure PlayNote,
so the effect would be not so evident (you speak about HALF time!)

So, I suggest you debug your program and check if duration is actually
200, or gets altered by some misterious bug...

Hope you find your way out to enjoy real music!




Wed, 16 Sep 1998 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. PC Speaker's sound

2. MessageBeep( -1 ) to sound the pc speaker

3. Playing sound files through pc-speaker?

4. pc speaker

5. PC-SPEAKER - VOLUME ?

6. port 0061 & PC-speaker

7. Turn off pc-speaker?

8. PC-Speaker WAV/VOC in DOS

9. How to play .WAV file through PC Speaker?

10. Playing WAV files through the PC-Speaker

11. Send PC speaker beeps to SB ???

12. Help me stop the PC speaker please!

 

 
Powered by phpBB® Forum Software