示例#1
0
    def load(self):
        """load.

        Loading preset into Reaper.
        """
        #load chunk from reaper and decode it
        chunk_from_reaper = rpre.save()
        decoded_chunk_from_reaper = chunk_from_reaper.decode_vst_chunk()

        project = reapy.Project()
        selected_track = project.get_selected_track(0)
        selected_track.instrument.delete()
        selected_track.add_fx(chunk_from_reaper.plugin_dll)

        #read nks file and get chunk
        preset_to_convert = nksf.NKSF(self.filepath, True, True, True)
        new_chunk = preset_to_convert._NKSF__chunks["PCHK"].data

        #convert chunk into list with length 210
        length = 210
        presetdata = [
            new_chunk[i:i + length] for i in range(0, len(new_chunk), length)
        ]

        #insert reaper specific header and footer
        """This is used to calculate the number of list elements for the header of the fx state chunk
        it is built up the following:
        4 Bytes: VST ID
        4 Bytes: Reaper Magix Number
        4 Bytes: Number of Inputs
        8 Bytes by Number of inputs: Input Mask
        4 Bytes: Number of outputs
        8 Bytes by Number of outputs: output Mask
        4 Bytes: Something I don't know
        8 Bytes: seems to be the end 01 00 00 00 00 00 10 00
        """
        instrument_description_lenth = 4 + 4 + 4 + (
            selected_track.instrument.n_inputs *
            8) + 4 + (selected_track.instrument.n_outputs * 8) + 4 + 8
        # calculate number of list elements needed for length. Per element its 210 bytes
        no_list_elements = int(instrument_description_lenth /
                               210) + (instrument_description_lenth % 210 > 0)

        if no_list_elements == 1:
            progchunk = [decoded_chunk_from_reaper[0]] + presetdata
        else:
            progchunk = decoded_chunk_from_reaper[0:no_list_elements -
                                                  1] + presetdata
        pgm_name = b'\x00' + "test".encode() + b'\x00\x10\x00\x00\x00'
        progchunk.append(pgm_name)

        #load new chunk into reaper
        chunk_from_reaper.encode_vst_chunk(progchunk)
        rpre.load(chunk_from_reaper)
示例#2
0
def render_audio(folder: str, preset_name: str, chunk) -> str:
    """Render Audio.

    Renders audio inside Reaper

    Parameters
    ----------
        folder: folder where to store audio
        preset_name: name of audio file


    Returns
    -------
    renderpath: full path to rendered audio

    """
    #open new tab
    reapy.perform_action(40859)

    #set renderpath in project file
    logging.debug('Rendering: ' + preset_name)
    renderpath = folder + "\\" + preset_name + ".mp3"
    set_output_path(renderpath)

    #set name of track,as rendering takes trackname for filename
    project = reapy.Project()
    vst_track = project.tracks[0]
    vst_track.name = preset_name

    #load preset to track 1
    project.select_all_tracks()
    rp.load(chunk)
    time.sleep(2)

    #save project so changes get updated
    project.save()

    project.select_all_tracks()

    #call render action by ID
    reapy.perform_action(42230)

    logging.debug("Finished Rendering")

    #remove VSTI to not get issues when loading next time
    vst_track.instrument.delete()
    project.save()

    #close tab
    reapy.perform_action(40860)
    return renderpath
示例#3
0
decoded_chunk_from_reaper = chunk_from_reaper.decode_vst_chunk()

presetpath = r"C:\Users\phili\Desktop\fxp\omni"

for filename in os.listdir(presetpath):
    #read nks file and get chunk
    fxppreset = fxp.FXPPreset(os.path.join(presetpath, filename))
    new_chunk = fxppreset.fxpchunk

    #convert chunk into list with length 210
    length = 210
    progchunk = [
        new_chunk[i:i + length] for i in range(0, len(new_chunk), length)
    ]

    #insert reaper specific header and footer
    progchunk.insert(0, decoded_chunk_from_reaper[0])
    pgm_name = b'\x00' + "test".encode() + b'\x00\x10\x00\x00\x00'
    progchunk.append(pgm_name)

    chunktest1 = rpre.save().decode_vst_chunk()
    #load new chunk into reaper
    chunk_from_reaper.encode_vst_chunk(progchunk)
    rpre.load(chunk_from_reaper)

    #todo validate
    chunktest2 = rpre.save().decode_vst_chunk()
    if chunktest1 == chunktest2:
        print("Failed: " + filename)
    else:
        print("Success: " + filename)
示例#4
0
#vstipreset = vsti.VSTPreset("C:\\Users\\phili\\Desktop\\amped.vstpreset")

print("Test")

start = "#pgm=bbb Funkeee\n"
#filepath= "C:\\Users\\phili\\Desktop\\bbb.FXP"
filepath = "C:\\Tyrell\\TyrellN6.data\\Presets\\TyrellN6\\Chapter 3.h2p"
fxppresetstream = open(filepath, "rb")
fxpchunk = fxppresetstream.read()
fxpchunk = fxpchunk.replace(b"\\r", b"\r")
fxpchunk = fxpchunk.replace(b"\\n", b"\n")
combined = start.encode() + fxpchunk

#split into size 280
length = 210
progchunk = [combined[i:i + length] for i in range(0, len(combined), length)]
progchunk.insert(0, msg[0])
progchunk.append(b'\x00')
msg2 = []
for ch in progchunk:
    bt = base64.b64encode(ch).decode()
    msg2.append(bt)

for a, b in zip(chunk.vst_chunk, msg2):
    print(a == b)

chunk.vst_chunk = msg2

rpre.load(chunk)
示例#5
0
#split into size 210
length = 210
vsti_chunk_dec = [vsti_chunk_combined[i:i+length] for i in range(0, len(vsti_chunk_combined), length)]

#add reaper specific data for plugin
vsti_chunk_dec.insert(0, reaper_chunk_dec[0])
vsti_chunk_dec.insert(1, reaper_chunk_dec[1])
vsti_chunk_dec.insert(2, reaper_chunk_dec[2])
vsti_chunk_dec.append(reaper_chunk_dec[-1])

#compare reaper and vstpreset chunk before encoding
for a,b in zip(vsti_chunk_dec, reaper_chunk_dec):
    print(a==b)

#encode vstpreset chunk
vsti_chunk_raw = []
vsti_string_dec = bytes()
for ch in vsti_chunk_dec:
    vsti_string_dec += ch
    bt = base64.b64encode(ch).decode()
    vsti_chunk_raw.append(bt)

#compare reaper and vstpreset chunk after encoding
for a,b in zip(reaper_chunk_raw.vst_chunk, vsti_chunk_raw):
    print(a==b)

#set new chunk in reaper track
reaper_chunk_raw.vst_chunk= vsti_chunk_raw
rpre.load(reaper_chunk_raw)

print("Finished")
示例#6
0
    def load(self):
        """load.

        Loading preset into Reaper.
        """
        rp.load(self.chunk)