Musical speaker fixed


Adds a speaker to the game that includes 189 instruments for use in music production. Fixed and expanded version of the original Musical speaker.

Content
6 months ago
1.1
111
Circuit network

b Occasionnal error when changing instrument

8 months ago

Hey ! i followed the instructions to add the other instruments after downloading the .zip from github.

I have tested changing instruments and noticed that sometimes i would get this error message :

Error message :

The mod Musical speaker fixed (1.0.0) caused a non-recoverable error.
Please report this error to the mod author.

Error while running event musical-speaker-fixed::on_gui_selection_state_changed (ID 60)
Value (-1.000000) outside of range. The data type allows values from 0 to 4294967295 in property tree at ROOT.i.note_id
stack traceback:
[C]: in function 'newindex'
__musical-speaker-fixed
/script/musical-speaker.lua:144: in function 'reset'
musical-speaker-fixed/script/musical-speaker.lua:115: in function 'setSettings'
musical-speaker-fixed/script/gui/gui.lua:135: in function 'writeSettingsToSpeaker'
musical-speaker-fixed/script/gui/gui.lua:196: in function 'guiHandler'
musical-speaker-fixed/script/gui/gui.lua:23: in function 'handler'
stdlib/stdlib/event/event.lua:342: in function 'pcall'
stdlib/stdlib/event/event.lua:362: in function 'dispatch_event'
stdlib/stdlib/event/event.lua:438: in function <stdlib/stdlib/event/event.lua:396>

I think it occurs when the speaker has a preset for instrument/set/note that are either null or too high, and when changing to another one that doesn't have as many notes/set it or something like that. I had it occuring when trying to select drumkit TR 808 or the electronic drumkit.

While a speaker is playing with anything >0 and a signal holding a value of 1, If you select the last instrument( Misc) , the last set( 808 Tom) , and the last note (C8), and then try to choose the "drumkit" instead of "misc" the middle field change to "brush 1" and it keeps playing tap tap tap tap, at this moment, attempting to change "brush1" for anything else seems to show the error message.

I don't know if it apply for this particular version of the mod with 1 instrument, or if i did something wrong when installing the other sounds. I'm still having a lot of fun :) thanks for the mod !

8 months ago

Hi, thanks for your feedback! Yes, as you suggested, this is due to switching to an instrument with fewer notes.
In Lua, indexing starts from 1, so the minimum index value in the note selection drop-down list is 1, and to bring this to normal indexing from 0, I subtract 1. But! When changing a set of notes, the old index value is saved and if it goes out of bounds, then this drop-down list will return 0. 0 minus 1, we get -1 and an error.
I've added additional checks for this and some other cases. If any value goes outside the limits (less than zero or more than the possible maximum), then a corresponding warning will be displayed. An incorrect value will be reset to a minimum. Therefore, if a note's index is too large (or negative), it will be replaced by the first note in the instrument. Same with instruments and categories.

8 months ago

Thank you for the explanation, however i'm still having problems : I found myself downloading from the github the 1GB folder again for fear of not knowing how to properly merge the new version and the previous sounds and i replaced the older .zip with it, but now i can't place a speaker without getting an error message :

The mod Musical speaker fixed (1.0.1) caused a non-recoverable error.
Please report this error to the mod author.

Error while running event musical-speaker-fixed::on_built_entity (ID 6)
musical-speaker-fixed/script/sounds.lua:41: attempt to index field '?' (a nil value)
stack traceback:
musical-speaker-fixed/script/sounds.lua:41: in function 'getProgrammableSpeakerInstrumentId'
musical-speaker-fixed/script/musical-speaker.lua:140: in function 'reset'
musical-speaker-fixed/script/musical-speaker.lua:115: in function 'setSettings'
musical-speaker-fixed/script/musical-speaker.lua:20: in function 'create'
musical-speaker-fixed/script/musical-speaker.lua:171: in function 'handler'
stdlib/stdlib/event/event.lua:342: in function 'pcall'
stdlib/stdlib/event/event.lua:362: in function 'dispatch_event'
stdlib/stdlib/event/event.lua:438: in function <stdlib/stdlib/event/event.lua:396>

This happens in editor on a new map, because the speaker doesn't show from the crafting tab of a player when not in editor.
I attempted to place not the "speaker" entity but also the invisible thing attached to it, this one can be placed without triggering an error but contrary to previous version, it doesn't use instrument category and groups, instead it seem problematic as it uses the 2 groups from the regular speaker and many extra "unkown key" which play the sound of the instruments.

I would need to know more lua to be more helpful i think :( i tried to look at the code at first thinking maybe it is possible to upload additionnal sounds as separate mods or rebundled them to fit in the mod portal, but it seemed too complicated, and even the smaller task of understanding the later change seem too difficult. I reverted back to the previous version to continue making mixtape !! still enjoying :) i know better how to avoid the error with the older version now

8 months ago

The version 1.0.2 works fine from what i have tested so far, I even added instrument from the github and edited the lua file, and did not encounter previous problems, thank you for the updates

8 months ago

Yes, sorry for the delay. Github also doesn't like large files. I posted this full version 1.0.2 on MEGA. I'll probably have to either deliver it in 2 different mods or tell people to unpack the archives with the mod and the sound set, and then combine them.

8 months ago

no worries ! and still no error since then :) It worked for me downloading the "old" sound from github and swapping them in the "new" 1.0.2 .zip I don't know how it would do in multiplayer, but i don't think anyone would want to hear my experiments atm anyway.

New response