website logo
Auteur
avatar
AmiDARK

Forum » » Création-Développement » » question multiview


Posté : 21-10-2012 18:40 icone du post

zzd10h,
J'ai téléchargé ton dernier exemple utilisant les signaux et ... impossible d'avoir un son.
Je précise, j'ai testé mes .WAV avec ton prog et ils fonctionnent ! Idem avec MultiView.

Alors je copie colle ce qui pourrait servir d'informations. Peut-être me suis-je gourré en copiant/collant/modifiant pour correspondre à mon moteur :

Ma définition de datas :
#define?END_SOUND_SIGNAL?(1L<<19)

#ifdef?__MORPHOS__
??#define?uint32?unsigned?int
??#define?uint16?unsigned?short
??#define?int32?long
?#endif


struct?DTSoundMessage
{
??struct?Message?sound_Msg;
??char?*soundMessage?;
};

/*?Variables?globales?au?fichier?lib?*/
struct?AudioStruct{
??BOOL?Exist;??????????????????//?Object?Exist??
//??APTR?ObjectPTR;????????????//?Object?buffer?pointer?useless.?now?use?zzd1 0h?sample.
??int Loop;???????????????????//?Is?loop?enabled?or?not??
??int Playing;????????????????//?Sound?is?actually?played?or?not.
??char*?FileName;??????????????//?Pointer?to?the?sound?filename.
??int?Audio3D;?????????????????//?Flag?for?3D?Sound?/?no?3D?Sound.
??//?eXtended?for?the?Audio?system?from?zzd10h?//
??char?*?nom_msgport;
??APTR?dtobject;
??ULONG?res;
??uint32?longueur;
??LONG?duree;
??int32?samplesParSec;
??int?nb_cycle;
??int?nb_cycle_temp;
??int8?balance;
??int16?volume;
??int16?increment;
??ULONG?dores;
??struct?MsgPort?*?DTMsgPort;
?};
struct?AudioStruct?AESound[?256?];
struct?dtTrigger?mydtt;

int?AHIAudioInitialized;


Ma fonction pour charger un fichier audio datatype :
void?DELoadSound(?char?*szFilename,?int?iID?){
??if?(?iID?>?0?){
????if?(?iID???????if?(?DESoundExist(?iID?)?==?0?){
????????if(?DEFileExist(?szFilename?)?==?TRUE?){
??????????AESound[?iID?].balance?=?0;
??????????AESound[?iID?].volume?=?64;
??????????#if?defined(?__amigaos4__?)
???????????????AESound[?iID?].dtobject?=?IDataTypes->NewDTObject(?(STRPTR)szF ilename,
????????????????????????????????????????????????????????????????DTA_GroupID,? GID_SOUND,
????????????????????????????????????????????????????????????????SDTA_Pan,?AES ound[?iID?].balance,
????????????????????????????????????????????????????????????????SDTA_Volume,? AESound[?iID?].volume,
????????????????????????????????????????????????????????????????SDTA_SignalTa sk,?(ULONG)IExec->FindTask(NULL),
????????????????????????????????????????????????????????????????SDTA_SignalBi tMask,?END_SOUND_SIGNAL,
????????????????????????????????????????????????????????????????TAG_END?);
???????????#else
????????????AESound[?iID?].dtobject?=?NewDTObject(?(STRPTR)szFilename,
?????????????????????????????????????????????????????DTA_GroupID,?GID_SOUND,< br />?????????????????????????????????????????????????????SDTA_Pan,?AESound[?iID?] .balance,
?????????????????????????????????????????????????????SDTA_Volume,?AESound[?iI D?].volume,
?????????????????????????????????????????????????????SDTA_SignalTask,?(ULONG) FindTask(NULL),
?????????????????????????????????????????????????????SDTA_SignalBitMask,?END_ SOUND_SIGNAL,
?????????????????????????????????????????????????????TAG_END?);
???????????#endif
??????????if?(?AESound[?iID?].dtobject?!=?NULL??){
????????????AESound[?iID?].Exist?=?TRUE;
????????????AESound[?iID?].Loop?=?0;
????????????AESound[?iID?].Playing?=?0;
????????????AESound[?iID?].Audio3D?=?0?;?//?This?sound?IS?NOT?a?3D?Audio?soun d.
????????????AESound[?iID?].FileName?=?LCreateString(?256?);
????????????LCopyString(?szFilename,?AESound[?iID?].FileName?);
????????????AESound[?iID?].res?=?IDataTypes->GetDTAttrs(?AESound[?iID?].dtobj ect,
?????????????????????????????????????????????????????????SDTA_Pan,?&AESound[? iID?].balance,
?????????????????????????????????????????????????????????TAG_END?);
????????????//?Creation?du?message?port?de?l'exemple?de?zzd10h?//
????????????AESound[?iID?].nom_msgport?=?DEAppend(?"DataT_SDPort_",?DEStrI(?i ID?)?);
????????????#if?defined(?__amigaos4__?)
??????????????AESound[?iID?].DTMsgPort?=?IExec->AllocSysObjectTags(?ASOT_PORT ,
????????????????????????????????????????????????????????????????????ASOPORT_N ame,?AESound[?iID?].nom_msgport,
????????????????????????????????????????????????????????????????????TAG_END?) ;
?????????????#else
??????????????AESound[?iID?].DTMsgPort?=?AllocSysObjectTags(?ASOT_PORT,
?????????????????????????????????????????????????????????????ASOPORT_Name,?AE Sound[?iID?].nom_msgport,
?????????????????????????????????????????????????????????????TAG_END?);
?????????????#endif
???????????}
?????????}
???????}
?????}
???}
?}


