From the original SynthMaker forum (2004–2014), with its members’ names and dates.
mwvdlee ·
Attached is a config file parser I made. The purpose is to allow files with meta information to be loaded together with a .WAV file, but obviously you could change it to do anything you want.
Layout is a bit nasty (trying to figure out the most readable way to do things; this probably isn't 😉 ).
What may be of interest is:
- The quoted string terminal used to match the "file" setting. Might be usefull to some.
- The "default" modules and the final "IsUsable" boolean result.
Feel free to comment, ridicule, destroy or fix anything you want 🙂
sunsynth ·
Wow mwvdlee,
ur layout is fine...
and ur work with the parser as a 'newbie' is awesome...
I tried it a few times but give up 2 quickly i think 😉
Your OSM really motivates me 2 look further into this area of SM!
Cheers and welcome,
Sunsynth
Jay ·
very good mwvdlee!
i was trying something like this a while ago when trying to create an sf2 loader! that was until i discovered sf2 files have many different formats of text file layout! bah!
but this is handy though for a few other uses. 🙂
best regards
mwvdlee ·
Just for fun, I started thinking how to read in binary files.
Seems it's quite possible, with one exception; byte 0x00 (or the EOF byte) stops Text Load from loading the file.
According to ASCII, it should indeed stop reading (EOF = End Of File) when read as a text file, but it would be fun if it didn't (feature request? 😉 ).
Other than that, the attached code just translates everything into a long string of NL-separated integers (which could easily be parsed using the parser modules). This means it will take up much more memory than the binary file (atleast 4x, probably more).
Binary saving should be about the reverse from this, maybe 0x00 will work with Text Save, but I haven't tried it.
Binary file reader:
Having the text display update real-time is slow. You can do it, but I did warn you 😉
Binary file for testing (32 bytes, has 0x00 at byte 31 and 0x01 at 32 (neither is read)):
THIS IS NOT A .OSM FILE, I just used that extension to get it attached.
rl ·
pretty cool, but unfortunately almost useless since Text Load stops at 0x00. Maybe time to bump an old feature request. IMO SM __should__ be capable to read and save binary files. There are lots of usage scenarios that make sense: SYS-EX files, parse out loop points from a wave file,..etc.
There should be a Binary File Load (and Save) module that reads in files in a format as the Sysex To String module does (giving a string in hex format like "A025FE3F...")
As a workaround I built a small C-program that does a conversion from binary to hex string text, then my schematic can read in and parse the text file.
sunsynth ·
Good idea rl...!
Start the request!
Walter
infuzion ·
mwvdlee wrote: Layout is a bit nasty (trying to figure out the most readable way to do things; this probably isn't.)
Feel free to comment, ridicule, destroy or fix anything you want
It is readable, & easier to understand than my own pref.txt reader I built years ago. I did find a few things to improve:
+made the preference extractors more portable & reusable
+module reduction
+changes don't "bounce" output anymore
+skinned the Deliminated/Quoted String module
mwvdlee ·
infuzion wrote: I did find a few things to improve
Nice work! I like the skinned delimited string, didn't know how to do that.
The delimited string as you proposed doesn't work as intended though, since the way it's implemented now means it works as: match the start delimiter, then match any character that is not ", then match the end delimiter. The problem is the middle part. It should be possible to make the two |-ed ranges matched by the middle part able to handle this, but for now I just removed the properties and made it into "Quoted String".
Other things I changed:
- Removed the "=" from the prefs modules' property, since it's always the same anyway.
- Implemented a way to handle new-lines by abusing 0x00 ASCII. The parser skips whitespace, which seems to be Space, NL, CR and Tab only. 0x00 isn't skipped and can thus be detected by the parser. And since the text loader stops loading at 0x00 and thus never loads a 0x00 in memory, it's save to use it. If you want, you can use any other character though.
That's it. Perhaps it would be a nice idea to make a "standard" set of modules of this setup.
I guess one of these days (in about 11 to be exact 😉 ) I'll have to fork up the cash to buy me a license 🙂
Wrote something here? To have a post removed or your name hidden, write to [email protected].