English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. Blitz Basic

 
 
Thread Tools
Old 18 July 2023, 09:52   #141
E-Penguin
Banana
 
E-Penguin's Avatar
 
Join Date: Jul 2016
Location: Darmstadt
Posts: 1,217
I notice the aminet version is 6.3 now; would anyone be interested in me updating the repo accordingly?
E-Penguin is offline  
Old 18 July 2023, 10:56   #142
E-Penguin
Banana
 
E-Penguin's Avatar
 
Join Date: Jul 2016
Location: Darmstadt
Posts: 1,217
I did it anyway

blitz_ptplayer updated to v6.3, latest on aminet. Disclaimer: I've not tested it!

https://github.com/E-Penguin/blitz_ptplayer
E-Penguin is offline  
Old 19 July 2023, 09:50   #143
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,381
Nice work
Daedalus is offline  
Old 19 July 2023, 10:47   #144
E-Penguin
Banana
 
E-Penguin's Avatar
 
Join Date: Jul 2016
Location: Darmstadt
Posts: 1,217
Not all of the functions in ptplayer.asm are exposed as blitz functions. I'm going to work on adding them to the next release. Some of them take a pointer to a memory structure as an argument, what's the best way to expose this to blitz (presumably as a NewType)? Some sort of res file?
E-Penguin is offline  
Old 19 July 2023, 13:00   #145
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,381
Yeah, a NewType sounds like the way to go. You could use a .res file or an include - I'd start with an Include anyway for testing.
Daedalus is offline  
Old 07 August 2023, 11:32   #146
TheoTheoderich
Registered User
 
Join Date: Jun 2017
Location: Ruhrgebiet / Germany
Posts: 55
Is there a way (in Amiblitz3) to use the PTPlayer.library to detect if a MOD file has been played completely to the end, so that I can load and play the next one?

I have several MOD files and would like to play them one after the other.

Thank you
TheoTheoderich is offline  
Old 07 August 2023, 16:15   #147
E-Penguin
Banana
 
E-Penguin's Avatar
 
Join Date: Jul 2016
Location: Darmstadt
Posts: 1,217
There's a "_mt_SongEnd" flag that you might be able to keep an eye on. It's not exported in the current version of the library but I suppose I could add a function to get it. In exchange you can test it for me

--------------
Edited to add: added the function to the attached updated version of the library. MTSongEnd should return the value of the mt_SongEnd flag. Now, precisely what this new flag does I'm not sure, but please let us know how you get on.

Last edited by E-Penguin; 07 August 2023 at 16:48.
E-Penguin is offline  
Old 07 August 2023, 16:33   #148
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,546
If you are refering to my ptplayer, then there is currently no way to stop it, once all patterns from the song arrangement list have been played. It will immediately restart with the first position.

IIRC, it is not so trivial to implement as it may seem. The last pattern positions may have started a sample which lasts longer than the pattern. It doesn't sound great to cut it immediately. Letting Audio DMA continue is also no option, because looped samples will continue forever.

I'm open for suggestions, of course!


Just checked the source and remembered that I already worked on it. There is an experimental Byte-sized variable (for C and assembler, may need BlitzBasic support) called
mt_SongEnd
(defaults to 0), which is incremented every time the song ends and repeats (when reaching 128 repetitions it flips back to 0). Setting it to
$ff
(-1), after starting the MOD, will theoretically stop replay when reaching the end. But it doesn't stop DMA or turn down volume. That would be up to you. (Not sure if I ever tested that.)

EDIT: Pengiun was faster. I shouldn't fall asleep while checking the source.

Last edited by phx; 07 August 2023 at 16:34. Reason: Zzzz
phx is offline  
Old 07 August 2023, 16:38   #149
E-Penguin
Banana
 
E-Penguin's Avatar
 
Join Date: Jul 2016
Location: Darmstadt
Posts: 1,217
My new function just returns mt_SongEnd, doesn't set it. I'll have to modify that. One moment...

If I've understood what's going on (and that is a big "if"...) if SongEnd is set to 0xFF (-1) then at the end of the current loop, mt_Enabled is set to false and playback stops. So you can poll MTIsEnabled to get the current state of the playback.

------------

OK, new version added:
Code:
; takes a value to set (0xFF = "end after this loop")
statement MTSongEnd byte
Code:
; returns whether the playback is ongoing or not
function MTIsEnabled
-----------------
Edited to remove attachment - updated one below

Last edited by E-Penguin; 11 August 2023 at 15:16.
E-Penguin is offline  
Old 07 August 2023, 20:09   #150
daxb
Registered User
 
