English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General

 
 
Thread Tools
Old 19 January 2019, 20:43   #1
LeCaravage
Registered User
 
LeCaravage's Avatar
 
Join Date: May 2017
Location: AmigaLand
Posts: 459
Amiga sfx/mod conversion & play

Hi,

My question is for Amiga 500 OCS using asm language.

I'm next to zero concerning music and sound on Amiga (it took me ages to figure out the use of P61a replay).

I have several question about programming sound on Amiga :

- Is it possible to use 3 channels protracker mod compacted with P61Con and sfx at the same time AND the more important not using CIA timing but VBL synch instead.
Trust me, I can't use the level 6 interrupt flag to play this module.

-The musician sent me sfx in IFF format. Is it possible to convert (or extract?) the raw sample and play it or, is it better to stick to IFF ?

- Does the phx replay could be used with VBL sync and module compacted format ?

I could try to find the solution myself but I'm on time pressure these weeks.

Thanks for help,
LeCaravage is offline  
Old 20 January 2019, 15:53   #2
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
Quote:
Originally Posted by LeCaravage View Post
- Is it possible to use 3 channels protracker mod compacted with P61Con and sfx at the same time
I didn't look into the P61 source, so perhaps Photon can shed some light on it, but there is a good chance that a player doesn't write to a channel's audio registers, when no music it played on it.

Quote:
AND the more important not using CIA timing but VBL synch instead.
I remember P61 had such an option...
But you will have to tell your musician that he can no longer set any finer grained replay speeds with the 'F' command. And you are wasting cycles (see below).

Quote:
-The musician sent me sfx in IFF format. Is it possible to convert (or extract?) the raw sample and play it or, is it better to stick to IFF ?
It is quite easy to convert IFF-SVX8 into raw format. You just have to strip the IFF header. The rest of the file is already raw Amiga format. Sometimes people even used IFF samples directly, because you don't hear the noise of the header in any case.

Quote:
- Does the phx replay could be used with VBL sync
My ptplayer requires CIA-B timer interrupts to enable audio-DMA and set the sample-loops after 496 ticks. When driving your player by VBL you have to do that with busy-waiting, which wastes a lot of cycles in your game frame.

Quote:
and module compacted format ?
I don't know how that compacted format works - so probably not.
phx is offline  
Old 20 January 2019, 16:33   #3
LeCaravage
Registered User
 
LeCaravage's Avatar
 
Join Date: May 2017
Location: AmigaLand
Posts: 459
I think I have to use the replay for P61 compacted and build myself a simple sfx 1 voice managing, because the compacted generated P61 file is saving quite a lot of Kb. The replay 6.1a allows vbl sync.
Anyway, your answer is complete and helpfull. Thanks pal.
LeCaravage is offline  
Old 20 January 2019, 16:47   #4
mcgeezer
Registered User
 
Join Date: Oct 2017
Location: Sunderland, England
Posts: 2,702
I use phx’s replayer and it is fantastic, i have no idea why u would use anything else.
I’m happy to give pointers around how i drive it. Very straight forward.

Geezer
mcgeezer is offline  
Old 20 January 2019, 17:33   #5
ross
Defendit numerus
 
ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
Quote:
Originally Posted by phx View Post
When driving your player by VBL you have to do that with busy-waiting, which wastes a lot of cycles in your game frame.
Not necessarily. You can defer the delay with a CIA-A timed IRQ. I've some patch code that do that
So you can leave off IRQ6 for something more 'aggressive'.
A module player that can interrupt a VBI can be excessive in some case, but yes, all depends on how you write your code

Quote:
Originally Posted by LeCaravage View Post
I think I have to use the replay for P61 compacted and build myself a simple sfx 1 voice managing, because the compacted generated P61 file is saving quite a lot of Kb. The replay 6.1a allows vbl sync.
Yes, these can be advantages that make the difference. I used P6112 myself when I had space problems.
I would also add the ability to 8-bit delta adjust samples data (so use less disk space when compressed, in addition to using less RAM space for module data).


Quote:
Originally Posted by mcgeezer View Post
I use phx’s replayer and it is fantastic, i have no idea why u would use anything else.
I’m happy to give pointers around how i drive it. Very straight forward.
Sure! phx's replayer is great, with some unique feature, and easy to use.
Absolutely a must if used in a video game.

Anyway also P6112 has is advantages (more 'demo' related).
Maybe one day a mix of the two..


--
PS: there is somewhere in a hukka's pack a new version of the Photon's P61 replayer.

From the history:
Code:
;SPECIAL NOTE FOR THIS VERSION:
;-----------------------------
; hacked by hukka/Void in 2016-06-30 to play EFx (Invert Loop) effect
; as it's played in ProTracker editor
; small fix/optimization to the hukka hack by ross in 2018-01-29
If interested you can also contact me.

