You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Offers an easy way to play note block songs in your application
11
12
- Good MIDI importer
12
13
- Supports most MIDI files
13
14
- Supports velocity and panning
14
15
- Can handle Black MIDI files
15
16
- Supports all NBS versions
16
17
- Version 0 - 5
17
-
- Supports undocumented features like Tempo Changers
18
+
- Supports Tempo Changers
18
19
- Many tools for manipulating songs
19
20
- Optimize songs for use in Minecraft (Transposing, Resampling)
20
21
- Resampling songs with a different TPS
@@ -34,29 +35,14 @@ If you just want the latest jar file you can download it from [GitHub Actions](h
34
35
## Usage
35
36
### Concepts and terminology
36
37
The main class of NoteBlockLib is the ``NoteBlockLib`` class. It contains all the methods for reading, writing and creating songs.
37
-
The utils for manipulating songs are located in the ``util`` package.
38
+
Some utils for manipulating and getting metrics about songs are located in the ``util`` package.
38
39
39
-
#### Song
40
-
Song is a wrapper class around the Header, Data and the View of a song.
41
-
The Header and Data classes are the low level representation of a song. They are used by I/O operations.
42
-
The View class is a high level representation of a song and is generated from the Header and Data classes.
40
+
The ``Song`` class is the main data structure for parsed songs. It contains generalized and format specific data.
41
+
The generalized data only includes the most important data of songs like the format, the title, the description, the author, the notes and the tempo.
42
+
To access format specific data you have to cast the song instance to a specific format (``NbsSong`` for example).
43
+
Most of the time you will only need the generalized data and all the methods for manipulating, playing and converting songs will work with the generalized data.
43
44
44
-
#### Header
45
-
The header usually contains the metadata of a song. This includes the author, the original author, the description, the tempo, the delay and the length of the song.
46
-
47
-
#### Data
48
-
The data contains all the notes of a song. This includes the tick at which the note should be played, the instrument and the key.
49
-
50
-
#### SongView
51
-
The SongView is a high level and generalized representation of a song. It contains only the most important information of a song.
52
-
The view is used for most operations like playing a song or manipulating it. Due to the fact that the view is a high level representation of a song, it is not suitable for I/O operations directly.
53
-
To create a low level representation (Song) from the view again you can use the ``NoteBlockLib.createSong(view, format)`` method.
54
-
The returned song only has the bare minimum of data required to be written to a file. You can use the setter methods of the Header and Data class to add more data to the song.
55
-
The view is generated by default only once when the Song class is created. If you want to refresh the view you can use the ``Song.refreshView()`` method.
56
-
57
-
#### Note
58
-
The Note class is a wrapper class around the instrument and key of a note. Each format has its own Note class which can have additional data like volume or panning.
59
-
One way of accessing that data is through the use of the ``NoteWithVolume`` and ``NoteWithPanning`` classes.
45
+
All data structures in NoteBlockLib are mutable and can be modified at any time. All data structures also have a ``copy`` method to create a deep copy of the data structure.
60
46
61
47
### Reading a song
62
48
To read a song you can use the ``NoteBlockLib.readSong(<input>, [format])`` method.
@@ -67,13 +53,13 @@ The format is optional and can be used to specify the format of the input. If th
67
53
To write a song you can use the ``NoteBlockLib.writeSong(<song>, <output>)`` method.
68
54
69
55
### Creating a song
70
-
The easiest way to create a song is to create a SongView and then use the ``NoteBlockLib.createSongFromView(<view>, [format])`` method to create a Song from it.
71
-
Alternatively you can create a Song directly by using the ``new Song(null, <header>, <data>)`` constructor. This requires you to create the Header and Data yourself.
56
+
The easiest way to create a song is to create a ``new GenericSong()``, fill in the data and then use the ``NoteBlockLib.convertSong(<song>, <format>)`` method to create a format specific song from it.
57
+
Alternatively you can create a format specific Song directly by using for example the ``new NbsSong()`` constructor. This requires you to fill in all the format specific data yourself.
72
58
73
59
### Playing a song
74
60
To play a song you can use the ``SongPlayer`` class. The SongPlayer provides basic controls like play, pause, stop and seek.
75
-
To instantiate it you can use the ``new SongPlayer(<songView>, <callback>)``constructor.
76
-
The callback contains basic methods like ``onFinished`` and``playNote``to handle the playback of the song.
61
+
To create a SongPlayer implementation, you have to create a class which extends the ``SongPlayer``class.
62
+
The SongPlayer class requires you to implement the``playNotes``method, but also offers several optional methods like ``onFinished``.
77
63
78
64
### Manipulating a song
79
65
There are multiple utils for manipulating a song.
@@ -84,104 +70,107 @@ This is very useful if you want to export the song as a schematic and play it in
84
70
85
71
#### MinecraftDefinitions
86
72
The MinecraftDefinitions class contains definitions and formulas for Minecraft related manipulations.
87
-
This includes multiple methods for getting notes within the Minecraft octave range, converting between Minecraft and NBS id systems and more.
73
+
This for example includes multiple methods for getting notes within the Minecraft octave range, such as transposing them.
88
74
89
75
#### SongUtil
90
-
This class has some general utils for manipulating songs like applying a modification to all notes of a song.
76
+
This class has some general utils for getting various metrics about a song.
91
77
92
78
## Examples
93
79
**Reading a song, transposing its notes and writing it back**
94
80
```java
95
-
Song<?, ?, ?> song =NoteBlockLib.readSong(newFile("input.nbs"));
81
+
Song song =NoteBlockLib.readSong(newFile("input.nbs"));
0 commit comments