User Tools

Site Tools


development:csdk:music

Importing and Playing Music

Just like for graphical assets, sound assets need to be stored in the assets/<your dir>/ directory and require to run make import to generate the necessary files. Contrary to the graphical assets they do not need to be loaded explicitly.

There are two types of sounds that can be played on the GameTank:

  • Songs
  • Sound Effects (SFX)

Enabling sounds

Enabling sounds requires the following in C:

  • Add #include “music.h” as an include file
  • Call init_dynawave() and init_music() at the beginning of the program
  • Call tick_music() for each screen refresh

e.g.

  init_dynawave();
  init_music();
  
  while (1) {
      // start a sound
      await_draw_queue();
      sleep(1);
      flip_pages();
      tick_music();
  }

Songs

Songs are imported from MIDI files and are called using play_song(), e.g.

#include "gen/assets/music.h"
play_song(&ASSET__music__mytune_mid, REPEAT_LOOP);

Sound Effects (SFX)

SFX are mini-sample .bin files generated by tools such as Sound Sculptor

#include "gen/assets/sfx.h"
play_sound_effect(&ASSET__sfx__bang_bin , 1);
development/csdk/music.txt · Last modified: 2024/09/15 20:20 by ecdhe