Starbound

Starbound

Not enough ratings
Creating a Basic Music Instrument Mod
By puppy in a soggy cardboard box
Wanting to make music instruments in Starbound? Well here's the answer! This guide takes you through the step by step process of making a simple mod to implement your own instruments into the game.
   
Award
Favorite
Favorited
Unfavorite
What You'll Need
There are three major things that you will need:
  • A text editor
  • A way to edit sprites
  • A digital audio interface of some kind
In my recommendation, using Notepad++[notepad-plus-plus.org] to code, PaintdotNET[www.getpaint.net] to create sprites, and FL Studio[www.image-line.com] to create the samples required will be easiest, as they are free while also being easy to use and navigate for starters (and it's what I will be using myself). Most anything will work for this, so use what you're comfortable with! (Basically just don't use Microsoft Notepad).
Getting Started
First of all, if we're going to be making any new items for Starbound, we need to create the mod folder that all of our work will go inside of.

Getting to the Starbound Folder
This can be done by going to your Steam library, right clicking on Starbound, then clicking on properties. You'ill then need to go to the Local Files tab and click on the Browse Local Files button, as seen on the right. This will open up the Starbound directory, which is where we will be spending a lot of time.

Setting up Your Mod's Folder
Now that we're inside of the Starbound directory, navigate to the mods folder, and create your mod's folder. Title it whatever you want, but it'd be best for convenience's sake to title it after your mod. Inside of this folder, you'll need two things for now:
  • A folder named items, all lowercase.
  • A folder named sfx, all lowercase.
Now that we have our basic folders to work with, we can begin coding our basics. From here, open your text editor, which will be Notepad++ in my case. The file we'll be creating will be used to make sure that the player can craft our instrument(s). Paste the following into your text editor:
[ { "op": "add", "path": "/defaultBlueprints/tier1/0", "value": { "item": "INSTRUMENTS_NAME" } } ]
Change the item name, where INSTRUMENTS_NAME is, to whatever instrument you'll be modding in or to whatever name so pleases you. It's really up to you! As long as it's the name of the item we'll be making shortly.

Now, save this file inside of your mod's folder with the name player.config.patch, making sure that the file type ends up as a PATCH file, as seen below.

Next, navigate inside of your items folder and create a new folder titled instruments. This folder is where we'll be putting both our sprites and our item's data. Backing out of there, go into your sfx folder now and add a folder titled, once again, instruments.

Now that we have all of this, we can begin creating our actual instrument!

Side Note on Adding More Instruments to the Config.patch
If necessary, you can add more instruments to this by duplicating the line and adding a comma at the end of the line prior, like so:
[ { "op": "add", "path": "/defaultBlueprints/tier1/0", "value": { "item": "INSTRUMENT1S_NAME" } }, { "op": "add", "path": "/defaultBlueprints/tier1/0", "value": { "item": "INSTRUMENT2S_NAME" } }, { "op": "add", "path": "/defaultBlueprints/tier1/0", "value": { "item": "INSTRUMENT3S_NAME" } } ]
Creating An Instrument
Create a new file in your text editor, and paste the following code in:
{ "itemName" : "bugle", "price" : 3000, "category" : "musicalInstrument", "inventoryIcon" : "bugleicon.png", "maxStack" : 1, "rarity" : "Common", "description" : "A bugle. Just a generic bugle.", "shortdescription" : "Bugle", "largeImage" : "bugle.png", "image" : "bugle.png", "tooltipKind" : "tool", "activeImage" : "bugle.png", "activeAngle" : 0, "activeHandPosition" : [0, 0], "handPosition" : [0, 0], "twoHanded" : true, "kind" : "bugle" }
In this example code, I've set up the instrument to be a bugle, which isn't at all what needs to be there. For your instrument, you'll need to change all of the following:
  • itemName needs to match what you wrote inside of your player.config.patch file, otherwise the player will not have direct blueprint access to it.
  • description and shortDescription are the item's tooltip and name respectively when looking at the item within Starbound.
  • inventoryIcon, largeImage, image, and activeImage will be touched on later when we make our instrument's sprite, so keep those in the back of your mind.
  • kind refers to the instrument's sound effect samples, which will also be touched on after we create our sprites.
For now, these are the only things in this file we'll be changing. So, save the file inside of your mods items/instruments folder. The name of the file should be the itemName listed followed by .instrument. In the case of my bugle, it would be bugle.instrument.

Making the Instrument's Sprites
Now comes the fun parts! Your instrument's in-hand sprite is up to you how you design it, but its not wishful thinking to hope that you would want it to look decent.

To ensure the placement of your instrument is good when being held by your player, use Silverfeelin's Starbound Instrumentalizer[silverfeelin.github.io], it's a great way to manage that the sprite sits well in the player's grasp. On the bottom right of the page, there's also a small guide to making an instrument sprite and fitting it to the player. Hopefully it will suffice!

Aside from the instrument's main sprite, we'll also need to create, as shown above in the code, a sprite for the inventory icon and, while completely optional, a sprite for when the instrument is being played (this is best for instruments like stringed instruments, which require a bow to play, or the trombone--basically anything that shows a physical motion or action when played).

Sometimes, if your instrument is small enough, you can get away with using the instrument's main sprite as the inventory icon (the Starbound devs did this with the trumpet). The icon itself should be a 16 pixel by 16 pixel image, but it can be another size if so desired.

Overall, your sprites may look something like these sprites of my trombone on the right.

Using the Instrument's Sprites
Once you have created all of your sprites, save them inside of the same folder we saved our instrument's file to, items/instruments. When naming them, I recommend saving them as the instrument's name, followed by active or icon if its either of those. Something like trombone.png, tromboneicon.png, and tromboneactive.png.

Open your instrument's .instrument file, and now change the image files to correspond to their new sprites. Make sure that you have the file's extension on the end when referring to it. Your code will not be able to find trombone over trombone.png or trombone.jpg. Your code should now look something like this:
{ "itemName" : "trombone", "price" : 3000, "category" : "musicalInstrument", "inventoryIcon" : "tromboneicon.png", "maxStack" : 1, "rarity" : "Common", "description" : "Whatever description, doesn't really matter.", "shortdescription" : "Trombone", "largeImage" : "trombone.png", "image" : "trombone.png", "tooltipKind" : "tool", "activeImage" : "tromboneactive.png", "activeAngle" : 0, "activeHandPosition" : [0, 0], "handPosition" : [0, 0], "twoHanded" : true, "kind" : "bugle" }
Notice that largeImage and image both share the same file. The largeImage is what shows when hovering over the item in the inventory or hotbar, whereas the image is when the player holds it. Changing the largeImage to have a different sprite is up to you if that sounds like something you'd like to do.

Giving an Instrument Sound
One of the last things now for your mod is to give this new instrument of yours some life. To do this, we need to give the instrument a library of samples to use when being played. Navigate to sfx/instruments, and create a new folder, preferably with the name of your instrument. Inside of this folder, we will put in all of our sample, alongside the tuning config file.

Create a new file in your text editor and paste the text from this link[pastebin.com] into it. This code is what creates the notes, aside from the supplied eight, for your instrument. Save this file into your sfx/instruments folder as tuning.config, making sure that the file extension becomes .config.

Now, we must make our sample files!

Side Note on Tuning.config
While it is possible to do with some ingenuity, I myself have neither experimented much with nor really know how to reconfigure the tuning config. There are most likely tutorials out there that can teach you how to do it, but I would personally advise not to mess with it unless you know what you're doing.
Creating the Sounds for an Instrument
Our instrument needs some files to pull its sounds from, so, let's give it some. If you already have samples of the instruments sounds, go to the header labeled for those who do. Otherwise, if you have nothing yet, head to the header labeled for those who don't.

For Those Who Do Have Their Samples
Given that we already have samples for our instrument, we need to verify that (a) we have all eight notes and that (b) we have them all in the proper file format.

In order for your samples to be usable, they must all be samples of the instrument playing A notes, each being from octaves 0 to 7, or alternatively 1 to 8. If they are not, then you may have some issues with how your instrument sounds in-game (notably the pitches being off or some notes being made unplayable). Next, if you do have all eight of these, make sure that they are all in .ogg format. If they are not, then use a converter of some kind to fix this, I personally recommend using Zamzar[www.zamzar.com].

Once you've done this, name them each a0 through a7 (and if you name them differently, make sure to change the names of the files found in tuning.config). Now skip down to the section labeled What It Should Look Like.

For Those Who Don't Have Their Samples
For those of you who don't have samples already, you're in the same barrel that I'm in almost every time I make a new instrument for my mod. Hopefully, you've already installed FL Studio or have some other program handy, and if you haven't, please do so.

Before we hop into FL Studio, find a soundfont file (using the .sf2 extension) somewhere on the internet of the instrument that you're wanting to use. Depending on what instrument it is, especially if it's some obscure instrument that almost no one has ever heard of, you may be unable to find a soundfont for it. I know I've had that problem my fair share of times. You can also use any VST plug-ins you find. Essentially, just find a way to emulate the instrument in question.

Opening FL Studio now, since we have our soundfont presumably, drag and drop your soundfont onto this box shown below. Yours may not look like mine exactly due to my use of an older version, but it should look similar at the least. Make sure to delete (right click them) any other boxes aside from the one containing your soundfont you've just dragged in.

Now, click on the grey bar to the right of your soundfont, which will open the piano roll where you can place notes for the soundfont to play. Begin by placing one note at the a0 key if you're doing a0 to a7, or put the note on a1 if you're doing a1 to a8.

If you press the play button (which can be triggered with space), your note will play. However, if no sound occurs, then there may be a problem. Either the soundfont cannot go as low as you'd like, or the note just isn't long enough for a sound to begin. If this is the case, try extending the note a few measures or moving it up to a1 and using a1 through a8 instead. If no sound plays once again, you may need to find a new soundfont to use.

Drag your note out and listen to see if it fades out or stays consistent. If it does begin to fade out, stretch the note to a length in which the note can fully die off, otherwise, if it drones on, you only really need to make it maybe four measures long.

Now, export this file by going to the top right of FL Studio, clicking File, navigating to Export, and exporting them as OGG files. Name this one, presumably your lowest note, as a0.ogg. Move this file into your instruments folder (sfx/instruments/Whatever You Named Your Instrument's Sound Library) and repeat again with the other seven notes you need (a1 through a7 or a2 to a8).

What It Should Look Like
Now that you have your files, it should look something like this. Eight .ogg files for the notes, each named a0 to a7, and a tuning.config file. If yours looks like the picture, then you're ready to move onto the next and final section where we will complete our mod.

Side Note on Better Soundfonts
There are a few things that make samples better when using them. The longer the note is, unless the instrument is meant to play shorter notes or pizzicato or what have you, the better it works out in Starbound. Additionally, if you're trying to stick with the style found in Starbound, typically the more digital sounding the samples are the better they'll fit with the overall sound. MIDI instruments are pretty much the bottom of the barrel for these kinds of samples, but the internet is littered with these kinds of soundfonts and sound banks.
Finishing Touches
At this stage, our instrument has received almost all of the code that it needs in order to work: the sprites it'll need to be viewed by the player properly and the sounds that it'll be playing. However, we still have a few small changes to be adding into our mod to make the instrument actually use its sounds and allow the player to access the instrument.

Final Touches on the Instrument's Code
Open the instrument's file once more, and head to the last line of the code where it defines the instrument's kind.
"handPosition" : [0, 0], "twoHanded" : true, "kind" : "bugle" }
Change the value to the name of the folder where its sounds are kept (the tuning.config and .ogg files). You may also change the rarity and price of the instrument, but they won't affect much in the mod that we've currently set up.

Aside from the position of the instrument (handPosition, activeAngle, and activeHandPosition), which we'll figure out at the very end of this tutorial, we're now good move on.

Making them Accessible to the Player
Assuming that there isn't a treasure pool or crafting station at play in your mod (which I could make a separate guide on at some point if anyone would like me to), we are going to make it so that the player can craft them simply by opening their default, hand crafting menu.

Navigate to the main folder of your mod, where we have items, sfx, and our PATCH file. Create a new folder titled recipes, and inside of this folder create another folder titled emptyhands. Open a new file in your text editor and paste the following code into it:
{ "input" : [ { "item" : "WHATEVER_ITEM_IT_TAKES", "count" : 1 } ], "output" : { "item" : "YOUR_INSTRUMENTS_NAME_HERE", "count" : 1 }, "groups" : [ "plain", "objects", "all", "tools" ] }
Once pasted in, change the values that you see fit, however I recommend leaving the groups alone and making the instrument require a small amount of something for the sake of testing. In my mods, I set the input item to money (pixels) with a count of 1 when testing. You can also give yourself admin in-game and spawn items in that way.

Testing your Instrument In-Game
Now that we've completed almost everything with our instrument, we can play-test it. Make sure that you have saved everything and that your mod's folder is currently inside of your Starbound mods folder.

Once in the game, simply open up your empty hands crafting menu and find the instrument. If all has gone well, it should show up and be craftable given that you have the materials you designated.

Assuming that you now have the instrument in your inventory, get it out and start playing it! Since we have yet to set up the correct hand positions, it's expected that it may look somewhat wonky when being held, so now you may fiddle around with the instrument's held position.

Without exiting the game, go into your instrument's file and try changing the values for the following:
  • activeAngle, the angle at which the instrument is anchored when playing music
  • activeHandPosition, the position relative to the hands where the instrument is while playing
  • handPosition, the position relative to the hands where the instrument is when not playing music
Expect to need to use decimals and negative numbers during this; it's a lot of trial and error until you get the right position.

To refresh the game and show any changes made to your instrument, type /reload into the game's chat.
The End
Hopefully you found this guide helpful! I know I had fun writing it all within a night (and then editing it about a year later). If there are any problems you have while trying this out, just send me a message or comment on this and I'll get back to you as soon as I can! Or, if you have any suggestions on how I can improve this tutorial, don't be afraid to let me know.

If you'd like to see what I've done using this method, go check out my mod!
1 Comments
Dragonborn500 27 Dec, 2019 @ 2:21pm 
No comment, No problem i will give a comment that you would be happy and i love your pikmin race.