ricco59 wrote:@ggn, is there a tuto to know how DSPmod34 works and how use it for sample playing (maybe a simple source code playing a .mod while playing 2 or 3 samples) ? It's my first try on Atari Falcon

Thanks again my Friend

Sure thing!
You can start without even integrating it in your code to see how it works by assembling "easy_use.s". Don't forget to change the path to your .mod file in label "dspmod34_mod" first. This should assemble and run properly as a .prg.
Now that we got it working, let's butcher it a bit

.
Go to label "dspmod34_voltab4" at line 256. Each word value tells the player how loud each channel will be. As you notice, there are 4 $7fff and 4 0 values. This means that the first 4 channels (which are used by the mod) are at max volume and the others are 0. For the player 0 means "don't use this channel ever". So change the first 2 zeros to say $3fff (which should be half the volume of the mod). If you assemble and run this, it should still play the mod fine.
Now, incbin a couple of samples so we can try the sample playing out.
From the docs, you can find that you have to call dspmod34_player+dspmod34_fx to play a sample. Also you have to set up some magic values before calling:
Code: Select all
d0: fx-Channel ( 0 ... 3 )
d1: Sample-Period
d2: Sample-Volume
d3: Sample-Position
a0: Sample-Start ( Adresse )
a1: Sample-Ende ( Adresse )
a2: Repeat-Start ( Adresse )
a3: Repeat-Länge ( Bytes )
So if you incbin your sample like this:
Code: Select all
my_ossom_sample: incbin "sample.raw"
my_ossom_sample_end:
you can load d0 with 0 to play your sample in the first fx channel (which is channel 5 if we count all channels), d2 with 64 (maximum allowable volume), d3 with 0 so we play the sample from start, a0 with my_ossom_sample, a1 with my_ossom_sample_end. If you don't want the sample to loop, just load a2 with my_ossom_sample and a3 with 2. Otherwise you need to calculate and enter the start position and length of the loop.
Which leaves us with d1 which I left for the end, because it's where the dreaded amiga comes into play. Because the mod player has to emulate the Paula chip to play the samples, it internally calculates sample frequencies using so called amiga period values. A quick search around the internets brought me to this site:
https://bel.fi/alankila/modguide/interpolate.txt where we see that the Paula clock is around 3546895Hz. So if we want to play a 8KHz mono sample we have to calculate the period as 3546895/2/8000=221.6809375, so let's say 222. (I'm not 100% sure where that /2 comes from - I'm not an expert on Amiga stuff, just bear with me, I just did the absolute minimum to get the thing working

).
So, with this knowledge we can now go to easy_use.s and add some code after line 88, i.e. after calling "dspmod34_supervisor_out" and before waiting for keypress. Something like:
Code: Select all
lea my_ossom_sample,a0
lea my_ossom_sample_end,a1
moveq #0,D0
move.w #222,D1
move.w #64,D2
moveq #0,D3
movea.l A0,A2
lea 2,A3
bsr dspmod34_player+dspmod34_fx
In theory this should play the sample once when the program is run. Perhaps you might want to change that "lea 2,a3" to something like "lea "my_ossom_sample_end-my_ossom_sample,a3" so it will loop the sample as long as the mod is playing.
And that should be all there is to it!
If you got this working then integrating it with your code shouldn't be too hard, just move the code from "begin" to "move.l #dspmod34_vbl,$04d2" in your startup code. If you check out the top of easy_use.s, there are some other useful routines to run, like turning the player off and on, etc etc.
Anyway, try this out and good luck
