Tweak docs
This commit is contained in:
+5
-3
@@ -3,9 +3,7 @@
|
||||
@date 20 April 2007
|
||||
@brief Play simple melodies.
|
||||
*/
|
||||
|
||||
#define MMELODY_TRANSPARENT 1
|
||||
|
||||
#include "system.h"
|
||||
#include "mmelody.h"
|
||||
|
||||
|
||||
@@ -43,6 +41,9 @@
|
||||
we could separate two indentical quarter notes with a comma, for
|
||||
example, A,A.
|
||||
|
||||
Eighth notes and triplets? *8 switches to interpreting the notes
|
||||
as eighth notes. *4 switches back to quarter notes.
|
||||
|
||||
Rests are easy. Each space represents one rest of quarter-note
|
||||
duration. Two spaces represent a half-note rest. Alternatively,
|
||||
we could represent this with " /".
|
||||
@@ -254,6 +255,7 @@ mmelody_play (mmelody_t mmelody, const char *str)
|
||||
mmelody->loop_start = 0;
|
||||
mmelody->loop_count = 0;
|
||||
mmelody->octave = MMELODY_OCTAVE_DEFAULT;
|
||||
/* Default to quarter notes. */
|
||||
mmelody_note_fraction_set (mmelody, 4);
|
||||
}
|
||||
|
||||
|
||||
+12
-7
@@ -43,24 +43,29 @@ typedef mmelody_obj_t *mmelody_t;
|
||||
|
||||
typedef void (* mmelody_callback_t) (void *data, uint8_t note, uint8_t volume);
|
||||
|
||||
extern mmelody_t
|
||||
mmelody_t
|
||||
mmelody_init (mmelody_obj_t *dev,
|
||||
uint16_t poll_rate,
|
||||
mmelody_callback_t play_callback,
|
||||
void *play_callback_data);
|
||||
|
||||
extern void
|
||||
/** Start playing a new melody. */
|
||||
void
|
||||
mmelody_play (mmelody_t mmelody, const char *str);
|
||||
|
||||
extern void
|
||||
|
||||
/** Update melody sequencer. */
|
||||
void
|
||||
mmelody_update (mmelody_t mmelody);
|
||||
|
||||
/* Set (base) speed in beats per minute (BPM). */
|
||||
extern void
|
||||
|
||||
/** Set (base) speed in beats per minute (BPM). */
|
||||
void
|
||||
mmelody_speed_set (mmelody_t mmelody, mmelody_speed_t speed);
|
||||
|
||||
/* Set volume as percentage of maximum. */
|
||||
extern void
|
||||
|
||||
/** Set volume as percentage of maximum. */
|
||||
void
|
||||
mmelody_volume_set (mmelody_t mmelody, mmelody_volume_t volume);
|
||||
|
||||
#endif
|
||||
|
||||
+3
-10
@@ -3,9 +3,7 @@
|
||||
@date 20 April 2007
|
||||
@brief Generate PWM for a piezo tweeter.
|
||||
*/
|
||||
|
||||
#define TWEETER_TRANSPARENT 1
|
||||
|
||||
#include "system.h"
|
||||
#include "tweeter.h"
|
||||
|
||||
|
||||
@@ -65,16 +63,11 @@ tweeter_note_play (tweeter_t tweeter, tweeter_note_t note, uint8_t velocity)
|
||||
duty = (period * velocity) >> 8;
|
||||
|
||||
tweeter_note_set (tweeter, period, duty);
|
||||
|
||||
#if 0
|
||||
printf ("note = %d, octave = %d, period = %d\n",
|
||||
note, index / TWEETER_SCALE_SIZE, period);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
int8_t
|
||||
/** Decide whether to turn tweeter on. */
|
||||
bool
|
||||
tweeter_update (tweeter_t tweeter)
|
||||
{
|
||||
if (tweeter->note_holdoff)
|
||||
|
||||
+7
-4
@@ -57,21 +57,24 @@ typedef tweeter_private_t tweeter_obj_t;
|
||||
typedef tweeter_obj_t *tweeter_t;
|
||||
|
||||
/* The scale table is usually defined with:
|
||||
|
||||
static tweeter_scale_t scale_table[] = TWEETER_SCALE_TABLE (LOOP_POLL_RATE);
|
||||
*/
|
||||
|
||||
extern int8_t
|
||||
|
||||
/** Decide whether to turn tweeter on. */
|
||||
bool
|
||||
tweeter_update (tweeter_t tweeter);
|
||||
|
||||
|
||||
/* The note and velocity are specified as per the MIDI standard except
|
||||
a note value of 0 indicates a rest (note off). The velocity has a
|
||||
maximum value of 127 and gives an indication of the note
|
||||
volume. */
|
||||
extern void
|
||||
void
|
||||
tweeter_note_play (tweeter_t tweeter, tweeter_note_t note, uint8_t velocity);
|
||||
|
||||
extern tweeter_t
|
||||
|
||||
tweeter_t
|
||||
tweeter_init (tweeter_obj_t *dev,
|
||||
uint16_t poll_rate,
|
||||
tweeter_scale_t *scale_table);
|
||||
|
||||
Reference in New Issue
Block a user