https://github.com/dockyardmc/dockyard-nbs
Dockyard library that implements the NBS file format and allows for playing noteblock songs in-game
https://github.com/dockyardmc/dockyard-nbs
Last synced: 5 months ago
JSON representation
Dockyard library that implements the NBS file format and allows for playing noteblock songs in-game
- Host: GitHub
- URL: https://github.com/dockyardmc/dockyard-nbs
- Owner: DockyardMC
- License: mit
- Created: 2024-09-12T15:48:49.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-09-14T18:59:10.000Z (almost 2 years ago)
- Last Synced: 2025-04-11T10:08:18.353Z (about 1 year ago)
- Language: Kotlin
- Size: 18.6 KB
- Stars: 3
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 🎶 Dockyard NBS Library🎵
dockyard-nbs is a dockyardmc library that implements the [NBS file format](https://opennbs.org/nbs) and allows for playing noteblock songs in-game
## Installation
**Kotlin DSL**
```kotlin
repositories {
maven {
name = "devOS"
url = uri("https://mvn.devos.one/releases")
}
}
dependencies {
implementation("io.github.dockyardmc:dockyard-nbs:1.0")
}
```
## Usage
You can parse the nbs file either using `NBSFile.fromFile(file)` or `NBSReader.read(file)`. You then get a `NBSTrack` class and you can then add a "listener" to it and use the `start()` method to play it
```kotlin
val track = NBSReader.read(File("./nbs/bad_apple.nbs"))
track.listeners.add(player)
track.start()
```
You can change the volume by either:
- Setting the `volume` field manually
- Using `fadeTo(volume, time)`, `fadeFromZero(time)`, `fadeToZero(time)` functions which interpolate the volume over time
You can control the playback of the track by using:
- `stop()` to stop the playback
- `start()` to start/resume playback
- `seek(time)` to skip
- `reset()` to stop the track and reset it to initial state
- `dispose()` to get dispose the track and the timer
You can also change the `looping` field to enable/disable automatic looping