Using play_note in a way that gets picked up by record
Hi all,
I'm updating a couple of instruments of mine with a feature to add some noise back into the sound. For this I created a slider that controls the volume of the noise group, and I also wanted the slider alone to trigger the sound instead of also having a button.
This is what I came up with, which works perfectly well 'in practice':
on ui_control ($noise_slider)
set_engine_par($ENGINE_PAR_VOLUME, $noise_slider, 69, -1, -1)
if ($noise_slider = 1)
play_note(120,127,0,0)
end if
end on
However, by bouncing anything that has been recorded with the noise active, the noise won't be present in the recording.
My thinking is that there could be a way of play_note actually 'printing' a constant midi note, but I am unsure if that is even a thing.
How would I get around this and have the noise sound be present when bouncing?
Thank you very much for any insight.
Comments
-
Hey there! While there are a few ways to achieve what you're looking for, I'd suggest going with the simplest one.
When bouncing recordings, the noise sample won't be audible if the noise slider isn't set to 1 (I'd change it to
noise_slider # 0
). To avoid delving into other solutions involving some advanced KSP, you could map it to a note that's outside the instrument's range, like C-1. Then, whenever the C-1 note is played, the noise sample will be triggered. You can also use a customevent_id
to trigger that specific sample infinitely. Check this out:on init declare noise_id declare const NOISE_NOTE:= 12 {C-1} end on on note if EVENT_NOTE = NOISE_NOTE
noise_id:= play_note(NOISE_NOTE, EVENT_VELOCITY, 0, 0) set_event_par_arr(noise_id, EVENT_PAR_ALLOW_GROUP, 0, -1) set_event_par_arr(noise_id, EVENT_PAR_ALLOW_GROUP, 1, 69) end if end on0 -
Hello! Thanks for your input.
Changing $noise_slider = 1 to $noise_slider # 0 still retains the same result upon stopping audio, with an added issue that made me opt for $noise_slider = 1 in the first place. That is, whenever you interact with the slider it keeps restarting the sample (which I have limited to 1 voice per group in any case), causing a nasty robotic sound.
I gave your code a go, but the effect was the same and it would only work with my previously described section of code.
As for your suggestion to map the sound to a note outside of the instrument's range, 120 is C8, so it falls outside of the instrument's range already, which is a piano :)
The way I'm triggering pedal sounds is directly through CC64:
on init
declare $new_id
end on
on controller
if ($CC_NUM = 64)
if (%CC[64] = 127)
$new_id := play_note(0,100,0,0)
else
play_note(1,100,0,0)
end if
end if
end on(my code tag isn't working, somehow. apologies)
This ends up working because CC64 gets recorded via midi. I wonder if linking an unused CC to the noise sound would work. But then the issue of it getting re-triggered constantly on every slider movement comes back.
So I guess the question there becomes how to only trigger a sample once and keep it triggered, allowing the slider room to then only control the group's volume.
Thanks again for your suggestions!
0 -
Having the sustain involved could complicate things further. In my scenario, the noise_slider callback should be removed, and only the code I sent you should be placed in the relevant callbacks. However, since the sustain pedal will silence all active voices, you'll need additional code to protect that noise sample. This means you should write your own sustain pedal script within your main code.
Regarding the bounced audio being captured within a DAW, wouldn't it be simpler to just add the noise sample in another audio track?
If you prefer not to delve deeply into KSP for the noise sample, and considering it's not a major functionality of the instrument based on your initial post, wouldn't it be better to add that noise sample to a separate Kontakt instrument? You could then load both instruments (main and noise) within a single Kontakt instance. The secondary .nki could include a line that disregards the default sustain pedal behavior and simply ignores any sustain engagement, meaning that your noise sample imported to that secondary .nki will play infinitely.
on init set_condition(NO_SYS_SCRIPT_PEDAL) end on
0 -
Apologies for the confusion, the pedal was just an example of another "key" in the instrument that is being triggered elsewhere. I've no intentions of mixing CC64 with this feature. And it's been a highly requested feature for these pianos (WP and WGP), which is why I'm attempting to check its feasibility.
Also, with the way the script is set up at this stage, any usage of CC64 doesn't cut out the sample. So really the only thing missing is for the note to be printed as if someone was holding C8 all the time, or I don't know what else 😅
What are the other more KSP-intensive methods that you think of?
0 -
Firstly, you'll need to declare a custom event for your noise sample, such as
noise_id
. Then, create a function to trigger that noise sample or group whenever thenoise_slider
is greater than 1. However, you may notice that this could trigger more than one voice whenever the noise slider is nudged. However, you mentioned that you're limiting the played voices using the group settings.Alternatively, you may need to script a sort of protection measure to
fade_out
the event and trigger it again. To trigger it again, you might need a flag indicating whether the noise sample should be played or not. Hope that helps you out! :)0 -
Forgot to mention that having your noise sample looped is a must. Don't forget to include that function inside the persistence_changed callback.
0 -
Thanks very much! I'll look into that.
Just a broad question to finish before diving in, can Kontakt actually create new midi information? Meaning, in real time, outside of using the midi object.
Thanks again for your time and input!
0 -
Yes, it's possible. For example, you'd use an arpeggiator to produce notes, which can then be exported as a MIDI file. Additionally, you have the option to record a performance, capturing both note and release events. After gathering all this data into an array, you can export it as MIDI. However, delving into MIDI manipulation is quite advanced. Check KSP manual → MIDI Object Commands
0
Categories
- All Categories
- 19 Welcome
- 1.5K Hangout
- 62 NI News
- 785 Tech Talks
- 4.1K Native Access
- 16.5K Komplete
- 2K Komplete General
- 4.3K Komplete Kontrol
- 5.7K Kontakt
- 1.6K Reaktor
- 378 Battery 4
- 845 Guitar Rig & FX
- 429 Massive X & Synths
- 1.3K Other Software & Hardware
- 5.8K Maschine
- 7.3K Traktor
- 7.3K Traktor Software & Hardware
- Check out everything you can do
- Create an account
- See member benefits
- Answer questions
- Ask the community
- See product news
- Connect with creators