Tutorials/Adding Sounds To Animations

Revision as of 07:00, 8 March 2024 by Frank The Farmer (talk | contribs) (Sounds like there's a new animation tutorial)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Preface

This is an advanced tutorial that will show you how to add sounds to your custom Pokémon's animations. It is required that you are familiar with the process of creating a custom Pokémon. You will need a finished model, an animation to apply the sounds to, and a sound file to apply to the animation. While the steps in this guide can be used to add any sound to any animation, it will primarily focus on adding a cry to your Pokémon.

Acquiring a valid ogg sound file to use is entirely on you. You will either have to make or find one.

Recommended Tools

This section will list some free tools and resources that can help you format your files and folders.

  • A Text Editor - If you are not using one already, they can be helpful for editing multiple files at once
    • Recommendations:
      • Visual Studio Code - You can open your entire addon folder and access all content within. Can also play sound files. Helps you visualize the folder structure of your addon.
  • Audio Editing Software - Minecraft only plays ogg sound files. You'll need something to convert audio files into this format.
    • Recommendations:
      • Audacity - Free software with many video tutorials on YouTube. Allows you to edit the sound file and export it to ogg format.
  • Blockbench - You will need it to load, edit, and export your animations.
  • The sounds.json Wiki Page - Lists some helpful properties you can use when creating the sounds JSON.


Step 1: Arrange The Folders Of Your Addon

Adding sounds would require you to add a sounds.json and one new branch of sound folders to your existing addon. For the sake of clarity, a complete addon with sounds would be arranged like so:

Folder Structure

  • (addon name)
    • pack.mcmeta
    • assets
      • cobblemon
        • bedrock
          • pokemon
            • animations
              • <folder named after your pokemon>
                • <pokemon>.animation.json
            • models
              • <folder named after your pokemon>
                • <pokemon>.geo.json
            • posers
              • <pokemon>.json
            • resolvers
              • <folder named after your pokemon>
                • 0_<pokemon>_base.json
        • lang
          • en_us.json
        • sounds.json
        • sounds
          • pokemon
            • <folder named after your pokemon>
              • <sound>.ogg
        • textures
          • pokemon
            • <folder named after your pokemon>
              • <pokemon>.png
              • <pokemon>_shiny.png
    • data
      • cobblemon
        • spawn_pool_world
          • <pokemon>.json
        • species
          • custom
            • <pokemon>.json


Arrange your asset folder similarly to the tree above so you can simply insert any new files with ease.

Step 2: Adding The Sound Keyframe

To get started, you will need one or more valid ogg sound files to use for your animations. Create one if you haven't already. You will be loading and editing your asset files in Blockbench for this step.

  1. Prepare your sound file(s)
  2. Open up Blockbench and load your model, texture, and animation files.
  3. Navigate to the animate tab and select the animation you want to add sounds to
    • If you don't have one, you can make one now. Making a simple cry animation where the Pokémon opens its mouth or some similar motion is recommended.
  4. Once your animation is selected, navigate to the TIMELINE window and click on the Animate Effects button.
  5. Click on the + button for sound to generate a new sound keyframe
    • The KEYFRAME window should have opened up once the keyframe was made
  6. Navigate to the KEYFRAME window and create an effect name for this keyframe
    • This would create a sound event which Minecraft can use to play a sound when this animation is played.
    • In the case of making cries, this effect should be named pokemon.<pokemon>.cry
      • Example: pokemon.charizard.cry
You should end up with something similar to Charizard's cry animation.
  1. Click on the Select Keyframe File located to the right of your effect name.
  2. Select and upload one of your prepared sound files
    • This will let the sound play in Blockbench whenever the sound keyframe is played in the animation.
  3. Adjust and edit the animation to your liking.
    • Now you can hear and see your animation. Should be easier to make adjustments.
  4. Once satisfied with your animation, save and export your animations to your addon.
    • Be sure to replace the old animation json in the folder. This new export has the data required to play the sound.
    • If you made any changes to the model or texture, be sure to export those again too.
    • If you just made a cry animation now, remember to add that animation to your Pokémon's poser file.
    • At most, you should have exported your animations, model, and texture. Don't worry about the sound file yet. Those will be arranged next.


Step 3: Arrange Your Sounds

Your sound files should be kept in the same format as Cobblemon's sound files. This should make it easier to mimic the sounds.json in the next step.

  1. Insert your ogg sound file into the folder named after your pokemon located deeper in the sounds folder.
  2. Rename this file to match the cry sound format of <pokemon>_cry.ogg
    • Example: charizard_cry.ogg
    • Can actually be named whatever you want. Just make sure you reference it correctly in Step 4.

If done correctly, your sound file should have a file address similar to this:
<your addon name> > assets > cobblemon > sounds > pokemon > <your pokemon>

You should end up with one or more <pokemon>_cry.ogg files in your Pokémon's sound folder. Depends on what you're making.

Step 4: Create The sounds.json

The next step is to create a sounds JSON to play your sounds in Minecraft. The sounds.json is responsible for assigning sound files to any sound events. This file is not exclusive to Cobblemon. You can learn more about it from the Minecraft Wiki.

The name of your sound event just needs to match the name of the effect you made in the previous section. It does not need to be a cry.

  1. Create a new text file and name it sounds.json
    • Make sure this new file name ends in .json and not any other file extension like .txt.
  2. Open this new JSON in your preferred text editor
  3. Copy and paste this entire code block example into the JSON
    • If you have more than one cry file, you can list more file addresses. They would have equal chances to be played by default.
{
   "pokemon.charizard.cry": {
       "sounds": ["cobblemon:pokemon/charizard/charizard_cry"]
   }
}
  1. Change all instances of "charizard" to be your Pokémon's name instead.
  2. If desired, add any special properties you want like subtitles.
  3. Save the file
  4. Insert this finished sounds.json into the cobblemon folder of your addon.
    • It must be in this folder and nowhere else. Otherwise, it wont be read.
    • Should be seated next to your sounds folder.

Step 5: Test Your Addon In Game

The final step is to make sure the sounds work.

  1. Copy your addon folder and place it in the "resourcepacks" and appropriate "datapacks" folder in the Minecraft root directory.
  2. Start up Minecraft and click on Options, then Resource Packs. Select your pack to load it.
    • Make sure you are using a version of your addon that includes all the new files and re-exports you just made.
  3. Load/create a Creative world save that contains your addon in the "datapacks" folder.
  4. Once in the world, you can run the command /pokegive <target pokemon>.
    • Since cries are only played when a Pokémon is brought out of the pokeball or sent into battle, you need to have the Pokémon in your party.
  5. Send out your Pokémon.
  6. If you assigned the sound properly to a cry animation, it should play the sound now.
    • If you assigned it to another animation, have your Pokémon perform that animation instead and listen for the sound.

If the sound is not being played, then something is not assigned properly. Make sure you followed the steps of this guide correctly and that your folder and file names are valid. Any capital letters or spaces in a file or folder name makes it unreadable. Additional help can be found in the Cobblemon Discord server.