A.D.A. Amiga Demoscene Archive

  Welcome guest! Please register a new account or log in

  

  

  

log in with SceneID

  

Demos Amiga Demoscene Archive Forum / Coding / How to mix sound output with a mod player?

 

Author Message
Arno Nuem
Member
#1 - Posted: 7 Dec 2010 22:03
Reply Quote
Topic says it all (I hope). I try to get the point on making sound fx output while a MOD player is playing. As Im no ASM pro, I have no clue how to "message" the player about my wish to play a sound.

Anybody here could give me some hint, where to start?

Thanks in advance!
noname
Member
#2 - Posted: 8 Dec 2010 09:54
Reply Quote
I never tried it for myself, but there is a constant called "channels" in The Player 6.1 source that seems to provide you with a possibility to keep some channels free for other use. So if you could imagine having 2+2 channels or 3+1 channels than that might be an option!?
Arno Nuem
Member
#3 - Posted: 8 Dec 2010 21:16
Reply Quote
Hm, I see... I should have mentioned that Im coding in pure C and I would like to have full control over all parts of my program... not enough ASM knowledge here to use players that come with ASM only sources ;)

For me the problem is the following: I tried to make a ptplay clone, done in pure C. It works so far, BUT it freezes as soon as I try to play a sound. I do this right now with some kind of flag checking (the player checks the flag and plays the appropriate sound. Well, sort of), but the sound is played (by the MOD player!) for a very short time and all freezes.

I suspect that there is some timing issue, but I have no clue were to get in with my sound request to the MOD player in order to not disturb the seemingly delicate timing.

Some general explanations about how to do sound playback while MOD playing with e.g. ptplay would be nice. Or, but quite impossible, p61 sources in C ;)
noname
Member
#4 - Posted: 9 Dec 2010 09:00
Reply Quote
What does the documentation say? Have you checked Amiga Rom Kernel Reference Manual: Devices?
Arno Nuem
Member
#5 - Posted: 12 Dec 2010 20:40
Reply Quote
ARKM: Devices is not very helpful with this, a pity. In my special case its just good enough to show how to block out any other (friendly) programs wishing to use Amiga audio ;)

My problem is still that I dont fully understand, how MOD playback is done with the "old" players. E.g., do they feed Paula using the CPU, or do they DMA? How do they break a sound then, when another note is due?

I think some tutorial about MOD playback is needed, so that even non-ASM-coders could learn some 1337 things ;)

Regards
ZEROblue
Member
#6 - Posted: 13 Dec 2010 09:50 - Edited
Reply Quote
You don't have to know any assembly to use the player. Check the docs to learn how to call it and assemble and link the object file when you compile your C code. It's all M68K machine code and it doesn't matter how it was produced, you just have to pay attention to what calling conventions are used.


#define REG(x, y) __reg(#x) y
#define SAVEREGS __regsused("d0/d1/d2/d3/d4/d5/d6/d7/a0/a1/a2/a3/a4 /a5/a6")

SAVEREGS void P61_Init(REG(a0, void*), REG(a1, void*), REG(a2, void*));
SAVEREGS void P61_Music(REG(a6, void*));
SAVEREGS void P61_End(REG(a6, void*));

// Obtain a pointer to module in chip memory and call P61_Init once
P61_Init(module, 0, 0);

// Call P61_Music every frame
P61_Music((void*)0xdff000);

// Call P61_End to stop playing
P61_End((void*)0xdff000);
Arno Nuem
Member
#7 - Posted: 13 Dec 2010 14:08
Reply Quote
@ZEROblue:

Yes, this would be the easiest way, and Ive done it already... without intermittend sound playback, that is.

Maybe I should make clear again, what Im searching for ;)

I need information, how exactly MOD players handle Paula audio output (DMA mode, start/stop timing and so on), so that I can alter my actual C ;) code accordingly. ATM it does pure CPU audio output, but thats not my final goal (besides the fact that it crashes as soon as I do sound output from another source than the MOD player itself, which "should" be save in turn. I did all to make this part as clean as possible for the OS, but I think that I still have some problem left, possibly resulting from misunderstanding how MOD playback exactly works).

Best information would be some step-by-step tutorial(/in-deep commenting on available ASM code), how things work.

At the end, the result could be made public domain, so that such questions could be answered by simple linking in the future. Well commented C code is worth some ;)
Arno Nuem
Member
#8 - Posted: 13 Dec 2010 23:24
Reply Quote
Hmm, I think I got a bit further with this... pls correct me, if Im wrong in my (simplified) understanding of things:

A MOD player does the change of notes by stopping DMA, waiting a bit, reload Paula´s registers, again waiting a bit, fire DMA and then returning to the rest of the code (if any). All of this is done in an interrupt, mostly VBL. Sometimes CIA B (?) interrupt is used for this (for more accurate timing).

If this is correct, my questions change a bit...

Is it correct, that ALL the playback code, including note and effect changes AND including the waiting for some time to allow Paula to reload registers, is done in the used interrupt (be it VBL or CIA)? If this is true, is there any chance to get a full program (game with heavy blitter gfx for example) running in the remaining time per frame on an AGA machine?

Maybe its a dumb question, but I never done much interrupt driven code in C, so I dont have much experience in estimating how much time such MOD replay code might consume... Im aware of the fact that my code should be as fast as possible, but before achieving this, I think I should do a working code first ;)

In the meantime, I found some example code how to "inject" sound requests into some kind of MOD replay routine, so I think I will solve this problem with some time to think about it.

 

  Please register a new account or log in to comment

  

  

  

 

A.D.A. Amiga Demoscene Archive, Version 3.0