Skip to content

Commit ffb404f

Browse files
committed
Docs and formatting, bump to 0.5.1
1 parent 2ea4d30 commit ffb404f

File tree

5 files changed

+35
-16
lines changed

5 files changed

+35
-16
lines changed

CHANGELOG.md

+7-13
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11

22
# Version changelog
33

4-
## 0.5
4+
### 0.5.1
5+
6+
57

6-
### 0.5.0
8+
## 0.5
79

810
- Rename `number` module to `num`.
911
- Simplify generic `Smf<T>` to `Smf`, `SmfBytemap` and generic `parse`/`write` functions.
@@ -26,29 +28,23 @@
2628
`Smf` with prebuilt tracks use `Smf { header, tracks }` construction.
2729
- Added `Arena` to make track construction more ergonomic.
2830

29-
## 0.4
30-
3131
### 0.4.1
3232

3333
- Add support for the `.rmi` RIFF wrapper for MIDI files.
3434
- Errors are now a thin pointer in release mode.
3535
- Add a `TrackIter::running_status_mut` method.
3636
- Update `README.md` to match `0.4`.
3737

38-
### 0.4.0
38+
## 0.4
3939

4040
- `EventKind::parse` and `Event::read` no longer return event bytes.
4141
- Simplify `lenient` and `strict` features to a simple `strict` feature.
4242

4343
## 0.3
4444

45-
## 0.3.0
46-
4745
- Add support for writing MIDI files and events.
4846
- Handle running status more correctly.
4947

50-
## 0.2
51-
5248
### 0.2.2
5349

5450
- Fix pitch bend messages being read with the wrong endianness.
@@ -58,7 +54,7 @@
5854
- Update `README.md` to match the API of `0.2`.
5955
- Added an `ErrorKind::mesage` method.
6056

61-
### 0.2.0
57+
## 0.2
6258

6359
- Move error framework from `error-chain` to `failure`.
6460
- Renamed `Varlen` to `u28`.
@@ -71,8 +67,6 @@
7167
- Renamed `EventKind::read` to `EventKind::parse` to match the rest of the parse methods.
7268
- Added an optional (enabled by default) `std` feature to make the crate `no_std + alloc`.
7369

74-
## 0.1
75-
7670
### 0.1.3
7771

7872
- Rename `Fps::as_u8` and `Fps::from_u8` to `Fps::as_int` and `Fps::from_int`.
@@ -85,7 +79,7 @@
8579

8680
- Add `as_int` method to convert MIDI integers to primitives.
8781

88-
### 0.1.0
82+
## 0.1.0
8983

