RE: Converting/Playing WAV files

From: Marko Mäkelä (msmakela_at_cc.hut.fi)
Date: 2000-05-18 10:50:41

On Thu, 18 May 2000, COPLIN, Nicholas. wrote:

> Hi all, (sorry for late reply but my email server was down 11/5 - 17/5)
> thanks for the info Marko, could you explain how though I would play the
> 4bit sample? I just don't know enough about the SID - I can program notes..
> but digital sounds?  Is it just a case of volume modulation?

Yep, basically you use the master volume register (the low nybble of
$d418) as a 4-bit D/A converter.  It works, because the master volume
control also amplifies the DC bias offset (which probably wasn't intended,
and the amplification was reduced in the 85xx series SID, which makes
digital samples play very quiet on newer C64s).

A simple player could pack two samples in one byte, and load them in a
loop like this:

loop:
lda (sample),y
tax
and #$0f
sta $d418
txa
lsr
lsr
lsr
lsr
sta $d418
iny
bne loop
(increment the more significant part of the pointer here)

If you want good quality, count the cycles and ensure that the writes to
$d418 occur at even intervals.  Also note that incrementing the high byte
of the sample buffer takes some cycles.  You may want to compensate for
this (add some NOP instructions before the loop, and have the iny:bne loop
jump to those extra instructions).

	Marko

-
This message was sent through the cbm-hackers mailing list.
To unsubscribe: echo unsubscribe | mail cbm-hackers-request@dot.tcm.hut.fi.

Archive generated by hypermail 2.1.1.