Viewport
-
we are attempting to take categories (subfolders) of samplemaps on left veiwport (viewport2) and the right viewport (viewport1) display the samplemaps in that category and make them loadable.
the sorted object is throwing out the right data in the watcher
{ "Brass": [ "FreshHornStaccato" ], "Guitar": [ "AcousticCampfire" ], "Keys": [ "DeepFuzzVibe", "HorrorPianoFuzz" ], "Piano": [ "CloudyJazzPno", "GoldenPiano", "RustyPiano" ], "Strings": [ "ChamberTremelo", "ChamberViolinPizz", "ChamberViolinSpiccati", "ChamberViolinTremble", "MidMedSoloString", "MovieStringStacc", "SoloViolinLeg", "ViolinPizz1", "ViolinStaccato", "ViolinStaccatoB" ], "Vox": [ "WhooMaleVox" ] }
however the keyArray is simply spitting out []
-
Try this
HiseSnippet 924.3ocsV01iSaDDdctXDwsWUQp+.rtOkS55ImVfVUDp2kjKGoPNhvWSqDBg1a8Dx1Xuq050G3Cw+Y9GPm0qSbB0ffH07oLOyK9YFO6y5oJICxxjJhSmKKRAhy25FVHzKFrfxEjwCINem6DZlFT9Vn9EozrLHh33r24F.mNsIk+d+u2mFSELnFhPlI4L3I7DttFc5IOlGGOhFAWxS1H56dxXlTLPFKyQ9rma.IkxVReEbA0DVKWhysNKhqkpPMUCYXL8kQEgKjuVXieFOieULXL5QBwBYgICVviiltpWyHDm1Sq678rc9O3NgGwWiWOA99RG90Yr4Lvo01Tp8VTp2mhRijwQlB7InmyFzqskd2wMjo3o5ZOFt8MtiE3Km4TbruIsrwRZcxdtCjXDB8wIzkvHEZrNit2OH3H+6EDb3C12aeOb3mo8ulp7kW8O9Oz+sd99GzWg07fey+4nAZNRAYKdjTIv9kwnZ4AH9KNxD444bMUUG5oLYdllyFPSRmyUPcjOFJ1njCAHcT9M2LieEbvQVL7InjpobpPZbUmZITctCvcknh+fdyMSQ3pjO2LaE1HqfdFxjBKx5REpUbwq1fH3a7jq.0kJHAhWmZE5LtLliEEISSNBS4lwAuQmlJh6.q7gaSSfHytfkBqwkWyAKT4zcEtIRagdBrN3Z9zaan0uXZDsec+OS9l5d+uVHkSnwfAzDg269nUhkPwoJEs.2Kd9Kdfm2bop6RetvrqbXYMVEwwo4YK5tzrSYf22CW.yjwvwoXmo6pUlMuUAenc0yadtfo4RrbhKjZ3ohtG58VuNduyy+icMedi9Lq4JYbLnZzsQpQ84RrqH27F6Hraiyg0Ahm+19.9s9xNfyrm51HPoXrfqeZJTYWKAzqAI.R0wV7e+43gTM0nJTggwkBJM2PGmgv0nDqUini6PHaoVlhhr+GADTFSFkGiKAaosYDwqbfyisDQLBEhLttXSQ9uBAufFE7Zra+Bo6cbmx0rEMy2VMvWbp8+Meqt9Xe2ylOGX5Zx11czeuq2U7UPkmIy0njwDJpb7Fhi6E4Ig3MnL.YhP.w3Cx0okYixZGXrMSlPPDUZ7A7WkydFamJm8V4jjPYJ4KY1SJlKntcIBxIQ4cycvOR.s86QJO8f44Fbb.IAu27kLlYT7iH2aNmeZGx4m2gbt6Njy81gbt+NjyurC47qe1bLexxo4ZYh8XBBL8rRYDGmyDTbKqbij7ufXii6F
-
Oh, there's your problem
const var obj = {}; // some object const var keyArray = []; for(k in obj) keyArray.push(k);
You are declaring an empty object which you are using in the for loop. So the output will be empty.
-
@d-healey im assuming its supposed to be pulling from the sorted object. so do i replace the word object with sorted?
-
Yeah, if that's what you want it to do. And you can delete the other keyarray stuff.
-
ok now the keyArray has the categories. but when i changed the line:
Viewport2.set("items", list.join("\n"));
to
Viewport2.set("items", keyArray.join("\n"));
it says
Line 10, column 37: Unknown function 'join'like usual
-
@mwplugs What does keyArray contain?
-
@d-healey ```
[
"Brass",
"Guitar",
"Keys",
"Piano",
"Strings",
"Vox"
] -
@mwplugs as desired it shows the categories
-
But what does it contain at the point you are calling the
join
function. -
@d-healey im simply trying to get the viewport to use the keyArray list.
the only implementation ive seen that works to use lists is
Viewport1.set("useList", true);
Viewport1.set("items", list.join("\n")); -
without join it displays all on one line/selection basically as one long word
-
The program runs from top to bottom, so if you do something with
keyArray
near the top of your script, beforekeyArray
is populated, you won't get any useful results. You need to make sure things happen in the correct order. -
@d-healey there we go! ok so i got the left to populate with categories by rearranging.
now how do i get the samplemaps on the right to correspond to the category selected on the left?
-
im guessing i will have to have another list being made based on the selection somehow
-
Content.makeFrontInterface(1024, 768); const var Voice1 = Synth.getSampler("Voice1"); const var list = Voice1.getSampleMapList(); inline function createTwoLevelHierarchy() { local allList = Voice1.getSampleMapList(); local obj = {}; for(id in allList) { local tokens = id.split("/"); local key = tokens[0]; local value = tokens[1]; if(obj[key]) obj[key].push(value); else obj[key] = [value]; } return obj; } const var sorted = createTwoLevelHierarchy(); const var keyArray = []; for(k in sorted) keyArray.push(k); Console.print(trace(keyArray)); const var Viewport1 = Content.getComponent("Viewport1"); Viewport1.set("useList", true); Viewport1.set("items", list.join("\n")); const var Viewport2 = Content.getComponent("Viewport2"); Viewport2.set("useList", true); Viewport2.set("items", keyArray.join("\n")); inline function loadSampleFromViewport(component, value) { Voice1.loadSampleMap(list[value]); } Viewport1.setControlCallback(loadSampleFromViewport);
-
You'll probably want something like Lindon made - https://forum.hise.audio/topic/1404/help-with-custom-user-preset-example/9
-
@d-healey yes ive checked that out. difference is he is manually creating the array for the categories. i just need to pull from the sorted object the same as we pulled categories and made them into keyArray, but instead make them list the samplemaps per category selected. there will ultimately be nearly 1000 samplemaps so doing them manually seems like a bad idea. if we are able to pull the categories from the sorted object then why not the samplemaps based on category? seems like what should be done opposed to manually creating arrays for each
-
@mwplugs Just run the object through a loop and pull out the data, same as keyArray but for the value instead of the keys.
-
im assuming the k here
for(k in sorted)
keyArray.push(k);is reffering to key
so changing it to v pull the values?