pysynth/wrappers/mml.py
def decode(self, chord=False):

        """
        Decodes the given MML input.

        We may change our state,
        or toggle a note to be on in the sequencer.

        We also have the option to operate in chord mode,
        meaning that we do not attempt to stop notes.

        :param chord: Determines if we are working with a chord
        :type chord: bool
        """

        # Get our input from the source:

        inp = self.source.get()

        print(inp)

        # Check to see if we are reading a note:

        if inp in self.note_map:

            # Lets handle and read the note:

            self.read_note(no_time=chord)

            if not chord:

                # Increment our invalid index:

                self.num_processed += 1

            return

        # Check if we are resting:

        if inp == 'r':

            # We are resting, get length

            time_amount = self.read_length()

            # Add a rest event:

            self.command.rest(self.find_time_type(time_amount))

            self.num_processed += 1

            return

        # Check if we are reading a chord:

        if inp == '[':

            # Lets continuously read until we reach the end:

            for _ in self.source.read_until(']'):

                # Pass the input onto ourselves:

                self.decode(chord=True)

            # We are done, let's determine the length:

            length = self.find_time_type(self.read_length())

            # Add the event to the SeqCommand:

            self.command.chord(self.notes, length)

            print("Adding chords with notes: {}".format(self.notes))
            print("Length: {}".format(length))

            self.notes.clear()

            self.num_processed += 1

            return

        # Check if we are going up or down an octave:

        # OG: < increased, > decreased

        if inp in ['<', '>']:

            # Determine if we are going up or down:

            if inp == '<':

                # Increase the octave:

                self.octave += 1

                return

            if inp == '>':

                # Decrease the octave:

                self.octave -= 1

                return

        # Check if we are starting a loop:

        if inp == '/' and self.source.peek() == ':':

            # We are starting a loop, lets set our start index:

            self.source.forward()

            self.loop_index = self.num_processed

            return

        if inp == ':' and self.source.peek() == '/':

            # We are at the end of a loop!

            self.source.forward()

            # Add a repeat event to the SeqCommand:

            self.command.repeat(self.loop_index, self.read_number())

            return

        # Check if we are working with endless looping:

        if inp == '$':

            # We are endlessly looping, let's add it at the end:

            self.loop = True

            return

        # Check if we are changing our octave:

        if inp == 'o':

            # Octave is changing, let's read the value:

            self.octave = self.read_number() - 4

            return

        # Check for a velocity value

        if inp == 'v':

            # Reading a velocity value;

            self.velocity = self.read_number()

        # Check for a change in default length:

        if inp == 'l':

            # Default length is changing, let's read the value:

            self.default_length = self.read_length()

            return

        # Check for change in velocity:

        # Check for change in tempo:

        if inp == 't':

            # Tempo is changing, let's read the value:

            self.tempo = self.read_length()

            return

        # Check for track change:

        if inp == ';':

            # Change in track, let's reset ourselves:

            if self.loop:

                # We are forever looping, lets add it:

                self.command.repeat(0, -1)

            # Add our current command chain:

            self.seq.add_seqcom(self.command)

            # Create a new SeqCommand:

            self.command = SeqCommand(self.seq)

            return

        Decodes the given MML input.

        We may change our state,
        or toggle a note to be on in the sequencer.

        We also have the option to operate in chord mode,
        meaning that we do not attempt to stop notes.

        :param chord: Determines if we are working with a chord
        :type chord: bool
        
Decodes the given MML input.
We may change our state,
or toggle a note to be on in the sequencer.

