|
1 | | -# nbs-audio |
2 | | - An utility to render note block songs to a variety of audio formats |
| 1 | +# nbswave |
| 2 | + |
| 3 | +A Python package to render note block songs to a variety of audio formats. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +nbswave is a Python package aimed at rendering note block songs from [Open Note Block Studio](https://opennbs.org/) to audio tracks. |
| 8 | + |
| 9 | +## Setup |
| 10 | + |
| 11 | +The package can be installed with `pip`. |
| 12 | + |
| 13 | +```shell |
| 14 | +$ pip install nbswave |
| 15 | +``` |
| 16 | + |
| 17 | +In order to use the package, [FFmpeg](https://www.ffmpeg.org/) must be available: |
| 18 | + |
| 19 | +1. Download precompiled binaries for `ffmpeg` and `ffprobe` [here](https://ffbinaries.com/downloads). |
| 20 | +2. Add the destination folder to your `PATH`, or, alternatively, place both executables in the root folder of the project. |
| 21 | + |
| 22 | +## Usage |
| 23 | + |
| 24 | +```python |
| 25 | +from nbswave import * |
| 26 | + |
| 27 | +render_audio("song.nbs", "output.mp3") |
| 28 | +``` |
| 29 | + |
| 30 | +The output format will be detected automatically based on the file extension. |
| 31 | + |
| 32 | +### Custom instruments |
| 33 | + |
| 34 | +In order to render songs with custom instruments, you have a few options: |
| 35 | + |
| 36 | +1. Copy the sounds manually to the `sounds` folder |
| 37 | + |
| 38 | +2. Pass the path to a folder (or ZIP file) containing custom sounds: |
| 39 | + |
| 40 | +```python |
| 41 | +from pathlib import Path |
| 42 | + |
| 43 | +nbs_sounds_folder = Path.home() / "Minecraft Note Block Studio" / "Data" / "Sounds" |
| 44 | +render_audio("song.nbs", "output.mp3", custom_sound_path=nbs_sounds_folder) |
| 45 | +``` |
| 46 | + |
| 47 | +If any sound file used in the song is not found in that location, a `MissingInstrumentException` will be raised. This behavior can be suppressed with the following argument: |
| 48 | + |
| 49 | +```python |
| 50 | +render_audio("song.nbs", "output.mp3", ignore_missing_instruments=True) |
| 51 | +``` |
| 52 | + |
| 53 | +### Advanced usage |
| 54 | + |
| 55 | +For more advanced use cases where you might need more control over the export process, it's possible to use the `SongRenderer` class. This will allow you to load custom instruments from multiple sources, as well as query which instruments are still missing: |
| 56 | + |
| 57 | +```python |
| 58 | +from nbswave import * |
| 59 | + |
| 60 | +renderer = SongRenderer("song.nbs") |
| 61 | + |
| 62 | +renderer.load_instruments(nbs_sounds_folder) |
| 63 | +renderer.load_instruments("some_more_instruments.zip") |
| 64 | + |
| 65 | +renderer.missing_instruments() |
| 66 | +``` |
| 67 | + |
| 68 | +## Contributing |
| 69 | + |
| 70 | +Contributions are welcome! Make sure to open an issue discussing the problem or feature suggestion before creating a pull request. |
| 71 | + |
| 72 | +This project uses [poetry](https://python-poetry.org/) for managing dependencies. Make sure to install it, and run: |
| 73 | + |
| 74 | +```shell |
| 75 | +$ poetry install |
| 76 | +``` |
| 77 | + |
| 78 | +This project follows the [black](https://github.com/psf/black) code style. Import statements are sorted with [isort](https://pycqa.github.io/isort/). |
| 79 | + |
| 80 | +```shell |
| 81 | +$ poetry run isort nbswave |
| 82 | +$ poetry run black nbswave |
| 83 | +$ poetry run black --check nbswave |
| 84 | +``` |
| 85 | + |
| 86 | +--- |
| 87 | + |
| 88 | +License - [MIT](https://github.com/Bentroen/nbswave/blob/main/LICENSE) |
0 commit comments