home *** CD-ROM | disk | FTP | other *** search
- /* Sound Effect Demo
- ** -----------------
- ** This is a simple demo that plays a sound effect. Try changing the
- ** IFF file to another one on your hard drive and play that.
- **
- ** Press LMB to play the sound.
- ** Press RMB to exit the demo.
- */
-
- #include <proto/games.h>
- #include <proto/exec.h>
- #include <exec/memory.h>
-
- struct GMSBase *GMSBase;
- extern struct ExecBase *SysBase;
-
- struct Sound Sound =
- {
- SMV1, /* Structure version */
- CHANNEL_ALL, /* Channel to play through */
- 1, /* Priority */
- 0, /* Sample header */
- 0, /* Sample address */
- 0, /* Sample length */
- OCT_C0S, /* Sample period */
- 100, /* Sample volume */
- 0, /* Sound attributes */
- "GAMESLIB:data/SND.Lightning" /* Sound file */
- };
-
- /*=========================================================================*/
-
- void main(void)
- {
- ULONG Mouse;
-
- if (GMSBase = (struct GMSBase *) OpenLibrary("games.library", 0)) {
- if (AllocAudio() == ERR_OK) {
- if (InitSound(&Sound) == ERR_OK) {
-
- do {
- Mouse = ReadMouse(JPORT1);
-
- if (Mouse & MB_LMB) {
- PlaySoundPri(&Sound);
- Sound.Octave += 2;
- if (Sound.Octave > OCT_A4)
- Sound.Octave = OCT_G0S;
- while (ReadMouse(JPORT1) & MB_LMB) {}
- }
- } while (!(Mouse & MB_RMB));
-
- FreeSound(&Sound);
- }
- FreeAudio();
- }
- CloseLibrary((struct Library *)GMSBase);
- }
- }
-