Elements used in the Balls and Things games for the RETRO.
Dependents: RETRO_BallsAndPaddle RETRO_BallAndHoles
SoundFx.cpp
- Committer:
- maxint
- Date:
- 2015-02-06
- Revision:
- 0:3d0db4e183ee
- Child:
- 1:71185a0aadfc
File content as of revision 0:3d0db4e183ee:
#include "SoundFX.h" SoundFX::SoundFX() : // pwm(P0_18), music(P0_18) { // this->pwmTicksLeft=0; this->fMute=false; music.setCompletionCallback(this, &SoundFX::musicCompleted); } void SoundFX::checkPwm() { /* if(this->fMute || this->pwmTicksLeft == 0) this->pwm.write(0.0); else { this->pwmTicksLeft--; this->pwm.write(0.5); } */ } void SoundFX::musicCompleted(void) { /* PwmOut pwm(P0_18); pwm = 0.0; pwm.period(0.1); pwm.write(0.00); */ } void SoundFX::reset() { /* this->pwmTicksLeft=0; this->pwm.period_ms(1); this->pwm.write(0.00); */ /* PwmOut pwm(P0_18); pwm.write(0.00); */ } void SoundFX::setMute(bool fMute) { this->fMute=fMute; } bool SoundFX::getMute() { return(this->fMute); } void SoundFX::beep(int nDuration) //nDuration=1 { if(this->fMute) return; // this->pwmTicksLeft = nDuration; } void SoundFX::beepShort() { if(this->fMute) return; /* this->pwm.period_ms(2); this->pwmTicksLeft = SoundFX::BOUNCE1_SOUND_TICKS; */ music.play("T240 L32 O6 C"); } void SoundFX::beepLong() { if(this->fMute) return; /* this->pwm.period_ms(1); this->pwmTicksLeft = SoundFX::BOUNCE2_SOUND_TICKS; */ music.play("T240 L8 O5 C"); } void SoundFX::beepLow() { if(this->fMute) return; /* this->pwm.period(1.0/220); this->pwm.write(0.5); wait_ms(150); this->pwm.write(0.0); */ music.play("T180 L4 O3 C"); } void SoundFX::play(char *szPlay) { if(this->fMute) return; music.play(szPlay); } void SoundFX::playTune() { if(this->fMute) return; /* this->pwm.period(1.0/220); this->pwm.write(0.5); wait_ms(150); this->pwm.write(0.0); this->pwm.period(1.0/196); this->pwm.write(0.5); wait_ms(150); this->pwm.write(0.0); this->pwm.period(1.0/164.81); this->pwm.write(0.5); wait_ms(150); this->pwm.write(0.0); */ // music.setCompletionCallback(this, &SoundFX::musicCompleted); //music.play("T224L8O5CL16>C<P16GP16L8EL16P16>C<GP16L8E.L16P16L8C#L16>C#<P16G#P16L8FL16P16>C#<G#P16L8F.L16P16L8CL16>C<P16GP16L8EL16P16>C<GP16L8E.L16P16D#EFP16FF#GP16GG#AP16L8>C<P8L4>C"); music.play("T120 O3 L16 F L4 C F L8 C"); }