00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #include <dos.h>
00037
00038 #include <callback.h>
00039 #include <mytrace.h>
00040 #include <timeout.h>
00041
00042 #include "spkrnote.h"
00043
00044
00045
00046 using namespace Monitor::Utility;
00047
00048
00049
00050 int SpeakerNote::busy = 0;
00051
00052
00053 SpeakerNote::SpeakerNote(Frequency newFrequency, Length newLength)
00054 : frequency(newFrequency), length(newLength)
00055 {
00056 _USEMYTRACE_("SpeakerNote::SpeakerNote(newFrequency, newLength)")
00057 }
00058
00059
00060
00061 SpeakerNote::~SpeakerNote()
00062 {
00063 _USEMYTRACE_("SpeakerNote::~SpeakerNote()")
00064 }
00065
00066
00067
00068 void
00069 SpeakerNote::sound() const
00070 throw (Note::Busy)
00071 {
00072 _USEMYTRACE_("SpeakerNote::sound()")
00073
00074 if (busy)
00075 {
00076 throw Busy();
00077 }
00078 else
00079 {
00080 busy = !0;
00081
00082
00083 ::sound(frequency);
00084
00085
00086 new Timeout(ConstCallback< SpeakerNote >(*this,
00087 &SpeakerNote::endSound),
00088 length,
00089 "note length");
00090 }
00091 }
00092
00093
00094
00095 void
00096 SpeakerNote::endSound() const
00097 {
00098 _USEMYTRACE_("SpeakerNote::endSound()")
00099
00100
00101 ::nosound();
00102
00103 busy = 0;
00104 }
00105
00106
00107
00108 SpeakerNote::Frequency
00109 SpeakerNote::getFrequency() const
00110 {
00111 _USEMYTRACE_("SpeakerNote::getFrequency()")
00112
00113 return frequency;
00114 }
00115
00116
00117
00118 void
00119 SpeakerNote::setFrequency(Frequency newFrequency)
00120 {
00121 _USEMYTRACE_("SpeakerNote::setFrequency(newFrequency)")
00122
00123 frequency = newFrequency;
00124 }
00125
00126
00127
00128 SpeakerNote::Length
00129 SpeakerNote::getLength() const
00130 {
00131 _USEMYTRACE_("SpeakerNote::getLength()")
00132
00133 return length;
00134 }
00135
00136
00137
00138 void
00139 SpeakerNote::setLength(Length newLength)
00140 {
00141 _USEMYTRACE_("SpeakerNote::setLength(newLength)")
00142
00143 length = newLength;
00144 }