# Sound: the YM2149, the STE's DMA sound, the Microwire and the LMC1992 ## YM2149 PSG (DOC: HWSPEC 4.1, 9; core: ay8910-python) Three square-wave channels, noise, an envelope, a mixer and two 8-bit ports behind sixteen registers, clocked at **2 MHz** from GLUE (HWSPEC 4.1; SVC "Glue": 8 MHz divided). Its outputs are mixed with the cartridge port's audio in and sent to the monitor speaker (HWSPEC 4.1). Register select at FF8800 (write), read at FF8800, write data at FF8802 (HWSPEC 9). Atari's note: treat PSG accesses as critical regions in software (Appendix C 841017D: the select-then-write pair is not atomic). The ports are machine I/O, not sound (HWSPEC 9): | Port | Bit | ST use | | --- | --- | --- | | A (output) | 0 | floppy side 0/1 | | A | 1, 2 | drive 0, drive 1 select (active low) | | A | 3, 4 | RS-232 RTS, DTR | | A | 5 | Centronics STROBE | | A | 6 | general purpose output (the monitor connector's GPO; on the STE the genlock clock input takes the pin: STEADD) | | A | 7 | reserved | | B | 0-7 | parallel (printer) data | **ay8910-python** (`76cace3`, published) models the YM2149 per input clock (a 32-step envelope; the AY's die model is its judge for the AY parts; "the Yamaha parts' timing inside a step" is unverified, its README) with both ports, and names the Atari ST among its targets; its example is clocked at "an Atari ST's" 2 MHz. The board supplies the port callbacks and runs it at the GLUE-derived 2 MHz (MAME: 2,005,311 Hz, OBSERVED, a quarter of the CPU clock). Nothing new is expected from the core. MAME's log shows TOS reading port A while it is set as an output (OBSERVED: "read from YM2149 SSG Port A set as output"): what a real YM2149 returns there is a question for ay8910-python's claims (raise it upstream if the board needs it: U15). ST music is often "digi" sound: the CPU writes the three channels' volumes at a sample rate from an MFP timer interrupt, so the PSG's volume DAC curve and the exact write times matter (the YM2149 DAC table in ay8910-python is measured on a real YM2149: ayumi, MIT). ## STE DMA sound (DOC: STEADD "DMA Sound") Two 8-bit signed channels (stereo: the high byte of each word is left) or mono; samples fetched by DMA **during horizontal blanking** into a four-word FIFO and played at 6258, 12517, 25033 or 50066 Hz; a frame is a start and an end address (end = first byte past the frame); mode 1 plays once, mode 3 repeats, with new start/end registers held until the current frame ends; the DMA-sound-active signal drives the MFP's Timer A input and is XORed into GPIP 7. Registers FF8900-FF8913, mode FF8921. The DAC output passes a four-pole switched low-pass at 40% of the sample rate and a two-pole 16 kHz low-pass, then the LMC1992, then the RCA jacks and the monitor (STEADD). Atari gives the rates as rounded figures; how they divide from the video crystal is U16 (the GSTMCU's sheets labelled SOUND in ASIC should say). ## Microwire and the LMC1992 (DOC: STEADD "MICROWIRE Interface", "Volume and Tone Control") A 16-bit data register (FF8922) and a 16-bit mask register (FF8924): writing the data starts shifting the masked bits out, most significant first, taking about 16 µs; writes are blocked while sending; reads return the shifting snapshot. The LMC1992 has address 10 and a 9-bit data field: master volume (0 to -80 dB), left and right volume (0 to -40 dB), treble and bass (±12 dB), and the mix select (mix the PSG or not) (STEADD lists only the commands Atari uses; the LMC1992 data sheet, National TL/H/10789, was found only on datasheet aggregator sites and is not pinned). ## Modelling (proposed) PSG per input clock (the core); DMA sound per sample with its fetches placed in the MMU's blanking slots; the analogue filters and the LMC1992 as one functional output stage, marked as the family's "sound: good enough" rule allows, its constants from STEADD.