Help needed with js error code

Hey guys, I’m using this script and everything seems fine but after selecting certain tracks I get this error message which requires me to restart OSC. Any help with be appreciated

I'm not sure exactly what is happening but to explain what I'm seeing is... you are getting an undefined property when reading from trackarticulations.

The stack trace is showing it occurs in the oscinFilter, line 62:36.

I guess the incoming name or data from oscFilter isn't being handled to check for undefined. So you could put some error checking in to handle the error. For example inside oscInFilter:

if (trackarticulations === undefined) {
    // then handle the undefined here...
}

Its possible that maybe the name of the track isn't the same as what is setup in your custom module? I believe I read that with the mackie you have to have identical names, or identifiers at least. I could be mistaken as I don't have this setup in my OSC.

I'm not sure if any of my thoughts help or not, hopefully, someone else can give some more advice.

Cheers,
DMDComposer

1 Like

There's an error in your custom module, something like

someObjectVariable[someOtherVariable].trackarticulations

Under some conditions (which you need to track down with the messages received by OSC), the result of someObjectVariable[someOtherVariable] is undefined and produces an error when accessed like an object (which is what .trackarticulations does, it tries to access the object's value associated with the key "trackarticulations").

You might circumvent the issue by using some conditional to ignore the cases where this happen although this may just hide the problem and there's no guarantee it won't cause errors elsewhere :

var object = someObjectVariable[someOtherVariable]
if (object !== undefined) {
  var articulations = object.trackarticulations
  // now do something with articulations
}
1 Like

Thanks guys, I’ll give those a try and hopefully it fixes the issue. I tried but wasn't able to get it fixed. Perhaps if someone has time they can look at my custom module and see where I'm going wrong. Btw I'm using the vibrato plugin as an insert to show instrument track articulations. For the most part it works well but I noticed some track numbers don't work.

osc-custom-module.js (8.8 KB)

Ok, here's what happens: CC 121 with value 21 is sent by the DAW (that's from your screenshot), then at line 61:

patch = args[2].value + addAllCc

Here, patch equals 21 because addAllCc equals 0 (set with CC 120), then at line 62

labelTexts = instruments[patch].trackarticulations

fails for the reason I explained above, because the instruments object has no entry for the key 21 (lines 5 to 29).

1 Like

Thank you for the reply. But I’m a complete newbie when it comes to JavaScript. I’m confused what I’m suppose to change in the script to fix the error ?

Hi Mike1,

I believe what jean-emmanuel was trying to tell you is this.

In your custom module, lines 5-29 are below:

