Support

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

saving/loading sample banks (as single file)

For general discussion related FlowStone

Re: saving/loading sample banks (as single file)

Postby RJHollins » Mon Apr 27, 2015 11:04 pm

Or maybe you mean like putting the files into an array and marshall that array? also good...

Not much I can explain from my rookie perspective [sorry]. Maybe NuBeat will catch this thread ... he could probably explain more helpful.

For one of my projects, I had some 16 - 20 arrays that are automatically 'dynamic allocated' by Mashall and stored and loaded in a very simple routine to a single file. Again ... not sure if it would apply to your needs ... but the Marshall Routine was so elegant and simple that I thought to mention it.

I'm following this thread to learn from you guys ! :mrgreen:
RJHollins
 
Posts: 1571
Joined: Thu Mar 08, 2012 7:58 pm

Re: saving/loading sample banks (as single file)

Postby KG_is_back » Mon Apr 27, 2015 11:15 pm

If ruby can load from pointer, it might be possible to copy the raw PCM into a file. Problem with that is, that to load waves form file to wave array prim, we would need to convert them to wavs and still use the temporary file stuff. On the other hand, we might write our own "wave array prim" which would hold the waves as frames. Then we'd use their pointers in custom wave array prims. Trog was working on something like this and someone revived the project quite recently, it seems much more stable than using mem with toaddress prim.
KG_is_back
 
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: saving/loading sample banks (as single file)

Postby tulamide » Tue Apr 28, 2015 1:05 am

KG_is_back wrote:that's kind of the part of my pseudocode. The length (preferably in bytes) is stored just before each wave file. The opening works kinda like this:
1.create empty temp.wav and set @i=0
1.form the "bank"file read the first 4 bytes as int (determines the size of the following data) ->size
2.copy bytes[5..(4+size)] to temp.wav
3.load the temp.wav to waveArray prim at first index
4.set @i=@i+4+size
5.form the "bank"file read the 4 bytes as int starting from @i ->size
6.copy bytes[@i+5..(@i+4+size)] to temp.wav
7.load the temp.wav to waveArray prim at respective index
8.repeat steps 4-7 until the end of the "bank"file
9.delete temp.wav

That sounds right and can be done with Ruby.

KG_is_back wrote:What concerns me is synchronization...

As much as I would like to see a two headed unicorn, I'm afraid you don't need to be concerned. All you need is already there. You could create a structure similar to this:
Instead of looping inside Ruby, you mark the start of your "bank loading". Then you order to load into the wave array and check one of the two array outputs, until the array size matches the number of files you currently expect. As soon as it matches you send a trigger to the Ruby module, Ruby adds 1 to a counter, and the whole procedure repeats, until all files are loaded. Taking your list it means you would always stop execution after point 3 and wait for the trigger before continuing with step 4.

EDIT: This was written with the assumption that the outputs of the wave array will only be filled after loading. Since the information they provide are in the very first block of the wave file, it is also possible that they are filled after having read just that block, before the actual sound data is loaded. That would have to be tested (with long files to have enough time to check it).
"There lies the dog buried" (German saying translated literally)
tulamide
 
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: saving/loading sample banks (as single file)

Postby KG_is_back » Tue Apr 28, 2015 1:39 am

OK I have a version that saves a given string on the beginning of the file (preset data may be put there for example). However, I'm struggling with the wave save prim. Apart from the fact that it doesn't work at all :x , it has no output to indicate whether the saving is finished.

EDIT: one very obvious thing occurred to me right now... I don't need to save temporary wave files - I may just simply use the original ones. Along with loading waves into wave array I will store their paths. Then when wavearray should be saved as bank, I open the original files one by one and load them to the bank file.
This all assumes the files still exist and weren't modified in any way. Also It would make impossible to reuse wave files that are in the bank file (ie. edit the bank after its creation). This can be cheated though - with additional few lines of code, temp.wav files will be created form original bank to be stored in new bank.
KG_is_back
 
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: saving/loading sample banks (as single file)

Postby Tronic » Tue Apr 28, 2015 4:54 am

try this http://wavefilegem.com/ it's an pure ruby wave file read/write
see the code example it have all you need for the request task.
Tronic
 
Posts: 539
Joined: Wed Dec 21, 2011 12:59 pm

Re: saving/loading sample banks (as single file)

Postby KG_is_back » Tue Apr 28, 2015 5:32 pm

OK guys, it seems to be working fine...
You can also store additional data string with the bank (for example preset string).

known bugs:
-sometimes Windows doesn't permit deleting of the temp file. BTW you may easily edit path and name of the temp file in "load" module. I wasn't able to completely solve this problem.
-Attempting to save bank, that has samples loaded from bank fails! When saving a bank, the saved waves are loaded from harddisk. On load, temp file is used while loading waves and is deleted afterwards. I will solve this later, by loading such files form the original bank.
-"\r" return character is not saved by the thing for some reason. In the data string this is sorted out by removing it on save. On load every "\n" character is replaced by "\r\n"
Attachments
bank v0.1.fsm
(2.33 KiB) Downloaded 784 times
KG_is_back
 
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Previous

Return to General

Who is online

Users browsing this forum: No registered users and 80 guests