English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General

 
 
Thread Tools
Old 01 October 2022, 09:58   #1
sandruzzo
Registered User
 
Join Date: Feb 2011
Location: Italy/Rome
Posts: 2,281
Ptplayer question

In order to play an sfx, I'm using _mt_playsfx. Is it possible to know when sfx finishes playing?
sandruzzo is offline  
Old 01 October 2022, 12:24   #2
roondar
Registered User
 
Join Date: Jul 2015
Location: The Netherlands
Posts: 3,406
Not that I can see in the docs, no. But don't you know how long your SFX takes to play? You should be able to use that knowledge, or alternatively use the period/frequency and length to calculate it if that's desirable.
roondar is offline  
Old 01 October 2022, 15:04   #3
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
It's hidden, but it is documented. When you look at the description of
_mt_playfx
in the ptplayer.readme, you can read:
Code:
  RETURN VALUES: A pointer to a channel-status structure (see ptplayer.h)
  when the sample is scheduled for playing, and NULL when the request was
  ignored.
Then have a look at this channel-status structure:
Code:
typedef struct SfxChanStatus
{
  UWORD n_note;
  UWORD n_cmd;
  UBYTE n_index;   /* channel index 0..3 */
  UBYTE n_sfxpri;  /* sfx_pri when playing, becomes 0 when done */
  /* Rest of structure is currently not exported. Don't rely on it! */
} SfxChanStatus;
Note the comment behind
n_sfxpri
. It means that you can poll this byte until it becomes zero, which means the channel has become idle. It works and I used it in some of my games.
phx is offline  
Old 03 October 2022, 09:48   #4
sandruzzo
Registered User
 
Join Date: Feb 2011
Location: Italy/Rome
Posts: 2,281
@phx

Is it the same with asm?
sandruzzo is offline  
Old 03 October 2022, 11:09   #5
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
Sure. The structure offset of
n_sfxpri
is obviously 5, so try this:
Code:
        bsr     _mt_playfx
        move.l  d0,a0
playing tst.b   5(a0)
        bne     playing
phx is offline  
Old 03 October 2022, 11:26   #6
sandruzzo
Registered User
 
Join Date: Feb 2011
Location: Italy/Rome
Posts: 2,281
@phx Thanks for your help and time! I'm using V3.8b version. Is there any new one?
sandruzzo is offline  
Old 03 October 2022, 13:41   #7
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
Quote:
Originally Posted by sandruzzo View Post
I'm using V3.8b version. Is there any new one?
Not sure what you mean. I never released such a version. The last release was V6.2: http://aminet.net/package/mus/play/ptplayer
phx is offline  
Old 03 October 2022, 13:53   #8
sandruzzo
Registered User
 
Join Date: Feb 2011
Location: Italy/Rome
Posts: 2,281
@phx

Sorry, my fault, it is the protracker version: v2.3b
sandruzzo is offline  
Old 03 October 2022, 14:34   #9
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
Originally I based my player on the source text and features of the official V2.3b source, but that has no longer much relevance.
phx is offline  
Old 03 October 2022, 14:41   #10
roondar
Registered User
 
Join Date: Jul 2015
Location: The Netherlands
Posts: 3,406
Quote:
Originally Posted by phx View Post
It's hidden, but it is documented. When you look at the description of
_mt_playfx
in the ptplayer.readme, you can read:
Code:
  RETURN VALUES: A pointer to a channel-status structure (see ptplayer.h)
  when the sample is scheduled for playing, and NULL when the request was
  ignored.
Then have a look at this channel-status structure:
Code:
typedef struct SfxChanStatus
{
  UWORD n_note;
  UWORD n_cmd;
  UBYTE n_index;   /* channel index 0..3 */
  UBYTE n_sfxpri;  /* sfx_pri when playing, becomes 0 when done */
  /* Rest of structure is currently not exported. Don't rely on it! */
} SfxChanStatus;
Note the comment behind
n_sfxpri
. It means that you can poll this byte until it becomes zero, which means the channel has become idle. It works and I used it in some of my games.
Ah, I'll admit I only read the function prototypes
Nice to see it's in there though!
roondar is offline  
Old 04 October 2022, 14:07   #11
sandruzzo
Registered User
 
Join Date: Feb 2011
Location: Italy/Rome
Posts: 2,281
@phx Works very good! I like it, very usefull! Thanks
sandruzzo is offline  
Old 06 October 2022, 05:47   #12
sandruzzo
Registered User
 
Join Date: Feb 2011
Location: Italy/Rome
Posts: 2,281
@phx

Speaking about sample rate, is there a way to get it from a sample, or do I have to set it by myself every time? When I play an sfx, I can hear some sort of "tac" when it start, do I have to take care of something to avoid it?

(sorry for my dummy guestions, but I'm not a very well into music and sfx stuffs)

Last edited by sandruzzo; 06 October 2022 at 06:39.
sandruzzo 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
PTPlayer / Vertical Blank Interrupt / 060 DanielAllsopp Coders. Asm / Hardware 41 08 April 2022 23:15
Amiblitz 3 and PtPlayer Nightshft Coders. Blitz Basic 4 14 November 2021 00:28
Problem with ptplayer MacSpain support.Other 2 23 January 2020 19:52
Amiga 1200...board revisions question / wire link modification question voyager_1701e support.Hardware 3 20 February 2014 12:32
T.F.X Question ???? synchro Amiga scene 29 13 September 2004 01:13

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 08:44.

Top

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