/** ** Ask to the sound server to play a sound attached to a unit. The ** sound server may discard the sound if needed (e.g., when the same ** unit is already speaking). ** ** @param unit Sound initiator, unit speaking ** @param voice Type of sound wanted (Ready,Die,Yes,...) */ void PlayUnitSound(const CUnit &unit, UnitVoiceGroup voice) { CSound *sound = ChooseUnitVoiceSound(unit, voice); if (!sound) { return; } bool selection = (voice == VoiceSelected || voice == VoiceBuilding); Origin source = {&unit, unsigned(UnitNumber(unit))}; //Wyrmgus start // if (UnitSoundIsPlaying(&source)) { if (UnitSoundIsPlaying(&source) && voice != VoiceHit && voice != VoiceMiss && voice != VoiceStep) { //Wyrmgus end return; } int channel = PlaySample(ChooseSample(sound, selection, source), &source); if (channel == -1) { return; } //Wyrmgus start // SetChannelVolume(channel, CalculateVolume(false, ViewPointDistanceToUnit(unit), sound->Range)); SetChannelVolume(channel, CalculateVolume(false, ViewPointDistanceToUnit(unit), sound->Range) * sound->VolumePercent / 100); //Wyrmgus end SetChannelStereo(channel, CalculateStereo(unit)); //Wyrmgus start SetChannelVoiceGroup(channel, voice); //Wyrmgus end }
/** ** Ask the sound server to play a sound for a missile. ** ** @param missile Sound initiator, missile exploding ** @param sound Sound to be generated */ void PlayMissileSound(const Missile &missile, CSound *sound) { if (!sound) { return; } int stereo = ((missile.position.x + (missile.Type->G ? missile.Type->G->Width / 2 : 0) + UI.SelectedViewport->MapPos.x * PixelTileSize.x) * 256 / ((UI.SelectedViewport->MapWidth - 1) * PixelTileSize.x)) - 128; clamp(&stereo, -128, 127); Origin source = {NULL, 0}; //Wyrmgus start // unsigned char volume = CalculateVolume(false, ViewPointDistanceToMissile(missile), sound->Range); unsigned char volume = CalculateVolume(false, ViewPointDistanceToMissile(missile), sound->Range) * sound->VolumePercent / 100; //Wyrmgus end if (volume == 0) { return; } int channel = PlaySample(ChooseSample(sound, false, source)); if (channel == -1) { return; } SetChannelVolume(channel, volume); SetChannelStereo(channel, stereo); }
number CalculateVolume(const Volume& vol, Grid::VertexAttachmentAccessor<APosition>& aaPos) { switch (vol.reference_object_id()) { case ROID_TETRAHEDRON: return CalculateVolume(static_cast<Tetrahedron>(vol), aaPos); case ROID_PRISM: return CalculateVolume(static_cast<Prism>(vol), aaPos); case ROID_PYRAMID: return CalculateVolume(static_cast<Pyramid>(vol), aaPos); case ROID_HEXAHEDRON: return CalculateVolume(static_cast<Hexahedron>(vol), aaPos); default: UG_ASSERT(false, "dont know how to calculate given volume."); } return NAN; }
/** ** Play a game sound ** ** @param sound Sound to play ** @param volume Volume level to play the sound */ void PlayGameSound(CSound *sound, unsigned char volume) { Origin source = {NULL, 0}; int channel = PlaySample(ChooseSample(sound, false, source)); if (channel == -1) { return; } SetChannelVolume(channel, CalculateVolume(true, volume, sound->Range)); }
/** ** Ask to the sound server to play a sound attached to a unit. The ** sound server may discard the sound if needed (e.g., when the same ** unit is already speaking). ** ** @param unit Sound initiator, unit speaking ** @param sound Sound to be generated */ void PlayUnitSound(const CUnit *unit, CSound *sound) { Origin source = {unit, unit->Slot}; int channel = PlaySample(ChooseSample(sound, false, source)); if (channel == -1) { return; } SetChannelVolume(channel, CalculateVolume(false, ViewPointDistanceToUnit(unit), sound->Range)); SetChannelStereo(channel, CalculateStereo(unit)); }
void clusterfnc::Merge(clusterdat* c1, clusterdat* c2){ //c2 and c1 are going to be in c3 from now on. int index = 0; for (index=0;index<640*480;index++) { if (!(c2->points[index]==0)) { c1->points[index] = c2->points[index]; } } c1->pntfnc.Center(&c1->center,&c2->center,&c1->center); CalculateVolume(c1); FindCenter(c1); }
number CalculateVolume(geometry_traits<Volume>::iterator begin, geometry_traits<Volume>::iterator end, Grid::VertexAttachmentAccessor<APosition>& aaPos) { number result = 0; geometry_traits<Volume>::iterator iter = begin; while (iter != end) { Volume* vol = *iter; result += CalculateVolume(*vol, aaPos); iter++; } return result; }
int main() { int v = CalculateVolume(); printf("The volume of your input is %d", v); getchar(); getchar(); return 0; }
void clusterfnc::Flatten(clusterdat* c1, int maxDepth){ float maxZValue = c1->vol.location.z + maxDepth; if (c1->vol.depth > maxDepth) { int index = 0; for (index=0;index<640*480;index++) { if (!(c1->points[index]==0)) { if (c1->points[index]->z > maxDepth) { c1->points[index]->z = maxDepth; //ALTERED } } } FindCenter(c1); CalculateVolume(c1); } }
void CVRC6Square2::RefreshChannel() { if (!m_bEnabled) return; unsigned int Period = CalculatePeriod(false); unsigned int Volume = CalculateVolume(15); unsigned char DutyCycle = m_iDutyPeriod << 4; unsigned char HiFreq = (Period & 0xFF); unsigned char LoFreq = (Period >> 8); m_pAPU->ExternalWrite(0xA000, DutyCycle | Volume); m_pAPU->ExternalWrite(0xA001, HiFreq); m_pAPU->ExternalWrite(0xA002, 0x80 | LoFreq); }
/** ** Ask the sound server to play a sound for a missile. ** ** @param missile Sound initiator, missile exploding ** @param sound Sound to be generated */ void PlayMissileSound(const Missile &missile, CSound *sound) { int stereo = ((missile.position.x + missile.Type->G->Width / 2 - UI.SelectedViewport->MapPos.x * PixelTileSize.x) * 256 / ((UI.SelectedViewport->MapWidth - 1) * PixelTileSize.x)) - 128; clamp(&stereo, -128, 127); Origin source = {NULL, 0}; int channel = PlaySample(ChooseSample(sound, false, source)); if (channel == -1) { return; } SetChannelVolume(channel, CalculateVolume(false, ViewPointDistanceToMissile(missile), sound->Range)); SetChannelStereo(channel, stereo); }
/** ** Play a game sound ** ** @param sound Sound to play ** @param volume Volume level to play the sound */ void PlayGameSound(CSound *sound, unsigned char volume, bool always) { Origin source = {NULL, 0}; CSample *sample = ChooseSample(sound, false, source); if (!always && SampleIsPlaying(sample)) { return; } int channel = PlaySample(sample); if (channel == -1) { return; } SetChannelVolume(channel, CalculateVolume(true, volume, sound->Range)); }
/** ** Ask to the sound server to play a sound attached to a unit. The ** sound server may discard the sound if needed (e.g., when the same ** unit is already speaking). ** ** @param unit Sound initiator, unit speaking ** @param voice Type of sound wanted (Ready,Die,Yes,...) */ void PlayUnitSound(const CUnit *unit, UnitVoiceGroup voice) { CSound *sound = ChooseUnitVoiceSound(unit, voice); if (!sound) { return; } bool selection = (voice == VoiceSelected || voice == VoiceBuilding); Origin source = {unit, unit->Slot}; int channel = PlaySample(ChooseSample(sound, selection, source)); if (channel == -1) { return; } SetChannelVolume(channel, CalculateVolume(false, ViewPointDistanceToUnit(unit), sound->Range)); SetChannelStereo(channel, CalculateStereo(unit)); }
void CVRC6Square2::RefreshChannel() { unsigned int Period = CalculatePeriod(); unsigned int Volume = CalculateVolume(); unsigned char DutyCycle = m_iDutyPeriod << 4; unsigned char HiFreq = (Period & 0xFF); unsigned char LoFreq = (Period >> 8); if (!m_bGate || !Volume) { WriteExternalRegister(0xA002, 0x00); return; } WriteExternalRegister(0xA000, DutyCycle | Volume); WriteExternalRegister(0xA001, HiFreq); WriteExternalRegister(0xA002, 0x80 | LoFreq); }
/** ** Ask to the sound server to play a sound attached to a unit. The ** sound server may discard the sound if needed (e.g., when the same ** unit is already speaking). ** ** @param unit Sound initiator, unit speaking ** @param sound Sound to be generated */ void PlayUnitSound(const CUnit &unit, CSound *sound) { if (!sound) { return; } Origin source = {&unit, unsigned(UnitNumber(unit))}; //Wyrmgus start // unsigned char volume = CalculateVolume(false, ViewPointDistanceToUnit(unit), sound->Range); unsigned char volume = CalculateVolume(false, ViewPointDistanceToUnit(unit), sound->Range) * sound->VolumePercent / 100; //Wyrmgus end if (volume == 0) { return; } int channel = PlaySample(ChooseSample(sound, false, source)); if (channel == -1) { return; } SetChannelVolume(channel, volume); SetChannelStereo(channel, CalculateStereo(unit)); }
void Cluster::Flatten(int maxDepth){ float maxZValue = vol.location->z + maxDepth; std::vector<Point*> newlist; std::vector<Point*>::iterator iter; Point *p; if (vol.depth > maxDepth) { for (iter=points.begin();iter<points.end();iter++) { //go through list, make new list, apply to old list p = (Point*)*iter; if (p->z<maxZValue) { newlist.push_back(new Point(p)); } } points = newlist; FindCenter(); CalculateVolume(); } }
/** ** Play a game sound ** ** @param sound Sound to play ** @param volume Volume level to play the sound */ void PlayGameSound(CSound *sound, unsigned char volume, bool always) { if (!sound) { return; } Origin source = {NULL, 0}; CSample *sample = ChooseSample(sound, false, source); if (!always && SampleIsPlaying(sample)) { return; } int channel = PlaySample(sample); if (channel == -1) { return; } //Wyrmgus start // SetChannelVolume(channel, CalculateVolume(true, volume, sound->Range)); SetChannelVolume(channel, CalculateVolume(true, volume, sound->Range) * sound->VolumePercent / 100); //Wyrmgus end }
/** ** Ask the sound server to play a sound for a missile. ** ** @param missile Sound initiator, missile exploding ** @param sound Sound to be generated */ void PlayMissileSound(const Missile *missile, CSound *sound) { int stereo; stereo = ((missile->X + missile->Type->G->Width / 2 - UI.SelectedViewport->MapX * TileSizeX) * 256 / ((UI.SelectedViewport->MapWidth - 1) * TileSizeX)) - 128; if (stereo < -128) { stereo = -128; } else if (stereo > 127) { stereo = 127; } Origin source = {NULL, 0}; int channel = PlaySample(ChooseSample(sound, false, source)); if (channel == -1) { return; } SetChannelVolume(channel, CalculateVolume(false, ViewPointDistanceToMissile(missile), sound->Range)); SetChannelStereo(channel, stereo); }
void CMMC5Square2Chan::RefreshChannel() { if (!m_bEnabled) return; int Period = CalculatePeriod(false); int Volume = CalculateVolume(15); char DutyCycle = (m_iDutyPeriod & 0x03); unsigned char HiFreq = (Period & 0xFF); unsigned char LoFreq = (Period >> 8); unsigned char LastLoFreq = (m_iLastPeriod >> 8); m_iLastPeriod = Period; WriteExternalRegister(0x5015, 0x03); WriteExternalRegister(0x5004, (DutyCycle << 6) | 0x30 | Volume); WriteExternalRegister(0x5006, HiFreq); if (LoFreq != LastLoFreq) WriteExternalRegister(0x5007, LoFreq); }
/// <summary> /// Computes the density of the body assuming a spherical form. /// The radius must be defined. /// </summary> /// <returns>The volume of the body</returns> double Characteristics::CalculateDensity() { return mass / CalculateVolume(); }