[comp.sys.amiga.tech] Audio questions

murphy@pur-phy (William J. Murphy) (04/02/89)

I've just finished typing in and compiling Bob Peck's program audio.c
from Programmer's Guide to the Amiga (gee that sounds like Hitchhiker's
Guide to the Galaxy, was that similarity intended Bob?). Anyhow, I see how
one can control the sampling rate of the audio chip, but how do I convert that
into real time numbers?  Let's say for example your waveform has 16 data points
and you set the period value to be 428, what frequency would you be producing
out of the speaker?  

My guess is that it will be freq = sampling rate/(428 * 16), but what's the
sampling rate?

The next question that I have may be a bug in the program.  When I played the
program 12 times in a row, I received an error "cannot create a reply port".
This makes me think that something is not returning its port to the system. 
I checked my program, and the DeletePort(auReplyPort) and DeletePort(auLockPort)
are present in the finishup routine, so I am not sure what's happening.  If
someone else could check this on their program (if you have it entered already),
it would be appreciated.

Bill Murphy                         "Facts!, what we demand are solid facts!
murphy@newton.physics.purdue.edu     Wait, What we demand is a total absence of
                                     solid facts." Vroomfondel, Philosopher.
-------------------------------------------------------------------------------

murphy@pur-phy (William J. Murphy) (04/04/89)

In article <2093@pur-phy> murphy@newton.physics.purdue.edu (William J. Murphy) writes:
>
>I've just finished typing in and compiling Bob Peck's program audio.c
>from Programmer's Guide to the Amiga (gee that sounds like Hitchhiker's
>Guide to the Galaxy, was that similarity intended Bob?). Anyhow, I see how
>one can control the sampling rate of the audio chip, but how do I convert that
>into real time numbers?  Let's say for example your waveform has 16 data points
>and you set the period value to be 428, what frequency would you be producing
>out of the speaker?  
>
>My guess is that it will be freq = sampling rate/(428 * 16), but what's the
>sampling rate?
Well, to answer my own questions, I dug through an RKM at the bookstore and 
found that each tic of period = 279.365 ns. Thus the formula is

      frequency = 1/(279.365e-9 * Period * Repeat_of_Data)
                = 1/(279.365e-9 * 428 * 16)    = 522.7 Hz


>
>The next question that I have may be a bug in the program.  When I played the
                                        ^^^ Or a bug in the programmer!!!
>program 12 times in a row, I received an error "cannot create a reply port".
>This makes me think that something is not returning its port to the system. 
>I checked my program, and the DeletePort(auReplyPort) and DeletePort(auLockPort
   ^^^^^^^^^^^^^^^^^^ and I just checked it again, my error for not CALLING
finishup to delete the appropriate ports.  Sorry. :-(


Bill Murphy                         "Facts!, what we demand are solid facts!
murphy@newton.physics.purdue.edu     Wait, What we demand is a total absence of
                                     solid facts." Vroomfondel, Philosopher.
-------------------------------------------------------------------------------
>

jesup@cbmvax.UUCP (Randell Jesup) (04/05/89)

In article <2097@pur-phy> murphy@newton.physics.purdue.edu.UUCP (William J. Murphy) writes:
>In article <2093@pur-phy> murphy@newton.physics.purdue.edu (William J. Murphy) writes:
>>My guess is that it will be freq = sampling rate/(428 * 16), but what's the
>>sampling rate?
>Well, to answer my own questions, I dug through an RKM at the bookstore and 
>found that each tic of period = 279.365 ns. Thus the formula is
>
>      frequency = 1/(279.365e-9 * Period * Repeat_of_Data)
>                = 1/(279.365e-9 * 428 * 16)    = 522.7 Hz

	Note: only for NTSC!!!

-- 
Randell Jesup, Commodore Engineering {uunet|rutgers|allegra}!cbmvax!jesup