Crates.io | asciimusic |
lib.rs | asciimusic |
version | 0.1.3 |
source | src |
created_at | 2019-12-08 23:34:37.805683 |
updated_at | 2019-12-08 23:41:23.291295 |
description | Simple and fun, but largely useless, program and library for processing a base32-based text format to audio output |
homepage | https://gitlab.com/Taywee/asciimusic |
repository | https://gitlab.com/Taywee/asciimusic |
max_upload_size | |
id | 187401 |
size | 26,351 |
Experiments in encoding music in ascii. Might have some sort of leading data to indicate tempo, note fade out, simultaneous voices (and maybe their corresponding volumes), number of characters per note, bottom pitch frequency, and division of the note (ie. a packed representation might have 5 bits for pitch and 3 for length). Maybe even some bits for instrument selection.
Maybe integrate with SDL or something so that it can play music on its own. Maybe use a proper gui toolkit so that musical phrases can directly be loaded in and other people can use it. (perhaps making it a web-related project could be doable. This would probably have to be webassembly, because I'd prefer to do the bulk in Rust).
Keep in mind for the following values that these bits will not be 8 bits per input bytes. If the input bytes are base-64, each character only gives 6 bits. With base32, input characters only give 5 bits.
Base32 is clearer and easier to work with, but base64 will give 5.25 octaves for a single character instead of just 2.58. 2.5 octaves is barely the cello's own pitch range without thumb position. 5.25 is enough to go from the bottom of the cello's pitch to way above the Violin's natural pitch.
Bits per note (0 will be a rest, so the total is always reduced by 1):
Alternately, it might be a good idea to make it a signed representation and calculate all notes relative to the previous one, with the "base frequency" just being the starting frequency. This would half the jump distance (so a 5-bit representation would only be able to jump up 15 semitones and down 16).
Assuming a base of 16th notes. Finest subdivision is 16th notes here. Triplets of the higher note is possible by taking it down to sixths with the tempo. Three sixths make a half, two make a third.
bits per length: longest encodable note. (0 will not be possible)
A reasonable setup is base64 input. Initial blocks set up tempo and other such things, including how many voices, and what instrument each voice gets. Then the beats come in. Each instrument that needs a beat (its previous note or rest has finished) will, in order, expect to pull a beat. Voices are not specified inline, they just pull the next applicable note at the right time. At the beginning, all the beginning notes will be each for one of the voices. If one voice had a longer note than the others, it will take longer for it to need its own note.
Another reasonable setup is base32 input, with each voice needing its own base frequency, allowing each voice to have an individually reasonable 2.5 octave range. Somebody could have two voices with the same instruments to fake having a higher range, but that would involve long-resting the instrument at all other times (which isn't a big deal. For base32 with one character for note and one character for length and a base of 16th notes, that's one rest every two measures).