Chord Player Inversions || Help with Indexing!
-
I built a one note chord generator. I've worked out Root position and 1st Inversion. The problem is, when I script for 2nd inversion, something goes wacky.... the way I have it scripted here seems to increment the inverted note every time the key is pressed in succession.
Can you spot what could be the cause? See my 'else if (inv1NOW ==3)' statement.
This is script for Button1 for example..// onNoteOn if (nn == 60) // TRIGGER CHORD 1 { local inv1NOW = cmbInversion1.getValue(); // GRAB COMBOBOX INVERSION VALUE 1 = ROOT, 2 = 1ST inversion, 3 = 2ND inversion and so on... if (inv1NOW == 1) // ROOT POSITION { chord1[0] = 0; } else if (inv1NOW == 2) // FIRST INVERSION { chord1[0] = 0 + 12; } else if (inv1NOW == 3) // SECOND INVERSION // HERE'S WHERE IT GETS WEIRD.... { chord1[0] = 0 + 12; // <------------------------------------------------------------< chord1[1] = chord1[1] + 12; // Why does it incriment everytime here but not up there ^ } Button1.setValue(1); // VISUAL FEEDBACK for (c1 = 0; c1 < chord1.length; c1++) // PLAYING NOTES HAPPENS HERE { noteEventIds[nn].push(Synth.playNote(chord1[c1] + offset + Octave1 + Chord1Choice - 1, velocity)); } }
I've tried to set the 'cmbInversion1 combobox getValue' as a const var in onInit thinking that the increment is happening every time (n == 60) because its in onNoteOn and within that code block....but calculating that value outside of onNoteOn doesn't change anything for me.
-
C Chazrox marked this topic as a question
-
C Chazrox referenced this topic
-
@d-healey I had the statement written that way you suggested but why does one increment on every button press and the other one doesnt?
-
This post is deleted! -
@Chazrox because in the first line you explicitly force it to be 12, so in the end it never changes
and in the second line it's the old value + 12. So next time the old value will be the new one, +12… this is an incrementation. -
@ustk How would you recommend going about this?
-
I don't see any incrementing going on.
if (inv1NOW == 1) // ROOT POSITION { chord1[0] = 0; // 0 } else if (inv1NOW == 2) { chord1[0] = 0 + 12; // 12 } else if (inv1NOW == 3) { chord1[0] = 0 + 12; // 12 }
-
@d-healey Thats what I was thinking....I ended up just scripting '-12' on all the corresponding onNoteOffs. Probably added another 50 lines of code but it works! Just finished up scripting all my functions now. I got all my chord options up to 3rd Inversions as of now. Thank You!
Figuring this thing out was a doozy!
I also got midi out to DAW working as CHORDS or ARP mode! yee!
-
C Chazrox has marked this topic as solved
-
@Chazrox said in Chord Player Inversions || Help with Indexing!:
I also got midi out to DAW working as CHORDS or ARP mode! yee!
Looks cool!
Since compiling as MIDI FX is currently not working (as I understand it), are you planning on releasing this as an instrument instead?
Trying to understand how that would work in various DAWs. I'm assuming you're taking a MIDI input from the DAW (either from a connected controller or a MIDI clip in the DAW), then outputting MIDI from your instrument plugin that is meant to play another instrument plugin?
Routing like that is easy in Reaper but other DAWs seem less flexible (I'm looking at you, Logic).