You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
			
				
					
					
						
							65 lines
						
					
					
						
							2.0 KiB
						
					
					
				
			
		
		
		
			
			
			
				
					
				
				
					
				
			
		
		
	
	
							65 lines
						
					
					
						
							2.0 KiB
						
					
					
				| String[] patternLabels = {}; | |
| String[] banksLabels = {}; | |
| int[] soundNumbersArray = {}; | |
| int[] dividersArray = {}; | |
| int[] banksArray = {}; | |
| int[] bpmPatArray = {}; | |
| int[] bpmsArray = {}; | |
| boolean[][][] patternsArray = {}; | |
| 
 | |
| void loadData() { | |
|    | |
|   JSONObject json; | |
|   json = loadJSONObject("data.json"); | |
| 
 | |
|   JSONArray pattsArray = json.getJSONArray("patterns"); | |
|   JSONArray bnksArray = json.getJSONArray("banks"); | |
|   JSONArray bpmArray = json.getJSONArray("bpm"); | |
|    | |
|   for(int bpm=0; bpm<bpmArray.size(); bpm++) { | |
|     JSONObject single = bpmArray.getJSONObject(bpm);  | |
|     bpmsArray = append(bpmsArray, single.getInt("value")); | |
|   } | |
|    | |
|   bpm = bpmsArray[0]; | |
|    | |
|   for(int bnk=0; bnk<bnksArray.size(); bnk++) { | |
|     JSONObject single = bnksArray.getJSONObject(bnk);  | |
|     banksLabels = append(banksLabels, single.getString("name")); | |
|   } | |
|    | |
|   for(int pat=0; pat<pattsArray.size(); pat++) { | |
|     JSONObject single = pattsArray.getJSONObject(pat);  | |
|     JSONArray singlePattsArray = single.getJSONArray("pattern"); | |
|     boolean[][] tmpPat = {}; | |
|      | |
|     patternLabels = append(patternLabels, single.getString("name")); | |
|     soundNumbersArray = append(soundNumbersArray, single.getInt("numSounds")); | |
|     dividersArray = append(dividersArray, single.getInt("divider")); | |
|     banksArray = append(banksArray, single.getInt("bank")); | |
|     bpmPatArray = append(bpmPatArray, single.getInt("bpm")); | |
|      | |
|     for(int x=0; x<singlePattsArray.size(); x++) { | |
|       boolean[] tmpRow = {}; | |
|       JSONArray rowsArray = singlePattsArray.getJSONArray(x); | |
|       for(int y=0; y<rowsArray.size(); y++) { | |
|         boolean boolVal = rowsArray.getBoolean(y); | |
|         tmpRow = (boolean[]) append(tmpRow, boolVal); | |
|       } | |
|       tmpPat = (boolean[][]) append(tmpPat, tmpRow); | |
|     } | |
|     patternsArray = (boolean[][][]) append(patternsArray, tmpPat); | |
|   } | |
| 
 | |
|   /* | |
|   for(int i=0; i<patternsArray.length; i++) { | |
|     println("######"+i); | |
|     for(int x=0; x<patternsArray[i].length; x++) { | |
|       println("######"+x); | |
|       printArray(patternsArray[i][x]); | |
|     } | |
|   } | |
|   */ | |
| 
 | |
| 
 | |
| }
 |