@@ -8,24 +8,31 @@ use crate::Error;
8
8
9
9
/// Information regarding how audio file should be processed.
10
10
///
11
- /// Refer to the [BSMG Wiki](https://bsmg.wiki/mapping/map-format/audio.html) for language-agnostic documentation.
12
- #[ derive( Debug , PartialEq , Eq , Deserialize , Serialize ) ]
11
+ /// Refer to the [BSMG Wiki](https://bsmg.wiki/mapping/map-format/audio.html)
12
+ /// for language-agnostic documentation.
13
+ #[ derive( Debug , Clone , PartialEq , Eq , Deserialize , Serialize ) ]
13
14
#[ serde( rename_all = "camelCase" ) ]
14
15
#[ serde( default ) ]
15
16
pub struct Audio {
16
17
/// Should be "4.0.0", that's the currently supported schema version.
17
18
pub version : String ,
18
19
/// Used for verifying internal relationships and leaderboard integrity.
19
20
///
20
- /// Refer to the [BSMG Wiki](https://bsmg.wiki/mapping/map-format.html#checksums) for language-agnostic documentation.
21
+ /// Refer to the
22
+ /// [BSMG Wiki](https://bsmg.wiki/mapping/map-format.html#checksums) for
23
+ /// language-agnostic documentation.
21
24
pub song_checksum : String ,
22
25
/// Measures duration of audio file in samples.
23
26
///
24
- /// Refer to the [BSMG Wiki](https://bsmg.wiki/mapping/map-format/audio.html#sample-count) for language-agnostic documentation.
27
+ /// Refer to the
28
+ /// [BSMG Wiki](https://bsmg.wiki/mapping/map-format/audio.html#sample-count)
29
+ /// for language-agnostic documentation.
25
30
pub song_sample_count : u32 ,
26
31
/// Caches quality level of audio file.
27
32
///
28
- /// Refer to the [BSMG Wiki](https://bsmg.wiki/mapping/map-format/audio.html#song-frequency) for language-agnostic documentation.
33
+ /// Refer to the
34
+ /// [BSMG Wiki](https://bsmg.wiki/mapping/map-format/audio.html#song-frequency)
35
+ /// for language-agnostic documentation.
29
36
pub song_frequency : u32 ,
30
37
/// See [`BpmData`].
31
38
pub bpm_data : Vec < BpmData > ,
@@ -47,40 +54,52 @@ impl Default for Audio {
47
54
}
48
55
49
56
impl Audio {
50
- /// Instatiates an [`Audio`] from an audio file, typically named `BPMInfo.dat`.
57
+ /// Instatiates an [`Audio`] from an audio file, typically named
58
+ /// `BPMInfo.dat`.
51
59
pub fn from_file ( path : impl AsRef < Path > ) -> Result < Self , Error > {
52
60
Ok ( serde_json:: from_str ( & fs:: read_to_string ( path) ?) ?)
53
61
}
54
62
}
55
63
56
64
/// Alters BPM of specified region.
57
65
///
58
- /// Refer to the [BSMG Wiki](https://bsmg.wiki/mapping/map-format/audio.html#bpm-regions) for language-agnostic documentation.
59
- #[ derive( Debug , PartialEq , Eq , Default , Deserialize , Serialize ) ]
66
+ /// Refer to the
67
+ /// [BSMG Wiki](https://bsmg.wiki/mapping/map-format/audio.html#bpm-regions) for
68
+ /// language-agnostic documentation.
69
+ #[ derive( Debug , Clone , PartialEq , Eq , Default , Deserialize , Serialize ) ]
60
70
#[ serde( default ) ]
61
71
pub struct BpmData {
62
72
/// Start sample index.
63
- pub si : usize ,
73
+ #[ serde( rename = "si" ) ]
74
+ pub start_index : usize ,
64
75
/// End sample index.
65
- pub ei : usize ,
76
+ #[ serde( rename = "ei" ) ]
77
+ pub end_index : usize ,
66
78
/// Start beat.
67
- pub sb : usize ,
79
+ #[ serde( rename = "sb" ) ]
80
+ pub start_beat : usize ,
68
81
/// End beat.
69
- pub eb : usize ,
82
+ #[ serde( rename = "eb" ) ]
83
+ pub end_beat : usize ,
70
84
}
71
85
72
86
/// Applies normalization to loudness of audio file within specified region.
73
87
///
74
- /// Refer to the [BSMG Wiki](https://bsmg.wiki/mapping/map-format/audio.html#lufs-data) for language-agnostic documentation.
75
- #[ derive( Debug , PartialEq , Eq , Default , Deserialize , Serialize ) ]
88
+ /// Refer to the
89
+ /// [BSMG Wiki](https://bsmg.wiki/mapping/map-format/audio.html#lufs-data) for
90
+ /// language-agnostic documentation.
91
+ #[ derive( Debug , Clone , PartialEq , Eq , Default , Deserialize , Serialize ) ]
76
92
#[ serde( default ) ]
77
93
pub struct LufsData {
78
94
/// Start sample index.
79
- pub si : usize ,
95
+ #[ serde( rename = "si" ) ]
96
+ pub start_index : usize ,
80
97
/// End sample index.
81
- pub ei : usize ,
98
+ #[ serde( rename = "ei" ) ]
99
+ pub end_index : usize ,
82
100
/// Loudness.
83
- pub l : usize ,
101
+ #[ serde( rename = "l" ) ]
102
+ pub loudness : usize ,
84
103
}
85
104
86
105
#[ cfg( test) ]
@@ -100,15 +119,15 @@ mod tests {
100
119
song_sample_count : 1149214 ,
101
120
song_frequency : 44100 ,
102
121
bpm_data : vec ! [ BpmData {
103
- si : 0 ,
104
- ei : 1149214 ,
105
- sb : 0 ,
106
- eb : 26 ,
122
+ start_index : 0 ,
123
+ end_index : 1149214 ,
124
+ start_beat : 0 ,
125
+ end_beat : 26 ,
107
126
} ] ,
108
127
lufs_data : vec ! [ LufsData {
109
- si : 0 ,
110
- ei : 1149214 ,
111
- l : 0 ,
128
+ start_index : 0 ,
129
+ end_index : 1149214 ,
130
+ loudness : 0 ,
112
131
} ] ,
113
132
}
114
133
}
0 commit comments