From Amiga Development Wiki
Revision as of 12:27, 30 August 2015 by AmigaDeveloper (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


AHI is an audio system for Amiga created by Martin Blom. It replaces the original audio.device developed by Commodore-Amiga, however, AHI is not suitable for low end Amigas.

Since developing audio applications using audio.device need careful coding and understanding the original Amiga audio hardware (Paula) it is not covered here.

AHI has device and library interfaces to play sound, but use of library interface is not recommended. You should always use low level interface only (also known as device interface).


#include <devices/ahi.h>
#include <proto/exec.h>
int main()
   struct MsgPort *port = CreateMsgPort();
   if (port)
      struct AHIRequest req;
      req.ahir_Std.io_Message.mn_Node.ln_Type = NT_REPLYMSG;
      req.ahir_Std.io_Message.mn_ReplyPort = port;
      req.ahir_Std.io_Message.mn_Length = sizeof(struct AHIRequest);
      req.ahir_Version = 2;
      if (OpenDevice("ahi.device", AHI_DEFAULT_UNIT, (struct IORequest *)&req, 0) == 0)
         /* call player routine to get sample data */
         req.ahir_Std.io_Command = CMD_WRITE;
         req.ahir_Std.io_Data = playback_buffer; /* Sample data to play */
         req.ahir_Std.io_Length = playback_buffer_length; /* Length of sample data in bytes */
         req.ahir_Type = AHIST_S16S; /* 16-bit, stereo */
         req.ahir_Frequency = 44100; /* Frequency in Hz */
         req.ahir_Volume = 0x10000; /* Volume to max */
         req.ahir_Position = 0x8000; /* Stereo position (this is in the middle) */
         SendIO((struct IORequest *)&req);
         /* now we have finished and can quit... */
         /* Abort all pending request */
         AbortIO((struct IORequest *)&req);
         WaitIO((struct IORequest *)&req);
         CloseDevice((struct IORequest *)&req);
   return 0;


AHI developer archive for AmigaOS