Korok.io

Audio

Korok supports two types of Player:

  • Music Player - can only play one sound at a time.
  • Effect Player - can play serveral sounds at the same time.

Music player is designed to play long music tracks, effect player is used to play short sound effect. Korok only supports Ogg/Vorbis and WAV file format.

Play

You can load audio and play like:

                        
func (*MainScene) Load() {
    // stream the file from disk, good for longer music tracks
    asset.Audio.Load("ambient.ogg", true) 

    // load the file into memory, good for short sound effects
    asset.Audio.Load("birds.wav", false)  
}

func (m *MainScene) OnEnter(g *game.Game) {
    ogg, _ := asset.Audio.Get("ambient.ogg")
    wav, _ := asset.Audio.Get("birds.wav")

    audio.PlayMusic(ogg)
    audio.PlayEffect(wav)
}
                        

By default, music player can only play streamed sound and effect player can only play in-memory static sound, this is a convention in Korok.