[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: apple II 8bit sound programmers
Simon D. Williams wrote:
On Tue, 31 Jan 2006, Michael J. Mahon wrote:
Very cool, Simon. It's remarkable how effective time multiplexing
is in producing a multi-voiced effect! I guess it's just like
replacing chords with arpeggios.
So this got me thinking about ways to combine audio files "on the
fly"... two options I've come up with are:
1) Replace every second byte in file A with every second byte from file
B. This
is quite fast, but effectively halves the sample rate of the
original files.
And the absolute difference between the two samples will be a
very audible noise, since it will be at 5.5kHz
2) Add file A to file B on a byte-by-byte basis. This takes a lot
longer, but
the sound quality is vastly improved.
In fact, this is perfect. The result is *exactly* the result of
an audio mix of the two sample streams.
In the second case I simply PEEKed the two corresponding bytes, added
them together, subtracted 128 and limited the new value to between 0
and 255.
This approach does cause a little clipping, but in the context of 5-bit
sound
that's quite acceptable.
If you add them together, then LSR, you'll get a perfect average of
the two samples (sum / 2), still excess-128, ready to play, no overflow.
(After the ADC, the Carry is the high bit, which the shift puts back
where it belongs.)
((A+128) + (B+128)) / 2 = ((A + B) / 2) + 128
Obviously in order for this to be at all useful, I'll have to come up
with an
assembly routine to do the job... the question is: do I have to resort
to
performing 16-bit addition and subtraction, or (as I suspect) is there
a better
way to handle the arithmetic with some clever bit-twiddling?
-s
See above. ;-)
-michael
Music synthesis for 8-bit Apple II's!
Home page: http://members.aol.com/MJMahon/
"The wastebasket is our most important design
tool--and it is seriously underused."