Join Date: Oct 2009
Location: Germany
Posts: 3,308
I guess the problem is that Protracker modules do not really have an end. They just start from the beginning in a loop. Modules can play in random order. Some mods use the command F00 (if I remember right) to stop it but this also doesn't mean that the mod is finished (sample still playing like phx mentioned). It is more or less guessing the end of a mod if you don't know it. For most mods it will work but some will be cut or play longer.
daxb is offline  
Old 08 August 2023, 14:21   #151
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,546
Quote:
Originally Posted by E-Penguin View Post
If I've understood what's going on (and that is a big "if"...) if SongEnd is set to 0xFF (-1) then at the end of the current loop, mt_Enabled is set to false and playback stops. So you can poll MTIsEnabled to get the current state of the playback.
Correct.
You could even set SongEnd to 0xFE (-2) to play a MOD twice, then stop.
phx is offline  
Old 08 August 2023, 16:33   #152
TheoTheoderich
Registered User
 
Join Date: Jun 2017
Location: Ruhrgebiet / Germany
Posts: 55
Thanks for your help.
I will try it with AmiBlitz3 :-)
TheoTheoderich is offline  
Old 08 August 2023, 17:53   #153
saimon69
J.M.D - Bedroom Musician
 
Join Date: Apr 2014
Location: los angeles,ca
Posts: 3,603
Quote:
Originally Posted by daxb View Post
I guess the problem is that Protracker modules do not really have an end. They just start from the beginning in a loop. Modules can play in random order. Some mods use the command F00 (if I remember right) to stop it but this also doesn't mean that the mod is finished (sample still playing like phx mentioned). It is more or less guessing the end of a mod if you don't know it. For most mods it will work but some will be cut or play longer.
At least on productions made on Blitz and Scorpion i experienced F00 to crash the game; this has been around for some time so i think might be a "wontfix"
saimon69 is offline  
Old 08 August 2023, 18:04   #154
daxb
Registered User
 
Join Date: Oct 2009
Location: Germany
Posts: 3,308
F00 is a valid command so a fix should be done. Mod players handle it differently (stop or skip at least).
daxb is offline  
Old 09 August 2023, 15:14   #155
TheoTheoderich
Registered User
 
Join Date: Jun 2017
Location: Ruhrgebiet / Germany
Posts: 55
Hello...
I still have some problems using the PTPlayer.library with AmiBlitz3.9.9

There is an example code in the Examples folder from AmiBlitz3, but I can´t get it to work.

Every command from this Library is tokanized by AB3 (in blue bold font), exept for one command:
MTPlayFX

The mod is played fine (so I assume the Library is working correct), but I can not play the clap sound effect by pressing the left mouse button (right mousebuttion ends this example).

The command MTSoundFX is working, but it is stated in the documentation, that it is included for compatibility reasons only and that I should use the MTPlayFX command instead. The MTSoundFX command seems to make some problems in my game Settle the World, so I would like to replace it with the MTPlayFX command.

What can I do that AmiBlitz "recordnize" this MTPlayFX command to play sound effects?

Sorry for this question, but I am trying around with this already for many hours....


Code:
WBStartup

INCLUDE "ptplayer_inc.ab3"

MTInstall 1 ; Install the CIA MOD player routine (1=PAL,0=NTSC)

LoadBank 0,"playingw.mod",2 ; Load a module into chipmem
addrMod.l=Bank(0) ; Get the pointer to the module

DEFTYPE .sfx clap         ; Create a sfx instance
LoadSound 0,"909Clap.iff" ; Load a sound
; Initialize a sfx for ptplayer
SFXInit{&clap,0,64,-1,1} ; {*pointer.sfx, sound_index, volume, channel (-1=best), priority (>0) }

MTInit 0,0 ; Initialize a module from bank 0, start position = 0
MTPlay On  ; Start playing the module

While Joyb(0)<2
  VWait
  If Joyb(0)=1
    MTPlayFX &clap
  EndIf
Wend

MTEnd    ; Stop playing the current mod
MTRemove ; Remove the CIA MOD player routine

End

Last edited by TheoTheoderich; 09 August 2023 at 15:41.
TheoTheoderich is offline  
Old 09 August 2023, 15:39   #156
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,546
Quote:
Originally Posted by TheoTheoderich View Post
Every command from this Library is tokanized by AB3 (in blue bold font), exept for one command:
MTPlayFX
I have no experience with BlitzBasic, but when I look into E-Penguin's modifications to ptplayer.asm then I notice that the Basic statement definition for
MTPlayFX
is missing there.
MTSoundFX
is defined, as you already mentioned. Should be easy to add, as the
_mt_playfx_stub
stub is already there.

Quote:
Code:
LoadSound 0,"909Clap.iff"
Be careful with IFF samples. ptplayer needs raw samples, with the first two bytes cleared (like the Protracker instrument samples). When you load an IFF sample the IFF-header will be included, which doesn't always sound nice.
phx is offline  
Old 09 August 2023, 16:00   #157
TheoTheoderich
Registered User
 
