2 Questions: calcModulation and Osc sync / Boolean in onNote

Post topics about HALion scripting.
Post Reply
AposMus
Junior Member
Posts: 180
Joined: Fri Nov 14, 2014 11:41 am
Contact:

2 Questions: calcModulation and Osc sync / Boolean in onNote

Post by AposMus » Mon Jun 12, 2017 7:11 pm

Question 1:

I often use short decay pitch or filter envelope drops to add some bite to a synth sound's attack. To spare the internal zone envelopes for other uses, I made a simple modulation parameter to do the job. There is a problem though.

When playing lower notes, there are noticeable variations in the attack character of successive notes, especially sounds with a longer release. It sounds like the oscillator phase and rapid envelope decay are out of sync (with fixed phase osc). The modulation param also doesn't take "Key On Del" into account. I'm guessing this has something to do with the execution order of the program tree.

The same thing happens with the standard Env Midi Module.

I've tried various ways of delaying the mod param to sync with onNote, but nothing worked. Any ideas?

Code: Select all

defineModulation("Quick Decay", false)

modVal = 1
durationMS = 15

function calcModulation()
	if retrigger then
		modVal = 1
		retrigger = false
	end
	rate = getSamplingRate() / 32
	rateVal = 1 / (rate * (durationMS / 1000))
	if modVal <= 0 then
		modVal = 0
	else
		modVal = modVal - rateVal
	end	
	return modVal
end

function onNote(event)
	retrigger = true
	postEvent(event)
end

function onRelease(event)
	postEvent(event)
end
Question 2:

I have a boolean parameter tied to a UI switch with no callback function. It's only there to retrieve the state of the switch.

As soon as you use the boolean parameter in the onNote function, it changes the values to 0 and 1 instead of false and true. This messes with the shorthand "if boolParam then" syntax, as both become true. Even when the "if statement" is inside an external function and called from onNote, this still happens.

I know this runs in different threads in the Halion engine, but as parameters are variables, this is kind of strange.

Any help with these 2 questions would be much appreciated.
Cubase Pro 8.5.2
Halion 6
HSO
Padshop Pro
Dark Planet
Windows 7 64bit, AMD Phenom IIx6 1055t, 8GB Ram, Gigabyte GA-880G-UD3H F2, Nvidia GeForce GTS450
https://dewetvanderspuy.co.za/

misohoza
Member
Posts: 834
Joined: Sun Oct 05, 2014 12:18 am
Contact:

Re: 2 Questions: calcModulation and Osc sync / Boolean in on

Post by misohoza » Mon Jun 12, 2017 7:39 pm

Hi AposMus.

Regarding your second question, can you use an integer parameter instead?
Or maybe an indexed string array with two entries, on and off.

I had similar problems problem with boolean parameters and if statements. In the end I went with the integer option.


Edit: Actually I think it works if you assign the value of the Boolean parameter to a local variable first.
Something like:

Code: Select all

defineParameter("Play",nil,true)

function onNote(event)
  local p=this:getParameter("Play")
  if p then postEvent(event) end
end

Win 10 Home, 64 bit, 8 gb ram,
Cubase Pro 9, Wavelab Pro 9, Halion 6, Dorico,
NI Komplete 10 Ultimate, Ozone 7,
UR 44

misohoza
Member
Posts: 834
Joined: Sun Oct 05, 2014 12:18 am
Contact:

Re: 2 Questions: calcModulation and Osc sync / Boolean in on

Post by misohoza » Tue Jun 13, 2017 6:22 pm

When playing lower notes, there are noticeable variations in the attack character of successive notes, especially sounds with a longer release. It sounds like the oscillator phase and rapid envelope decay are out of sync (with fixed phase osc). The modulation param also doesn't take "Key On Del" into account. I'm guessing this has something to do with the execution order of the program tree.

The same thing happens with the standard Env Midi Module.

I've tried various ways of delaying the mod param to sync with onNote, but nothing worked. Any ideas?
Having a go at your first question I came up with this. Each note on event should trigger the modulation and also take the Key on delay into account as long as it's set to ms. Don't know if that helps.

Code: Select all

defineModulation("Quick Decay", false)

modVal = 1
durationMS = 15
zone=this.parent:getZone()

function calcModulation()
  rate=getSamplingRate()/32
  rateVal=1/(rate*(durationMS/1000))
  modVal=modVal-rateVal
  if modVal<0 then
    modVal=0
  end
  return modVal
