@ -26,6 +26,7 @@ This is mostly meant for development and testing.
#Standard Library Modules
import re
from typing import Dict
#Third Party Modules
from calfbox import cbox
@ -35,10 +36,10 @@ from . import pitch
from . duration import DB , DL , D1 , D2 , D4 , D8 , D16 , D32 , D64 , D128
lyToMidi = { } #filled for all pitches on startup, below
for ly , _pitch in pitch . ly2pitch . items ( ) :
lyToMidi : Dict [ str , int ] = { } #filled for all pitches on startup, below
for lyPitchString , _pitch in pitch . ly2pitch . items ( ) :
octOffset = ( pitch . octave ( _pitch ) + 1 ) * 12 #twelve tones per midi octave
lyToMidi [ ly ] = octOffset + pitch . halfToneDistanceFromC ( _pitch )
lyToMidi [ lyPitchString ] = octOffset + pitch . halfToneDistanceFromC ( _pitch )
lyToTicks = {
@ -68,7 +69,7 @@ def pattern(lilypondString:str, channel, velocity:int=100):
"""
Return a cbox pattern
a python byte data type with midi data for cbox .
Channel is 1 - 16. """
#cbox.Pattern.serialize_event(position, midibyte1 (noteon), midibyte2(pitch), midibyte3(velocity))
channel - = 1
@ -79,7 +80,7 @@ def pattern(lilypondString:str, channel, velocity:int=100):
patternBlob + = cbox . Pattern . serialize_event ( tickCounter , 0x90 + channel , midiPitch , velocity ) # note on
patternBlob + = cbox . Pattern . serialize_event ( endTick , 0x80 + channel , midiPitch , velocity ) # note off
tickCounter = tickCounter + durationInTicks #no -1 for the next note
pattern = cbox . Document . get_song ( ) . pattern_from_blob ( patternBlob , tickCounter )
#return patternBlob, startTick
return pattern