English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General > Coders. Releases

 
 
Thread Tools
Old 25 July 2020, 12:03   #101
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,541
Quote:
Originally Posted by girv View Post
With AddICRVector the TA and TB interrrupts are separated for you so ...
In fact I already thought about doing an OS-friendly version of the player. This would also involve allocating the audio channels from audio.device, for example. But I never needed that myself and there are so many other things to do...

Quote:
The system I had before did the same thing except it supported repeating the effect, but repeats were only actually used for two effects so I'll see if I can work around it.
It would probably need an additional flag to mark the sample als infinite, so the player nevers declares the channel to be available again. And you might need a new function to stop it.

An easier workaround for you may be not to use one channel for music at all and start your repeating samples there.

Quote:
Maybe a future enhancement for ptplay?
Probably. Although it is unusual for a sound effect in games to play endlessly.
phx is offline  
Old 25 July 2020, 12:20   #102
girv
Mostly Harmless
 
girv's Avatar
 
Join Date: Aug 2004
Location: Northern Ireland
Posts: 1,149
Quote:
Originally Posted by phx View Post
In fact I already thought about doing an OS-friendly version of the player. This would also involve allocating the audio channels from audio.device, for example. But I never needed that myself and there are so many other things to do...

I had most (all?) of the OS-side already, and I'd hoped to work on hooking it up to the player this week, but there are so many other things to do...



Quote:
Originally Posted by phx View Post
It would probably need an additional flag to mark the sample als infinite

I had a repeat count in the sfx structure, which could also be -1 for infinite. I used the infinite repeat for background effects like wind or an engine noise. Your idea of locking out a channel for these effects might be workable ... though I only use them rarely.
girv is offline  
Old 01 September 2020, 23:55   #103
girv
Mostly Harmless
 
girv's Avatar
 
Join Date: Aug 2004
Location: Northern Ireland
Posts: 1,149
I actually have a version that works with OS-allocated audio channels and CIA-B interrupts now. Super untidy yet

TLDR:
Use AddICRVector to set up a Timer A and Timer B interrupt on CIA-B.
Have the TA interrupt server call mt_TimerAInt
Have the TB interrupt server call whatever ptplayer has stored in the address pointed to by mt_Lev6Int
Comment out various bits of ptplayer related to manual setting of level 6 interrupt things
Change rte to rts

Question: in the interrupt handlers there is a nop before the rte. What's that for?
girv is offline  
Old 02 September 2020, 00:37   #104
Galahad/FLT
Going nowhere
 
Galahad/FLT's Avatar
 
Join Date: Oct 2001
Location: United Kingdom
Age: 50
Posts: 9,016
Quote:
Originally Posted by girv View Post
I actually have a version that works with OS-allocated audio channels and CIA-B interrupts now. Super untidy yet

TLDR:
Use AddICRVector to set up a Timer A and Timer B interrupt on CIA-B.
Have the TA interrupt server call mt_TimerAInt
Have the TB interrupt server call whatever ptplayer has stored in the address pointed to by mt_Lev6Int
Comment out various bits of ptplayer related to manual setting of level 6 interrupt things
Change rte to rts

Question: in the interrupt handlers there is a nop before the rte. What's that for?
Its probably to do with the instruction before it to ensure on machines with 040/060 that the preceeding instruction gets processed properly on machines that are too fast.
Galahad/FLT is offline  
Old 02 September 2020, 15:39   #105
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,541
Quote:
Originally Posted by girv View Post
Use AddICRVector to set up a Timer A and Timer B interrupt on CIA-B.
Have the TA interrupt server call mt_TimerAInt
Have the TB interrupt server call whatever ptplayer has stored in the address pointed to by mt_Lev6Int
After some good suggestions from Ross the current version of the player no longer modifies the level 6 interrupt vector, and it uses a simple toggle to alternative between the two TB interrupt routines. You can get the latest source for comparison, if your are interested.

Quote:
Originally Posted by Galahad/FLT View Post
Its probably to do with the instruction before it to ensure on machines with 040/060 that the preceeding instruction gets processed properly on machines that are too fast.
Exactly.
phx is offline  
Old 03 September 2020, 15:11   #106
girv
Mostly Harmless
 
girv's Avatar
 
Join Date: Aug 2004
Location: Northern Ireland
Posts: 1,149
Ah I've just posted my modified 5.3 version here
https://gist.github.com/johngirvin/8...e2f439bb074e95

But I'd be interested in the latest code. Does it have other improvements?
girv is offline  
Old 04 September 2020, 11:23   #107
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,541
Quote:
Originally Posted by girv View Post
Ah I've just posted my modified 5.3 version here
https://gist.github.com/johngirvin/8...e2f439bb074e95

But I'd be interested in the latest code. Does it have other improvements?
Yes, a few. I should really consider a release now. You may download the beta of V5.4 here: http://phoenix.owl.de/ptplayer54beta.lha

From the Readme:
Code:
- Fixed sign-bug in tremolo/vibrato command 7xx (Antiriad/EAB).
- New function _mt_samplevol may be used to redefine a sample's volume.
- _mt_playfx now returns a pointer to the selected channel status structure
  when the sample was scheduled for playing and returns NULL when ignored.
