TKL Instruments...
Moderators: Moderator, Developer, DM
-
Endelyon
- Posts: 3606
- Joined: Sun Jul 06, 2014 4:24 am
Re: TKL Instruments...
Did you test to see if unmodified versions of the scripts worked any better? The code bugs could have existed from inception.
-
Ambaryerno
- Posts: 467
- Joined: Tue Jun 15, 2010 1:32 am
Re: TKL Instruments...
It does work if I put back the original INCLUDE file. Maybe there's something referenced in either the Include or one of the other scripts that I missed, but I'm not 100% sure where to look. I'm trying to reach back out to the creator to see if he has any other thoughts, but last I heard from him he hadn't looked at the code in years so doubted he could offer much help.
The problem I remember from working on my feat scripts from MotLS is that the Include doesn't really compile per se, so there could also be an error that the toolset doesn't see.
One thing I didn't do was change the GUI buttons to reflect the changes I made to how pitches are identified, since I was focusing entirely on the Write function. Maybe there's something there that's tripping it up when it loads (however it's also happening with the Drum instrument, which I didn't touch at all).
The problem I remember from working on my feat scripts from MotLS is that the Include doesn't really compile per se, so there could also be an error that the toolset doesn't see.
One thing I didn't do was change the GUI buttons to reflect the changes I made to how pitches are identified, since I was focusing entirely on the Write function. Maybe there's something there that's tripping it up when it loads (however it's also happening with the Drum instrument, which I didn't touch at all).
Last edited by Ambaryerno on Mon Jun 15, 2020 11:23 am, edited 1 time in total.
Julia "la Belle" - Duelist, singer, and shameless flirt. Currently deciding whether she wants to fight you or @$%& you.
Julia's Songbook
Lucia Kayla - If her parents find out she left the Island she'll likely be grounded until she's 500.
Julia's Songbook
Lucia Kayla - If her parents find out she left the Island she'll likely be grounded until she's 500.
-
Valefort
- Retired Admin
- Posts: 9779
- Joined: Thu Apr 28, 2011 5:07 pm
- Location: France, GMT +2
Re: TKL Instruments...
Weird, did you recompile every script using that updated include file ?
Mealir Ostirel - Incorrigible swashbuckler
-
Ambaryerno
- Posts: 467
- Joined: Tue Jun 15, 2010 1:32 am
Re: TKL Instruments...
You know, I didn't think of trying that, either (though thinking about it now I probably should have done that before I even tried to test it). I may give that a shot first to see if that isolates what got borked.
Julia "la Belle" - Duelist, singer, and shameless flirt. Currently deciding whether she wants to fight you or @$%& you.
Julia's Songbook
Lucia Kayla - If her parents find out she left the Island she'll likely be grounded until she's 500.
Julia's Songbook
Lucia Kayla - If her parents find out she left the Island she'll likely be grounded until she's 500.
-
Ambaryerno
- Posts: 467
- Joined: Tue Jun 15, 2010 1:32 am
Re: TKL Instruments...
All right, just tried compiling all scripts, and they all compiled successfully.
Julia "la Belle" - Duelist, singer, and shameless flirt. Currently deciding whether she wants to fight you or @$%& you.
Julia's Songbook
Lucia Kayla - If her parents find out she left the Island she'll likely be grounded until she's 500.
Julia's Songbook
Lucia Kayla - If her parents find out she left the Island she'll likely be grounded until she's 500.
-
Valefort
- Retired Admin
- Posts: 9779
- Joined: Thu Apr 28, 2011 5:07 pm
- Location: France, GMT +2
Re: TKL Instruments...
And same behaviour on the TKL GUI ?
Mealir Ostirel - Incorrigible swashbuckler
-
Ambaryerno
- Posts: 467
- Joined: Tue Jun 15, 2010 1:32 am
Re: TKL Instruments...
That's correct.
Julia "la Belle" - Duelist, singer, and shameless flirt. Currently deciding whether she wants to fight you or @$%& you.
Julia's Songbook
Lucia Kayla - If her parents find out she left the Island she'll likely be grounded until she's 500.
Julia's Songbook
Lucia Kayla - If her parents find out she left the Island she'll likely be grounded until she's 500.
-
Ambaryerno
- Posts: 467
- Joined: Tue Jun 15, 2010 1:32 am
Re: TKL Instruments...
This is the code I changed.
First expanding and defining the instrument ranges for Lute and Flute.
Second, putting a warning if a note is out of range:
First expanding and defining the instrument ranges for Lute and Flute.
Code: Select all
//Defines note names, works with the Play Sounds function further up to associate a note with a sound file
string GetNoteName(int iPitch)
{
string sInstrument;
// is this a melody note?
if (iPitch < 100 || (iPitch > 200 && iPitch < 300) || (iPitch > 323 && iPitch < 350) || (iPitch > 373 && iPitch < 400))
{
if (iPitch < 100)
{
sInstrument = "Lute Note: ";
if (iPitch > 50)
iPitch -= 50;
switch (iPitch)
{
case 1: return sInstrument + "C2";
case 2: return sInstrument + "Db2";
case 3: return sInstrument + "D2";
case 4: return sInstrument + "Eb2";
case 5: return sInstrument + "E2";
case 6: return sInstrument + "F2";
case 7: return sInstrument + "Gb2";
case 8: return sInstrument + "G2";
case 9: return sInstrument + "Ab2";
case 10: return sInstrument + "A2";
case 11: return sInstrument + "Bb2";
case 12: return sInstrument + "B2";
case 13: return sInstrument + "C3";
case 14: return sInstrument + "Db3";
case 15: return sInstrument + "D3";
case 16: return sInstrument + "Eb3";
case 17: return sInstrument + "E3";
case 18: return sInstrument + "F3";
case 19: return sInstrument + "Gb3";
case 20: return sInstrument + "G3";
case 21: return sInstrument + "Ab3";
case 22: return sInstrument + "A3";
case 23: return sInstrument + "Bb3";
case 24: return sInstrument + "B3";
case 25: return sInstrument + "C4";
case 26: return sInstrument + "Db4";
case 27: return sInstrument + "D4";
case 28: return sInstrument + "Eb4";
case 29: return sInstrument + "E4";
case 30: return sInstrument + "F4";
case 31: return sInstrument + "Gb4";
case 32: return sInstrument + "G4";
case 33: return sInstrument + "Ab4";
case 34: return sInstrument + "A4";
case 35: return sInstrument + "Bb4";
case 36: return sInstrument + "B4";
case 37: return sInstrument + "C5";
case 38: return sInstrument + "Db5";
case 39: return sInstrument + "D5";
case 40: return sInstrument + "Eb5";
case 41: return sInstrument + "E5";
}
}
else if (iPitch > 200 && iPitch < 300)
{
sInstrument = "Flute Note: ";
if (iPitch > 250)
iPitch -= 50;
iPitch -= 200;
switch (iPitch)
{
case 1: return sInstrument + "C1";
case 2: return sInstrument + "Db1";
case 3: return sInstrument + "D1";
case 4: return sInstrument + "Eb1";
case 5: return sInstrument + "E1";
case 6: return sInstrument + "F1";
case 7: return sInstrument + "Gb1";
case 8: return sInstrument + "G1";
case 9: return sInstrument + "Ab1";
case 10:return sInstrument + "A1";
case 11:return sInstrument + "Bb1";
case 12:return sInstrument + "B1";
case 13:return sInstrument + "C2";
case 14:return sInstrument + "Db2";
case 15:return sInstrument + "D2";
case 16:return sInstrument + "Eb2";
case 17:return sInstrument + "E2";
case 18:return sInstrument + "F2";
case 19:return sInstrument + "Gb2";
case 20:return sInstrument + "G2";
case 21:return sInstrument + "Ab2";
case 22:return sInstrument + "A2";
case 23:return sInstrument + "Bb2";
case 24:return sInstrument + "B2";
case 25:return sInstrument + "C3";
case 26:return sInstrument + "Db3";
case 27:return sInstrument + "D3";
case 28:return sInstrument + "Eb3";
case 29:return sInstrument + "E3";
case 30:return sInstrument + "F3";
case 31:return sInstrument + "Gb3";
case 32:return sInstrument + "G3";
case 33:return sInstrument + "Ab3";
case 34:return sInstrument + "A3";
case 35:return sInstrument + "Bb3";
case 36:return sInstrument + "B3";
}
}
else if ((iPitch > 323 && iPitch < 350) || (iPitch > 373 && iPitch < 400))
{
sInstrument = "Drum Note: ";
if (iPitch > 373)
iPitch -= 50;
iPitch -= 323;
switch (iPitch)
{
case 1: return sInstrument + "C1";
case 2: return sInstrument + "Db1";
case 3: return sInstrument + "D1";
case 4: return sInstrument + "Eb1";
case 5: return sInstrument + "E1";
case 6: return sInstrument + "F1";
case 7: return sInstrument + "Gb1";
case 8: return sInstrument + "G1";
case 9: return sInstrument + "Ab1";
case 10:return sInstrument + "A1";
case 11:return sInstrument + "Bb1";
case 12:return sInstrument + "B1";
case 13:return sInstrument + "C2";
case 14:return sInstrument + "Db2";
case 15:return sInstrument + "D2";
case 16:return sInstrument + "Eb2";
case 17:return sInstrument + "E2";
case 18:return sInstrument + "F2";
case 19:return sInstrument + "Gb2";
case 20:return sInstrument + "G2";
case 21:return sInstrument + "Ab2";
case 22:return sInstrument + "A2";
case 23:return sInstrument + "Bb2";
case 24:return sInstrument + "B2";
case 25:return sInstrument + "C3";
case 26:return sInstrument + "Db3";
case 27:return sInstrument + "D3";
case 28:return sInstrument + "Eb3";
case 29:return sInstrument + "E3";
case 30:return sInstrument + "F3";
case 31:return sInstrument + "Gb3";
case 32:return sInstrument + "G3";
case 33:return sInstrument + "Ab3";
case 34:return sInstrument + "A3";
case 35:return sInstrument + "Bb3";
case 36:return sInstrument + "B3";
}
}
}
// or is this a chord?
else if (iPitch < 200)
{
sInstrument = "Lute Chord: ";
if (iPitch > 150)
iPitch -= 50;
switch (iPitch)
{
case 101:return sInstrument + "C Major";
case 102:return sInstrument + "Db Major";
case 103:return sInstrument + "D Major";
case 104:return sInstrument + "Eb Major";
case 105:return sInstrument + "E Major";
case 106:return sInstrument + "F Major";
case 107:return sInstrument + "Gb Major";
case 108:return sInstrument + "G Major";
case 109:return sInstrument + "Ab Major";
case 110:return sInstrument + "A Major";
case 111:return sInstrument + "Bb Major";
case 112:return sInstrument + "B Major";
case 113:return sInstrument + "C minor";
case 114:return sInstrument + "Db minor";
case 115:return sInstrument + "D minor";
case 116:return sInstrument + "Eb minor";
case 117:return sInstrument + "E minor";
case 118:return sInstrument + "F minor";
case 119:return sInstrument + "Gb minor";
case 120:return sInstrument + "G minor";
case 121:return sInstrument + "Ab minor";
case 122:return sInstrument + "A minor";
case 123:return sInstrument + "Bb minor";
case 124:return sInstrument + "B minor";
case 125:return sInstrument + "C half-diminished";
case 126:return sInstrument + "Db half-diminished";
case 127:return sInstrument + "D half-diminished";
case 128:return sInstrument + "Eb half-diminished";
case 129:return sInstrument + "E half-diminished";
case 130:return sInstrument + "F half-diminished";
case 131:return sInstrument + "Gb half-diminished";
case 132:return sInstrument + "G half-diminished";
case 133:return sInstrument + "Ab half-diminished";
case 134:return sInstrument + "A half-diminished";
case 135:return sInstrument + "Bb half-diminished";
case 136:return sInstrument + "B half-diminished";
}
}
// or is this a percussion sound?
else
{
sInstrument = "Percussion Hit: ";
if (iPitch > 350)
iPitch -= 50;
switch (iPitch)
{
case 301: return sInstrument + "Cow Bell (a1)";
case 302: return sInstrument + "Taiko (b1)";
case 303: return sInstrument + "Triangle (c1)";
case 304: return sInstrument + "Guiro (d1)";
case 305: return sInstrument + "Frame Drum (e1)";
case 306: return sInstrument + "Open Snare (f1)";
case 307: return sInstrument + "Closed Snare (g1)";
case 308: return sInstrument + "Tabla (h1)";
case 309: return sInstrument + "Tambourine (i1)";
case 310: return sInstrument + "Anvil (j1)";
case 311: return sInstrument + "Cow Bell (a2)";
case 312: return sInstrument + "Taiko (b2)";
case 313: return sInstrument + "Triangle (c2)";
case 314: return sInstrument + "Guiro (d2)";
case 315: return sInstrument + "Frame Drum (e2)";
case 316: return sInstrument + "Open Snare (f2)";
case 317: return sInstrument + "Closed Snare (g2)";
case 318: return sInstrument + "Tabla (h2)";
case 319: return sInstrument + "Tambourine (i2)";
case 320: return sInstrument + "Anvil (j2)";
}
}
return "Unrecognized Pitch";
}Code: Select all
//Check for octave
//if (iRow == 1 && sLowerChar != "c")
//{
// SendMessageToPC(oPC, "Error at character " + IntToString(iPosition) + ": The only note that can use the '3' row is C.");
// SetLocalInt(oInstrument, "NOTES_RECORDED_TRACK" + sOption, iNotesWritten);
// return;
//}
if ((sGUIFile == "tkl_performer_lute.xml" && iRow == 1) || (sGUIFile == "tkl_performer_lute.xml" && iRow == 5 && (sLowerChar != "c" || sLowerChar != "db" || sLowerChar != "d" || sLowerChar != "eb" || sLowerChar != "e")))
{
SendMessageToPC(oPC, "Error at character " + IntToString(iPosition) + ": This instrument has a range of C2 to E5.");
SetLocalInt(oInstrument, "NOTES_RECORDED_TRACK" + sOption, iNotesWritten);
return;
}
iPitch = GetMelodyPitch(sChar, sChar2, iRow, bDrums, iInstrumentOffset);
if (iPitch == -1)
{
SendMessageToPC(oPC, "Error at character " + IntToString(iPosition) + ": Invalid melody note.");
SetLocalInt(oInstrument, "NOTES_RECORDED_TRACK" + sOption, iNotesWritten);
return;
}
AssignCommand(oPC, DelayCommand(fWriteDelay, WriteNote(oInstrument, iNotesWritten, iTrack, iPitch, fDelay)));
fWriteDelay += 0.01f;
iPosition += 2;
iNotesWritten++;Julia "la Belle" - Duelist, singer, and shameless flirt. Currently deciding whether she wants to fight you or @$%& you.
Julia's Songbook
Lucia Kayla - If her parents find out she left the Island she'll likely be grounded until she's 500.
Julia's Songbook
Lucia Kayla - If her parents find out she left the Island she'll likely be grounded until she's 500.
-
Mance
- Posts: 49
- Joined: Fri Mar 02, 2018 11:05 pm
Re: TKL Instruments...
Wow. You did a lot of work here. 
-
Ambaryerno
- Posts: 467
- Joined: Tue Jun 15, 2010 1:32 am
Re: TKL Instruments...
Expanding these ranges is just step one. If I can get THIS to work, I'd love to add more instruments.
Stuff like harp or lyre, various other wind instruments (pipes, both bag and otherwise, shawm, etc.), violin, and even voice (no actual singing for, but at least have a generic Male and Female "Ahhhh" which could be used to make it clearer what the melody line is FOR the lyrics).
Stuff like harp or lyre, various other wind instruments (pipes, both bag and otherwise, shawm, etc.), violin, and even voice (no actual singing for, but at least have a generic Male and Female "Ahhhh" which could be used to make it clearer what the melody line is FOR the lyrics).
Julia "la Belle" - Duelist, singer, and shameless flirt. Currently deciding whether she wants to fight you or @$%& you.
Julia's Songbook
Lucia Kayla - If her parents find out she left the Island she'll likely be grounded until she's 500.
Julia's Songbook
Lucia Kayla - If her parents find out she left the Island she'll likely be grounded until she's 500.
-
Ambaryerno
- Posts: 467
- Joined: Tue Jun 15, 2010 1:32 am
Re: TKL Instruments...
Ok, I figured out what was breaking the interface. I was using the Override version, which didn't play nice with the script. I switched to using the Module version instead.
Still working on getting the range increase itself to work. I can get both instruments to play notes written beyond two octaves, however the sounds loop back around to the lower register as it continues up the scale. Also, the range limit isn't quite working properly. The lute returns an error that pitches it DOES have are out of range (specifically on C5 - E5) and the flute isn't alerting you to when you've gone out of range at all.
I'm SO CLOSE.
Still working on getting the range increase itself to work. I can get both instruments to play notes written beyond two octaves, however the sounds loop back around to the lower register as it continues up the scale. Also, the range limit isn't quite working properly. The lute returns an error that pitches it DOES have are out of range (specifically on C5 - E5) and the flute isn't alerting you to when you've gone out of range at all.
I'm SO CLOSE.
Julia "la Belle" - Duelist, singer, and shameless flirt. Currently deciding whether she wants to fight you or @$%& you.
Julia's Songbook
Lucia Kayla - If her parents find out she left the Island she'll likely be grounded until she's 500.
Julia's Songbook
Lucia Kayla - If her parents find out she left the Island she'll likely be grounded until she's 500.
-
Ambaryerno
- Posts: 467
- Joined: Tue Jun 15, 2010 1:32 am
Re: TKL Instruments...
Dammit. I've gone over the Include and several other scripts, made a number of changes, and I simply cannot find what part keeps resetting the pitches to the first octave.
On the lute it plays fine from C2-B3. But as soon as it hits C4 it goes back to C2 again (C5 does the same). I thought I've found everywhere that could be doing it but I must be missing SOMETHING.
Is there anyone who can double-check the code to see if there's something I've missed? Maybe everything's blending together too much and I'm just not seeing it.
On the lute it plays fine from C2-B3. But as soon as it hits C4 it goes back to C2 again (C5 does the same). I thought I've found everywhere that could be doing it but I must be missing SOMETHING.
Is there anyone who can double-check the code to see if there's something I've missed? Maybe everything's blending together too much and I'm just not seeing it.
Julia "la Belle" - Duelist, singer, and shameless flirt. Currently deciding whether she wants to fight you or @$%& you.
Julia's Songbook
Lucia Kayla - If her parents find out she left the Island she'll likely be grounded until she's 500.
Julia's Songbook
Lucia Kayla - If her parents find out she left the Island she'll likely be grounded until she's 500.
-
Ambaryerno
- Posts: 467
- Joined: Tue Jun 15, 2010 1:32 am
Re: TKL Instruments...
Still working on this. I thought I'd try modifying the UI to see if maybe there's something being called from there, so I added all the new octaves. Now the UI never loads on-Equip.
I think I'm in over my head.
I think I'm in over my head.
Julia "la Belle" - Duelist, singer, and shameless flirt. Currently deciding whether she wants to fight you or @$%& you.
Julia's Songbook
Lucia Kayla - If her parents find out she left the Island she'll likely be grounded until she's 500.
Julia's Songbook
Lucia Kayla - If her parents find out she left the Island she'll likely be grounded until she's 500.
-
Ambaryerno
- Posts: 467
- Joined: Tue Jun 15, 2010 1:32 am
Re: TKL Instruments...
Ahem...
Right now it ONLY works for the Lute. The current stumbling block is how the performer defines the octaves. Basically, it looks like this:
There's three key parts to the code: The first is that the pitch is set to 0. In the second part it takes each pitch from C to B and assigns it a number value from 1 - 12. then in the second part, it checks for the number value after the pitch (C2, D3, etc.). That number is the row. By default, Row 1 uses the basic pitch number from 1-12. In the original script, each row adds 12 to the pitch (so Row 2 runs from 13-24, Row 3 from 25-36, etc.). This coincides with the sound files.
What I did here, was tweak the rows so that Row 2 adds 0 to the pitch value, Row 3 adds 12, etc. This allows the Lute to be written from C2 to E5 and receive the correct pitches.
NOW, here's the sticky part:
I've tried a number of methods to check for the instrument type and set the Row values based on that, but I can't seem to find one that works. The result is that the flute is currently playing two octaves higher than it should be (IE, when writing a D4 it's playing Pitch 25 instead of Pitch 1).
While I might be able to get around that by renaming the sound files, this will run into a second problem in that there's not enough pitches in the range (the flute goes to A6, which would be Pitch 55. Each instrument only has 50 pitches available for its primary and secondary sound). Writing it down two octaves could probably work, but would not be ideal. A big part of what I want to do is use the correct notation to make it easier to import from MIDI files (also, it's easier to guess what the relative pitches are between instruments).
Right now it ONLY works for the Lute. The current stumbling block is how the performer defines the octaves. Basically, it looks like this:
Code: Select all
int GetMelodyPitch(string sChar, string sChar2, int iRow, int bDrums, int iInstrumentOffset)
{
string sGUIFile;
int iPitch = 0;
string sLower = GetStringLowerCase(sChar);
if (sChar2 == "#")
iPitch++;
else if (sChar2 == "b")
iPitch--;
if (sLower == "c")
iPitch += 1;
else if (sLower == "d")
iPitch += 3;
else if (sLower == "e")
iPitch += 5;
else if (sLower == "f")
iPitch += 6;
else if (sLower == "g")
iPitch += 8;
else if (sLower == "a")
iPitch += 10;
else if (sLower == "b")
iPitch += 12;
else
return -1;
// don't allow B#'s
if (iPitch > 12)
iPitch = 12;
// check for second octave
if (iRow == 2)
iPitch += 0;
// check for third octave
if (iRow == 3)
iPitch += 12;
// check for fourth octave
if (iRow == 4)
iPitch += 24;
// check for fifth octave
if (iRow == 5)
iPitch += 36;
// add the instrument offset
iPitch += iInstrumentOffset;
return iPitch;
}What I did here, was tweak the rows so that Row 2 adds 0 to the pitch value, Row 3 adds 12, etc. This allows the Lute to be written from C2 to E5 and receive the correct pitches.
NOW, here's the sticky part:
I've tried a number of methods to check for the instrument type and set the Row values based on that, but I can't seem to find one that works. The result is that the flute is currently playing two octaves higher than it should be (IE, when writing a D4 it's playing Pitch 25 instead of Pitch 1).
While I might be able to get around that by renaming the sound files, this will run into a second problem in that there's not enough pitches in the range (the flute goes to A6, which would be Pitch 55. Each instrument only has 50 pitches available for its primary and secondary sound). Writing it down two octaves could probably work, but would not be ideal. A big part of what I want to do is use the correct notation to make it easier to import from MIDI files (also, it's easier to guess what the relative pitches are between instruments).
Julia "la Belle" - Duelist, singer, and shameless flirt. Currently deciding whether she wants to fight you or @$%& you.
Julia's Songbook
Lucia Kayla - If her parents find out she left the Island she'll likely be grounded until she's 500.
Julia's Songbook
Lucia Kayla - If her parents find out she left the Island she'll likely be grounded until she's 500.
-
Ambaryerno
- Posts: 467
- Joined: Tue Jun 15, 2010 1:32 am
Re: TKL Instruments...
Disregard what I just said, because I GOT IT.
That's it, both instruments are now working on extended ranges when using the Write function.
Phase one of my attempt to upgrade the TKL Performer has been completed, and is ready to send to the team. I still don't have the expanded instrument ranges working on the GUI, but IMO that's much less important.
That's it, both instruments are now working on extended ranges when using the Write function.
Phase one of my attempt to upgrade the TKL Performer has been completed, and is ready to send to the team. I still don't have the expanded instrument ranges working on the GUI, but IMO that's much less important.
Julia "la Belle" - Duelist, singer, and shameless flirt. Currently deciding whether she wants to fight you or @$%& you.
Julia's Songbook
Lucia Kayla - If her parents find out she left the Island she'll likely be grounded until she's 500.
Julia's Songbook
Lucia Kayla - If her parents find out she left the Island she'll likely be grounded until she's 500.