Skip to content

Commit

Permalink
classical Big D
Browse files Browse the repository at this point in the history
  • Loading branch information
chestnutcase committed Oct 2, 2019
1 parent e9d8fad commit ac766d2
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 0 deletions.
1 change: 1 addition & 0 deletions canon_in_dddddddddd/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.DS_Store
49 changes: 49 additions & 0 deletions canon_in_dddddddddd/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Canon in DDDDDDDDDD

Gives maximum `D` to your music – this python program finds all occurences of the `D` note in your music sheet, and applies `B i g D` to jam in as many `D` semiquavers as possible!

Canon in D, before `B i g D`:

![screenshot_1](screenshot_1.png)

After `B i g D`:

![screenshot_2](screenshot_2.png)

Johann Pachelbel would be proud. [MuseScore Demo here for listening](https://musescore.com/user/14865386/scores/5745835)

## Usage:

Install dependency:

```
pip install -r requirements.txt
```

Big D a music score in MusicXML format:

```
python canon.py input.musicxml destination.musicxml
```

Big * a music score with other notes:

```
python canon.py input.musicxml dest.musicxml --note A
```

This will spam AAAAAAAAAA instead of DDDDDDDDDD inside your music score.

## Features

- Big D
- Works on both treble and bass clef
- Very Big D
- It sounds nicer
- Can also do big F

## Limitations

- You might get a warning when opening the result MusicXML file in MuseScore, but it should work out fine. Lowly mortal programs cannot handle the amount of `B i g D` in our school's curriculum.
- Titles and other cosmetic items, including some dynamics, in the MusicXML file are stripped after processing.
- Your orchestra will not play this
33 changes: 33 additions & 0 deletions canon_in_dddddddddd/canon.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import argparse
import partitura
import copy

parser = argparse.ArgumentParser()
parser.add_argument('in', help="Input musicxml file")
parser.add_argument('out', help="Destination file")
parser.add_argument('--note', help='Change the note to replicate')
args = parser.parse_args()

score = partitura.load_musicxml(getattr(args, "in"))

to_purge = []
added_notes = []

for note in score.timeline.iter_all(partitura.score.Note, include_subclasses=True):
if note.step == "D" and note not in added_notes and note.duration > 1:
containing_timepoint = next(iter([point for point in score.timeline.points if note in point.starting_objects[partitura.score.Note]]))
for i in range(0, note.duration):
new_d = copy.copy(note)
new_d._sym_dur = None
new_d.start = score.timeline.get_or_add_point(note.start.t + i)
new_d.end = score.timeline.get_or_add_point(new_d.start.t + 1)
score.timeline.add(new_d, containing_timepoint.t + i, containing_timepoint.t + i + 1)
to_purge.append(note)
added_notes.append(new_d)

for note in to_purge:
score.timeline.remove(note)

f = open(args.out, "wb")
partitura.save_musicxml(score, f)
f.close()
Binary file added canon_in_dddddddddd/screenshot_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added canon_in_dddddddddd/screenshot_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ac766d2

Please sign in to comment.