View Single Post
Old 05 June 2017, 10:26   #39
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,500
There have been some improvements to the ptplayer 2.0 release on Aminet, years ago. Besides some bug fixes and enhancements there is a more flexible function for playing sound effects, which was already used in games like Power Glove and Tiger Claw. From the readme:

Quote:
The sound fx system gives you the possibility to play samples on a channel of your choice or on the channel which the player thinks is the best one.

It may be a channel which is currently not replaying music and/or has the longest period of silence ahead. This has the effect that the replayed song is often not disturbed at all.

Up to four sound effects can be played at the same time and any of them has its own priority, which is especially useful when trying to play several sounds on the same channel. You may for example define that a shooting-sound has a higher priority than a jumping-sound.

For automatic channel selection you can additionally reserve specific channels for music only, or define the maximum number of channels which may be used for sound effects at once.

The master volume is always applied to the music, but does not affect external sound effects at all.
The new sound-fx function interface:
Code:
_mt_playfx(a6=CUSTOM, a0=SfxStructurePointer)
  Request playing of a prioritized external sound effect, either on a
  fixed channel or on the most unused one.
  Structure layout of SfxStructure:
    APTR sfx_ptr (pointer to sample start in Chip RAM, even address)
    WORD sfx_len (sample length in words)
    WORD sfx_per (hardware replay period for sample)                
    WORD sfx_vol (volume 0..64, is unaffected by the song's master volume)
    BYTE sfx_cha (0..3 selected replay channel, -1 selects best channel)  
    BYTE sfx_pri (unsigned priority, must be non-zero)
  When multiple samples are assigned to the same channel the lower
  priority sample will be replaced. When priorities are the same, then
  the older sample is replaced.
  The chosen channel is blocked for music until the effect has
  completely been replayed.
To make the ptplayer 4.0 easier to maintain for me I integrated the small-data and the single-section variants into a single source text, using BASEREG by default. But I never released it, because I was not happy about the fact that BASEREG is only supported by vasm and AsmOne.

Now a reworked 5.0 can be found on Aminet (http://aminet.net/mus/play/ptplayer.lha), which is portable enough to work on most assemblers. Tested are: Devpac, vasm, PhxAss, Basm, SNMA, AsmOne, AsmPro. Additionally I added a leading underscore to all exported function- and variable-names, so they can be directly accessed from C source texts as well.
phx is offline  
 
Page generated in 0.04308 seconds with 11 queries