Make the Gain knob smooth the gain?
-
hey guys, i want to make the value of this knob smoothly gain from -100 to 0 (-100, -99, -98...-2,-1,0) instead of going directly from -100 to 0, how should i do it?
-
@CatABC What you're asking for is the default behaviour. How are you trying to control it?
-
@d-healey
I use code control. When the keyswitch is triggered, I need to slowly decay the volume of Sampler1 to -100 and slowly increase the volume of Sampler2 to 0.function onNoteOn() { for (i = 0; i < 4; i++) { ksGain[i].setAttribute(ksGain[i].Gain, -100); } ksGain[0].setAttribute(ksGain[0].Gain, 0); }
-
@d-healey Or is there any other way to Xfade?
-
@CatABC Ah I see. I think there is a better way to do this. Fade out the individual notes instead using
Synth.addVolumeFade();
-
@d-healey Emmm, forgive my stupidity, I don't know how to use it. Should it be in the ScriptProcessor of Sampler1 or in the ScriptProcessor of Sampler2? How can it fade out the samples of Sampler1?
-
@CatABC It depends on exactly what you want to do, but it should probably go outside of both the samplers.
In the
on note on
callback you need to store the ID of each note in a midi list.Then when you want to fade out a particular note you can retrieve the ID and add the volume fade.
If you only need to handle one note at a time (monophonic) then you can probably skip the MIDI list and just use a reg variable.
-
@d-healey
Thanks David, I tried a lot and I'm now clueless again,
I think my logic is very confusing now. I hope to complete the KeySwitch switching on an uninterrupted note. When the new KeySwitch enters, fade out the sample of the previous Sampler and fade in the sample of the new Sampler. I hope that the faded-in sample is played from the beginning.
so I made a snippet, could you help me with this?
HiseSnippet 2326.3oc6aszaajbDdFJM1lzO1GYQPPNDzQHGnhYnHodGkEVun7JXIKESY4cgwhMiloIYCMr6IyzTxDF5XNji4ePtkqAA4PNt+.BxOh7Kv2xgbvopoGNOjHoFQ30aVYQXQntptq9qqt5p+pVv66Irn99BOM8BGzykpoeOiF83x1az1jw01dSM86Z7DZuFmxjVs0VumqouO0VSWehGicPO+jZAedyiV2zwjaQiEoocnfYQ2g0gIikt+pOg43rkoM8.VmD8dtU21Rv2P3H5BfYBiJZtlVGa1h9TSra4Lz9BS+1Z5+Ri4qMq0b1KZWq17Kufk4BzkaZ1rY0YsmatE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QkbZrpt68GWrIxFghK4UVy2GiMXcbcn04m.oP.IHF+TivRp5KMcltcEbgaaAmYkLQ5ynROVqVTujXefKn0jRnlrXIe1pOiBY9RxW3Wr5NPxRSucC31OV9hpY2WLp8qehgBtjf2K65AG5I9vjC8yDcwGTYWSHPEJAy.xL1.ntZQCKyFyunmCyDnZWAaq3txsCZfu+QnxpXa8PkU6qbb4oWaX7z+c+1m+29PgmNbjYhwJc+P4oeIjhuVwYu1O.3r+lG88Mm8ZCjy9+MmA4JRZmbAV6C4O1wkxWOegQwWejz0ggdUIqmUt5CjpdFYpmBVijj9kyQeroneEXnGSPOev2i3u1x6UZ12vw9CHN10tgi8Mbrugi8Uii8cTK2aa7TAyu+AqfeOCuAN4k+i+56dt0uq4vt2ITuSXzS+PhK6r2vkMCbYmcfbYm3cv6OO9u870Npr3aNeckMaFe13qLi1a3zdCm1.oydCm1qSbZycCm1uq3z99XN5XZ4I9FKUlSLV9NARf0MO3+sB4M1EaSpdQVJc.9BeikUZScgAVabG3ri6.mabG37i6.WXbG3hi6.W5xGHRmastRQG0QVMsc2udvUQ5504HWofSGZ+OhPWPzA
-
@CatABC You don't need to put the midi processors within each sampler. Just use one below the interface script. You don't need a loop in on note on.
Start really simple.
Make a practice project with only one sampler.
Every time you play a note the previous note is turned off.Once you have that working we can start getting more complicated.
-
@d-healey When I only use one Sampler, it can achieve that when the second note appears, the previous note will no longer sound, but when I add a second Sampler, it needs to be triggered at the same time with the KeySwitch below, which makes the script completely illogical and gives me a headache.
-
@CatABC said in Make the Gain knob smooth the gain?:
When I only use one Sampler, it can achieve that when the second note appears, the previous note will no longer sound
Share the snippet you have made for one sampler and we'll go from there.
-
@d-healey
This is my method using only one Sampler, I used artificial notesHiseSnippet 1352.3oc4Ws0aaTDEdVaOHrSnkhpP73REOjhJQdcb7EPQ04hcZTqaCYcaAwCUS1cV6QY8LK6NaRrphTE+R3m.Oxi7Sp+CfyryZ60tNEWqREB1Ghx41b9lybt4iCENznHQHxnTuQATj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4axVX4Zx91mArrv8V3iUiMWLdys.7BUf+Si2zQVeBtsmG7ZOErEvc9g257o26P4FZnrF1lwoICBR.xmmPa9bnRx7PJmFpBpVW2tGl+zu+aK6tGAK8tG5B4dPQWTfHZlC1lNj0CZ6Ekkop7Hj9yI0hY4uOTWrPQu99cfK4BswlHiCSRW1cnHlKmI8H+R+l7NrRSg+cuRS9w4IJO2MFVGIAIqOkd1ri4CR4WtfzaaBoQtz41fp5Qc2HcT2dwRITXqFxcCLqOWDRSYkLYO6iGZINiah8XWZKicNSs+RzBNjOXsJe+73UbLFsYCC7os4mS8gcKRv3mgSmvMl6ruicEbQv.Am4jM.bBUFx52mFlE6K7BsqTBiHmx41sNg5SIYKm+pVOBJCIgpAjqXrv5cd27E9d8EXMbMUslL+uwHt7++bD2IhX0ltcIPhJrnKF1GzFlr3PS25QsVuQNU+.McYEsdzB2Mg3OguTgVJZiTgViE9AwGCINghW3naZoxk+3DNv8lm7axKh6pnMsdytTCgNyuvwY1i5MLrxpZ3VqpgUWUC2dUMr1pZX8U0vF+8FpFbtaL7yNzkrHDrUdxOxwvnMm.Y7IUGn+Bn0aimN
-
@CatABC You can use
Message.getEventId()
to get the event ID if you don't want to make the note artificial.Now modify this script so that when you press a keyswitch key (whichever key you want), while another is held down already, it turns off the note that is held down and plays a new note of the one that was held.
For example, if you're holding down C3 and you play C0, you turn off C3. Then you play a new C3 note. - And you ignore the C0 note.
All of this in a single sampler, for now.
-
@d-healey
When I use Message.getEventId();, and play two different notes, the previous note does not close.And I don't know how to convert the events into notesfunction onNoteOn() { if(eventIds != -1) { Synth.noteOffByEventId(eventIds); } eventIds = Message.makeArtificial(); if (Message.getNoteNumber() == 36) { Message.ignoreEvent(true); Synth.playNote(60, 20); } } function onNoteOff() { if(Message.makeArtificial() == eventIds) { eventIds = -1; } if(Message.makeArtificial() == 0) { Engine.allNotesOff(); } }
-
This returns an event ID that you need to store, so that you can turn the note off when the key is lifted. Otherwise you'll get hanging notes.
Synth.playNote(60, 20);
@CatABC said in Make the Gain knob smooth the gain?:
if(Message.makeArtificial() == eventIds)
Here you should use
Message.getEventId()
instead ofmakeArtificial
@CatABC said in Make the Gain knob smooth the gain?:
if(Message.makeArtificial() == 0)
{
Engine.allNotesOff();
}What's this meant to do?
-
Synth.playNote(60, 20);
The 60 here should be the note that was pressed before,
Synth.playNote("eventIds's note", 20);
I can't stop the artificial notes
function onNoteOn() { if(eventIds != -1) { Synth.noteOffByEventId(eventIds); } eventIds = Message.getEventId(); if (Message.getNoteNumber() == 36) { Message.ignoreEvent(true); Synth.playNote(60, 20); } } function onNoteOff() { if(Message.getEventId() == eventIds || Message.getEventId() == Message.makeArtificial()) { eventIds = -1; } }
In this case, the D3 note cannot be turned off -
@CatABC said in Make the Gain knob smooth the gain?:
Synth.playNote(60, 20);
You need to store the ID of the note in a variable so that you can turn it off later.
@CatABC said in Make the Gain knob smooth the gain?:
Message.makeArtificial()
I think you're misunderstanding the purpose of this function.
-
@CatABC Here's a basic example using a sine-wave generator.
I've put everything in the interface script but in a real project it should be in a separate MIDI processor.
HiseSnippet 1122.3oc2Ws0aZbDEdVr2ntj1nlpnp73Vo9.T4ZAXLwnHqXaLNEUiMx33z2hlL6YgQdYlMyNKsnJ+er+Txq8o1yrKW10F4hQsMpkGPbNy4x245LzSIYPTjTQrJd4jPfX8418mHzCaMjxEjNGSrdhcWZjFTtorNZRHMJB7HVVa7ZCCKmMIIe93qNhFPELXAKB4JImAmxGw0K316fejGDbB0CtjOJiz0OnCSJZICjwHd1vtBIjxtlN.NiZDqfM4GnQCIVem8t01gU26Ed0psayFLZCnoO02u5Nd0q2XulU2oIs9dMfJ6RrdTaOtVp5qoZHBM5QRuI8GJ+YQpCthGwee.XHpR5idNkMo0PdfWuYImHBwxt2hT0FoopmY2k6wmyeQJ6KSNvcgFYSZVEtOHU8A.IqLPZyTH8T69LEOTu3DCddrcGAVA8oXsIKTRkkT32KX2RhRHzaOhdMbhBIlqQoFUprkK9U4WVrHVehztWG4tuas5yogwnpc7LbaKFvEv1LEfQmIKbJORWBUclLa6i09ReeylFyofAtAX20YRM7R+XASykBWovPetnT4h+ZQm.IiF3JPa2EiHraX6APhBmEO58fxXamhNbe2RnL6iXqbQGTsDNycJpxUzfXnzLuU18a120fBTRizNIc8aKLN12+nIsS079rfwwN2TD+ZtPQ2VnsbSsaX.chgNyAYhlq.LH45IkJiF0wwXREniUh4BwGHjJHATkzpXv36aLw8L6goGAx6tHQrvSlZ6gJM2my3zfRoAPwaJ5d6Luu+CM0e2zjHSF1jfW47qnbZvkGWl9SkLHv3UCzt0wlEIK+joJVRj.4sbGabxbAwAm7SiOZ0lFYoiKYDTJ5H35yCgozmHC7LSYlee2YWxz4M7WuoywTM0LNOkGJWHfkICbrNFFiKPSGtcrOFhtVKCwUn2YxG24H8hCn57KhLqnmd.lOxM8alvEQXaW1U3OfsSUt2sSqJDepcOtlMb4XrvRvHlo9m.iS2o+E1s88AldA.2z9jeZcWfu5t+Iot+w18w0mIyJIN+qSnceKcL39ZP.JSxq58bI7uspWBGtxWBeNSit+REUDEJixY39vH9kRgIKrf4ahvaPfObgoZlkeKIUszi93qNACxkpSeJtFLos3vQxXgNWavF4qCatZit4mHxH+RtgcyOAW5+2yX0mvI+buKwYFF6yGEF.sEiw65PNFL9U39LeZbfdF27M1ckBY3PofyxV0u.zJ9fAfJK1WZ.cnViOebAmmcvEP.Py1A+sGbJ14QUXdBVybwC+MZKsd8b6T35ZlFc+u6F6M9+8F6KjwZtXPWJ1D9K3eJ.eHTebQICPuKDP.ZbaqBlkcozULzoaJEdID+A9Y5gUMzVSOr5rC+WwGinLk7crz2FY5S+rDNXbKR9uVN3e5CocqRRduT1Z4HbK26Xr7l5NJVacUbm0Uw5qqh6ttJ1XcU7Eqqh68Wqn4RnCi0xQoilDR2dsSdfokUaAE6xSlHH+IYKulm
-
@d-healey
I tested your snippet, but in this case the second C0 triggers the playing of C2 again, is it possible to not trigger the playing note when there is no note above? -
@CatABC said in Make the Gain knob smooth the gain?:
is it possible to not trigger the playing note when there is no note above?
Yes, this was just an example to get you started.
Synth.isKeyDown()
might help here.