9084
- Initial release.
9185

Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "midly"
3-
version = "0.5.0"
3+
version = "0.5.1"
44
edition = "2018"
55
authors = ["negamartin"]
66
include = [
@@ -10,8 +10,8 @@ include = [
1010
description = "Fast and complete MIDI parser and writer"
1111
repository = "https://github.com/negamartin/midly"
1212
readme = "README.md"
13-
keywords = ["parser", "audio", "midi", "no_std"]
14-
categories = ["multimedia", "multimedia::audio", "multimedia::encoding"]
13+
keywords = ["midi", "no_std", "audio", "parser"]
14+
categories = ["multimedia::audio", "multimedia::encoding", "multimedia"]
1515
license = "Unlicense"
1616

1717
[features]

src/io.rs

+8
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ impl<'a> Cursor<'a> {
142142
cur: 0,
143143
}
144144
}
145+
145146
/// Create a cursor from a buffer and the cursor within it.
146147
pub fn from_parts(buffer: &mut [u8], cursor: usize) -> Cursor {
147148
assert!(
@@ -153,6 +154,7 @@ impl<'a> Cursor<'a> {
153154
cur: cursor,
154155
}
155156
}
157+
156158
/// Yield the underlying buffer and the cursor within it.
157159
///
158160
/// The cursor is guaranteed to be `cursor <= buffer.len()`.
@@ -164,10 +166,12 @@ impl<'a> Cursor<'a> {
164166
pub fn slice(&self) -> &[u8] {
165167
self.buf
166168
}
169+
167170
/// Get a mutable reference to the whole underlying buffer.
168171
pub fn slice_mut(&mut self) -> &mut [u8] {
169172
self.buf
170173
}
174+
171175
/// Get the position of the cursor.
172176
pub fn cursor(&self) -> usize {
173177
self.cur
@@ -177,10 +181,12 @@ impl<'a> Cursor<'a> {
177181
pub fn written(&self) -> &[u8] {
178182
&self.buf[..self.cur]
179183
}
184+
180185
/// Get a reference to the portion of the buffer that is not yet written.
181186
pub fn unwritten(&self) -> &[u8] {
182187
&self.buf[self.cur..]
183188
}
189+
184190
/// Split the buffer into the written and unwritten parts.
185191
pub fn split(&self) -> (&[u8], &[u8]) {
186192
self.buf.split_at(self.cur)
@@ -190,10 +196,12 @@ impl<'a> Cursor<'a> {
190196
pub fn written_mut(&mut self) -> &mut [u8] {
191197
&mut self.buf[..self.cur]
192198
}
199+
193200
/// Get a mutable reference to the portion of the buffer that is not yet written.
194201
pub fn unwritten_mut(&mut self) -> &mut [u8] {
195202
&mut self.buf[self.cur..]
196203
}
204+
197205
/// Split the buffer into the written and unwritten parts.
198206
pub fn split_mut(&mut self) -> (&mut [u8], &mut [u8]) {
199207
self.buf.split_at_mut(self.cur)

src/primitive.rs

+14
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ impl Format {
359359
_ => bail!(err_invalid!("invalid smf format")),
360360
})
361361
}
362+
362363
pub(crate) fn encode(&self) -> [u8; 2] {
363364
let code: u16 = match self {
364365
Format::SingleTrack => 0,
@@ -399,6 +400,7 @@ impl Timing {
399400
Ok(Timing::Metrical(u15::from(raw)))
400401
}
401402
}
403+
402404
pub(crate) fn encode(&self) -> [u8; 2] {
403405
match self {
404406
Timing::Metrical(ticksperbeat) => ticksperbeat.as_int().to_be_bytes(),
@@ -457,24 +459,31 @@ impl SmpteTime {
457459
fps,
458460
})
459461
}
462+
460463
pub fn hour(&self) -> u8 {
461464
self.hour
462465
}
466+
463467
pub fn minute(&self) -> u8 {
464468
self.minute
465469
}
470+
466471
pub fn second(&self) -> u8 {
467472
self.second
468473
}
474+
469475
pub fn frame(&self) -> u8 {
470476
self.frame
471477
}
478+
472479
pub fn subframe(&self) -> u8 {
473480
self.subframe
474481
}
482+
475483
pub fn fps(&self) -> Fps {
476484
self.fps
477485
}
486+
478487
pub fn second_f32(&self) -> f32 {
479488
self.second as f32
480489
+ ((self.frame as f32 + self.subframe as f32 / 100.0) / self.fps.as_f32())
@@ -494,6 +503,7 @@ impl SmpteTime {
494503
Ok(SmpteTime::new(hour, minute, second, frame, subframe, fps)
495504
.ok_or(err_invalid!("invalid smpte time"))?)
496505
}
506+
497507
pub(crate) fn encode(&self) -> [u8; 5] {
498508
let hour_fps = self.hour() | self.fps().as_code().as_int() << 5;
499509
[
@@ -531,6 +541,7 @@ impl Fps {
531541
_ => unreachable!(),
532542
}
533543
}
544+
534545
/// Does the conversion to a 2-bit fps code.
535546
pub(crate) fn as_code(self) -> u2 {
536547
u2::from(match self {
@@ -540,6 +551,7 @@ impl Fps {
540551
Fps::Fps30 => 3,
541552
})
542553
}
554+
543555
/// Converts an integer representing the semantic fps to an `Fps` value (ie. `24` -> `Fps24`).
544556
pub fn from_int(raw: u8) -> Option<Fps> {
545557
Some(match raw {
@@ -550,6 +562,7 @@ impl Fps {
550562
_ => return None,
551563
})
552564
}
565+
553566
/// Get the integral approximate fps out.
554567
pub fn as_int(self) -> u8 {
555568
match self {
@@ -559,6 +572,7 @@ impl Fps {
559572
Fps::Fps30 => 30,
560573
}
561574
}
575+
562576
/// Get the actual `f32` fps out.
563577
pub fn as_f32(self) -> f32 {
564578
match self.as_int() {

src/smf.rs

+3
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,7 @@ impl Header {
553553
}
554554

555555
/// An iterator over all *tracks* in a Standard Midi File.
556+
/// Created by the [`parse`](fn.parse.html) function.
556557
///
557558
/// This type is always available, even in `no_std` environments.
558559
#[derive(Clone, Debug)]
@@ -728,6 +729,7 @@ impl<'a, T: EventKind<'a>> Iterator for EventIterGeneric<'a, T> {
728729
}
729730

730731
/// An iterator over the events of a single track.
732+
/// Yielded by the [`TrackIter`](struct.TrackIter.html) iterator.
731733
///
732734
/// This iterator is lazy, it parses events as it goes, and therefore produces `Result<TrackEvent>>`
733735
/// rather than `TrackEvent`.
@@ -801,6 +803,7 @@ impl<'a> Iterator for EventIter<'a> {
801803

802804
/// An iterator over the events of a single track that keeps track of the raw bytes that make up
803805
/// each event.
806+
/// Created by the [`EventIter::bytemapped`](struct.EventIter.html#method.bytemapped) method.
804807
///
805808
/// This iterator is lazy, it parses events as it goes, and therefore produces
806809
/// `Result<(&[u8], TrackEvent)>>` rather than just `(&[u8], TrackEvent)`.

0 commit comments

Comments
 (0)