![]() |
![]() |
#161 |
Banana
Join Date: Jul 2016
Location: Darmstadt
Posts: 1,217
|
Updated .obj and .asm here (maybe phx could check I'm not doing anything stupid!).
To use MTPlayFX you have to pass the address of an SfxStructureobject and return a pointer to an SfxChanStatusobject. You probably want to create a few newtypes for it. Something like: Code:
NewType SfxStructure sfx_ptr.l ; Pointer to sample start in Chip RAM sfx_len.w ; Sample length in words sfx_per.w ; Hardware replay period for sample sfx_vol.w ; Volume 0..64 sfx_cha.b ; 0..3 selected replay channel, -1 selects best channel sfx_pri.b ; Priority range 1..127 End NewType NewType SfxChanStatus n_note.w ; UWORD translates to word (.w) in Blitz Basic n_cmd.w ; Another word n_index.b ; UBYTE translates to byte (.b) in Blitz Basic n_sfxpri.b ; Another byte End NewType --- edited to remove attachment, updated one below Last edited by E-Penguin; 11 August 2023 at 15:15. |
![]() |
![]() |
#162 | |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,551
|
Quote:
_mt_loopfx_stub, but you didn't do that in _mt_playfx_stub. Does Blitz always pass a longargument in d0? There might also be some room for optimization, as you only have to save/restore the registers which you modify in the stubs (mostly a6). All ptplayer functions follow the standard M68k-ABI, which means only d0-d1 and a0-a1 are scratch registers. The rest is preserved. |
|
![]() |
![]() |
#163 | |
Banana
Join Date: Jul 2016
Location: Darmstadt
Posts: 1,217
|
Ah, I'd overlooked that. (another) updated library+src attached. I'll push it to github once someone's tested it.
Blitz passes in arguments in d0-d5 (pg 34 of the BlitzUM) and expects a4-a6 to be restored to initial values at the end of it all. I'm following idrougge's examples from his original blitz-wrapper. Quote:
Edited to remove old version of the library Last edited by E-Penguin; 11 August 2023 at 20:30. |
|
![]() |
![]() |
#164 | |
Registered User
Join Date: Jun 2017
Location: Ruhrgebiet / Germany
Posts: 55
|
@E-Pinguin
Thank you very much for your help. But sadly I donĀ“t know what this sentence means: Quote:
But I can not figure out, how to use it. I am trying the example file for ptplayer which came with AmiBlitz3 DEFTYPE .sfx means your SfxStructure Code:
WBSTARTUP NEWTYPE .sound _data.l _period.w _length.w _loop.l _looplength.w _pad.b[2] End NEWTYPE NEWTYPE .sfx sfxPtr.l ; Pointer to sample start in chip ram, even address sfxLen.w ; Sample length sfxPer.w ; Hardware replay period for sample sfxVol.w ; Volume 0..64, is unaffected by the song's master volume sfxCha.b ; 0..3 selected replay channel, -1 selects best channel sfxPri.b ; unsigned priority, must be non-zero ;sfxSiz.b End NEWTYPE Statement SFXInit {*fx.sfx, snd.w, vol.w, cha.b, pri.b} *_snd.sound = Peek.l(Addr Sound(snd)) ; Get the pointer to the sound *fx\sfxPtr=*_snd\_data ; Copy the data *fx\sfxLen=*_snd\_length ; ... *fx\sfxPer=*_snd\_period *fx\sfxVol=vol *fx\sfxCha=cha *fx\sfxPri=pri ;*fx\sfxSiz=siz End Statement NEWTYPE .SfxChanStatus n_note.w ; UWORD translates to word (.w) in Blitz Basic n_cmd.w ; Another word n_index.b ; UBYTE translates to byte (.b) in Blitz Basic n_sfxpri.b ; Another byte End NEWTYPE MTInstall 1 ; Install the CIA MOD player routine (1=PAL,0=NTSC) DEFTYPE .sfx clap LoadSound 0,"909Clapp.iff" ; Initialize a sfx for ptplayer SFXInit{&clap,0,64,-1,1} ; {*pointer.sfx, sound_index, volume, channel (-1=best), priority (>0) } MTPlayFx &clap MTEnd ; Stop playing the current mod MTRemove ; Remove the CIA MOD player routine End Return value needed for this function call Sorry for all my questions...but I am still learning. |
|
![]() |
![]() |
#165 |
Banana
Join Date: Jul 2016
Location: Darmstadt
Posts: 1,217
|
chan_status.l = MTPlayFx &clap if chan_status != 0 then it should have played properly. It didn't previously return a value, now it does. In Blitz you must put the return value somewhere even if you don't do anything with it. |
![]() |
![]() |
#166 |
Registered User
Join Date: Jun 2017
Location: Ruhrgebiet / Germany
Posts: 55
|
Thanks, but there must still be something wrong.
With chan_status.l = MTPlayFx(&clap), only a buzz comes out of the speakers. With MTSoundFX the sound is at least played once before an error message (Guru -. illigal instruction) comes, so at least I know that the sound file is OK. Last edited by TheoTheoderich; 11 August 2023 at 16:29. |
![]() |
![]() |
#167 |
Banana
Join Date: Jul 2016
Location: Darmstadt
Posts: 1,217
|
Debugging time... Can you print out the value of the sfx object fields?
I wonder whether it's being created properly. |
![]() |
![]() |
#168 |
Banana
Join Date: Jul 2016
Location: Darmstadt
Posts: 1,217
|
OK, the problem definitely isn't you, it's the library. I've tested it with some old code which I know works with the previous version (based on an older version of the ptplayer.asm). Either I made a mistake when I upgraded to the latest version on aminet (most likely) or we've somehow uncovered a bug in phx's code (least likely). I'll review my diffs.
--------------------------- OK, I found the problem. The solution is a bit nasty. _mt_soundfxinternally calls _mt_playfx. The blitz library wraps these with "stubs" to save off registers a3-a6 and restore them at the end. Previously, _mt_playfxwasn't exposed to blitz so it didn't do any register saving. Now however, it is exposed so must also do a save/restore. This wasn't being done properly, it is now, so _mt_playfxshould work. The downside is that calling _mt_soundfxnow saves/restores the registers twice, once itself and once again when calling through to _mt_playfx. I don't know the best way of improving it. exit_playfxwould need to know whether it had been called via _mt_soundfxor directly via _mt_playfxand only restore the registers in the latter case (else let the registers be restored at the end of _mt_soundfx). Maybe it doesn't matter for the sake of a few cycles every now and then, I guess you're not hammering sound effects at it every frame. Last edited by E-Penguin; 11 August 2023 at 20:29. |
![]() |
![]() |
#169 |
Banana
Join Date: Jul 2016
Location: Darmstadt
Posts: 1,217
|
So, this works.
Note the changes in SFXInit, and MTInit has to be called otherwise there's weird background sound. I guess it requires a mod to be at least loaded, if not actually playing. Code:
WBStartup NEWTYPE .sound _data.l _period.w _length.w _loop.l _looplength.w _pad.b[2] End NEWTYPE NEWTYPE .sfx sfxPtr.l ; Pointer to sample start in chip ram, even address sfxLen.w ; Sample length sfxPer.w ; Hardware replay period for sample sfxVol.w ; Volume 0..64, is unaffected by the song's master volume sfxCha.b ; 0..3 selected replay channel, -1 selects best channel sfxPri.b ; unsigned priority, must be non-zero ;sfxSiz.b End NEWTYPE Statement SFXInit {*fx.sfx, snd.w, vol.w, cha.b, pri.b} *_snd.sound = Addr Sound(snd) ; Get the pointer to the sound *fx\sfxPtr=*_snd\_data ; Copy the data *fx\sfxLen=*_snd\_length ; ... *fx\sfxPer=*_snd\_period *fx\sfxVol=vol *fx\sfxCha=cha *fx\sfxPri=pri ;*fx\sfxSiz=siz End Statement NEWTYPE .SfxChanStatus n_note.w ; UWORD translates to word (.w) in Blitz Basic n_cmd.w ; Another word n_index.b ; UBYTE translates to byte (.b) in Blitz Basic n_sfxpri.b ; Another byte End NEWTYPE MTInstall 1 ; Install the CIA MOD player routine (1=PAL,0=NTSC) LoadBank 0,"test_it_.mod",2 MTInit 0,0 ; Weirdness happens if this isn't called to point to some valid mod DEFTYPE .sfx clap LoadSound 0,"ow-sound.8svx" ; Initialize a sfx for ptplayer SFXInit{&clap,0,64,-1,1} ; {*pointer.sfx, sound_index, volume, channel (-1=best), priority (>0) } ; Start the music play loop, if you want to ;MTPlay On ; Wait 10s VWait 500 ad.l = 0 For i=0 To 10 ad = MTPlayFx(&clap) VWait 50 Next i MTEnd ; Stop playing the current mod MTRemove ; Remove the CIA MOD player routine End |
![]() |
![]() |
#170 |
Registered User
Join Date: Jun 2017
Location: Ruhrgebiet / Germany
Posts: 55
|
Thank you very much.
This new code was also not working, due to the error: "CanĀ“t convert types" in the Statement SFXInit line: "*_snd.sound = Addr Sound(snd) ; Get the pointer to the sound" But I found out, that changing the SFXInit snd parameter from "snd.w" to "snd.l" solves this problem. Now the MTPlayFX command is working fine ![]() Tomorrow I will try to implement it into my game Settle the World and will do some more testing ![]() Thank you very much for your help @E-Pinguin. |
![]() |
![]() |
#171 | |
Registered User
Join Date: Jan 2009
Location: Barcelona / Spain
Posts: 434
|
Hi, I tried to update Blitz libs with this new version, and although it seems to be working, it changes the order of all the commands for older source codes. What was MasterSetVolume is now MTSoundFX, etc, etc.
Is it possible to keep the order of the commands? otherwise it is a mess. Thanks! Quote:
|
|
![]() |
![]() |
#172 |
Registered User
Join Date: Dec 2013
Location: Auckland
Posts: 3,548
|
I've created another wrapper (but based on the existing one) for the purposes of the Scorpion Engine, but I've put it on github if anyone has any use for it or wants to submit pull requests.
It's mainly different in that it doesn't use the bank library, sound library etc, and that Blitz specific code is kept separate from ptplayer.asm so future updates can be dropped in without needing to merge. It uses the 6.4 beta (cheers Phx), which may be final if there's no further changes. https://github.com/earok/ptplayer_blitzwrapper_scorpion |
![]() |
![]() |
#173 | |
Registered User
Join Date: Jan 2009
Location: Barcelona / Spain
Posts: 434
|
Thanks for sharing it! I have tried it and I have the same problem with function names not being the correct ones. I think it is related with latests versions of Amiblitz, it doesn't happen in Amiblitz 3.8, for example
Quote:
|
|
![]() |
![]() |
#174 | |
Registered User
Join Date: Dec 2013
Location: Auckland
Posts: 3,548
|
Quote:
Is there another copy of the library present that could be conflicting? |
|
![]() |
![]() |
#175 | ||
Banana
Join Date: Jul 2016
Location: Darmstadt
Posts: 1,217
|
Quote:
Quote:
![]() |
||
![]() |
![]() |
#176 | |
Registered User
Join Date: Jan 2009
Location: Barcelona / Spain
Posts: 434
|
Quote:
![]() |
|
![]() |
![]() |
#177 |
Registered User
Join Date: Nov 2019
Location: Celle / Germany
Posts: 147
|
Sorry, I missed this topic.
The Problem may be, that AmiBlitz3 uses a faster tokenization-routine - yes, the compiler stills needs tokenized sources. As the commands are reordered in the blitzlib, the tokens have changed. The tokenization routine that runs when loading a source does not know the new tokens. But you can use the menu-option "help/update instruction index" once to update the token-hashmap. Anyother problem with reordering of commands is, that AmiBlitz3 used the first command in each lib to identify the libname - as there is no other effective way to do it. After replacing a lib with reordered commands, you have to update the file "system/token_mapping_libs.txt". --- I'd like to update the distribution with the changed playerlib. Can someone provide me please the lasted version ? Last edited by Honitos; 06 September 2023 at 11:31. |
![]() |
![]() |
#178 | |
Registered User
Join Date: Jan 2009
Location: Barcelona / Spain
Posts: 434
|
Thank you, I was able to update the library following the provided steps!!!
Now the first function is MTInstall instead of MTinit, changing it fixed it. I noticed there isn't MTPlay anymore, it looks like MTEnable is the replacement. Quote:
|
|
![]() |
![]() |
#179 |
This cat is no more
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,381
|
zoned tunes where tempo doesn't seem to register (sbagman.mod). Works with any tracker but not with ptplayer.
|
![]() |
![]() |
#180 |
Registered User
Join Date: Dec 2016
Location: Warsaw area
Posts: 153
|
Im working on my game Robot Jet Action 2 https://eab.abime.net/showthread.php?t=116486
The game is developed in BB2. And I was wondering if I can play sub tunes in module with ptplayer? TIA |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
![]() |
||||
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 |
|
|