home *** CD-ROM | disk | FTP | other *** search
- // Copyright 1993, Mark T. Pflaging
- // Interface for class SB_SoundFile.
- // See also comments in "SndFile.cpp".
- #ifndef __SNDFILE_HPP
- #define __SNDFILE_HPP
-
- #include <malloc.h>
- #include "standard.hpp"
- #include "emm.hpp"
-
- class SB_SoundFile;
-
- class strSnd {
- public:
- char * name;
- SB_SoundFile * sound;
- };
-
- #define MAXSOUNDS 100
-
- struct wav_header {
- char id1[4]; // "RIFF"
- unsigned long junk1; // Don't really need this length
- char id2[8]; // "WAVEfmt "
- unsigned long blklen;
- unsigned int indicator;
- unsigned int stereoval;
- unsigned long sr; // sample rate.
- unsigned long blkpersec;
- unsigned int blkspersamp;
- unsigned int bits_per_sample;
- char id3[4]; // "data"
- unsigned long sample_len; // sample length on disk
- };
-
- class SB_SoundFile
- #ifndef OLD_WAY
- : LIMEMS
- #endif
- {
- static log_to_phys_map quadphys[4]; // 4 physical-to-logical mappings
- static SB_SoundFile * current_file;
-
- #ifdef OLD_WAY
- signed char far * aligned;
- signed char far *raw;
- #else
- int pages, first_page, last_page;
- static int current_page, pages_left, is_not_maptime;
- static unsigned long bytes_left;
- static SoundBlaster * device;
- #endif
-
- unsigned long sr; // sample rate.
- unsigned sl; // sample length in memory
- unsigned long sample_len; // sample length on disk
- Boolean stereo;
-
- static strSnd sndRefs[MAXSOUNDS];
- static int currentSnds;
-
- void InitRef(char * refname) {
- sndRefs[currentSnds].name = refname;
- sndRefs[currentSnds].sound = this;
- ++currentSnds;
- }
- Boolean ReadHeader(int fd);
-
- void guess(istream & where, char * addr);
-
- public:
- SB_SoundFile(char * refname, char * filenm) : sr(11000), stereo(False) {
- Init(refname, filenm);
- }
- ~SB_SoundFile() {
- // I'm assuming that all the SB_SoundFiles get deleted
- // at the same time. This is easier to handle consider
- // the stupidity of the EMM.
- #ifdef OLD_WAY
- farfree(raw);
- #endif
- }
-
- static void KillAllSounds(); // Deletes every SB_SoundFile
-
- unsigned long getSampleRate() { return sr; }
- void setStereo(Boolean arg) { stereo = arg; }
-
- void Init(char * refname, char * filenm);
- void MapInSound(int first, int howmany);
-
- void OutVoice_DMA(SoundBlaster & device);
- void Play(SoundBlaster & device) {
- OutVoice_DMA(device);
- }
- static SB_SoundFile * Find(char * ref);
- static Boolean nextDMAtransfer() {
- return current_file->NextDMASegment();
- }
- Boolean NextDMASegment();
- };
-
- #endif
-