Skip to content
This repository was archived by the owner on Jun 26, 2025. It is now read-only.

Commit b2b08ff

Browse files
committed
feat: midi
1 parent ed6521a commit b2b08ff

File tree

8 files changed

+320
-265
lines changed

8 files changed

+320
-265
lines changed

competition/midi/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
target
2+
*.mid
3+
*.midi
Lines changed: 44 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ version = "0.1.0"
44
edition = "2021"
55

66
[dependencies]
7+
midly = "0.5.3"
78
rand = "0.9.1"
89
rand_chacha = "0.9.0"
9-
flac-encoder = { git = "https://github.com/jaspwr/flac-encoder-rs", optional = true }
1010

11-
[features]
12-
flac = ["dep:flac-encoder"]

competition/midi/prob.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---toml
2+
[fuzz]
3+
exec = ["cargo", "run", "--release", "--", "generate"]
4+
env = {}
5+
6+
[judge]
7+
exec = ["cargo", "run", "--release", "--quiet", "--", "validate"]
8+
9+
[problem]
10+
points = 15
11+
difficulty = 2
12+
---
13+
14+
# 🎹 MIDI
15+
Jane wrote a song and wants to build a synthesizer to play it. As individual notes on a synthesizer require separate oscillators, she needs to know the minimum number of oscillators required to play her song.
16+
17+
Given a sequence of MIDI messages, determine maximum number of notes playing at the same time.
18+
19+
## Input Format
20+
Each line represents a [MIDI message](https://www.mixagesoftware.com/en/midikit/help/HTML/midi_events.html). Each message contains a time in milliseconds, a MIDI opcode and a note number (ignore velocity).
21+
* The two relevant MIDI opcodes are `0x8c` for note off and `0x9c` for note on.
22+
* The note number is an integer between 0 and 127.
23+
24+
```
25+
0 156 60
26+
1000 140 60
27+
500 156 64
28+
2000 140 64
29+
2000 156 63
30+
2100 140 63
31+
```
32+
In this example, note 60 is played from 0 to 1000 ms, note 64 is played from 500 to 2000 ms and note 63 is played from 2000 ms to 2100 ms.
33+
* The maximum number of notes playing at the same time is 2.
34+
* If a note off and on event are sent on the same frame (such as in the case with notes 64 and 63), they do not overlap.
35+
* If a note is turned on again while it's already held or turned off while it's already released, that message does nothing.
36+
37+
## Output Format
38+
Output a single integer, the maximum number of notes playing at the same time.

0 commit comments

Comments
 (0)