diff --git a/Bashrc.wiki b/Bashrc.wiki index ab4eb71..8ac32d1 100644 --- a/Bashrc.wiki +++ b/Bashrc.wiki @@ -187,6 +187,25 @@ As an added bonus, the `-l` option will print the url for that product's support ---- +== `sing()` and `note2freq()` == + +https://git.thurstylark.com/vcsh/bashrc.git/tree/.bashrc.d/sing.bash + +I was having trouble writing music scripts for the pcspkr because all the examples that I could find only used frequency numbers as arguments to `beep`, and it was difficult to map frequency numbers to musical note letters in the process of making my own tunes. `note2freq()` solves this issue by taking a musical note in the form of `[accidental]`, where: + +* `` is one of `A` through `G` +* `[accidental]` is one of: + * `b` for flat + * `s` for sharp + * omitted for a natural note +* `` is `1` through `7` + +`sing()` takes a list of notes in this same form along with note length in ms, uses `note2freq()` to translate each one to a frequency number and constructs a string of arguments that `beep` can use to play the entire tune in one go. + +Both of these in tandem make beep tune writing way easier. + +---- + ==Weechat== https://git.thurstylark.com/vcsh/bashrc.git/tree/.bashrc.d/weechat.bash