@@ -3184,6 +3184,14 @@ class Sound:
31843184 # Introduce yourself, wait for completion:
31853185 Sound.speak('Hello, I am Robot').wait()
31863186
3187+ # Play a small song
3188+ Sound.play_song((
3189+ ('D4', 'e3'),
3190+ ('D4', 'e3'),
3191+ ('D4', 'e3'),
3192+ ('G4', 'h'),
3193+ ('D5', 'h')
3194+ ))
31873195 """
31883196
31893197 channel = None
@@ -3339,8 +3347,10 @@ def play_song(cls, song, tempo=120, delay=50):
33393347
33403348 It supports symbolic notes (e.g. ``A4``, ``D#3``, ``Gb5``) and durations (e.g. ``q``, ``h``).
33413349
3342- Accepted note symbols and values are defined by the :py:attr:`NOTES` and :py:attr:`NOTE_VALUES`
3343- dictionaries. The value can be suffixed by modifiers:
3350+ For an exhaustive list of accepted note symbols and values, have a look at the :py:attr:`_NOTE_FREQUENCIES`
3351+ and :py:attr:`_NOTE_VALUES` private dictionaries in the source code.
3352+
3353+ The value can be suffixed by modifiers:
33443354
33453355 - a *divider* introduced by a ``/`` to obtain triplets for instance
33463356 (e.g. ``q/3`` for a triplet of eight note)
@@ -3405,21 +3415,21 @@ def beep_args(note, value):
34053415 Returns:
34063416 str: the arguments to be passed to the beep command
34073417 """
3408- freq = Sound .NOTE_FREQUENCIES [note .upper ()]
3418+ freq = Sound ._NOTE_FREQUENCIES [note .upper ()]
34093419 if '/' in value :
34103420 base , factor = value .split ('/' )
3411- duration = meas_duration * Sound .NOTE_VALUES [base ] / float (factor )
3421+ duration = meas_duration * Sound ._NOTE_VALUES [base ] / float (factor )
34123422 elif '*' in value :
34133423 base , factor = value .split ('*' )
3414- duration = meas_duration * Sound .NOTE_VALUES [base ] * float (factor )
3424+ duration = meas_duration * Sound ._NOTE_VALUES [base ] * float (factor )
34153425 elif value .endswith ('.' ):
34163426 base = value [:- 1 ]
3417- duration = meas_duration * Sound .NOTE_VALUES [base ] * 1.5
3427+ duration = meas_duration * Sound ._NOTE_VALUES [base ] * 1.5
34183428 elif value .endswith ('3' ):
34193429 base = value [:- 1 ]
3420- duration = meas_duration * Sound .NOTE_VALUES [base ] * 2 / 3
3430+ duration = meas_duration * Sound ._NOTE_VALUES [base ] * 2 / 3
34213431 else :
3422- duration = meas_duration * Sound .NOTE_VALUES [value ]
3432+ duration = meas_duration * Sound ._NOTE_VALUES [value ]
34233433
34243434 return '-f %d -l %d -D %d' % (freq , duration , delay )
34253435
@@ -3433,7 +3443,7 @@ def beep_args(note, value):
34333443 #: standard US abbreviation and its octave number (e.g. ``C3``).
34343444 #: Alterations use the ``#`` and ``b`` symbols, respectively for
34353445 #: *sharp* and *flat*, between the note code and the octave number (e.g. ``D#4``, ``Gb5``).
3436- NOTE_FREQUENCIES = _make_scales ((
3446+ _NOTE_FREQUENCIES = _make_scales ((
34373447 ('C0' , 16.35 ),
34383448 ('C#0/Db0' , 17.32 ),
34393449 ('D0' , 18.35 ),
@@ -3564,7 +3574,7 @@ def beep_args(note, value):
35643574 #: For instance, the note value of a eight triplet will be ``NOTE_VALUE['e'] / 3``.
35653575 #: It is simpler however to user the ``3`` modifier of notes, as supported by the
35663576 #: :py:meth:`Sound.play_song` method.
3567- NOTE_VALUES = {
3577+ _NOTE_VALUES = {
35683578 'w' : 1. ,
35693579 'h' : 1. / 2 ,
35703580 'q' : 1. / 4 ,
0 commit comments