end

function onNote(event)
  postEvent(event)
 wait(zone:getParameter("VoiceControl.KeyOnDelay"))
  modVal=1
end
Win 10 Home, 64 bit, 8 gb ram,
Cubase Pro 9, Wavelab Pro 9, Halion 6, Dorico,
NI Komplete 10 Ultimate, Ozone 7,
UR 44

AposMus
Junior Member
Posts: 180
Joined: Fri Nov 14, 2014 11:41 am
Contact:

Re: 2 Questions: calcModulation and Osc sync / Boolean in on

Post by AposMus » Wed Jun 14, 2017 12:03 pm

Thanks misohoza

With Q1 I did end up using and integer switch, I'm just curious though how a boolean can change to an integer mid script. Also I like a certain conformity in the script, so having to change it for one parameter kind of bugs me.

As for Q2, that is something I already tried, but it doesn't really work. Delaying the note doesn't get rid of the attack phase issues, but I'm working on another idea, so might post it when I'm done.
Cubase Pro 8.5.2
Halion 6
HSO
Padshop Pro
Dark Planet
Windows 7 64bit, AMD Phenom IIx6 1055t, 8GB Ram, Gigabyte GA-880G-UD3H F2, Nvidia GeForce GTS450
https://dewetvanderspuy.co.za/

Matthias Klag
Steinberg Employee
Posts: 32
Joined: Sat Feb 23, 2013 9:33 am

Re: 2 Questions: calcModulation and Osc sync / Boolean in on

Post by Matthias Klag » Tue Jun 20, 2017 3:35 pm

Hi ApoMus,

regarding the "QuickDecay" and calcModulation, I think, you must use note expression, instead.

In general, the modulations from MIDI modules are monophonic. That is, the same modulation value goes to all voices that are still being processed.

If you use changeNoteExpression, you should be able to send the "QuickDecay" with every note and do this polyphonically.

Cheers,

Matthias
Matthias Klag - HALion Developer
Steinberg Media Technologies GmbH
Hamburg, Germany
Checkout Steinberg on YouTube, Twitter and Facebook!

Matthias Klag
Steinberg Employee
Posts: 32
Joined: Sat Feb 23, 2013 9:33 am

Re: 2 Questions: calcModulation and Osc sync / Boolean in on

Post by Matthias Klag » Tue Jun 20, 2017 4:21 pm

Hi AposMus,

regarding the boolean parameter, unfortunately, this is a bug. I created a bug report, so it gets fixed.

Here, is a workaround.

Code: Select all

defineParameter("Play",nil,true)
function onNote(event)
    if Play and Play ~= 0 then
        postEvent(event)
    end
end
The workaround from misohoza is fine, too. Thanks @misohoza for posting this.

After the fix Play will keep its boolean values. The workarounds above should still work after we have fixed this problem.

You should not use this statement:

Code: Select all

    if Play == 1 then
       postEvent(event)
    end
This will not work anymore after our fix.

Sorry, for the inconvenience this might cause.

Best,

Matthias
Matthias Klag - HALion Developer
Steinberg Media Technologies GmbH
Hamburg, Germany
Checkout Steinberg on YouTube, Twitter and Facebook!

AposMus
Junior Member
Posts: 180
Joined: Fri Nov 14, 2014 11:41 am
Contact:

Re: 2 Questions: calcModulation and Osc sync / Boolean in on

Post by AposMus » Wed Jun 21, 2017 1:51 pm

Hi Matthias, good to hear from you.

Thanks for the boolean workaround. I'm glad it's a bug, because I was beginning to doubt my understanding of the scripting language and thought I missed something major in the reference manual.

I eventually defined my switch parameter with integers instead of a boolean, but I'm going change that.

The "QuickDecay" using the changeNoteExpression function is working like a charm. I wouldn't have thought of that. One just has to keep controller smoothing in mind.

Thanks for the feedback.
Cubase Pro 8.5.2
Halion 6
HSO
Padshop Pro
Dark Planet
Windows 7 64bit, AMD Phenom IIx6 1055t, 8GB Ram, Gigabyte GA-880G-UD3H F2, Nvidia GeForce GTS450
https://dewetvanderspuy.co.za/

Post Reply

Return to “Halion Scripting”

Who is online

Users browsing this forum: No registered users and 1 guest