In fact, this sample play sample 0, wait it finish, play sample 1, wait it finish, play sample 2.
Now, I'm not sure if : 1. I must create 1 process per sound played at the same time or, can I use the same process to play more than 1 sample at the same time ? Can someone help me ?
Thank you.
Regards, AmiDARK.
All we have to decide is what to do with the time that is given to us.
if(AHIDevice) {
printf("Unable to open %s/0 version 4\n",AHINAME);
goto cleanup;
}
// Make a copy of the request (for double buffering)
AHIiocopy = AllocMem(sizeof(struct AHIRequest), MEMF_ANY);
if(! AHIiocopy) {
printf("can't do AllocMem for AHIiocopu\n");
goto cleanup;
In that function exactly depacking and plaing of modules in loops happenes. Code are ugly of course, for sure WaitIO and alt are using there wrong, but it works and you can catch main idea here (how create a process with passing to it name of music file).
and if I define all 8 samples like you did, it should allow to play 8 samples at the same time ?
More to this,
- 2 nd Question : Imagine I have 1 sample running and I want to add 1 I do not need to define a new proc but I can define values needed for the new song and use :
SendIO((struct IORequest *) AHIios[1]);
to start playing the sound ?
And then, I'll remove the proc when no sound is played or when my app quit . Right ?
- 3rd Question : Another question, can I define a new sound out from the proc itself ? or should it be the proc itself that define the sound ? (for exemple initialize a new proc that run in background and define new sound when needed)
- 4th Question : Can I stop a sound from playing ? at any moment ?
Thank you for everything.
Kindest Regards, Freddix aka AmiDARK.
All we have to decide is what to do with the time that is given to us.
- 1 st Question : Its more not about "samples" itself, its about reserving the ahi IO structs. It can be for the small buffer data, or for big one. You also can redefine it with not problems (for example, you play one sound, then you close ahi and alt, and for second sound, you can use the same routine).
I use 2 IO strcuts-buffers just because i need 2 buffers in my player_routine (for making double-buffering). It possible of course make everythinkg with 1 IO, or with 10IO (as you wish).
So it not about plaing at one time, but about just reserving the same twice for double-buffering (for avoid sutterings beetwen parts of data).
- 2st Question: Yes, if you not close older resources, you not need to open it again, and just adding IO will be ok.
- 3st Question: I do not remember right what happenes when you will be remove you Process from memory in hardcore way, but by logic, if you will remove it hardcore it will stops all works of course. That how looks my Stop_Play() fucntion:
You send signal to your process (and you need to check always on that signal in your main player routine), and when it return that everything end, then stop everythink/clean/exit/close/etc. You can see that logic of my fucntions are bad. I.e. i put for example code for cleaning/close/remove ahi reqst/dev to the player routine (it just was more easy for my brains). But in general you need prepare normal fucntions for open/play/close.
-4st question: Yes, just by sending signal SIGBREAKF_CTRL_C to your player process (and you need to check it all the time while music plays in your player routine).
That of course only about how i do that. For sure its lame and wrong :)
What essentially makes this routine "single-tasking" is the DoIO() call. If you replace this for SendIO() the function would return immediately while the sound is playing and you could start another sound the same way.
Then you Wait() on the signals from all iorequests you have sent and take care of them (DeleteIO etc) one at a time when they are done.
Of course you have to rewrite your play function such that it doesn't free everything at the end but instead keeps the state (using globals instead of locals?) so you can free it all later.
In this case I would actually suggest swapping to another language, such as C++ or PortablE and create a proper class which handles your plaing. Then just create as many instances as you like, encapsulate everything and coordinate it all from a Wait(class1.signal | class2.signal | class3.signal) or something in the main program event loop. No need for processes.
Software developer for Amiga OS3 and OS4. Develops for OnyxSoft and the Amiga using E and C and occasionally C++
@Deniil Thank you for your comment. Concerning the functions it confirm what I suspected ;) I will start this tomorrow.
Concerning the AmiDARK Engine, I will remain under C... No need for C++ ... I found the C++ classes and others stuffs complicated to do thing I found to be more easier without these classes system ..
It's simply I have used to code this way during several years ... It will probably need many months for me to adapt to C++ so .... no C++ for the moment
Thank you all for your comment I should be able to do my sound functions now :)
@ + AmiDARK.
All we have to decide is what to do with the time that is given to us.
So next version of DarkEngine will be with music/sound support ? :) Will be cool also to have Sync-music functions (like getting the bass details, volume details, and with basing on it can be done pretty good visual effects).
@kas1e The next alpha may be released soon (before completing sound plugin (sound is only load/Delete/clone/play/loop audio sounds WAV/MP3/OGG/RIFF/.... it's not music plugin) or later when sound plugin is done. Music plugin will came later ;) Concerning sound track informations, all will depend on the library I'll find that allow to play tracker files ... I will not try to recreate the wheel by creating my own music support so, all will depend on the library I'll use ... If you have any suggestion feel free to post them ;)
All we have to decide is what to do with the time that is given to us.
SDL_mixer / Mikmod and ModPlug imho are easy for usage on aos4 for mp3/ogg and alt modules like xm/mod/it. But that libs does not have any good functions for getting info about music (well, its imho, i not research it very deeply). Sadly that we do not have FMOD. FMOD have pretty nice functions like:
Of course implementing own sound-engine which will grab all the info are pretty hard .. (imho). But that sync-with-music functions can allow to create quality animation/demos.