Skip to main content

nbs/noteblocks/
note.rs

1use super::instrument::Instrument;
2/// A Note is a Noteblock
3#[derive(Debug)]
4pub struct Note {
5    /// The instrument of the note block.
6    /// This is 0-15, or higher if the song uses custom instruments.
7    pub instrument: Instrument,
8    /// The key of the note block, from 0-87, where 0 is A0 and 87 is C8.
9    /// 33-57 is within the 2-octave limit.
10    pub key: i8,
11    /// The velocity/volume of the note block, from 0% to 100%.
12    /// Only avabile in the new format version 4.
13    pub velocity: Option<i8>,
14    /// The stereo position of the note block, from 0-200.
15    /// 100 is center panning.
16    /// Only avabile in the new format version 4.
17    pub panning: Option<i8>,
18    /// The fine pitch of the note block in cents.
19    /// The max in Note Block Studio is limited to -1200 and +1200.
20    /// 0 is no fine-tuning.
21    /// ±100 cents is a single semitone difference.
22    /// Only avabile in the new format version 4.
23    pub pitch: Option<i16>,
24}
25
26impl Note {
27    pub fn new(
28        instrument: Instrument,
29        key: i8,
30        velocity: Option<i8>,
31        panning: Option<i8>,
32        pitch: Option<i16>,
33    ) -> Self {
34        Note {
35            instrument,
36            key,
37            velocity,
38            panning,
39            pitch,
40        }
41    }
42}