npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

blheli_32_to_rtttl

v2.0.0

Published

This script takes a BLHELI_32 music string and converts it to RTTTL for BlueJay ESC firmware

Downloads

8

Readme

BLHELI_32 to RTTTL Converter

This is a simple JavaScript program that converts BLHELI_32 notation into RTTTL notation. It also removes spaces, tabs, and invalid symbols. The code consists of a few regular expressions and several functions that handle different parts of the conversion process.

How to Use

To use the program, you will need to have a BLHELI_32 string. Simply call the

`convertBlheli32ToRtttl(unformattedSourceMelody, songName = 'test', speed = 210, duration = 8, octave = 5)

function with the prefix and the unformatted BLHELI_32 string as arguments. The function will return the RTTTL string and an array of any invalid symbols that were found.

Example Usage

let unformatted_source_Melody = 'C6 2/8 G#2 1/2 C#5 8/8 P2 INVALID1 djs !/';
let rtttl_string = convertBlheli32ToRtttl(unformatted_source_Melody, 'teest1', 420, 8, 5);
console.log(rtttl_string);
This will output the following:
// Result
rtttl_string = ["teest1:b=420,o=5,d=8:8c6,2g#2,8c#5,2p", ["INVALID1", "djs", "!/"]];

// To access only the RTTTL string, use the following:
rtttl_string[0];

Limitations

Even though the script always produces a working output it does not handle every possible case. The following are some limitations of the script:

  1. It does not handle cases where the fraction is not 1/x (eg 2/3 8/8). They will be interpreted as 1/X (eg 2/3 will be interpreted as 1/3, and 8/8 will be interpreted as 1/8).
  2. Incorrect syntax may not be always handled correctly. For example C#4 4 4will be interpreted as 44C#4instead of invalidating the second 4.
  3. There may be some valid BLHELI_32 syntax that is not handled by the script. If you find any, please let me know.

Code Explanation

Regular Expressions

There are four regular expressions used in this program:

noteRegex: matches any valid note, including sharps and octaves durationWholeRegex: matches any whole-duration number, such as 1, 2, 4, 8, etc. durationFractionRegex: matches any fraction-duration in the format of 1/X, where X is any whole-duration number noteWithDurationRegex: matches any note that includes a duration in the format of A1/4, where A is any note and 1/4 is any valid duration Functions There are four functions used in this program:

getIntoRightFormat(): converts BLHELI_32 notation into a format that can be used by the program, and removes spaces, tabs, and invalid symbols splitIntoNoteObject(): takes a formatted note string and returns a Note object with a tune and duration property splitAllNotes(): takes a formatted BLHELI_32 string and returns an array of Note objects joinNotesToRtttl(): takes an array of Note objects and returns an RTTTL string Classes There is one class used in this program:

Note: a simple class for a note, which has a tune and duration property, and a get_rtttl_string() method that returns an RTTTL string for the note.