Esempio n. 1
0
def trackRun(tr, line):
    """ Entry point for track command. """

    # We check if track type is correct.
    pu.checkTrackType(tr)

    # initalize tracks 2 and 3
    setTuning(tr)

    out1 = ["%s Riff  " % tr]
    out2 = ["%s Riff  " % fTrack]
    out3 = ["%s Riff  " % sTrack]

    line = ''.join(line)[:-1]

    for a in line.split(';'):
        if not ']' in a:
            attr, note = ('', a)
        else:
            attr, note = a.split(']', 1)

        # we now have just the note info to worry about. The stuff in []
        # is tucked away in 'attr'.

        if '%' in note:
            flatNote = attr + note.replace('%', '')
            normNote = attr + note2rest(note)
            sharpNote = attr + note2rest(note)

        elif '*' in note:
            sharpNote = attr + note.replace('*', '')
            normNote = attr + note2rest(note)
            flatNote = attr + note2rest(note)

        else:
            sharpNote = attr + note2rest(note)
            flatNote = attr + note2rest(note)
            normNote = attr + note

        out1.extend([normNote, ';'])
        out2.extend([flatNote, ';'])
        out3.extend([sharpNote, ';'])

    pu.addCommand(''.join(out1))
    pu.addCommand(''.join(out2))
    pu.addCommand(''.join(out3))

    if MMA.debug.debug:
        print(''.join(out1))
        print(''.join(out2))
        print(''.join(out3))

    pu.sendCommands()
Esempio n. 2
0
def trackRun(trackname, line):
    # We check if track type is correct.
    pu.checkTrackType(trackname)
    # We parse the arguments. Errors are thrown if something is wrong,
    # printing the correct usage on screen. Default are used if needed.
    # parseCommandLine also takes an optional boolean argument to allow
    # using of arguments not declared with pu.addArgument, default is False.
    args = pu.parseCommandLine(line)
    
    # This is how we access arguments.
    pattern = args["Pattern"]
    strum   = args["Strum"]
    volumeN = args["Volume"]
    volumeM = args["VolumeMuted"]
    volumeE = args["VolumeEmph"]
    volumeP = args["VolumePick"]
    
    # This is the logic for the plugin.
    all_normal = ""
    all_muted = ""
    
    for bar_pattern in pattern.split(";"):
        if "." in bar_pattern:
            bar_pattern = bar_pattern.lower().split(".")
        else:
            # you can avoid commas when not using ue, ux, de, dx
            bar_pattern = bar_pattern.lower()

        strums_normal = []
        strums_muted = []
        
        step = float(pu.getSysVar("TIME"))/len(bar_pattern)
        for i, c in enumerate(bar_pattern):
            t = 1+step*i
        
            if c == "u":
                strums_normal.append("{:0.4} -{} {}".format(t, strum, volumeN))
            elif c == "ue":
                strums_normal.append("{:0.4} -{} {}".format(t, strum, volumeE))
            elif c == "um":
                strums_normal.append("{:0.4} 0 0".format(t))
                strums_muted.append("{:0.4} -{} {}".format(t, strum, volumeM))
                
            elif c == "d":
                strums_normal.append("{:0.4} +{} {}".format(t, strum, volumeN))
            elif c == "de":
                strums_normal.append("{:0.4} +{} {}".format(t, strum, volumeE))
            elif c == "dm":
                strums_normal.append("{:0.4} 0 0".format(t))
                strums_muted.append("{:0.4} +{} {}".format(t, strum, volumeM))
                
            elif c == "x":
                strums_normal.append("{:0.4} 0 0".format(t))
                strums_muted.append("{:0.4} 0 {}".format(t, volumeM))
                
            elif c == "0":
                strums_normal.append("{:0.4} 0 0".format(t))
                
            elif c.lstrip("0").isdigit():
                for s in c:
                    strums_normal.append("{:0.4} 0 {}:{}".format(t, s, volumeP))

            elif c == "-":
                pass
                
            else:
                #printUsage()
                pu.error("{}: unrecognized command in strum pattern: '{}'.".format(pu.getName(), c))    
     
        bar_normal = ("{" + "; ".join(strums_normal) + ";}") if len(strums_normal) > 0 else "z"
        bar_muted  = ("{" + "; ".join(strums_muted)  + ";}") if len(strums_muted)  > 0 else "z"
        
        all_normal += bar_normal + " "
        all_muted  += bar_muted + " "
        

    # If you don't send all the commands together the result is commands 
    # are reversed since each is pushed as the very next command to be executed.
    # So we save all the commands (with addCommand) and send them at the end
    # (with sendCommands).
    
    pu.addCommand("{} Sequence {}".format(trackname, all_normal))
    pu.addCommand("{}-Muted SeqClear".format(trackname))
    pu.addCommand("{}-Muted Copy {}".format(trackname, trackname))
    pu.addCommand("{}-Muted Voice MutedGuitar".format(trackname))
    pu.addCommand("{}-Muted Sequence {}".format(trackname, all_muted))
    pu.sendCommands()