Add mmelody_active_p

This commit is contained in:
Michael Hayes
2011-08-31 02:54:28 +00:00
parent 97712ead60
commit 0373ac2a1d
3 changed files with 21 additions and 1 deletions
+6 -1
View File
@@ -100,7 +100,12 @@ static void button_task (__unused__ void *data)
button_update ();
if (button_push_event_p (BUTTON1))
mmelody_play (melody, tune1);
{
if (mmelody_active_p (melody))
mmelody_play (melody, 0);
else
mmelody_play (melody, tune1);
}
}
+9
View File
@@ -257,6 +257,8 @@ mmelody_play (mmelody_t mmelody, const char *str)
mmelody->octave = MMELODY_OCTAVE_DEFAULT;
/* Default to quarter notes. */
mmelody_note_fraction_set (mmelody, 4);
/* Stop what is currently sounding. */
mmelody_note_play (mmelody, 0);
}
@@ -277,6 +279,13 @@ mmelody_volume_set (mmelody_t mmelody, mmelody_volume_t volume)
}
bool
mmelody_active_p (mmelody_t mmelody)
{
return mmelody->cur != 0;
}
void
mmelody_update (mmelody_t mmelody)
{
+6
View File
@@ -68,4 +68,10 @@ mmelody_speed_set (mmelody_t mmelody, mmelody_speed_t speed);
void
mmelody_volume_set (mmelody_t mmelody, mmelody_volume_t volume);
/** Return non-zero if playing. */
bool
mmelody_active_p (mmelody_t mmelody);
#endif