GitXplorerGitXplorer
j

TunePlayer

public
1 stars
0 forks
0 issues

Commits

List of commits on branch main.
Verified
1e43f71a8ba6fa8abff65d09c86d772e8c07f3c2

Merge pull request #7 from jgOhYeah/development

jjgOhYeah committed a year ago
Verified
0ca95cc55418db9b3232482239494ce30abbd7df

Merge pull request #6 from jgOhYeah/main

jjgOhYeah committed a year ago
Unverified
75da5c6537934779bbb17280a2a64e95c5263626

Fixed stop sound for 32u4

jjgOhYeah committed a year ago
Unverified
d96090463e02f10517d550baf8d5950c223a6d83

Added ATmega32u4 support for TimerOneSound

jjgOhYeah committed a year ago
Unverified
3986e4e84bfe383f24b010cfee36557ed3f21f86

Fixed compile warnings for the ESP32 platform

jjgOhYeah committed a year ago
Unverified
72193b52d1a5f2b2234bb960bdf2097b39a58070

Stopped TimerOneSound being included by default for non-AVR platforms, added const to FlashTuneLoader

committed a year ago

README

The README file for this repository.

TunePlayer Arduino Lint Actions Status

An Arduino library to decode and play simple tunes.

Each note is stored as a 16 bit integer and the method of loading tunes and how each note is played is reconfigurable. The current anticipated method of tune playing revolves around a pwm square wave on a piezo siren or speaker.

Quick links

This library is inspired (but not compatible with) the PICAXE tune command

This cppQueue library is required to be installed.

Getting started

See the simple example for this in one file.

Installation

Search for TunePlayer in the Arduino library manager or download this repository and copy it to the libraries folder (for me, ~/Documents/Arduino/libraries/). If not installed already, the cppQueue library should be installed as well.

Hardware

The simplest way is to connect a piezo buzzer / siren (e.g. smoke alarm) to the output pin (pin 9 in the examples). For makimum loudness, you will probably need a driver circuit and tune things to resonate.

Include the library

#include <TunePlayer.h>

Add the tune

See the Musescore Plugin page for a fairly straightforward way to generate the tunes.

// Converted from 'FucikEntryoftheGladiatorsPNO' by TunePlayer Musescore plugin V1.6
const uint16_t FucikEntryoftheGladiatorsPNO[] PROGMEM = {
    0xe118, // Tempo change to 280.0002 BPM
    0x3a38,0x2a38,0x1a18,0x2a18,0x1a18,0xa18,0xb838,
    // ...
    0xf000 // End of tune. Stop playing.
};

Create the required objects

FlashTuneLoader flashLoader; // Where the notes come from
#define PIEZO_PIN 9
ToneSound piezo(PIEZO_PIN); // What plays the notes
TunePlayer tune; // Coordinates everything and does things at the right times.

Set up to play

flashLoader.setTune(FucikEntryoftheGladiatorsPNO);
tune.begin(&flashLoader, &piezo);

Play

tune.play();

Regularly update

This needs to be called as often as possible while the tune is playing.

tune.update();

Other functionality

See the API reference.