Skip to content

Latest commit

 

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rudimentary music maker/sound library with Python

Generating tone with pygame code taken and modified from: https://stackoverflow.com/a/16268034

Using the program:

First, install pygame and numpy.

pip install pygame
pip install numpy

Then you can run main.py. Doing so will play the "Sweet Child 'O Mine" intro by "Guns 'n Roses".

Playing around with the library:

To play a note, you can use the Note class:

from Note import Note
Note('C4').play() # Plays middle C for 1 second.

Note('E4', 3).play() # Plays E4 for 3 seconds

To play a chord, use the play_chord() method and pass in a list of Notes:

# Plays a C major chord
Note.play_chord([
    Note('C4'),
    Note('E4'),
    Note('G4')
])

The Tone class

Currently, the Tone class only generates sine waves.
Here's how you do so:

from play_tone import Tone

frequency = 440
duration = 1

# Plays a 440 Hz sine wave for 1 second.
Tone.sine(frequency, duration=duration)

About

Rudimentary music maker in Python

Resources

Stars

4 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages