LFO Waveform index problem

Post topics about HALion scripting.
Post Reply
User avatar
abject39
Member
Posts: 264
Joined: Sat Jan 17, 2015 8:20 pm
Location: Ventura, Ca
Contact:

LFO Waveform index problem

Post by abject39 » Mon Jan 15, 2018 3:56 am

Using the filtertype code in some of the built-in Halion libraries I created the following code to create new index names for a monophonic LFO waveforms.

Code: Select all

--Capitalize all LFO waveform parameters
MidiModule1=this.parent:getMidiModule("LFO 1")
LFO1Waveforms={
  {name="SINE",   index=0},
  {name="TRIANGLE",   index=1},
  {name="SAW",   index=2},
  {name="PULSE",   index=3},
  {name="RAMP",   index=4},
  {name="LOGARITHMIC ",   index=5},
  {name="SAMPLE & HOLD 1",   index=6},
  {name="SAMPLE & HOLD 2",   index=7},
}
 
function getLFO1WaveformNames()
  LFO1WaveformNames={}
  for i=1,#LFO1Waveforms do
    LFO1WaveformNames[i]=LFO1Waveforms[i].name
  end
end

getLFO1WaveformNames()

last = {}

function LFO1WaveformChanged()
  MidiModule1:setParameter(1,LFO1Waveforms[LFO1Waveform].index)
end

defineParameter("LFO1Waveforms",nil,1,LFO1WaveformNames,LFO1WaveformChanged)
The code isn't working. I'm getting a "Parameter change callback LFO1Waveforms = TRIANGLE: 512: attempt to index global 'LFO1Waveforms' (a number value): this.parent:getMidiModule("LFO 1"):setParameter(1,LFO1Waveforms[LFO1Waveform].index)" error but I'm not sure why. Anyone know what's wrong here?
My vision is uncompromising: to transcend my clients dreams by mesmerizing their audience with the world's finest audio arrangements and products.

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

Re: LFO Waveform index problem

Post by misohoza » Mon Jan 15, 2018 11:11 pm

Hi abject39,

There are two issues here.

You are using the same name for your parameter and also the table containing the values (LFO1Waveforms).
That's giving you the error message.

The second issue is just an oversight. In your function you are missing letter "s" ([LFO1Waveform]). Your parameter is called LFO1Waveforms. When the function is called it will be looking for the value of "LFO1Waveform" which will be nil because you didn't define such parameter or variable and give you another error message.

Once you fix those two things your script should work fine.

Code: Select all

--Capitalize all LFO waveform parameters
MidiModule1=this.parent:getMidiModule("LFO 1")
lfo1Waveforms={
  {name="SINE",   index=0},
  {name="TRIANGLE",   index=1},
  {name="SAW",   index=2},
  {name="PULSE",   index=3},
  {name="RAMP",   index=4},
  {name="LOGARITHMIC ",   index=5},
  {name="SAMPLE & HOLD 1",   index=6},
  {name="SAMPLE & HOLD 2",   index=7},
}
 
function getLFO1WaveformNames()
  LFO1WaveformNames={}
  for i=1,#lfo1Waveforms do
    LFO1WaveformNames[i]=lfo1Waveforms[i].name
  end
end

getLFO1WaveformNames()

last = {}

function LFO1WaveformChanged()
  MidiModule1:setParameter(1,lfo1Waveforms[LFO1Waveforms].index)
end

defineParameter("LFO1Waveforms",nil,1,LFO1WaveformNames,LFO1WaveformChanged)
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

User avatar
abject39
Member
Posts: 264
Joined: Sat Jan 17, 2015 8:20 pm
Location: Ventura, Ca
Contact:

Re: LFO Waveform index problem

Post by abject39 » Tue Jan 16, 2018 6:08 am

misohoza wrote:
Mon Jan 15, 2018 11:11 pm
Hi abject39,

There are two issues here.

You are using the same name for your parameter and also the table containing the values (LFO1Waveforms).
That's giving you the error message.

The second issue is just an oversight. In your function you are missing letter "s" ([LFO1Waveform]). Your parameter is called LFO1Waveforms. When the function is called it will be looking for the value of "LFO1Waveform" which will be nil because you didn't define such parameter or variable and give you another error message.

Once you fix those two things your script should work fine.

Code: Select all

--Capitalize all LFO waveform parameters
MidiModule1=this.parent:getMidiModule("LFO 1")
lfo1Waveforms={
  {name="SINE",   index=0},
  {name="TRIANGLE",   index=1},
  {name="SAW",   index=2},
  {name="PULSE",   index=3},
  {name="RAMP",   index=4},
  {name="LOGARITHMIC ",   index=5},
  {name="SAMPLE & HOLD 1",   index=6},
  {name="SAMPLE & HOLD 2",   index=7},
}
 
function getLFO1WaveformNames()
  LFO1WaveformNames={}
  for i=1,#lfo1Waveforms do
    LFO1WaveformNames[i]=lfo1Waveforms[i].name
  end
end

getLFO1WaveformNames()

last = {}

function LFO1WaveformChanged()
  MidiModule1:setParameter(1,lfo1Waveforms[LFO1Waveforms].index)
end

defineParameter("LFO1Waveforms",nil,1,LFO1WaveformNames,LFO1WaveformChanged)
Oh man! How did I miss that lol. The parameter wasn't supposed to have the S there on the end. I removed it and it all worked!
My vision is uncompromising: to transcend my clients dreams by mesmerizing their audience with the world's finest audio arrangements and products.

Post Reply

Return to “Halion Scripting”

Who is online

Users browsing this forum: No registered users and 1 guest