If you have a problem or need to report a bug please email : support@dsprobotics.com
There are 3 sections to this support area:
DOWNLOADS: access to product manuals, support files and drivers
HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects
USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here
NEW REGISTRATIONS - please contact us if you wish to register on the forum
Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright
Load / Save any File to Schematics
7 posts
• Page 1 of 1
Load / Save any File to Schematics
Hello!
I experimented with ruby and binary files - And i got it managed to store any files eaven binary things to the schematic by saving each single byte with ruby.
So packing some files to the VST may now be no problem anymore
Regards
C.Hackl
I experimented with ruby and binary files - And i got it managed to store any files eaven binary things to the schematic by saving each single byte with ruby.
So packing some files to the VST may now be no problem anymore
Regards
C.Hackl
- Attachments
-
- load&save any File.fsm
- (291.94 KiB) Downloaded 1375 times
Last edited by chackl on Fri Oct 18, 2013 10:02 am, edited 4 times in total.
100% accuracy is the guarantee to your success. The value alters if you combine it with musical creativity.
-
chackl - Posts: 233
- Joined: Tue Aug 17, 2010 8:46 pm
- Location: Austria / Salzburg
Re: Load / Save any File to Schematics
This becomes even more powerful when you use the Array.pack and String.unpack methods.
These let you turn any kind of numeric data into String form for saving, and back again - in this case the term "String" is used in its most general sense; a sequence of bytes, not necessarily interpreted as being characters.
For example...
...gives you a String byte-sequence that encodes the array of float numbers (single precision in this case).
And...
...will get you back to the original array.
Also, check out the Marshal class - even more powerful!
This has methods that allow you to turn almost any Ruby object into a serialized String and back again - including even Arrays etc. nested many levels deep.
You can even make this work for your own custom classes of object if you define the correct 'load' and 'dump' methods in your new class - all you need is some way to turn your object into a string and back again (possibly by the Marshal methods of any component objects).
There are a few exceptions where this doesn't work - for example many of the FS GUI objects lack the necessary Marshal methods, so, as yet, you can't easily save GraphicsPaths, Pens, etc.
These let you turn any kind of numeric data into String form for saving, and back again - in this case the term "String" is used in its most general sense; a sequence of bytes, not necessarily interpreted as being characters.
For example...
- Code: Select all
byte_string = [0.123, 0.543, 1.462, 7.890].pack('F*')
...gives you a String byte-sequence that encodes the array of float numbers (single precision in this case).
And...
- Code: Select all
my_array = byte_string.unpack('F*')
...will get you back to the original array.
Also, check out the Marshal class - even more powerful!
This has methods that allow you to turn almost any Ruby object into a serialized String and back again - including even Arrays etc. nested many levels deep.
- Code: Select all
hashed_arrays = { "Array1" => [10,20,30], "Array2" => [40,50,60] }
File.open(my_file,"w"){|file| Marshal.dump(hashed_arrays, file)}
hashed_arrays = File.open(my_file, "r"){|file| Marshal.load(file)}
You can even make this work for your own custom classes of object if you define the correct 'load' and 'dump' methods in your new class - all you need is some way to turn your object into a string and back again (possibly by the Marshal methods of any component objects).
There are a few exceptions where this doesn't work - for example many of the FS GUI objects lack the necessary Marshal methods, so, as yet, you can't easily save GraphicsPaths, Pens, etc.
All schematics/modules I post are free for all to use - but a credit is always polite!
Don't stagnate, mutate to create!
Don't stagnate, mutate to create!
-
trogluddite - Posts: 1730
- Joined: Fri Oct 22, 2010 12:46 am
- Location: Yorkshire, UK
Re: Load / Save any File to Schematics
I did an uppdate now:
I had some errors with load ans save state and corrected to the correct file dialog
Torg:
I sea what you mean - i also thought of that way for example combining files into one file with ruby.
There is only one thing why i have not done it jet:
I do not get this F....ING ZLIB running - to compress data
Update is in first post
Regards
I had some errors with load ans save state and corrected to the correct file dialog
Torg:
I sea what you mean - i also thought of that way for example combining files into one file with ruby.
There is only one thing why i have not done it jet:
I do not get this F....ING ZLIB running - to compress data
Update is in first post
Regards
100% accuracy is the guarantee to your success. The value alters if you combine it with musical creativity.
-
chackl - Posts: 233
- Joined: Tue Aug 17, 2010 8:46 pm
- Location: Austria / Salzburg
Re: Load / Save any File to Schematics
Hi C.Hackl,
I'm following along your thread here ... trying to continue learning.
I'm being help on a new file/data SAVE & LOAD routine. TROG posted the Ruby Marshal code which is absolutely great.
I don't want to interrupt your thread at all ... but I was looking at your post as I search for implementing some 'Directory Management' functions to dress out this Marshal routine.
Looking at your code, I see some sections of interest.
I've been using TROG's 'Save Load Application Data settings file' that has default directory locations, find if a file exists, and can create a Folder to store in.
I'm not confident in my writing of RUBY that would involve things like directories or creating folders ... don't need to tempt a disaster I feel safer with GREEN. Yet was wondering if you had plans to have these type of functions for this module ?
sorry to interrupt ... thanks for your posts !!!
I'm following along your thread here ... trying to continue learning.
I'm being help on a new file/data SAVE & LOAD routine. TROG posted the Ruby Marshal code which is absolutely great.
I don't want to interrupt your thread at all ... but I was looking at your post as I search for implementing some 'Directory Management' functions to dress out this Marshal routine.
Looking at your code, I see some sections of interest.
I've been using TROG's 'Save Load Application Data settings file' that has default directory locations, find if a file exists, and can create a Folder to store in.
I'm not confident in my writing of RUBY that would involve things like directories or creating folders ... don't need to tempt a disaster I feel safer with GREEN. Yet was wondering if you had plans to have these type of functions for this module ?
sorry to interrupt ... thanks for your posts !!!
- RJHollins
- Posts: 1571
- Joined: Thu Mar 08, 2012 7:58 pm
Re: Load / Save any File to Schematics
Ive just added now a Save Load for complet dirs and subdirs
Regards
EDIT- And i can not upload it ^^
EDIT2 - It got over 2MB so i had to delete the files inside -sorry
Regards
EDIT- And i can not upload it ^^
EDIT2 - It got over 2MB so i had to delete the files inside -sorry
100% accuracy is the guarantee to your success. The value alters if you combine it with musical creativity.
-
chackl - Posts: 233
- Joined: Tue Aug 17, 2010 8:46 pm
- Location: Austria / Salzburg
Re: Load / Save any File to Schematics
maybe the WAV data file is bulking up the filesize ?!?
- RJHollins
- Posts: 1571
- Joined: Thu Mar 08, 2012 7:58 pm
Re: Load / Save any File to Schematics
If you save a file within a schematic - it will gow ^^
This is a normal natural Computer phenomenon
This is a normal natural Computer phenomenon
100% accuracy is the guarantee to your success. The value alters if you combine it with musical creativity.
-
chackl - Posts: 233
- Joined: Tue Aug 17, 2010 8:46 pm
- Location: Austria / Salzburg
7 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 108 guests