- Wait 576 ticks for audio DMA instead of 496, which fixes issues with
  low notes on a few A1200 configurations. (No, this doesn't harm the
  player's performance, as it is a timer interrupt.)
- Defining the symbol MINIMAL lets you assemble a minimal version of
  the player, without the ability to insert sound effects and without
  master-volume or changing samples volumes.
- Improved interrupt handling, following a suggestion of Ross/EAB.
- Minor optimizations.
phx is offline  
Old 06 September 2020, 17:09   #108
girv
Mostly Harmless
 
girv's Avatar
 
Join Date: Aug 2004
Location: Northern Ireland
Posts: 1,149
Updated the gist to 5.4 beta

This isn't a "clean" version that could be released as it has some changes specific to my game and modifications to the player code. It would probably take another IFD symbol to control making the regular or "os-friendlier" version.

Things to look at:
- removed SDATA feature
- changed rte to rts
- removed clearing of EXTERN bit in INTREQ
- mt_Delay, mt_MasterVol, mt_MasterFade
- fiddled with the TB interrupt routine
girv is offline  
Old 13 September 2020, 11:46   #109
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,541
ptplayer 6.0 release

I have finally released a new version. It took so long because we have currently no new game in a state to easily test all modifications ourselves. So thanks to all the beta testers!

The latest bug fix, not included in the 5.4beta, finally makes _mt_musicmask work as expected. You can download the release from Aminet: http://aminet.net/mus/play/ptplayer.lha

Full list of changes:
Code:
- _mt_musicmask works as documented now! Sound effects will never play
  on the masked channels. Previously it was rather a hint not to use them.
- Fixed sign-bug in tremolo/vibrato command 7xx (Antiriad/EAB).
- New function _mt_samplevol may be used to redefine a sample's volume.
- _mt_playfx now returns a pointer to the selected channel status structure
  when the sample was scheduled for playing and returns NULL when ignored.
- Wait 576 ticks for audio DMA instead of 496, which fixes issues with
  low notes on a few A1200 configurations. (No, this doesn't harm the
  player's performance, as it is a timer interrupt.)
- Defining the symbol MINIMAL lets you assemble a minimal version of
  the player, without the ability to insert sound effects and without
  master-volume or changing samples volumes.
- Improved interrupt handling, following a suggestion of Ross/EAB.
- Minor optimizations.
phx is offline  
Old 05 January 2021, 11:03   #110
BigT
Registered User
 
Join Date: Apr 2020
Location: Melbourne / Australia
Posts: 23
Firstly a big thank you for all the work that has gone into this player and for sharing it with the community ! It is much appreciated. Whilst reviewing the code, was wondering whether line 295 of ptplayer.asm is correct
move.w d0,INTREQ(a0) ; should this be a6 instead of a0 ?
BigT is offline  
Old 05 January 2021, 11:08   #111
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,369
this package is a lifesaver. I was considering replacing the music OR sfx games player by that one (if memory allowed to) in whdload. Would be a cool project. Premiere or Wonderdog would be good candidates.
jotd is offline  
Old 05 January 2021, 11:31   #112
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,541
Quote:
Originally Posted by BigT View Post
Whilst reviewing the code, was wondering whether line 295 of ptplayer.asm is correct
move.w d0,INTREQ(a0) ; should this be a6 instead of a0 ?
Yes, that's a bug! Good catch! Fixed it. Luckily it has no noticeable effect, because even in the rare situations where the EXTER interrupt flag is still set it won't do any harm. Besides, in most games mt_remove_cia() is never called, because the game only ends by rebooting the machine.

BTW, due to popular request I added the functions mt_loopfx() and mt_stopfx() to play endless, looped sound effects. Here are the changes of the 6.1beta, which may be released soon:
Quote:
- Fixed note delay command (EDx), which still played the previous note
in some situations (Antiriad/EAB).
- Symbol ENABLE_SAWRECT may be used to disable sawtooth and rectangle
waveforms for vibrato and tremolo, which saves memory for their tables
(suggested by Antiriad).
- Removed cia.i and custom.i include files and included the required
symbols directly into the source.
- New function mt_loopfx() for playing looped sound effects.
- New function mt_stopfx() for immediately stopping a sound effect.
Beta version is here: http://phoenix.owl.de/ptplayer61beta.lha
phx is offline  
Old 05 January 2021, 13:21   #113
BigT
Registered User
 
Join Date: Apr 2020
Location: Melbourne / Australia
Posts: 23
Quote:
Originally Posted by phx View Post
Yes, that's a bug! Good catch! Fixed it. Luckily it has no noticeable effect, because even in the rare situations where the EXTER interrupt flag is still set it won't do any harm. Besides, in most games mt_remove_cia() is never called, because the game only ends by rebooting the machine.

BTW, due to popular request I added the functions mt_loopfx() and mt_stopfx() to play endless, looped sound effects. Here are the changes of the 6.1beta, which may be released soon:


Beta version is here: http://phoenix.owl.de/ptplayer61beta.lha

No worries, I'm probably one of the few trying to use the code in a semi OS friendly way by returning back to the OS CLI after my program is done. Thx for the link to the beta, I'll definitely have a look.
BigT is offline  
Old 11 February 2021, 19:59   #114
h0ffman
Registered User
 
Join Date: Aug 2008
Location: Salisbury
Posts: 768
Hey Phx

I've got a slightly weird issue with the sound effects engine which is obviously down to my use case but wondered if you had any thoughts on how I can fix it.

My game has a dynamic sound buffer meaning when you enter each room, the sound effects for that room are unpacked into a buffer in chip ram. The issue is that the sound engine is leaving the dma running at the previous sound effects volume so when the buffer is refilled for the next room it ends playing a high pitch noise.

I updated to 6.1 beta in the hope that calling _mt_stopfx for all 4 channels would prevent this from happening but it seems that the engine detects that the sample has ended so doesn't turn it off.

If music was playing (which it will be eventually) then it'll probably not be as much of a problem, but would like to see if I can get this resolved anyway.

Was thinking one way would be to load the pointer / repeat after the DMA has kicked off to be a dedicated clean word in chipram. That way, when the sample finishes it'll be outside of the dynamic buffer. I had a look at implementing this myself but it looks like as though the loading of the hardware registers is somewhat intertwined with the protracker playback engine?

Any thoughts would be greatly appreciated.
h0ffman is offline  
Old 11 February 2021, 20:38   #115
h0ffman
Registered User
 
Join Date: Aug 2008
Location: Salisbury
Posts: 768
OK, maybe ignore me, think I found and patched it although it might need a little more work to patch looped samples back in.
h0ffman is offline  
Old 12 February 2021, 15:03   #116
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,541
Quote:
Originally Posted by h0ffman View Post
My game has a dynamic sound buffer meaning when you enter each room, the sound effects for that room are unpacked into a buffer in chip ram.
Ok. So we are only talking about sound effects and not about music.

Quote:
The issue is that the sound engine is leaving the dma running at the previous sound effects volume so when the buffer is refilled for the next room it ends playing a high pitch noise.
Yes. For simplicity the player uses the same technique to put sfx into an idle loop as it does with music samples. The first word of a sample always has to be zero to make it work.

Quote:
I updated to 6.1 beta in the hope that calling _mt_stopfx for all 4 channels would prevent this from happening but it seems that the engine detects that the sample has ended so doesn't turn it off.
Correct.

Quote:
Was thinking one way would be to load the pointer / repeat after the DMA has kicked off to be a dedicated clean word in chipram. That way, when the sample finishes it'll be outside of the dynamic buffer.
Yes. In fact the player already uses the word at $0 for this purpose when playing Mods from PC-trackers, which set the repeat-length to zero and/or fail to clear the first word of a sample.

Anyway, if I understand your problem correctly, the simplest solution would be to call
_mt_end
, before changing your dynamic buffer. It disables all Audio DMA and sets all volumes to zero.

Otherwise, I could imagine an option in the player, which defines that you can guarantee the word at $0 being cleared. You may try the following patch and assemble with
NULL_IS_CLEARED=1
:
Code:
Index: ptplayer.asm
===================================================================
RCS file: /usr/src/cvs/ptplayer/ptplayer.asm,v
retrieving revision 1.35
diff -u -r1.35 ptplayer.asm
--- ptplayer.asm        5 Jan 2021 10:12:43 -0000       1.35
+++ ptplayer.asm        12 Feb 2021 14:00:50 -0000
@@ -138,6 +138,12 @@
 ENABLE_SAWRECT equ     1
        endc

+; Set this if you can guarantee that the word at $0 is cleared and if
+; you want to use if for idle-looping of samples.
+       ifnd    NULL_IS_CLEARED
+NULL_IS_CLEARED        equ     0
+       endc
+
 ; Delay in CIA-ticks, which guarantees that at least one Audio-DMA
 ; took place, even with the lowest periods.
 ; 496 should be the correct value. But there are some A1200 which
@@ -1005,13 +1011,18 @@
        beq     .1                      ; no sfx playing anyway
        moveq   #1,d0
        move.b  d0,n_sfxpri(a0)
-       move.w  d0,n_sfxlen(a0)         ; idle loop at sample-start
+       move.w  d0,n_sfxlen(a0)         ; idle loop
        move.w  #108,n_sfxper(a0)       ; enter idle as quickly as possible
        clr.w   n_sfxvol(a0)            ; and cut volume
+       ifne    NULL_IS_CLEARED
+       clr.b   n_looped(a0)
+       clr.l   n_sfxptr(a0)            ; use $0 for idle-looping
+       else
        tst.b   n_looped(a0)
        beq     .1
        clr.b   n_looped(a0)
        subq.l  #2,n_sfxptr(a0)         ; idle loop at sample-start - 2
+       endc
 .1:    move.w  #$c000,INTENA(a6)

        rts
@@ -1344,6 +1355,9 @@
        move.l  a0,AUDLC(a5)
        move.w  d0,AUDLEN(a5)
        moveq   #1,d0                   ; idles after playing once
+       ifne    NULL_IS_CLEARED
+       sub.l   a0,a0
+       endc

        ; save repeat and period for TimerB interrupt
 .2:    move.l  a0,n_loopstart(a2)
@@ -1509,8 +1523,12 @@
        move.w  (a0)+,d0                ; length
        bne     .4

+       ifne    NULL_IS_CLEARED
+       moveq   #0,d2                   ; use $0 for empty samples
+       else
        ; use the first two bytes from the first sample for empty samples
        move.l  mt_SampleStarts(a4),d2
+       endc
        addq.w  #1,d0

 .4:    move.l  d2,n_start(a2)
@@ -1538,7 +1556,6 @@
        add.l   d3,d2
        add.l   d3,d2
        move.w  (a0),d0
-;      beq     idle_looping            ; @@@ shouldn't happen, d0=n_length!?
        move.w  d0,n_replen(a2)
        exg     d0,d3                   ; n_replen to d3
        add.w   d3,d0
@@ -1552,11 +1569,16 @@

 no_offset:
        move.w  (a0),d3
+       ifne    NULL_IS_CLEARED
+       cmp.w   #1,d3
+       beq     .1
+       bhi     set_replen
+       else
        bne     set_replen
-idle_looping:
+       endc
        ; repeat length zero means idle-looping
-       moveq   #0,d2                   ; FIXME: expect two zero bytes at $0
        addq.w  #1,d3
+.1:    moveq   #0,d2                   ; expect two zero bytes at $0
 set_replen:
        move.w  d3,n_replen(a2)
 set_len_start:
phx is offline  
Old 21 February 2021, 15:12   #117
h0ffman
Registered User
 
Join Date: Aug 2008
Location: Salisbury
Posts: 768
Thanks for the reply PHX. So the solution I came up with was to have a dedicated word in chip ram for the idle. If the sfx being played is a single shot, then it loads this pointer instead of the sample pointer meaning when the sfx ends, I'm in a safe area of chip ram which wont get overwritten when my buffer gets refilled on a room change. All my high pitch noise is now gone.

Code:
	; save repeat and period for TimerB interrupt
.2:               move.l     a0,n_loopstart(a2)
                  cmp.b      #1,d0
                  bne        .3
                  move.l     #NullSample,n_loopstart(a2)
.3:
                  move.w     d0,n_replen(a2)
                  move.w     n_sfxper(a2),d0
                  move.w     d0,AUDPER(a5)
                  move.w     d0,n_period(a2)
                  move.w     n_sfxvol(a2),AUDVOL(a5)
I have to say it's a really nice system to work with. Made adding the sfx to Metal Gear pretty simple. Also it's really nice to be able to write the music with all 4 channels. I allocate elements of the music which are less noticeable when the get muted by sound effects to the last channel.
h0ffman is offline  
Old 21 February 2021, 15:13   #118
h0ffman
Registered User
 
Join Date: Aug 2008
Location: Salisbury
Posts: 768
and I've just spotted a potential bug here.

should be ..

Code:
                  cmp.w      #1,d0
h0ffman is offline  
Old 22 February 2021, 14:14   #119
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,541
Yes, your solution will work, as long as you only care about one-shot effects.

I just hoped somebody would test the general solution for your problem (my patch above), so I can check that in for the next release.
phx is offline  
Old 22 February 2021, 16:24   #120
h0ffman
Registered User
 
Join Date: Aug 2008
Location: Salisbury
Posts: 768
Hey PHX, I see, so you're doing kinda the same thing except but using address $0 as the clear word.

Looped samples were dealt with still as I tell it to stop playing sfx on all four channels before a room change.

Anyways, I'll grab your latest beta and give it a try.

One thing I have noticed is the master volume doesn't appear to be effecting samples which are already playing. I have a short fade which occurs when soundtracks are switched and the looped samples being played by the mod are not reducing until another sample is played.

Is that how it currently works, i.e. master volume doesn't come into effect until a sample is triggered?
h0ffman is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
MOD-player with external sound effects phx Coders. Asm / Hardware 14 18 June 2012 10:41
Amiga Forever&Protracker bad sound moriez support.WinUAE 14 06 January 2009 01:26
What was the first Amiga tracker to support external midi instruments Kola Amiga scene 3 09 December 2008 19:20
Sound/Protracker package Dunny request.Apps 3 23 July 2008 19:17
Sampled sound player? cdoty Coders. General 7 25 August 2007 16:21

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 13:33.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.10226 seconds with 14 queries