Created
November 18, 2020 22:43
-
-
Save retorquere/068818beb07df049aad6ae1f5457a23d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import MutableSequence, Sequence, Tuple, Type, Union, Optional, Iterator | |
from pymusicxml.music_xml_objects import Note, Pitch, Duration | |
from xml.etree import ElementTree | |
class PercussionPitch(Pitch): | |
def render(self) -> Sequence[ElementTree.Element]: | |
pitch_element = ElementTree.Element("unpitched") | |
step_el = ElementTree.Element("display-step") | |
step_el.text = self.step | |
#alter_el = ElementTree.Element("alter") | |
#alter_el.text = str(self.alteration) | |
octave_el = ElementTree.Element("display-octave") | |
octave_el.text = str(self.octave) | |
pitch_element.append(step_el) | |
#pitch_element.append(alter_el) | |
pitch_element.append(octave_el) | |
return pitch_element, | |
class PercussionNote(Note): | |
def __init__(self, duration: Union[Duration, str, float], ties: str = None, | |
notations=(), articulations=(), notehead: Union['Notehead', str] = None, | |
directions: Sequence['Direction'] = (), stemless: bool = False): | |
super().__init__(self.note, duration, ties, notations, articulations, notehead, directions, stemless) | |
self.pitch = PercussionPitch(self.pitch.step, self.pitch.octave, self.pitch.alteration) | |
def render(self): | |
rendered = super().render() | |
#assert len(rendered) == 1 | |
#instrument = ElementTree.Element("instrument") | |
#instrument.set('id', f'P1-I{self.key}') | |
#rendered[0].append(instrument) | |
return rendered | |
class AcousticBassDrum(PercussionNote): | |
key=35 | |
note='B0' | |
instrument='Acoustic Bass Drum' | |
class BassDrum1(PercussionNote): | |
key=36 | |
note='C1' | |
instrument='Bass Drum 1' | |
class SideStick(PercussionNote): | |
key=37 | |
note='C#1' | |
instrument='Side Stick' | |
class AcousticSnare(PercussionNote): | |
key=38 | |
note='D1' | |
instrument='Acoustic Snare' | |
class HandClap(PercussionNote): | |
key=39 | |
note='Eb1' | |
instrument='Hand Clap' | |
class ElectricSnare(PercussionNote): | |
key=40 | |
note='E1' | |
instrument='Electric Snare' | |
class LowFloorTom(PercussionNote): | |
key=41 | |
note='F1' | |
instrument='Low Floor Tom' | |
class ClosedHiHat(PercussionNote): | |
key=42 | |
note='F#1' | |
instrument='Closed Hi Hat' | |
class HighFloorTom(PercussionNote): | |
key=43 | |
note='G1' | |
instrument='High Floor Tom' | |
class PedalHiHat(PercussionNote): | |
key=44 | |
note='Ab1' | |
instrument='Pedal Hi-Hat' | |
class LowTom(PercussionNote): | |
key=45 | |
note='A1' | |
instrument='Low Tom' | |
class OpenHiHat(PercussionNote): | |
key=46 | |
note='Bb1' | |
instrument='Open Hi-Hat' | |
class LowMidTom(PercussionNote): | |
key=47 | |
note='B1' | |
instrument='Low-Mid Tom' | |
class HiMidTom(PercussionNote): | |
key=48 | |
note='C2' | |
instrument='Hi Mid Tom' | |
class CrashCymbal1(PercussionNote): | |
key=49 | |
note='C#2' | |
instrument='Crash Cymbal 1' | |
class HighTom(PercussionNote): | |
key=50 | |
note='D2' | |
instrument='High Tom' | |
class RideCymbal1(PercussionNote): | |
key=51 | |
note='Eb2' | |
instrument='Ride Cymbal 1' | |
class ChineseCymbal(PercussionNote): | |
key=52 | |
note='E2' | |
instrument='Chinese Cymbal' | |
class RideBell(PercussionNote): | |
key=53 | |
note='F2' | |
instrument='Ride Bell' | |
class Tambourine(PercussionNote): | |
key=54 | |
note='F#2' | |
instrument='Tambourine' | |
class SplashCymbal(PercussionNote): | |
key=55 | |
note='G2' | |
instrument='Splash Cymbal' | |
class Cowbell(PercussionNote): | |
key=56 | |
note='Ab2' | |
instrument='Cowbell' | |
class CrashCymbal2(PercussionNote): | |
key=57 | |
note='A2' | |
instrument='Crash Cymbal 2' | |
class Vibraslap(PercussionNote): | |
key=58 | |
note='Bb2' | |
instrument='Vibraslap' | |
class RideCymbal2(PercussionNote): | |
key=59 | |
note='B2' | |
instrument='Ride Cymbal 2' | |
class HiBongo(PercussionNote): | |
key=60 | |
note='C3' | |
instrument='Hi Bongo' | |
class LowBongo(PercussionNote): | |
key=61 | |
note='C#3' | |
instrument='Low Bongo' | |
class MuteHiConga(PercussionNote): | |
key=62 | |
note='D3' | |
instrument='Mute Hi Conga' | |
class OpenHiConga(PercussionNote): | |
key=63 | |
note='Eb3' | |
instrument='Open Hi Conga' | |
class LowConga(PercussionNote): | |
key=64 | |
note='E3' | |
instrument='Low Conga' | |
class HighTimbale(PercussionNote): | |
key=65 | |
note='F3' | |
instrument='High Timbale' | |
class LowTimbale(PercussionNote): | |
key=66 | |
note='F#3' | |
instrument='Low Timbale' | |
class HighAgogo(PercussionNote): | |
key=67 | |
note='G3' | |
instrument='High Agogo' | |
class LowAgogo(PercussionNote): | |
key=68 | |
note='Ab3' | |
instrument='Low Agogo' | |
class Cabasa(PercussionNote): | |
key=69 | |
note='A3' | |
instrument='Cabasa' | |
class Maracas(PercussionNote): | |
key=70 | |
note='Bb3' | |
instrument='Maracas' | |
class ShortWhistle(PercussionNote): | |
key=71 | |
note='B3' | |
instrument='Short Whistle' | |
class LongWhistle(PercussionNote): | |
key=72 | |
note='C4' | |
instrument='Long Whistle' | |
class ShortGuiro(PercussionNote): | |
key=73 | |
note='C#4' | |
instrument='Short Guiro' | |
class LongGuiro(PercussionNote): | |
key=74 | |
note='D4' | |
instrument='Long Guiro' | |
class Claves(PercussionNote): | |
key=75 | |
note='Eb4' | |
instrument='Claves' | |
class HiWoodBlock(PercussionNote): | |
key=76 | |
note='E4' | |
instrument='Hi Wood Block' | |
class LowWoodBlock(PercussionNote): | |
key=77 | |
note='F4' | |
instrument='Low Wood Block' | |
class MuteCuica(PercussionNote): | |
key=78 | |
note='F#4' | |
instrument='Mute Cuica' | |
class OpenCuica(PercussionNote): | |
key=79 | |
note='G4' | |
instrument='Open Cuica' | |
class MuteTriangle(PercussionNote): | |
key=80 | |
note='Ab4' | |
instrument='Mute Triangle' | |
class OpenTriangle(PercussionNote): | |
key=81 | |
note='A4' | |
instrument='Open Triangle' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment