Play sound beeps corresponding to musical notes.
Project description
A python module to play sound beeps corresponding to musical notes from the command line or another python program.
How to use it from another python program:
import musicalbeeps
player = musicalbeeps.Player(volume = 0.3,
mute_output = False,
hide_warnings = True)
# Examples:
# To play an A on default octave n°4 for 0.2 seconds
player.play_note("A", 0.2)
# To play a G flat on octave n°3 for 2.5 seconds
player.play_note("G3b", 2.5)
# To play a F sharp on octave n°5 for the default duration of 0.5 seconds
player.play_note("F5#")
# To pause the player for 3.5 seconds
player.play_note("pause", 3.5)
Initializations parameters for the Player
class:
Name | Type | Default | Description |
---|---|---|---|
volume |
float |
0.5 |
Set the volume. Must be between 0 and 1 |
mute_output |
bool |
False |
Mute the output displayed when a note is played |
hide_warnings |
bool |
True |
Hide warnings triggered by PortAudio by muting stderr when a note is played |
How to use it from the command line:
musicalbeeps --help
usage: musicalbeeps [-h] [--silent] [--volume VOLUME] [file]
Play sound beeps corresponding to musical notes.
positional arguments:
file a file containing musical notes
optional arguments:
-h, --help show this help message and exit
--silent disable player output
--volume VOLUME volume between 0 and 1 (default=0.5)
how to use:
Notes are read from a file passed as argument, or directly from the
standard input. Each note must be on a new line.
note format:
Each note must be formatted like so: 'A5#:1.5' (without quotes)
Where:
- 'A' is the note (between A and G, can be lowercase)
- '5' is the octave (between 0 and 8, default=4)
- '#' (or 'b') is optional and used to play a sharp or flat note
- ':1.5' is the duration of the note (1.5 seconds here, default=0.5)
pause:
You can pause the player by replacing the note by the 'pause' word.
For exemple, 'pause:5' will pause the player for 5 seconds.
Examples:
-
To play a sharp B on octave n°5 for 1.2 seconds:
echo "B5#:1.2" | musicalbeeps
-
To play the content of a file:
musicalbeeps file_to_play.txt
Example files are provided in the music_scores directory of the GitHub repository.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
MusicalBeeps-0.2.0.tar.gz
(4.7 kB
view hashes)
Built Distribution
Close
Hashes for MusicalBeeps-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aa495a16f177cc8bbc6a22cd3a070d8bbae0c562f7043b0af32ae1638e135a1b |
|
MD5 | 936c5e8bdcce2b6d5b03527c431c622b |
|
BLAKE2b-256 | d09edc8b6660108154c78a6eac3997c8ec9da91039b34ed34ff477f2df33bc55 |