Page 1 of 1

problem: deleting waves form middle of wave array

Posted: Sat Feb 08, 2014 11:36 am
by KG_is_back
I'm working on a sampler and I came across a problem regarding sample indexing. Let's say I have 7 samples loaded and couple of parameters (array-parameters - one value for each sample per parameter). If I want to delete value form end of an array, that's no problem. However when I want to delete sample somewhere form the middle, let's say sample at index 4. It is no problem with the parameter arrays to delete value at index 4 leaving only 6 values in the array. However that doesn't work for wave array - you can only clear the wave leaving empty wave at that index (so the array will still have 7 waves with the 4th being empty).

Is there a way around it?

Apparently, reloading the whole array every time I delete a wave is stupid idea. I was thinking of creating an integer array, that would hold indexes of the actual samples related to parameters. So when I delete the wave at index 4, the int array would say [0,1,2,3,5,6]. However I have problem achieving that. Can anyone help me?

Re: problem: deleting waves form middle of wave array

Posted: Sat Feb 08, 2014 11:57 am
by Nubeat7
delete_if in ruby should do it..

Re: problem: deleting waves form middle of wave array

Posted: Sun Feb 09, 2014 8:02 pm
by KG_is_back
That is not what I was looking for - this can easily be done in intArray primitive. I'm trying to do this relative to wave array, so the IntArray will hold indexes of where that particular sample is in the wave array. I have problem adding new "sample" to new slot in wave array while adding index of that wave to the new value in int Array.

Re: problem: deleting waves form middle of wave array

Posted: Sun Feb 09, 2014 8:10 pm
by KG_is_back
Actually I was thinking of using ruby to pack the wave index, velocity and key rages and couple of other parameters as a ruby array and create an array of arrays for the samples and all to them related data. However my ruby skills are quite low, so I might need help with that.

Re: problem: deleting waves form middle of wave array

Posted: Mon Feb 10, 2014 10:20 am
by stw
Did you already try the SetArray prim form the R&D components for reindexing?

Re: problem: deleting waves form middle of wave array

Posted: Mon Feb 10, 2014 10:58 am
by KG_is_back
Thats not actually a bad idea! copy the last wave onto the place of the deleted and then resize array. Saves place! Reindexing full array would probably be on overshot.