In case anyone is using MidiZyx2abc to make ABC files from MIDI files, you might want to use these regular expressions to prepare the file for pasting in to Codea as a variable…
This one adds the escape character \ in front of the apostrophes that denote higher octaves:
Pattern: /([a-g’])'/gxsm
Replace: $1\’
If you care about how long the lines get, use this to ‘word wrap’, it puts a newline character after every 40 - 80 characters, depending on chord endings and bar lines:
Pattern: /(\[.{40,80}?\]\s?\|?\s?)/gxm
Replace: $1\
Then use this one, it adds …’ to start and
’ to end of a line:
Thanks to @MdMbunny, @Codeslinger and @KMEB I have incorporated some improvements, but still a long way to go… ! Next plan is to implement multi voicing as per the ABC standard.
Hi @JockM, I looked into it briefly and settled on gist as a lightweight alternative. If it would encourage collaboration I could be convinced to move to a project. If you’ve looked at the code you will know I’m not a software engineer… so I would benefit from some help. Some questions:
Can I manage it from the iPad?
Will it make it easier to incorporate changes?
Is it much more overhead?
Over the last few evenings I have been working on restructuring the class, reducing global namespace pollution (thanks!), and adding multivoicing and different instrument sounds. I will look in to GitHub again and perhaps start my next version there.
Well if you make it a full GitHub project you can have an issue tracker, and a wiki for documentation. People can also watch the project and be notified if there are changes.
Its also a bit handier for people who are using the Codea Run Time producing something for the App Store.
Now as I say in your case you aren’t joining that many strings and it is only being done once. But you may find this way easer to read (I know I do).
A Note On Performance:Premature optimization is the root of all evil. So don’t get too obsessed about things like the ..operator in general. If you are joining a relatively small number of strings, or doing it just once, it doesn’t matter much in the grand scheme of things.
However if you are joining a lot of strings, or doing it in a loop (so it all adds up), etc; then consider using table.insert() followed by a table.join().
Thanks @JockM, I recently discovered I could put the whole tune in text brackets like this:
[[X: 1
T: Bogg Blues]]
So that will save a lot of typing those … concatenations, and removes the need to escape certain characters.
Your point in the efficiency is right though, I am thinking of moving to a table approach for the main parsing of the tune because a lot of string operations are involved, and cumulatively they are taking too long.
Hi @JockM, yes, that’s right. I didn’t realise that wasn’t documented - TLL made it to fix issues with precision and caching that I came across when beta testing Cargo-Bot and developing the (equally Quixotic) music player.
@Simeon, another thing to add to the docs… and this ENCODE API is still so useful - thanks @Dylan I think it was who did it.
I fear a full implementation of sound()really is quixotic. the non-PCM portions of sound are so deeply reliant on SFXR that it would require either making a custom version of Löve2D with SFXR embedded in it, or rewriting SFXR (~1,400 lines of C++) in Lua.
Each approach has rather large negatives, as you can imagine.
So right now I am trying to find if there is a reasonable subset of sound’s generative capabilities I could implement. But to do that I have to know everything sound can do
On the plus side I do have soundBuffer()fully implemented…
Great, @JockM, I would love to try Love again. You know what we also need, is a good demo exploration of what soundbuffer() can do. I have dabbled, but still don’t understand it properly.
@Fred I may try and see if I can’t write something to show offsoundBuffer() it is one of those functions that seems so innocent, and at first the documentation seems obvious… until you start to dig in and realize that there are a lot of assumptions that are undocumented. I spent most of yesterday just working out
big endian vs little endian
signed vs unsigned
does soundBuffer() add to what is played or replace what is played
I also plan to write a small utility to convert PCM data into Lua strings, because it is a royal PITA to do it right now
this is crashing on me. I’m pretty sure I copied the files correctly because I did it twice. I wanna use music in my project but I don’t wanna have to do it through xcode. can this music player play a mp3 file I download from a royalty free website