AmigaPorts / ACE

Amiga C Engine
Mozilla Public License 2.0
154 stars 25 forks source link

Implement audio manager #32

Closed tehKaiN closed 5 years ago

tehKaiN commented 6 years ago

ACE is under development since 2013 and needs some form of outputting sound! After having that done, another issue will be made about making it better and more versatile.

Basic audio output is here: https://github.com/weiju/amiga-stuff/blob/master/hardware/soundfx.c

tehKaiN commented 5 years ago

There is a nice lib which does everything I need atm: http://eab.abime.net/showthread.php?t=65430

the list goes on. It's in asm and there's C header.

When targeting other targets, perhaps we can just rewrite it into more portable C code.

tehKaiN commented 5 years ago

aminet link: http://aminet.net/package/mus/play/ptplayer

SamuraiCrow commented 5 years ago

There's still room for enhancement here. If the sound manager's music routine writes Paula registers with the Copper, there's no further need for CIA timers OR VBlank interrupts. Just count the rows of pixels rendered and have the Copper write to the Paula registers. Once the current audio frame is written to the Copper list, trigger a callback hook to refresh the blocks with the Paula writes in them and update the y position based on 15 KHz horizontal sync (or pairs of them if scan doubled on AGA) and spool the block back into the queue. (There are a few corner cases with oversized blocks and having to skip over the vertical blank region but will work on a fast CPU without having to worry about the '060 screwing things up.)

tehKaiN commented 5 years ago

I don't like idea of using copper for it, since it would imply collisions with other stuff on copperlist and also, there's additional DMA penalty:

  1. you have to generate copper instructions and write them to list
  2. copper has to read them from mem and execute them

So I think vblank/cia is a way to go.

On a side note, I've tried to use ptplayer but failed miserably. ACE tends to re-enable and disable OS during game loadings and ptplayer's int/dma state doesn't get preserved correctly since it doesn't use ACE's systemSetInt and systemSetDma. Thus rewrite to C and tweak for ACE is needed.

SamuraiCrow commented 5 years ago

The original ProTracker 2.3d player won't work on an '060 or '080 because it depends on a delay being triggered by a multiply (I think) and on the '060+ that only takes one clock cycle. The typical workaround is to route the register accesses through the Copper as I had proposed so that the delay can be implemented with a CWait.

tehKaiN commented 5 years ago

To summarize discussion we had on slack, I'll paste the conclusion here:

I guess it should be up to user to choose implementation because some games are copper-intensive, some are not I think for now there's a need for at least one ptplayer implementation, then when second one arrives their interface could be unified and they can be selected by #ifdef

So I guess the first implementation in C gets incorporated into ACE, then we can add additional ones if there will be a need to do things differently.

tehKaiN commented 5 years ago

Basic audio management works quite reliably, so any future development regarding MOD replaying should go into separate issue. Let's merge it asap because those commits are getting rebased over and over again, waiting for no one knows what.

tehKaiN commented 5 years ago

also, master is not building because it relies on audio stuff now, so let's fix it by merging asap