Last edited by ross; 20 January 2019 at 17:53. Reason: PS
ross is offline  
Old 20 January 2019, 20:35   #6
LeCaravage
Registered User
 
LeCaravage's Avatar
 
Join Date: May 2017
Location: AmigaLand
Posts: 459
@Geezer : Thanks for the help proposal, much appreciated, but as already stated I need memory save.

@ross : PM sent.
LeCaravage is offline  
Old 21 January 2019, 18:34   #7
Photon
Moderator
 
Photon's Avatar
 
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,602
Quote:
Originally Posted by LeCaravage View Post
- Is it possible to use 3 channels protracker mod compacted with P61Con and sfx at the same time AND the more important not using CIA timing but VBL synch instead.
Yes, p61_mode=2, jsr p61_music in your Vblank. But check that the song is made for Vblank tempo: put the song in the Example source, set p61_mode=2, write exe, send to musician for approval.
Quote:
Originally Posted by LeCaravage View Post
-The musician sent me sfx in IFF format. Is it possible to convert (or extract?) the raw sample and play it or, is it better to stick to IFF ?
Raw. It's what the sound chip plays, anything else will eat CPU. If you convert it in your program, it eats RAM. I just convert them in Audiomaster, but I'm sure there's a command line program.

Ross, Hukka: nice find, I'm changing mine! But consider uploading as P6113 to Aminet as it's open source now. (This actually fixes all versions of The Player 6.1 so even if you have maybe a P6106 that has gotten fixed over the years you could make the same change in that.)
Photon is offline  
Old 21 January 2019, 18:44   #8
LeCaravage
Registered User
 
LeCaravage's Avatar
 
Join Date: May 2017
Location: AmigaLand
Posts: 459
@Photon : Indeed I asked the musician to not use > F20 effects -as written in the replay header source-.
And thanks for the additional tips.
LeCaravage is offline  
Old 21 January 2019, 20:39   #9
Photon
Moderator
 
Photon's Avatar
 
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,602
But I forgot to answer your questions about channels for SFX

Set channels=3 (f.ex.) and splitchans=0. This should leave the other channels untouched and could gain a few bytes in song file size.
Photon is offline  
Old 22 January 2019, 15:23   #10
ross
Defendit numerus
 
ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
Quote:
Originally Posted by Photon View Post
Ross, Hukka: nice find, I'm changing mine! But consider uploading as P6113 to Aminet as it's open source now.
ross is offline  
Old 07 February 2021, 21:08   #11
The Welder
Registered User
 
Join Date: Feb 2021
Location: Brighton
Posts: 2
Let me give you my input on this matter as I've used P41A -> P61A extensively in many demos and intros. Even written my own mod player.

P61A is actually very easy to do just about anything you want with, it's all about setting options and that's what source gets assembled. There is a setting in the replayer for VBL playback under a level-3 IRQ.

For playing music with P61A, by default it uses CIA-B on which there are two timers A and B. Timer A is set to ONE-SHOT mode and is used to control the Audio DMA. Timer B is set to CONTINUOUS and is used to play music that is tempo based, where the tempo is not 125bpm. CIA-B generates Level-6 interrupts, so when using audio timed DMA, you need to switch your IRQ handler so that it does the audio DMA and also the calls the play routine for the module.

So it basically works like this... You load your audio registers, but you need to wait for the DMA to start (which is usually about 6 scan lines, maybe more which is why you had those busy-loops in older replayers). However, with a CIA timer, you can load the audio registers and start a timer (in one-shot mode) and this timer will be set for about 6 scan lines, when you get the IRQ your DMA has started and you can set the registers accordingly. The useful this about this technique is that there is no busy waiting because you get signalled by an IRQ when the DMA starts. During this IRQ, you also switch out the current IRQ handler for the other one that is running on timer B for the tempo.

It's actually quite tricky to do nicely, but once you get there, everything is fine!

Now, you're talking about using CIA-A, which also has two timers A and B. Sure, you could use these timers, but be aware that CIA-A generates level-2 IRQ's and is used for the mouse and keyboard. The problem with using these timers is that since they're level-2 IRQ's, they can interrupt Level-3 IRQ's which is your Copper, Blitter and VBL. This can lead to all sorts of unfortunate tearing on the screen if get a level-2 IRQ interrupt your level-3 and eats your VBL interval. Moreover, if you've got any plans to return to the OS on exiting, you're going to find it INSANELY difficult to reset CIA-A back to a state where it's friendly to the operating system again.
The Welder is offline  
Old 07 February 2021, 21:20   #12
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,164
Your explanation is very interesting, specially the non-busy waits that a lot of players DON'T use, and use empty dbfs instead, which trashes the sound on fast machines.