Join Date: Jun 2017
Location: Ruhrgebiet / Germany
Posts: 55
Quote:
Originally Posted by phx View Post
I have no experience with BlitzBasic, but when I look into E-Penguin's modifications to ptplayer.asm then I notice that the Basic statement definition for
MTPlayFX
is missing there.
MTSoundFX
is defined, as you already mentioned. Should be easy to add, as the
_mt_playfx_stub
stub is already there.
To be honest... I have no clue how to do that and to create an updated library from it
I only can work with BlitzBasic/AmiBlitz3 code...i never learned ASM :-(

EDIT:
Could one of you please be so kind and add the MTPlayFX command to the PTPlayer.library, so I can use it with AmiBlitz3?
Thank you very much

EDIT2:
I think this is the part that needs to be added, but I do not know how to compile library
-Removed because of EDIT3-

EDIT3:
Ok, found out how to add the following code part into the ptplayer.asm and how to run the vasmm68k_mot to compile a new ptplayer.obj. I also found out how to replace the ptplayer.library in AmiBlitz3.
Now the MTPlayFX command is displayed with blue bold font, like any other AB3 command.
Code:
			
astatement
  	args    long
	libs
	subs    _mt_playfx,0,0
name    "MTPlayFX","sfxStructAddress.l"
Nice...but....
There is still an error somewhere.
When I try to run the ptplayer example from AmiBlitz3 it tells me that in line
Code:
MTPlayFX &clap
is an error "GURU! - CHK Instruction"

When I try it with my game, some strange errors occurs, like if AB3 can not find an end of a for-next or loop....after that it crashes most of the time.
Using MTSoundFX (the command which is not recommended anymore) the soundeffekt will be played, but after that it got the error "GURU! - Illegal Instruction".



Quote:
Be careful with IFF samples. ptplayer needs raw samples, with the first two bytes cleared (like the Protracker instrument samples). When you load an IFF sample the IFF-header will be included, which doesn't always sound nice.
I am aware of it and the sounds i am using are working fine with the MTSoundFX command. But in rar cases on some Amigas playing a sound with this MTSoundFX command seems to "speed up" the Mod-music which is also playing by around 60%.
So after playing a sound sample sometimes the music is played way to fast.

Last edited by TheoTheoderich; 09 August 2023 at 23:53.
TheoTheoderich is offline  
Old 10 August 2023, 22:15   #158
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,546
Quote:
Originally Posted by TheoTheoderich View Post
Could one of you please be so kind and add the MTPlayFX command to the PTPlayer.library, so I can use it with AmiBlitz3?
I expected E-Penguin to fix that in no time.
I am as unsure as you how to define a new BlitzBasic statement. I wonder why there are double args, subs and libs for some statements.

Quote:
Now the MTPlayFX command is displayed with blue bold font, like any other AB3 command.
Code:
            
astatement
      args    long
    libs
    subs    _mt_playfx,0,0
name    "MTPlayFX","sfxStructAddress.l"
Nice...but....
There is still an error somewhere.
When I try to run the ptplayer example from AmiBlitz3 it tells me that in line
Code:
MTPlayFX &clap
is an error "GURU! - CHK Instruction"
Hmm. I think you cannot call the ptplayer functions directly from AmiBlitz, because it needs to save/restore and initialize some registers first. A stub function for MTPlayFX is already there. Maybe try it with
_mt_playfx_stub
instead?

Quote:
But in rar cases on some Amigas playing a sound with this MTSoundFX command seems to "speed up" the Mod-music which is also playing by around 60%.
So after playing a sound sample sometimes the music is played way to fast.
I do not recommend to use ptplayer when the OS ist alive. Maybe some process, or AmiBlitz itself, modifies the CIA-B timer registers?
phx is offline  
Old 10 August 2023, 23:08   #159
E-Penguin
Banana
 
E-Penguin's Avatar
 
Join Date: Jul 2016
Location: Darmstadt
Posts: 1,217
I'll compile you up a new lib tomorrow with the blitz function fixed (the stub should sort out the registers saving and restoring).

Could you try the previous version? I used it with sound effects in Father Christmas vs Dinosaurs so I'm pretty sure that worked.

https://github.com/E-Penguin/blitz_p...b/ptplayer.obj

If I ever get a spare five minutes I'd like to create a test program in blitz all the functions and use that in regression testing.
E-Penguin is offline  
Old 11 August 2023, 08:12   #160
TheoTheoderich
Registered User
 
Join Date: Jun 2017
Location: Ruhrgebiet / Germany
Posts: 55
I tried the version from your link, but it is missing the MTPlayFX command in AmiBlitz.

This command is also missing in your ptplayer.asm on the same github page.


Quote:
Originally Posted by phx View Post
I do not recommend to use ptplayer when the OS ist alive. Maybe some process, or AmiBlitz itself, modifies the CIA-B timer registers?
The OS is turned off in my game because I am using the BLITZ command, so I hope that is not the problem.

Last edited by TheoTheoderich; 11 August 2023 at 08:31.
TheoTheoderich 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
Demos with music or sound effects in time with graphic effects mark_k request.Demos 7 07 December 2016 20:23
Sound issue, not all sound effects played. Connorsdad support.WinUAE 16 23 February 2015 16:32
Sound Effects in IK+ noel411 support.Games 3 07 September 2007 03:12
IK+ sound effects not working andreas support.WinUAE 4 26 July 2005 20:21
How to rip sound / effects wlcina support.Games 16 18 April 2005 03:09

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 10:27.

Top

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