Mon fichier pour lancer la lecture du son chargé :
void?DEPlaySound(?int?iID?){
??if?(?DESoundExist(?iID?)?==?1?){
????if?(?AESound[?iID?].Playing?>?0?){
??????DEStopSound(?iID?);
?????}
????if?(?AESound[?iID?].DTMsgPort?!=?NULL?){
??????//?Default?DTM_TRIGGER?method?from?zzd10h?datatype?play?sample?//
??????mydtt.MethodID??????=?DTM_TRIGGER;?/*?Fill?in?the?dtTrigger?struct?*/
??????mydtt.dtt_GInfo?????=?NULL;
??????mydtt.dtt_Function??=?STM_PLAY;
??????mydtt.dtt_Data??????=?NULL;
??????#if?defined(?__amigaos4__?)
????????AESound[?iID?].dores?=?IDataTypes->DoDTMethodA(?AESound[?iID?].dtobje ct,
????????????????????????????????????????????????????????NULL,?NULL,?(Msg)&myd tt?);
???????#else
????????AESound[?iID?].dores?=?DoDTMethodA(?AESound[?iID?].dtobject,
????????????????????????????????????????????NULL,?NULL,?(Msg)&mydtt?);
???????#endif
??????AESound[?iID?].Playing?=?1;
?????}
???}
?}


Ma fonction pour arrêter la lecture d'un son :
void?DEStopSound(?int?iID?){
??if?(?AHIAudioInitialized?==?1?){
????if?(?DESoundExist(?iID?)?==?1?){
??????if?(?AESound[?iID?].Playing?>?0?){
????????//?Default?DTM_TRIGGER?method?from?zzd10h?datatype?play?sample?//
????????mydtt.MethodID??????=?DTM_TRIGGER;?/*?Fill?in?the?dtTrigger?struct?*/
????????mydtt.dtt_GInfo?????=?NULL;
????????mydtt.dtt_Function??=?STM_STOP;
????????mydtt.dtt_Data??????=?NULL;
????????#if?defined(?__amigaos4__?)
??????????AESound[?iID?].dores?=?IDataTypes->DoDTMethodA(?AESound[?iID?].dtob ject,
??????????????????????????????????????????????????????????NULL,?NULL,?(Msg)&m ydtt?);
?????????#else
??????????AESound[?iID?].dores?=?DoDTMethodA(?AESound[?iID?].dtobject,
??????????????????????????????????????????????NULL,?NULL,?(Msg)&mydtt?);
?????????#endif
???????}
?????}
???}
?}


Bon il y a aussi une routine pour pause et une pour résume ... mais c'est comme STOP ou je change le STM_ avec STM_PAUSE & STM_RESUME.
Et la fonction pour supprimer un son de la mémoire :
void?DEDeleteSound(?int?iID?){
??if?(?DESoundExist(?iID?)?==?1?){
????if?(?AESound[?iID?].Playing?!=?0?){
??????DEStopSound(?iID?);
?????}
????#if?defined(?__amigaos4__?)
??????IExec->FreeSysObject(ASOT_PORT,?AESound[?iID?].DTMsgPort);
??????IDataTypes->DisposeDTObject(?AESound[?iID?].dtobject?);
?????#else
??????FreeSysObject(ASOT_PORT,?AESound[?iID?].DTMsgPort);
??????DisposeDTObject(?AESound[?iID?].dtobject?);
?????#endif
????LDeleteString(?AESound[?iID?].FileName?);
????AESound[?iID?].dtobject?=?NULL;
????AESound[?iID?].Exist?=?FALSE;
????AESound[?iID?].FileName?=?NULL;
???}
?}


Voila les fonctions que j'ai fait.

Par contre, la démo qui utilise ces fonctions est ici :
#!!!!!include!!!!!?"libamidark.h"
int?InKey;
void?DarkLoop(?void?){??
??//?Setup?Display.
??DESetDisplayMode(?640,?480,?32?);
??DESyncOn();
??DESyncRate(?60?);
??//?Load?the?4?samples?using?DataTypes.
??DELoadSound(?"Medias/oceanwave.wav",?1?);
??DELoadSound(?"Medias/break.wav",?2?);
??DELoadSound(?"Medias/DREAM.WAV",?3?);
??DELoadSound(?"Medias/electricarc.wav",?4?);
??InKey?=?0;

??while(?!DELoop()?){
????DECls();
????DESetCursor(?0,?0?);
????DEPrint(?"AmiDARK?Engine?now?play?Audio?Sounds?using?DATATYPES"?);
????DEPrint(?"Press?default?QUIT?KEY?to?stop?replay?music."?);
????DEPrint(?"?"?);
????DEPrint(?"Press?1?to?play?OceanWave.wav"?);
????DEPrint(?"Press?2?to?play?Break.wav"?);
????DEPrint(?"Press?3?to?play?Dream.wav"?);
????DEPrint(?"Press?4?to?play?ElectricArc.wav"?);
????//?Keyboard?key?1?to?4?start?replay?of?a?sound.
????InKey?=?DEScancode();?InKey--;
????if?(?InKey?>?0?){
??????if?(?InKey?????????DEPlaySound(?InKey?);
???????}
?????}
????DESync();
???}
??//?We?delete?sounds?from?memory.
??for?(?InKey?=?1;?InKey?????if?(?DESoundExist(?InKey?)?==?1?){
??????DEStopSound(?InKey?);
??????DEDeleteSound(?InKey?);
?????}
???}
?}

Cette démo charge 4 sons, et attends des touches clavier.
Les touches 1 à 4 lancent le son correspondant.
le !DELoop() force la démo à quitter lorsque la touche ESCAPE est pressée. Sinon la démonstration tourne en boucle...
J'ai beau presser une touche ... aucun son ne sort.
(j'ai fait un output debug du clavier, idem pour quand on joue un son, le charge, etc ... et tout est bien géré... Le pbe est donc bien dans les sons ... mais où ??? :( )...
D'ailleurs, j'ai un petit bug bizarre. Le dossier ou se trouve le .exe ne peut pas être supprimé... je dois redémarrer le 'Miga pour pouvoir le supprimer... Je n'ai pas ce soucis avec mes App. développées sous l'AmiDARK Engine qui n'utilisent pas les sons DataTypes... Zarb tout ça ...



Message édité par : AmiDARK / 21-10-2012 20:40
Message édité par : AmiDARK / 21-10-2012 21:14

Cet article provient de Le site des utilisateurs francophones actuels et futurs d'AmigaOS 4.x
https://amiga-ng.org/viewtopic.php?topic=1380&forum=14