var instruments = {
	0:{'trackname':'No Expression Map','trackarticulations':['','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','',]},
	1:{'trackname':'Berlin Symphonic Strings - Violins I','trackarticulations':['Melodic Legato','Pattern Legato','','','','','Sustains','Sustains Soft','Sustains Accented','','','','Marcato Long','Marcato Short','','','','','Spiccato','Staccato','Pizzicato','','','','Tremolo','Trills Minor','Trills Major','','','','','','','','','',]},
	2:{'trackname':'Berlin Symphonic Strings - Violins II','trackarticulations':['Melodic Legato','Pattern Legato','','','','','Sustains','Sustains Soft','Sustains Accented','','','','Marcato Long','Marcato Short','','','','','Spiccato','Staccato','Pizzicato','','','','Tremolo','Trills Minor','Trills Major','','','','','','','','','',]},
	3:{'trackname':'Berlin Symphonic Strings - Violas','trackarticulations':['Melodic Legato','Pattern Legato','','','','','Sustains','Sustains Soft','Sustains Accented','','','','Marcato Long','Marcato Short','','','','','Spiccato','Staccato','Pizzicato','','','','Tremolo','Trills Minor','Trills Major','','','','','','','','','',]},
	4:{'trackname':'Berlin Symphonic Strings - Celli','trackarticulations':['Melodic Legato','Pattern Legato','','','','','Sustains','Sustains Soft','Sustains Accented','','','','Marcato Long','Marcato Short','','','','','Spiccato','Staccato','Pizzicato','','','','Tremolo','Trills Minor','Trills Major','','','','','','','','','',]},
	5:{'trackname':'Berlin Symphonic Strings - Basses','trackarticulations':['Melodic Legato','','','','','','Sustains','Sustains Soft','Sustains Accented','','','','Marcato Long','Marcato Short','','','','','Spiccato','Staccato','Pizzicato','','','','Tremolo','','','','','','','','','','','',]},
	6:{'trackname':'Junkie XL Brass - Full Brass','trackarticulations':['','','','','','','Sustains','','','','','','Marcato Short','','','','','','Staccatissimo','','','','','','','','','','','','','','','','','',]},
	7:{'trackname':'Junkie XL Brass - Solo Trumpet','trackarticulations':['Sustains + Leg','','','','','','Sustains','Sustains Soft','Sforzando Sustains','','','','Marcato Long','Marcato Short','','','','','Staccatissimo','Staccato','','','','','','','','','','','Rips','','','','','',]},
	8:{'trackname':'Junkie XL Brass - Trumpets a3','trackarticulations':['Sustains + Leg','','','','','','Sustains','Sustains Soft','Sforzando Sustains','','','','Marcato Long','Marcato Short','','','','','Staccatissimo','Staccato','','','','','','','','','','','Rips','','','','','',]},
	9:{'trackname':'Junkie XL Brass - Trumpets a6','trackarticulations':['Sustains + Leg','','','','','','Sustains','Sustains Soft','Sforzando Sustains','','','','Marcato Long','Marcato Short','','','','','Staccatissimo','Staccato','','','','','','','','','','','Rips','','','','','',]},
	10:{'trackname':'Junkie XL Brass - Solo Horn','trackarticulations':['Sustains + Leg','','','','','','Sustains','Sustains Soft','Sforzando Sustains','','','','Marcato Long','Marcato Short','','','','','Staccatissimo','Staccato','','','','','','','','','','','Rips','','','','','',]},
	11:{'trackname':'Junkie XL Brass - Horns a4','trackarticulations':['Sustains + Leg','','','','','','Sustains','Sustains Soft','Sforzando Sustains','','','','Marcato Long','Marcato Short','','','','','Staccatissimo','Staccato','','','','','','','','','','','Rips','','','','','',]},
	12:{'trackname':'Junkie XL Brass - Horns a6','trackarticulations':['Sustains + Leg','','','','','','Sustains','Sustains Soft','Sforzando Sustains','','','','Marcato Long','Marcato Short','','','','','Staccatissimo','Staccato','','','','','','','','','','','Rips','','','','','',]},
	13:{'trackname':'Junkie XL Brass - Horns a12','trackarticulations':['Sustains + Leg','','','','','','Sustains','Sustains Soft','Sforzando Sustains','','','','Marcato Long','Marcato Short','','','','','Staccatissimo','Staccato','','','','','','','','','','','Rips','','','','','',]},
	14:{'trackname':'Junkie XL Brass - Solo Trombone','trackarticulations':['Sustains + Leg','','','','','','Sustains','Sustains Soft','Sforzando Sustains','','','','Marcato Long','Marcato Short','','','','','Staccatissimo','Staccato','','','','','','','','','','','Rips','','','','','',]},
	15:{'trackname':'Junkie XL Brass - Trombones a3','trackarticulations':['Sustains + Leg','','','','','','Sustains','Sustains Soft','Sforzando Sustains','','','','Marcato Long','Marcato Short','','','','','Staccatissimo','Staccato','','','','','','','','','','','Rips','','','','','',]},
	16:{'trackname':'Junkie XL Brass - Trombones a6','trackarticulations':['Sustains + Leg','','','','','','Sustains','Sustains Soft','Sforzando Sustains','','','','Marcato Long','Marcato Short','','','','','Staccatissimo','Staccato','','','','','','','','','','','Rips','','','','','',]},
	17:{'trackname':'Junkie XL Brass - Trombones a12','trackarticulations':['Sustains + Leg','','','','','','Sustains','Sustains Soft','Sforzando Sustains','','','','Marcato Long','Marcato Short','','','','','Staccatissimo','Staccato','','','','','','','','','','','','','','','','',]},
	18:{'trackname':'Junkie XL Brass - Bass Trombones a3','trackarticulations':['Sustains + Leg','','','','','','Sustains','Sustains Soft','Sforzando Sustains','','','','Marcato Long','Marcato Short','','','','','Staccatissimo','Staccato','','','','','','','','','','','Rips','','','','','',]},
	19:{'trackname':'Junkie XL Brass - Cimbassi a3','trackarticulations':['Sustains + Leg','','','','','','Sustains','Sustains Soft','Sforzando Sustains','','','','Marcato Long','Marcato Short','','','','','Staccatissimo','Staccato','','','','','','','','','','','Rips','','','','','',]},
	20:{'trackname':'Junkie XL Brass - Tuba','trackarticulations':['Sustains + Leg','','','','','','Sustains','Sustains Soft','Sforzando Sustains','','','','Marcato Long','Marcato Short','','','','','Staccatissimo','Staccato','','','','','','','','','','','Rips','','','','','',]},
}

Jean is saying that there is no entry index key "21". As you see above, you only have up to index key 20. That is why you're getting the error of undefined because index key 21 is undefined, or simply put, doesn't exist so JS doesn't know how to interpret it and throws an error.

I'm guessing as I'm not sure how this is set up on your side, but either two things:

  1. Create an index key object for "21" for the track you're trying to reference
    OR
  2. If it is Junkie XL Brass - Trombones a3 (I'm guessing from your first post with an error), you were trying to select, then the correct index key is 15 according to your instruments object.

Cheers,
DMDComposer

1 Like

Thank you for the reply. I created up to 171 different articulation indexes but random errors still seem to appear. Seems to happen sometimes when I disable to enable an instrument track as well.