We also have the option to operate in chord mode,
meaning that we do not attempt to stop notes.
Decodes the given MML input . We may change our state or toggle a note to be on in the sequencer . We also have the option to operate in chord mode meaning that we do not attempt to stop notes .
def decode(self, chord=False):
        inp = self.source.get()
        print(inp)
        if inp in self.note_map:
            self.read_note(no_time=chord)
            if not chord:
                self.num_processed += 1
            return
        if inp == 'r':
            time_amount = self.read_length()
            self.command.rest(self.find_time_type(time_amount))
            self.num_processed += 1
            return
        if inp == '[':
            for _ in self.source.read_until(']'):
                self.decode(chord=True)
            length = self.find_time_type(self.read_length())
            self.command.chord(self.notes, length)
            print("Adding chords with notes: {}".format(self.notes))
            print("Length: {}".format(length))
            self.notes.clear()
            self.num_processed += 1
            return
        if inp in ['<', '>']:
            if inp == '<':
                self.octave += 1
                return
            if inp == '>':
                self.octave -= 1
                return
        if inp == '/' and self.source.peek() == ':':
            self.source.forward()
            self.loop_index = self.num_processed
            return
        if inp == ':' and self.source.peek() == '/':
            self.source.forward()
            self.command.repeat(self.loop_index, self.read_number())
            return
        if inp == '$':
            self.loop = True
            return
        if inp == 'o':
            self.octave = self.read_number() - 4
            return
        if inp == 'v':
            self.velocity = self.read_number()
        if inp == 'l':
            self.default_length = self.read_length()
            return
        if inp == 't':
            self.tempo = self.read_length()
            return
        if inp == ';':
            if self.loop:
                self.command.repeat(0, -1)
            self.seq.add_seqcom(self.command)
            self.command = SeqCommand(self.seq)
            return
def decode ( self , chord = False ) : inp = self . source . get ( ) print ( inp ) if inp in self . note_map : self . read_note ( no_time = chord ) if not chord : self . num_processed += 1 return if inp == 'r' : time_amount = self . read_length ( ) self . command . rest ( self . find_time_type ( time_amount ) ) self . num_processed += 1 return if inp == '[' : for _ in self . source . read_until ( ']' ) : self . decode ( chord = True ) length = self . find_time_type ( self . read_length ( ) ) self . command . chord ( self . notes , length ) print ( "Adding chords with notes: {}" . format ( self . notes ) ) print ( "Length: {}" . format ( length ) ) self . notes . clear ( ) self . num_processed += 1 return if inp in [ '<' , '>' ] : if inp == '<' : self . octave += 1 return if inp == '>' : self . octave -= 1 return if inp == '/' and self . source . peek ( ) == ':' : self . source . forward ( ) self . loop_index = self . num_processed return if inp == ':' and self . source . peek ( ) == '/' : self . source . forward ( ) self . command . repeat ( self . loop_index , self . read_number ( ) ) return if inp == '$' : self . loop = True return if inp == 'o' : self . octave = self . read_number ( ) - 4 return if inp == 'v' : self . velocity = self . read_number ( ) if inp == 'l' : self . default_length = self . read_length ( ) return if inp == 't' : self . tempo = self . read_length ( ) return if inp == ';' : if self . loop : self . command . repeat ( 0 , - 1 ) self . seq . add_seqcom ( self . command ) self . command = SeqCommand ( self . seq ) return
Decodes the given MML input.
Decodes the given MML input .
"""
        Decodes the given MML input.

        We may change our state,
        or toggle a note to be on in the sequencer.

        We also have the option to operate in chord mode,
        meaning that we do not attempt to stop notes.

        :param chord: Determines if we are working with a chord
        :type chord: bool
        """ # Get our input from the source: # Check to see if we are reading a note: # Lets handle and read the note: # Increment our invalid index: # Check if we are resting: # We are resting, get length # Add a rest event: # Check if we are reading a chord: # Lets continuously read until we reach the end: # Pass the input onto ourselves: # We are done, let's determine the length: # Add the event to the SeqCommand: # Check if we are going up or down an octave: # OG: < increased, > decreased # Determine if we are going up or down: # Increase the octave: # Decrease the octave: # Check if we are starting a loop: # We are starting a loop, lets set our start index: # We are at the end of a loop! # Add a repeat event to the SeqCommand: # Check if we are working with endless looping: # We are endlessly looping, let's add it at the end: # Check if we are changing our octave: # Octave is changing, let's read the value: # Check for a velocity value # Reading a velocity value; # Check for a change in default length: # Default length is changing, let's read the value: # Check for change in velocity: # Check for change in tempo: # Tempo is changing, let's read the value: # Check for track change: # Change in track, let's reset ourselves: # We are forever looping, lets add it: # Add our current command chain: # Create a new SeqCommand:
self
chord
Determines if we are working with a chord
Determines if we are working with a chord