[comp.sys.amiga.audio] Real-time effects ?

jgllgher@vax1.tcd.ie (01/29/91)

	hi,
	   I've just acquired a sampler for my amiga which connects to the
parallel port and seems to conform to the standard for such devices (i.e. it
works with AudioMaster.).I would like to write some software to perform some 
real-time effects.I attempted to write a program which would just monitor the 
sampler i.e. it just fed the incoming samples to paula's AUD0DAT register.Since
I was only guessing at how the samples are read in,I was'nt really surprised 
when the program did'nt work.

Could anyone give me a few hints on how you're supposed to read in the sample
values? 

Also the sampler is stereo.I have no idea how this is this handled.

Also the when writing directly to the audio-data registers in paula,what values
should you put, for example, in the audio-period registers ? Does it matter ?

Since two samples are loaded into the audio-data registers at a time, how long
is there between the output of the first and second sample ? Am I missing out
on something very basic here?

Any suggestions or answers to any of the above would be much appreciated.Any
code examples would be even more welcome.I hope to write some fairly
comprehensive effects software but I can't even start without this basic
information.

________________________________________________________________________________
Dara Gallagher : jgllgher@vax1.tcd.ie
--------------------------------------------------------------------------------

ags@scs.carleton.ca (Alexander George Morison Smith) (01/31/91)

jgllgher@vax1.tcd.ie wrote on 29 Jan 91 15:21:12 GMT:
>I've just acquired a sampler for my amiga which connects to the parallel
>port and seems to conform to the standard for such devices (i.e.  it
>works with AudioMaster.)...  Could anyone give me a few hints on how
>you're supposed to read in the sample values?

I wrote a program for recording sound samples directly to disk
(AGMSRecordSound, available on BIX).  In the course of my
investigations, I found out a few things.  Here are the tech notes I
wrote up as part of the documentation:

Well, I found out a bit while writing this program.  Ok, two bits :-). 
For one thing, I found out how to use a digitizer: set CIAA port B to be
all inputs (the parallel port).  Set CIAB port A pins POUT and SEL to be
outputs.  The sampler spews out bytes to the parallel port with no
handshaking, at some rate that I assume is pretty fast.  Some digitizers
use a high level on SEL to connect the right audio input to the sampler
and a high level on POUT to connect the left channel.  AMAS just seems
to use the POUT bit to select left or right and seems to use right
instead of left.  Whatever.  Once you have the desired channel, you can
get a sample byte by reading the parallel port byte.  Subtract $80 from
it to make it into a signed number and store it away.  Allow a small
amount of time between switching from left to right (or vice versa) to
let the sampler update its value (the time for a few instructions should
be enough).

>Also the when writing directly to the audio-data registers in paula,
>what values should you put, for example, in the audio-period registers?
>Does it matter?

Yes, it does.  If you are writing individual values to the audio
registers then you must do several things.

For initialization, turn off the DMA bit for the channel you want to
manually write to and turn off the interrupt enable bit.  Set up the
audio period to 1 if you are doing your own timing and just writing
bytes.  Set the volume to max. 

Then for each sample do these steps:

1 - Turn off the interrupt has happened bit for the channel.  Yes, I
    know you have interrupts disabled but the sound chip needs to have
    the interrupt request bit cleared before it plays the next sample. 

2 - Take your sound sample byte and duplicate it into a word (16 bits). 
    Write the 16 bit value to the audio data register. 

>Since two samples are loaded into the audio-data registers at a time,
>how long is there between the output of the first and second sample? Am
>I missing out on something very basic here?

Well, the delay between the first byte and the second byte is the time
it takes for a counter to count down the audio period.  The counter runs
at a bit over 3 megahertz.  The same delay occurs between the second
byte and the loading of the first byte in the next word.  If there isn't
any next word, the audio hardware goes into an idle state and waits for
you to clear its interrupt has happened bit.  This is really too complex
to explain, you should look at the state machine diagram in the hardware
manual for Paula.

- Alex