home *** CD-ROM | disk | FTP | other *** search
- // Copyright 1993, Mark T. Pflaging
- //
- // Portions were borrowed from Jeff Bird's (cejjb@marlin.jcu.edu.au)
- // Sound Blaster Freedom routines dated 12 Feb 92
- //
- #include "sb.hpp"
-
- static void far interrupt (*OldIRQ)(...);
- volatile int DMA_complete;
- extern void far interrupt SBHandler(...);
-
- // Sets the sample rate to be used for digitizing or playback
- void SoundBlaster::Sample_Rate(unsigned long rate)
- {
- unsigned char tc;
-
- tc = (unsigned char)(256 - (1000000/rate));
-
- writedac(TIME_CONSTANT); // Command byte for sample rate
- writedac(tc); // Sample rate time constant
- }
-
- // Argument should be True for "speaker on", False for "speaker off".
- void SoundBlaster::Voice(Boolean state)
- {
- writedac((state) ? SPEAKER_ON : SPEAKER_OFF);
- }
-
- void SoundBlaster::Init_Voice_DMA(void interrupt (*handler)(...))
- {
- if (isValid()) {
- // Insert our IRQ handler into interrupt chain
- disable();
- OldIRQ = getvect(0x08 + IRQ);
- if(!handler) handler = SBHandler;
-
- setvect(0x08 + IRQ,handler);
- enable();
- DMA_complete = 1;
- }
- }
-
- void SoundBlaster::DeInit_Voice_DMA(void)
- {
- if (isValid()) {
- unsigned char tm;
-
- // Turn off stereo output
- if (Type == SBPro) writemixer(0x0e,0x11);
-
- // Restore old IRQ vector
- disable();
- setvect(0x08 + IRQ,OldIRQ);
- tm = inportb(0x21);
- outportb(0x21,tm | (1 << IRQ));
- enable();
- }
- }
-
- void SoundBlaster::reset_DMA_Complete(void)
- {
- DMA_complete = 0;
- }
-
- Boolean SoundBlaster::DMA_Complete(void)
- {
- return (DMA_complete ? True : False);
- }
-
- void SoundBlaster::Halt_DMA(void)
- {
- writedac(HALT_DMA);
- }
-
- void SoundBlaster::Continue_DMA(void)
- {
- writedac(CONTINUE_DMA);
- }
-