Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/james1236/buzzer_music
RPI Pico / Micropython library to play music through one or more buzzers, can automatically replace chords with fast arpeggios to simulate polyphony with a single buzzer. Music can be easily taken from onlinesequencer.net
https://github.com/james1236/buzzer_music
buzzer micropython passive-buzzer raspberry-pi raspberry-pi-pico rp2040 rpi-pico rpi-rp2
Last synced: 2 months ago
JSON representation
RPI Pico / Micropython library to play music through one or more buzzers, can automatically replace chords with fast arpeggios to simulate polyphony with a single buzzer. Music can be easily taken from onlinesequencer.net
- Host: GitHub
- URL: https://github.com/james1236/buzzer_music
- Owner: james1236
- License: mit
- Created: 2021-02-21T01:10:41.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2024-10-27T00:35:07.000Z (3 months ago)
- Last Synced: 2024-10-27T01:38:48.613Z (3 months ago)
- Topics: buzzer, micropython, passive-buzzer, raspberry-pi, raspberry-pi-pico, rp2040, rpi-pico, rpi-rp2
- Language: Python
- Homepage:
- Size: 43.9 KB
- Stars: 84
- Watchers: 6
- Forks: 17
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-raspberrypipico - Buzzer Music - Raspberry Pi Pico / Micropython library to play music through one or more buzzers. (Resources / Projects)
README
# buzzer_music
Play thousands of songs on your Raspberry Pi Pico with a buzzerMicropython library to play music through a buzzer, automatically replaces chords with fast arpeggios to simulate polyphony. Music can be easily taken from [onlinesequencer.net](https://onlinesequencer.net/)
Also supports playing music through multiple buzzers, dividing the currently playing notes across them for polyphony
### Online Simulator
See it working or test it out using this online simulator! [One Buzzer](https://wokwi.com/projects/384484222930823169) | [Multiple Buzzers](https://wokwi.com/projects/384484055755294721)
![buzzers](https://github.com/james1236/buzzer_music/assets/32351696/87245a5d-99e1-4d9d-a607-87499c3d1e27)
### Usage with RPi Pico / Other Micropython Board
1) Connect your buzzer to a ground pin and pin 0 on your Pico
2) Install micropython on your Pico and copy the files in this repository to it
3) Find some music on onlinesequencer.net (music aligned to the grid works best), click edit, select all notes with CTRL + A and then copy them with CTRL + C
4) Paste the string in place of the one in the example file, making sure to remove the "Online Sequencer:120233:" from the start and the ";:" from the endYou can pause and resume with `mySong.stop()` and `mySong.resume()`
### Board Compatibility
| Board | Compatible? |
|-------|-------------|
| Raspberry Pi Pico | Yes |
| Wemos D1 mini (ESP8266) | Yes [i8](/../../issues/8)|
| Raspberry Pi 3, 4 | Follow steps below |
| ESP32 | Yes [i14](/../../issues/14#issuecomment-2439775389)|### Raspberry Pi 3, 4 Compatibility
The following code was contributed by [@Miniontoby](https://github.com/Miniontoby) in [i10](/../../issues/10), simply create a file called `machine.py` in the same folder as the other files and put this code in it:
```python3
import RPi.GPIO as GPIO
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)class PWMchanged(GPIO.PWM):
def __init__(self, chan, freq):
super().__init__(chan, freq)
self.start(freq)
def duty(self,dutycycle): self.ChangeDutyCycle(dutycycle/65535)
def freq(self, value): self.ChangeFrequency(value)
def deinit(self): self.stop()
passdef PWM(pin):
GPIO.setup(pin, GPIO.OUT) # Just to make sure
return PWMchanged(pin, 50)def Pin(pin):
GPIO.setup(pin, GPIO.OUT)
return pin
```