Beeply module in Python
The beeply module in python will helps you produce musical notes using your computer’s characteristic beep sounds. It’s completely written in python ( using winsound and time module to be precise )
As this module is written using winsound, it will work only on Windows. This module contains only one class and a single method i.e beeply class and head() method.
Installation:
pip install beeply
Below are some examples which depicts the use of beeply module:
Example 1
A scale is the tonal basis of music. It is a set of tones from which one can generate melodies. The underscore _ is used for scale of sound If _ is given, it’s scale will be 1
Syntax:
obj = notes.beeps(duration in ms)
beeps is class, it’s constructor takes an arg ( optional ) of time duration if not given it will take it as 900 ms
If given make sure it’s in ms.
obj.hear(self,duration in ms)
Python3
# import required module from beeply.notes import * # Creating obj of beeply # It's has another arg of duration # By default it's 900 ms a = beeps() # It's has another arg of duration # By default it's 900 ms a.hear( 'A_' ) print ( "Done " ) # To acknowledge us a.hear( "A" ) |
Output:
It will produce tone of A at scale 1 and the at scale 0, you can head 2 beeps for 0.9 sec each.
Example 2
Python3
# import module from beeply.notes import * # create object with duration as argument a = beeps( 1154 ) # It will sound for 1154 ms a.hear( 'A_' ) # But if it is a.head( 'A_' , 5000 ) # Then it is for 5 sec i.e. 5000ms print ( "Done" ) |
Output:
If you will give duration as argument while making object ( i.e. while instantiating ) then it will be default duration for hear function too if not given specifically.
Please Login to comment...