For the CIAs, one thing is sure: you cannot save the reload timer value that was there before you changed it. But tools like whdload are able to get back to the OS nicely. Not saying that it's easy, but it's doable. Alain Malek (Hornet from HRTMon) provided me with such a routine, and I used it successfully with JST.

Are you sure that level 2 interrupt is going to interrupt level 3 interrupt? I don't think so. When entering copper/vblank/blitter interrupt, SR is set so it cannot be interrupted by a lower priority interrupt (unless you hack SR from within the interrupt of course)
jotd is online now  
Old 07 February 2021, 21:23   #13
Antiriad_UK
OCS forever!
 
Antiriad_UK's Avatar
 
Join Date: Mar 2019
Location: Birmingham, UK
Posts: 418
Quote:
Originally Posted by jotd View Post
Are you sure that level 2 interrupt is going to interrupt level 3 interrupt? I don't think so. When entering copper/vblank/blitter interrupt, SR is set so it cannot be interrupted by a lower priority interrupt (unless you hack SR from within the interrupt of course)
Yeah correct, it's the other way around. So your code in a level3 vbl will be interrupted by a level6 CIA. It wouldn't be interrupted by a level 2.
Antiriad_UK is offline  
Old 07 February 2021, 21:45   #14
The Welder
Registered User
 
Join Date: Feb 2021
Location: Brighton
Posts: 2
Quote:
Originally Posted by Antiriad_UK View Post
Yeah correct, it's the other way around. So your code in a level3 vbl will be interrupted by a level6 CIA. It wouldn't be interrupted by a level 2.


You're right.... the other way around. Whoops, although my StatusMonitor in my demos (a bit like Sanity's one, but not as good, used to do some horrible things to the SR to force stuff to happen)


My apologies people... I'm old. What else can I say. I've managed to find some old source where I did this, but had to extensively modify a Noisepacker player because that was the format the module was in!


np_irq1:
movem.l a0-a1/a6,-(sp)
lea $dff000,a6
tst.b $bfdd00
move.b #$19,$bfde00
lea np_irq2(pc),a0
move.l np_vbr(pc),a1
move.l a0,$78(a1)
move.w np_block+16(pc),$96(a6)
move.w #$2000,$9c(a6)
movem.l (sp)+,a0-a1/a6
nop
rte
np_irq2:
movem.l a0/a6,-(sp)
tst.b $bfdd00
lea $dff000,a6
move.l np_voidat1+18(pc),$d0(a6)
move.w np_voidat1+22(pc),$d4(a6)
move.l np_voidat1+50(pc),$c0(a6)
move.w np_voidat1+54(pc),$c4(a6)
move.l np_voidat1+82(pc),$b0(a6)
move.w np_voidat1+86(pc),$b4(a6)
move.l np_voidat1+114(pc),$a0(a6)
move.w np_voidat1+118(pc),$a4(a6)
move.l np_vbr(pc),a0
move.l np_oldirq(pc),$78(a0)
move.w #$2000,$9c(a6)
movem.l (sp)+,a0/a6
nop
rte
The Welder is offline  
Old 08 February 2021, 20:02   #15
Photon
Moderator
 
Photon's Avatar
 
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,602
As a sketch, there are 3 timings for Protracker module replay:
  1. Vblank (for SUBSTEP TEMPO <$20) or Lvl6 (for STEP TEMPO >=$20 - the module you use must be compatible with Vblank, else you play it... at the wrong tempo! )
  2. DMA set #1 (can be done at least sound-correctly with raster busy-wait of _9_ lines (5 if productivity modes/RTG not supported), but preferably with a lvl 6 interrupt, counted AFTER relevant DMA stops set in 1. A player today should have no dbf for this.
  3. Same for DMA set #2, preferably another lvl6 int. Can be deferred to next frame (requires padding of samples that last less long than a frame).

This is for a straight player, no extra stages performed, like requiring 1 frame to decompress notedata, or distributing decompression across multiple frames (requires SUBSTEP TEMPO Fxx <$20 and > than number of channels).

Last edited by Photon; 08 February 2021 at 20:07.
Photon 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
Lemmings with sfx & CD audio tracks jotd project.CD32 Conversion 12 21 April 2019 15:44
Gods with sfx & audio tracks jotd project.CD32 Conversion 60 24 January 2019 13:16
Casual Play & Serious Play Amiga Setups ransom1122 Retrogaming General Discussion 3 20 October 2015 21:35
Trapped I & II - Music & SFX? ecamber support.Games 5 28 March 2015 19:23
Amiga game mod player for PC aka how to play BP files wlcina support.Other 6 16 March 2012 00:03

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 18:53.

Top

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