Easy-Python  1.00.00Change to: 中文
Music

Functions

 Music ()
 Make new Music object. More...
 
 tempo (ticks, bpm)
 Set and get tempo infromation. More...
 
 play (music, wait, loop)
 Play music. More...
 
 pitch (frequency, duration, wait)
 Play a pitch. More...
 
 stop ()
 Stop play music. More...
 
 deinit ()
 Deinit music object. More...
 

Detailed Description

Function Documentation

Music ( )

Make new Music object.

Create an Music object and set tempo to initial value

Parameters
no
Returns
(no)
Example of usage:
from machine import Music
b=Music()
tempo ( ticks  ,
bpm   
)

Set and get tempo infromation.

Music.tempo()

Parameters
[in]ticksset ticks value, default : 4
[in]bpmset bpm value, default : 120
Note
If omitted the input parameters then will get the current value.
Returns
(no)
Example of usage:
from machine import Music
b=Music()
b.tempo(ticks=200, bpm=8)
b.tempo()
play ( music  ,
wait  ,
loop   
)

Play music.

Parameters
[in]musiccan be a note or a song.
[in]waitblock the function until finish the song, default: false
[in]loopkeep play the last note, default: false
Returns
(no)
Example of usage:
from machine import Music
music=['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B']
b=Music()
b.play('C#3:4',wait = 0,loop = 0)
b.play(music)
pitch ( frequency  ,
duration  ,
wait   
)

Play a pitch.

Parameters
[in]frequencyset frequency to generate a sound
[in]durationset durationm ex:1000 = 1second
[in]waitblock the function until finish the pitch
Returns
(no)
Example of usage:
from machine import Music
b=Music()
b.pitch(440,1000,0)
stop ( )

Stop play music.

Parameters
no
Returns
(no)
Example of usage:
music=['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B']
b=Music()
b.play(music)
b.stop()
deinit ( )

Deinit music object.

Parameters
no
Returns
(no)
Example of usage:
music=['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B']
b=Music()
b.play(music)
b.deinit()