Change Sample map via Prev-Next Button
-
@ulrik Yeahhhhh... Superb Thank you so very much :)
Working perfectly. -
@iamlamprey Awesome. Thank you :)
-
@MikeB I'm not familiar with the Audio Loop Player, what are you trying to do?
-
@MikeB do you have a snippet so we can see what you mean?
-
It works exactly once - then it doesn't work anymore?!??
HiseSnippet 1459.3oc4W8taaaCDmJNJs1adXcqeXeZPvaevFs0wt+c.aEyMINEYMowHNMXXEEALRz1DUhTfhNodEAXOB6QXOB6QXOB6QXOB8MX6HkjEUhhimGRwvlMBbNd7t6G+cj7N1SvcIQQbAxp79SBIHqOzt+Dlbz5ivTFZqMPVegc2mtqycb5IHQD4ZB9IQDgy1bdXOe7Dh3vV2Es1jPbTDwCYYU5oJCsJuLR+4ce6ZXeLykjMDBc.m5R1lFPkYi1qyyn99ah8H6SCLl886rkKmsN2mOF.YI6VnPr6qwCIOGql1R1HqU55QkbQeIVRhPVKuF2aR+Q7SXwy+.ZD8HehRnMpO3n3g2j66oPrZTz5in9d8RIiHDxxtWF0TJlZto8NTO5zwynnOVqvIyBS9vZoYAu1lvq07COKC3sbL7tgceWAMTloQgsOvdKljHFfgTfIrhmKZoGsh85bXFLYy.7qIaJ.goVT+gsZcamGzpUiutZE0WHUDIcNFKbdxXOJOaWPamG6n23zbHQpgqVpdM87zaWbRlYMky5xFRYjl9brmdFaR8IQPb483b+5wgKKX6gYd7.HDoPUEDdPHmAB0qEqV62LadFieT6KzDs1yXwyIuQdgFnTdl4CmHN9BmuRYsySaT0+7XmWVKBGD5SZ0t4I3iqc6Tw6lW7d4EuedwGjW7gZwWkDxpUVc0XJnuVc0JTlOP4NCFybkTNygyz5UvW.btaJ1uM.T+wjFUq71pUbfOSyq5LUr6ltIq3LbS3pBUJsds21auc+ttqu+gat61azcuSqcKEE7RcHdkheTQPCjltivrgDOc1+T3uYl4TQHA5qi88OBtTnd9UTJ4u5pI6epVI92hMMV2g4L97TV9YUHooVPwKK5.m5oCqjS3yrUL.jCT5qWeGLPwBv4vYf5pybMZjRNESPpQOMlmltLU64JBzpwu7zbAnsbAPMVbXpXCm6zVgmxWJLm04jhSIF3tg45TcVrn0oZ7qt04s9GsNiu+n30oAtyVmweMWcbIYWV8FUdakxUNshyYUMXPg5RbrOQTnZU0VwrLrNabvQDQJMlNQnrS95Z1WbcMyxttwriwD4rsXT4tgD1EUsCkPoPcukSPELUotp2GkT0quO0iHPTn310r04GjFvPmDqrRZiGWjwqMVJ4LswqXqxFSscZOKymspcrKlsW2N9pkBr9EasAVhUE8S3AfaBIBIUQ6VaPNF5lJtEfx1aPhdsjGpIpj8d.ttTp5MSC3OsamISE5bPm.blNzM6DIIg8o+HwrCOjQnruLhMya+guQj94vNznc3AfSvBXXqklWupobC7+BCu9qyzqW6xSFY9829AC+9NQmSndxQSG3WB5LhPGNxng1u4bg97srAMNx8F6ik46lT0BchB3nXt11TslwhnxIlIfqjVLmW3dC6dTo6nhw6REfWXi7UMdSZXupc2ACHtxLvtr8le+Ue24lP4SSgxzFlIwMleS6y23zLdH0uOuOjJbteHEzWmKj1xcVVmK2W.0knrglgRAytLLvEdlCuGmKUUeLeHWbGh.iJjf6yMaxwDQTdOnZSL9sbet8YaVzryVTfhNrsT1nuTx1x9kVHe.W5PkpyWCTuTQqRycBt3WG1pnmes7+pec36uaZJMev8Rd.a4TL1mpx2cYGS7gyIZL9IPIsA3w9xzQyeHYGNiGNhynt42mIEzgCIBSrW3B5IRIrW2rB2dDeBNxXC8W1YanOSr3rGU9avEsmetXV4qOyNFtNpS1N+2nBQo+eVgXO9XIbCK7rOAUcW1yGGzGtX1k.HgwH9pFpgVFTlpkakdeVeBySK7mvmDksUxVIJamp78RLBvtB9gtw82p1Kec8Hv5louSur8NJYmociaa2pYK3tbO5gttJ59NsQnhs4tKfM2aAr49KfMOXAr4gKfMOZAr4qloMphQOYrjGDeTDFnWW86KrrlVe2pD5u.qro+EC
-
@MikeB I can't open the snippet, Hise just compile and compile and I have to force quit Hise
-
-
@MikeB Try this:
Content.makeFrontInterface(600, 500); const var AudioLoopPlayer1 = Synth.getChildSynth("Audio Loop Player1"); Engine.loadAudioFilesIntoPool(); const var Random = Content.getComponent("Random"); const var Knob1 = Content.getComponent("Knob1"); const var Next = Content.getComponent("Next"); const var Prev = Content.getComponent("Prev"); const var inst = ["sample01.wav","sample02.wav","sample03.wav","sample04.wav","sample05.wav","sample06.wav"]; //Knob1 Sample inline function onKnob1Control(component, value) { Synth.getAudioSampleProcessor("Audio Loop Player1").setFile("{PROJECT_FOLDER}"+inst[value]); }; Content.getComponent("Knob1").setControlCallback(onKnob1Control); // Random Random.setControlCallback(onRandom_Control); inline function onRandom_Control(component, value) { if (value) { Knob1.setValue((Math.randInt(0, 5))); Knob1.changed(); } }; // Prev inline function onPrevControl(component, value) { if (value) { Knob1.getValue() > Knob1.get("min") ? Knob1.setValue(Knob1.getValue() - 1) : Knob1.setValue(Knob1.get("max")); Knob1.changed(); } }; Content.getComponent("Prev").setControlCallback(onPrevControl); // Next inline function onNextControl(component, value) { if (value) { Knob1.getValue() < Knob1.get("max") ? Knob1.setValue(Knob1.getValue() + 1) : Knob1.setValue(Knob1.get("min")); Knob1.changed(); } }; Content.getComponent("Next").setControlCallback(onNextControl);
-
Sidenote friends, I use Console.print(whateveri'mtryingtofigureouthere) religiously when something isn't working. I also try and approach it from a logic/pseudocode perspective, an example would be:
-
What is button "Next" supposed to do?
A. Increment another control. SoSlider.setValue(Slider.getValue + 1)
. -
Why isn't the "target" control updating?
A. Because we needControl.changed()
-
Why is the button sticking?
A. Because it's notMomentary
. -
Why is it calling the function twice?
A. Because we need to add a check to ONLY call it when it is ON (value of 1). -
Now it works but the slider is going to infinite/negative infinite!
A. Now we add a check, if the slider is already its MAX value, we set it to its MIN value, or vice-versa for prev buttons. This done with an
if statement
.
Incremental/iterative logic helps me arrive at a working solution, after that it's just optimizing the code for performance/readability.
Hopefully this helps someone :)
-
-
Great thank you very much.
I have found the error.
The slider was not from 0-5 but from 1-6 so HISE crashed every time.
Probably because there is no "sample07".And here is the finished snippet - Prev/Next/Random load sample in AudioLoopPlayer
I make a copy in the category Snippets
HiseSnippet 1533.3oc4XstaaaCEVJNJq1qYncq+X+jvXCPFsNwt21v15pyEmgrF2XDmVTfhhLFIZahJQJPQmVut.rGk9nr2f8JrGg8FrwKRVRtxWpWcxvl.BPN7vCOe9b9Nj7v1LpCJLjxLLKd7v.jg4Us5Ljv6uSeHlXr+tFleoUsaW8wnWyq1lgNq5QPhK0Gr0.WL8.JMnsGbHhYr8v.XXHx0vzrvOHM0r3pFpu+7gaC8fDGTxPFFOkhcPGf8w7jQa23QXOu8ftniw9ol8caruCkrC0iNP.yBV0LBfNuD1C8XnbZqXYXtVSWLmx5vgbTng4paScG1oO8UD87eJNDepGRJT2niXgzCuG0yUhX4nF6zG641NNbDZXXZ0NI3TPGbtgUKrKdz3IAoqoT.RrHc7vbkoAu5ogWs4Gdlof2pZ3ccqNNLb.OQiDaer09DNh0EJRAogkdtFq7KW0ZGpXFD9F9vWh1iIDFYg88qU6Vf6UqVkuc8RqWZyMAGPgt5zeWrGJDfIbJHfR8.UWpeqWpIoGlf1vS..k+2S5eARosEd2VBvM2r5EzmLXDEPDjyPN3LHKbY6xQdZ7xu5fG.TksazCwUTEkjcY07.xIBhlYYYbJYghJme.HlBHW.pe.kHDrKqUOlMOhPOs9DMQocLKjaeLQCjJGa9xcZl37kJKewmsEY5sXL3PPGnefl3CRngUUUqrO7YZr7ed.34kCUtsV8MdE7rx2JV71YEuSVw6lU7dYEuuR7EWR0MZVjNXBBQdHGNlRVBNDS7Daa.5Nfn7.fRTtVRtXh8MbhYV2RDu8Ffprdo2rdIf3aTEkJMqQ5nsVyu1ZiPDWxGrK+l1Gc3O1bmiOYuCOX2lGcd4aJyjOW4hWHYumK9apUPx0JBj6.87NUbnmcVreoTDDsiw1C37kP5Jk2zNJ+nfV2IohC4kmyNqbyzx7rNai6BriGVJGQBjepXtDHOUp21tETvKXhEWb3is73wJUjPH6zc5CI8Pt1wZNWmxuTNhRcyskcFaR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