Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: kitchenTimer_Clock SoundLibraryExample_Melody_ProgramData M3PI_SuiviLigne
Revision 15:d526205994e9, committed 2013-11-10
- Comitter:
- suupen
- Date:
- Sun Nov 10 07:13:32 2013 +0000
- Parent:
- 13:cd42abff5173
- Commit message:
- fixed the bug in the output end processing
;
Changed in this revision
| Sound.cpp | Show annotated file Show diff for this revision Revisions of this file |
| Sound.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/Sound.cpp Sun Oct 20 06:00:50 2013 +0000
+++ b/Sound.cpp Sun Nov 10 07:13:32 2013 +0000
@@ -48,10 +48,17 @@
void Sound::sound_out(float siji, int8_t fugo){
// siji no atai wo fugo ga minus no toki hanten
- if(fugo == 1){siji = 1.0 - siji;}
- _kijun = fugo;
+ if(siji != 0.0){ //@SS131110
+ if(fugo == 1){siji = 1.0 - siji;}
+ _kijun = fugo;
_pwm.write(siji); // 2tuizyo sound out settei site ,interrupt no nakade renzoku de pwm set wo suruto bousou suru.
+ }
+ else{ //@SS131110
+ // sound off //@SS131110
+ _kijun = 0; //@SS131110
+ _pwm.write(0.0); //@SS131110
+ } //@SS131110
}
/*****************************************
@@ -202,14 +209,26 @@
Description : enso ji no tugino onpu data syutoku
******************************************************************************/
void Sound::sound_ensoSyori(void) {
+
+ const sound_t END_DATA[] = { //@SS131110
+ // hanon siji 0:b(flat) 1:tujo 2:#(sharp) //@SS131110
+ // | C1 - B9 kan deno onkai(Gx ha 9x ni okikae te siji) 0xFF=end data //@SS131110
+ // | | time (1/1[ms]/count) //@SS131110
+ // | | | envelope(yoin) (1/1 [ms]/count) //@SS131110
+ // | | | | //@SS131110
+ {1,0xFF,0000,0} // end //@SS131110
+ };
+ sound_t data; //@SS131110
// enso data settei
if((sound_sound() == false) // oto no syuturyoku jikan hantei
& (onpu != NULL) // enso chu ka wo kakunin
){
// tugi no onpu data syutoku
- sound_t data = *onpu;
+//@SS131110 sound_t data = *onpu; //@SS131110
+ data = *onpu; //@SS131110
if(data.onkai == 0xff){
+ sound_sound(data); //@SS131110
onpu = NULL;
}
else{
@@ -219,6 +238,10 @@
}
}
+ else if(onpu == NULL){ //@SS131110
+ data = *END_DATA; //@SS131110
+ sound_sound(data); //@SS131110
+ }
}
@@ -453,3 +476,4 @@
+
--- a/Sound.h Sun Oct 20 06:00:50 2013 +0000 +++ b/Sound.h Sun Nov 10 07:13:32 2013 +0000 @@ -27,6 +27,7 @@ /* V0.1 : 2011/11/13 */ /* V0.2 : 2011/11/19 Added copyright notice */ /* V0.3 : 2013/10/20 LPC1114FN28 taiou */ +/* V0.4 : @SS131110 fixed the bug in the output end processing */ /***********************************************************************/ #ifndef _SOUND_H #define _SOUND_H