Adventurecraft-Awakening / AC-Legacy-Mod

The Legend of AC, a story of Legacy.
MIT License
6 stars 5 forks source link

Instrument player optimizations #52

Closed Kiroto closed 1 year ago

Kiroto commented 1 year ago

Instruments now an interface, more flexibility when creating instruments.

Allows for pitch, sound and volume variations per note played

New Song class (iterable) used for reading song strings and playing them (no tempo feature... yet).

New song playing algorithm (used by song containers, AKA signs) which doesn't iterate through the string twice per note. Said algorithm is the one the Song class uses to read the song strings, iterating once to encode, and a second time to play.

An Iterator could be made that iterates directly on the string as if it was the song, and it would reduce the amount of loops to just once per song.

Reduced else/if wall on the GUI music sheet to a search in an array, and now uses the note system.

An optimization could be made when determining the pitch of the notes, currently using Math.pow(2, <integer>) when playing each note which could be precompiled, memoized or otherwise optimized.

Also, should we consider this thing I made as a substitute for the old harp sprite? image