Stormworks: Build and Rescue

Stormworks: Build and Rescue

Not enough ratings
Easy-to-Program Music Player
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
Updated
59.143 KB
Jan 27, 2021 @ 4:43am
Dec 2, 2022 @ 5:08am
3 Change Notes ( view )

Subscribe to download
Easy-to-Program Music Player

Description
This is a microcontroller that plays music with a buzzer using a simple Lua program.

For users of previous versions(before 1.6.8)
Due to the change of buzzer timing in version 1.6.8, the buzzer does not sound as it did in the original version.
I have added a capacitor to the microcontroller on the Music Composite Reader.
For microcontrollers that have already been installed in the Composite Reader, place a capacitor between the Composite Reader and the output node and set charge=0sec, discharge>=0.2sec.
If the discharge is too long, continuous sound may not be played, so please set the appropriate length based on the tempo.



How to use
Combine the following two microcontrollers with a buzzer for play.

1. Music Composite Writer
This microcontroller defines musical scores and controls playing.
Write the score you want to play in the Lua gate of this microcontroller.
This microcontroller sends an On/Off signal to the Composite of a given number at the timing corresponding to the score you have described.

Nodes
  • Play:Play while "On", stop playing when "Off", resume playing when "On".
  • Reset:Play from the beginning(Cue)
  • Repeat:When "On" is selected, playback will be repeated; when "Off" is selected, playback will not begin until "Reset" or "Repeat" is pressed after the end of the play.
Properties
  • Tempo:The playing speed, which should be the number of quarter notes per minute (60 ticks/s).
  • Wait:The number of ticks to wait until the play starts.

2. Music Composite Reader
This microcontroller is used to pass the Composite's On/Off Pulse output by the Music Composite Writer to the Buzzer.
Set the pitch of each Buzzer based on the description of each node or the following information.
https://stormworks.gamepedia.com/Wiki/Guides/Music

You can delete nodes which is not need for play.

How to write music scores
Describe the score in the "note" function of the Lua block of Music Composite Writer using the "s" function.
The "note" function in the implementation sample contains the score for "A Lover's Concerto", so please delete this before using it.
Do not change anything except the "note" function and the value of the "bUnit" variable.

Description of the function
s(bar,beat,key,(unit)) : Function to represent a musical note.
1st Argument(bar)
Specify the bar(measure) number.

2nd Argument(beat)
Specify the position within the bar where the sound begins. Specify a value in the range of 1 to bUnit.
For example, if bUnit is 8, and a bar consists of three notes: a half note, a dotted quarter note, and an eighth note, the values of beat will be 1, 5, and 8, respectively.

3rd Argument(key)
Specify the key. Use the variables defined in the program that correspond to the scales. For C#5, it will look like Cs5.
Due to the specification of Buzzer the available range is D4 to D6.

4th Argument(unit) [optional]
Temporarily overwrites the value of bUnit.
Use Case:
If you want to write an entire bar in eighth-note units(bUnit=8), but only one bar in sixteenth-note units, you can specify unit=16 for that bar.


Re-uploading this module AS-IS is prohibited.
There are no restrictions on uploading microcontrollers with modified scores, or vehicles that incorporate this module.

This content is transraled from Japanese by DeepL.