Alive
News Team Current issue History Online Support Download Forum @Pouet

01 - 02 - SE - 03 - 04 - 05 - 06 - 07 - 08 - 09 - 10 - 11 - 12 - 13 - 14

Alive 6
[ Back to Main ]


4. DMA-Sound - the simple way to make music
-------------------------------------------
Registers:
  DMA-Sound Control Register:
    $FFFF8900  0 0 0 0 0 0 0 0 0 0 0 0 0 0 X X

    Writing a "00" to the last 2 bits terminate DMA sound replay.
    Bit 0 controls Replay off/on, Bit 1 controls Loop off/on
    (0=off, 1=on).

  DMA-Sound Start Address Register:
    $FFFF8902  0 0 X X X X X X X X X X X X X X   Hibyte
    $FFFF8904  X X X X X X X X X X X X X X X X   Midbyte
    $FFFF8906  X X X X X X X X X X X X X X X 0   Lowbyte

    These three registers contain the 24-bit address of the sample
    to play. Even though the samples are built on a byte-base, the
    DMA chip also only allows even addresses

  DMA-Sound Count Register:
    $FFFF8908  0 0 X X X X X X X X X X X X X X   Hibyte  (ro)
    $FFFF890A  X X X X X X X X X X X X X X X X   Midbyte (ro)
    $FFFF890C  X X X X X X X X X X X X X X X 0   Lowbyte (ro)

    Used internally for the DMA-soundchip to count from start- to
    end-address. No write access.

  DMA-Sound End Register:
    $FFFF890E  0 0 X X X X X X X X X X X X X X   Hibyte
    $FFFF8910  X X X X X X X X X X X X X X X X   Midbyte
    $FFFF8912  X X X X X X X X X X X X X X X 0   Lowbyte

    The address that the sample ends at. When the count registers
    have reached this address, the DMA-sound system will either
    stop or loop.

  DMA-Soundmode Register:
    $FFFF8920  0 0 0 0 0 0 0 0 X 0 0 0 X X X X

    Allows to toggle between several replay methods.
    Bit 7 switches Mono/Stereo (1 = Mono, 0 = Stereo),
    Bit 0 and 1 encode the replay rate:
      0 0  -  6258 Hz
      0 1  - 12517 Hz
      1 0  - 25033 Hz
      1 1  - 50066 Hz

Sounds fairly easy, right ? Unfortunately, it's not.

? I set all the registers, but there is no sound at all.
! The DMA soundsystem expects you to write the addresses of the
  sample to play in the same order you set the screen base
  address: Hi- then Midbyte, or Mid- then Hibyte, but in any
  case Lowbyte last. This is due to the fact that the address
  generator for the DMA sound is housed in the Shifter and uses
  the logic of the Video Shifter.

? I can't hear anything on my Falcon when trying to replay a
  6 KHz sample.
! The Falcon DMA-soundsystem does not support 6 KHz. The value
  "00" in the Soundmode-register means "OFF" on the Falcon.

? The sound is awful. This does not sound like my sample.
! On the STE, the DMA-soundsystem only works with signed sample
  files, featuring values from -128 over 0 to +127. Some sample
  programs use unsigned formats, ranging from 0 to 255 with
  128 representing zero-line of the sample. Those samples need
  to be converted first.

? I want to replay stereo samples. How can i know which sample
  will be played on which channel ?
! Stereo Samples have to be organized wordwise like
  Lowbyte -> right channel
  Hibyte  -> left channel

? My STE program to replay samples does not work very well on the
  Falcon.
! No, the Falcon's soundsystem is way more complex and can without
  any major programming interfere very well with the parts of the
  STE-soundsystem, especially since identical addresses are used for
  some purposes. If you want Falcon-compatibility of your STE-code,
  do not use "move"-instructions to set/unset bits of $FFFF8900
  and $FFFF8920 as this might override Falcon-specific registers.
  Best, leave them as they are and use AND to unset and OR to set
  certain bits.

? Will my STE code work on the TT ?
! Yes, it will. The TT's DMA-sound subsystem is identical to the
  one of the STE (In fact, it is not, but it has been made appear
  identical to the programmer in any case).

? I am trying to change the addresses of the sample while the
  DMA-sound plays, but it does not work.
! No, the DMA-Soundsystem latches the Start- and End-Register
  internally, so writing to these values only takes influence
  when the values are re-read, which happens when the sample
  has been played, if the DMA-soundsystem is switched to
  loop.

? Argh, i have now implemented DMA-sound to my program and now
  my whole screen-management goes wild
! This easily happens. The DMA-sound subsystem of the STE houses
  the "shifting logic" in the STE-Shifter. When starting the DMA
  sound to play a sample, you should not try to access the Shifter's
  registers directly afterwards but "wait" a few cycles.
  The simplest solution is to wait a single VBL after starting
  the DMA-sound before proceeding with your program.
  Once the DMA-sound plays, you can change DMA-sound registers
  without risking to screw up screen management.

? Can i get a "notice" from the DMA-soundsystem when it finished
  playing a sample ?
! Yes, you can use TIMER A as event counter which will be notified
  when a sample has been played completely.

? I want to replay a sample backwards.
! Does not work on the STE. The sample-counter can only be
  increased, not decreased.

[ Back to Main ]
[ Onto next Chapter ]

Alive 6