/* Simple sample player for AHI using the low-level API with double buffered AHIST_DYNAMICSAMPLE sounds. Usage: DoubleBuffer < [raw sample file] the file must be in mono 16 bit signed big endian format sampled in 17640 Hz. This software is Public Domain. */ #include #include #include #include #include #define EQ == #define MINBUFFLEN 10000 struct Library *AHIBase; struct MsgPort *AHImp=NULL; struct AHIRequest *AHIio=NULL; BYTE AHIDevice=-1; BYTE signal=-1; struct AHIAudioModeRequester *req=NULL; struct AHIAudioCtrl *actrl=NULL; BOOL DBflag=FALSE; // double buffer flag ULONG BufferLen=NULL; struct AHISampleInfo Sample0 = { AHIST_M16S, NULL, NULL, }; struct AHISampleInfo Sample1 = { AHIST_M16S, NULL, NULL, }; __asm __saveds ULONG SoundFunc(register __a0 struct Hook *hook, register __a2 struct AHIAudioCtrl *actrl, register __a1 struct AHISoundMessage *smsg) { if(DBflag = !DBflag) // Flip and test AHI_SetSound(0,1,0,0,actrl,NULL); else AHI_SetSound(0,0,0,0,actrl,NULL); Signal(actrl->ahiac_UserData,(1L<ahir_Version = 4; // Open at least version 4 of 'ahi.device'. if(!(AHIDevice=OpenDevice(AHINAME,AHI_NO_UNIT,(struct IORequest *)AHIio,NULL))) { AHIBase=(struct Library *)AHIio->ahir_Std.io_Device; if(req=AHI_AllocAudioRequest( AHIR_PubScreenName,"", AHIR_TitleText,"Select a mode and rate", AHIR_InitialMixFreq,17640, AHIR_DoMixFreq,TRUE, TAG_DONE)) { if(AHI_AudioRequest(req,TAG_DONE)) { if(actrl=AHI_AllocAudio( AHIA_AudioID,req->ahiam_AudioID, AHIA_MixFreq,req->ahiam_MixFreq, AHIA_Channels,1, AHIA_Sounds,2, AHIA_SoundFunc,&SoundHook, AHIA_UserData,FindTask(NULL), TAG_DONE)) { AHI_GetAudioAttrs(AHI_INVALID_ID,actrl, AHIDB_MaxPlaySamples,&playsamples, TAG_DONE); AHI_ControlAudio(actrl, AHIC_MixFreq_Query,&mixfreq, TAG_DONE); BufferLen=playsamples*17640/mixfreq; if (BufferLen