Class Song

Represents a note block song with helper methods.


import { Note, Song } from "@nbsjs/core";

// Create the song
const song = new Song();
song.name = "Hello";
song.description = "World!";

// Add a layer and a note
const layer = song.layers.create();
const note = new Note(0, {
"key": 42
});

// Add the note to the layer
layer.notes.set(0, note);

// Alternatively, create a note directly on the layer
layer.notes.add(4, 0, {
"key": 24
});

console.dir(song.layers);

Properties

author?: string

Author of the song.

autoSave: SongAutoSave = ...

Auto-save options for the song.

blocksAdded: number = 0

Number of times the user has added a note block.

This value does not update when methods such as LayerNotes#add is used!

blocksRemoved: number = 0

Number of times the user have removed a note block.

This value does not update when methods such as LayerNotes#delete is used!

description?: string

Description of the song.

importName?: string

Imported MIDI/Schematic file name.

instruments: SongInstruments = ...

Instruments of the song.

layers: SongLayers = ...

Layers within the song.

leftClicks: number = 0

Number of times the user has left-clicked on the song.

This value does not update when methods such as LayerNotes#add is used!

loop: SongLoop = ...

Looping options for the song.

minutesSpent: number = 0

Number of minutes spent on the song.

This value is not updated by nbs.js!

name?: string

Name of the song.

originalAuthor?: string

Original author of the song.

rightClicks: number = 0

Number of times the user has right-clicked on the song.

This value does not update when methods such as LayerNotes#delete is used!

timeSignature: number = 4

Time signature of the song.

From 2 to 8.

If this is 3, then the signature is 3/4.
version: number = 5

Version of NBS the song has been made with.

Currently, this does not affect the exported song structure properly, and should always be upgraded to 5.

https://opennbs.org/nbs

Methods

  • Playtime of the song in milliseconds.

    Returns number

    This currently does not support Note Block Studio's unofficial tempo changer layer.

  • Tick of the last measure of the song.

    Returns number

  • Length of the song in ticks.

    Returns number

  • Tempo of the song in ticks per second.

    Returns number

  • Amount of milliseconds each tick takes.

    Returns number

  • Sets the song's tempo in ticks per second.

    Parameters

    • ticksPerSecond: number

    Returns void

    Adjusts the time per tick upon modification.

  • Sets the song's amount of milliseconds per tick.

    Parameters

    • milliseconds: number

    Returns void

    Adjusts the tempo upon modification.

Constructors