|
Forum Index : Microcontroller and PC projects : ARRAY Question Help ?
| Author | Message | ||||
| TweakerRay Senior Member Joined: 01/08/2020 Location: GermanyPosts: 138 |
Hi ! I have a problem and maybe some of the more experienced programmers here can help. I work on a chiptune drum programm and I am hoping to otimize it a little. right now I use a lot of arrays to store infos I use for example 3 Arrays to store informations a Array called sstep(4,16) holds the info if a step is set and on which Instrument lane. Another Array stores the Volume information for that same pattern called volume (4,16) so here are the volume information of the single steps stored for 4 instruments. Another Array called Freq(4,16) stores the frequencies on 16 steps for 4 lanes. I am now implementing a feature where you can chain the programmed patterns to a song Right now I store all these information also to sdcard or can load them into so called Patternpages which are also: arrays Mstep1(4,16) contains all steps MVol1 (4,16) All Volume infos and so on... I hav 16 times 3 arrays with that info for the complete stored patterns for 16 memoryslots... I would have loved to use something like a 3 dimensional array where I cut simply do something like Volume (x) (4,16) = would be the complete info and I could use a running variable for all 16 memory slots... Maybe I could even store all the info in one big array... but I am too stupid to archieve that... Has anyone an Idea how I could do that more easily ? Right now I have for each stored pattern 3 Arrays which needs to be loaded and when I use chained patterns together it loads all info while just loading the stored page with all info. Here is the programm maybe it does make more sense to look at the code. I think this could be done more clever but I have not so much experience to do it smarter... Also my memory patterns which will be saved into 16 textfile maybe I could combine that to just one textfile and the programm can search in that textfile ? I mean overall its just a few numbers but they won't be saved with a , next to each other. Maybe have some idea how to make it more clever than I do right now... DrummachineV7.zip http://tweakerray.bandcamp.com |
||||
| mkopack73 Senior Member Joined: 03/07/2020 Location: United StatesPosts: 261 |
IIRC you can do up to 7 or 8 dimensional arrays if you need them... (check the documentation but I think that's the amount it states...) |
||||
| TweakerRay Senior Member Joined: 01/08/2020 Location: GermanyPosts: 138 |
Hi ! I checked the documentation but how can I put them together ? I get errors when I try for example to put my 2 dimension field into another one... I would love to have something like volume((x),(4,16 step information ) volinfo(4,16) (freqinfo(4,16) for 16 memory patterns... So "Look at the documentation" is not really helping because I did that already... http://tweakerray.bandcamp.com |
||||
| TweakerRay Senior Member Joined: 01/08/2020 Location: GermanyPosts: 138 |
Maybe I put my question more simple: I have 4 Instruments with 16 Steps... So I would probably need this array: (4,16,16,16) So this is for 4 Lanes , 16 step infos, 16 Volume , 16 Frequency Infos right ? And if I would like to store 16 pages of them it would be ? DIM Patternpage (16,4,16,16,16) ? Something like that ? And do I have to check the parameters like this ? Volume(Lane,x)= Patternpage(16,Lane,Step,Volume,Freq) So how can I chack a specific value from that big ARRAY and put it into a 2 dimension ARRAY ? http://tweakerray.bandcamp.com |
||||
| mkopack73 Senior Member Joined: 03/07/2020 Location: United StatesPosts: 261 |
Sorry, I'm just utterly confused by what you're trying to do... If you want to define a 2D array, you just do: dim myarray(size1,size2) as integer (where size1 and size2 are either variable names that have number values or you use numbers instead.. If you want more dimensions, just keep adding them like: dim myarray(size1, size2, size3, size4) as integer and so on... Then to access a specific value out of it, you do it by the index into each dimension: x = myarray(a, b, c, d) Where a-d are the indexes of the value you want to grab out of each dimension... You can only store 1 item in each cell of the array, and likewise can only grab 1 item at a time... Edited 2020-09-06 11:26 by mkopack73 |
||||
| mkopack73 Senior Member Joined: 03/07/2020 Location: United StatesPosts: 261 |
Ok, I'm confused... Are you trying to FIND or STORE information where you're putting things like (4,16 Step information), volinfo(4,16), freqinfo(4,6) ???? If you're trying to STORE then you're making copies of those values and putting them into the other table... Or just store the 4, 16 as 2 cells IF you're trying to read that then I think what you want is the index to read out of those other arrays (which means you're going to want to store the 4,16) and then pull those values out of the 3 other array tables afterwards... |
||||
| Turbo46 Guru Joined: 24/12/2017 Location: AustraliaPosts: 1646 |
I think I understand what you want to do but dimensions beyond 3 are something I have great difficulty with and I am not sure you have the right method. Can I suggest a different aproach? How about using: DIM Patternpage (16,4,48) ie: DIM Patternpage (page,lane,Tdata) where: Tdata + 0 = step Tdata + 1 = volume Tdata + 2 = frequency I think that step, volume and frequency are the same type of data and shouldn't be allocated a dimension in the array - hope that makes sense. Bill Keep safe. Live long and prosper. |
||||
| TweakerRay Senior Member Joined: 01/08/2020 Location: GermanyPosts: 138 |
Hi ! Thanks for your help ! @mkopack73: Sorry for the confusion. I try to explain what I want to archieve ;-) I have this programm above... (DrummachineV7) At the moment I store information in 2 dimensional arrays. I have a grid of 4 X 16 (16 Fields for 4 instruments Basedrum,Snare,Hihat,Add Sound) BD X X X X X X X X X X X X X X X X SD X X X X X X X X X X X X X X X X HH X X X X X X X X X X X X X X X X AS X X X X X X X X X X X X X X X X Each of these cells have stored info if the step is ON/OFF stored in sset(4,16) Each of these cells have volume info stored in volume(4,16) Each of these cells have frquency info stored in freq(4,16) Because the programm grew ... I implemented new features Like that you now can store these pages internally on 16 places and also on sd card. The new feature I am working on is a Chainmode... where you can put these patterns after another in a modular way. So you have a list of 64 Pattermemorys where you can say I want to play Pattern 1 for 4 times and then pattern 2 - 3 times and so on... right now I archieve that that the programm loads the complete pattern at the start when the locator is the first step playing it looks into the patternchainlist and sees "Page 4" and loads all infos (step set,volume,frequency and that for 4 instruments) The problem here is that it needs some time to do that. I though if the programm already knew that it does not need to load all that info because its already stored in one memory place... Right now I store these in 3 X 16 2 dimensional arrays for the first memory place i have mset1(4,16) & mvol1(4,16) , mfreq1(4,16) for the 2nd memory i use mset2(4,16) / mvol2(4,16) and mreq2(4,16) If I could transform these two dimensional arrays into a 3rd dimenstion I would not have to have explecit names for each memory place... but when I try to do that I get a dimension error and I don't know why. So the question would be how can I put all the 2 dimensional infos into a 3rd dimenstion so my patterns with 4 X 16 could be a catalog. the 3rd dimenstion would be the page of these 4 X 16 cells if I am correct. Then I could read them more easily. and the arrays would have not to be named like i did now. Right now the 4 sounds will be played when the locator will go over the step so it reads all the info and plays the sound. when I am in chainmode the programm loads the pattern page at start of step one so the goal is that the programm already knows what it's doing and does not need to load all 16 infos at start. instead just the 4 sounds it needs when playing... I hope I explain this now a little better what I want ;-) Thanks again for your support. http://tweakerray.bandcamp.com |
||||
| TweakerRay Senior Member Joined: 01/08/2020 Location: GermanyPosts: 138 |
I think I managed to include the 3 dimenstions-fields now into my programm... This makes things much easier than before ! Thanks at all for the help. Cheers TweakerRay http://tweakerray.bandcamp.com |
||||
| The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |