Skip to content

obsi.audio

simadude edited this page Oct 21, 2023 · 5 revisions

This module is designed for playing noteblock music. Some of the stuff was made specifically for the developer to handle themselves.

Here are some file formats that are supported:

  • NBS - Note Block Studio format that is used by Open Note Block Studio.
  • ONB - Obsi Note Block format that was designed specifically for Obsi game engine.

Editors for the supported file formats:

Functions of obsi.audio:

function description
obsi.audio.playNote Plays a single note of any instrument, with any pitch, after any or none delay
obsi.audio.playSound Same as obsi.audio.playNote, but plays any sound using Speaker.playSound
obsi.audio.isAvailable Checks if Obsi can use any of the speakers attached.
obsi.audio.refreshChannels Refreshes the list of speakers (channels).
obsi.audio.getChannelCount Returns the number of speakers (channels) that Obsi can use.
obsi.audio.notesPlaying Returns the number of notes that are queued for playing using audio.playNote
obsi.audio.newSound Creates a new obsi.Audio object that can be used later to play music.
obsi.audio.play Plays an obsi.Audio object with optional looping.
obsi.audio.stop Stops playing the music. If the obsi.Audio is provided, then all of the playing instances are stopped.
obsi.audio.isID Checks if the playing music at the specific ID is indeed the obsi.Audio object.
obsi.audio.pause Pauses the playing music. If the obsi.Audio is provided, then all of the playing instances are paused.
obsi.audio.unpause Unpauses the paused music. If the obsi.Audio is provided, then all of the paused instances are unpaused.
obsi.audio.isPaused Checks if the music at the specific ID is paused or not. Will return false if there is no song at that ID.
obsi.audio.setVolume Sets the volume at the specific ID is paused or not. If obsi.Audio is provided, then will set the volume of every playing audio of that source.
obsi.audio.getVolume Returns the volume at the specific ID. Returns 0 if audiobuffer at the ID is empty.

Functions

obsi.audio.playNote

Plays a single note of any instrument, with any pitch, after any or none delay.

Declared as:

obsi.audio.playNote(channel: integer, instrument: string, pitch: number, volume?: number, latency?: number)

obsi.audio.playSound

Same as obsi.audio.playNote, but plays any sound using Speaker.playSound

Declared as:

obsi.audio.playSound(channel: integer, sound: string, pitch: number, volume?: number, latency?: number)

obsi.audio.isAvailable

Checks if Obsi can use any of the speakers attached.

Declared as:

obsi.audio.isAvailable() -> boolean

obsi.audio.refreshChannels

Refreshes the list of speakers (channels).

Declared as:

obsi.audio.refreshChannels()

obsi.audio.getChannelCount

Returns the number of speakers (channels) that Obsi can use.

Declared as:

obsi.audio.getChannelCount() -> number

obsi.audio.notesPlaying

Returns the number of notes that are queued for playing using audio.playNote

Declared as:

obsi.audio.notesPlaying() -> number

obsi.audio.newSound

Creates a new obsi.Audio object that can be used later to play music.

Declared as:

obsi.audio.newSound(soundPath: string) -> obsi.Audio

obsi.audio.play

Plays an obsi.Audio object with optional looping. Returns the ID where the audio is playing in the audiobuffer.

Declared as:

obsi.audio.play(source: obsi.Audio, loop?: boolean) -> number

obsi.audio.stop

Stops playing the music. If the obsi.Audio is provided, then all of the playing instances are stopped.

Declared as:

obsi.audio.stop(source: obsi.Audio)
-- or
obsi.audio.stop(id: number)

obsi.audio.isID

Checks if the playing music at the specific ID is indeed the obsi.Audio object.

Declared as:

obsi.audio.isID(source: obsi.Audio, id: integer) -> boolean

obsi.audio.pause

Pauses the playing music. If the obsi.Audio is provided, then all of the playing instances are paused.

Declared as:

obsi.audio.pause(source: obsi.Audio)
-- or
obsi.audio.pause(id: integer)

obsi.audio.unpause

Unpauses the paused music. If the obsi.Audio is provided, then all of the paused instances are unpaused.

Declared as:

obsi.audio.unpause(source: obsi.Audio)
-- or
obsi.audio.unpause(id: integer)

obsi.audio.isPaused

Checks if the music at the specific ID is paused or not. Will return false if there is no song at that ID.

Declared as:

obsi.audio.isPaused(id: integer) -> boolean

obsi.audio.setVolume

Sets the volume at the specific ID is paused or not. If obsi.Audio is provided, then will set the volume of every playing audio of that source.

Declared as:

obsi.audio.setVolume(source: obsi.Audio, volume: number)
-- or
obsi.audio.setVolume(id: integer, volume: number)

obsi.audio.getVolume

Returns the volume at the specific ID. Returns 0 if audiobuffer at the ID is empty.

Declared as:

obsi.audio.getVolume(id: integer) -> number