Making a sample editor based off Segmenti

Hi! I am currently working on trying to figure out how I could make a sample editor that functions using a lot of the same functionality as Segmenti (i.e set start and end points, speed control and most importantly, a visual representation of the waveform). The hard part that im running into is how to take the segment and export it to a file. I personally would find great use in this to chop up long samples without having to load them into a computer and then using the file manager patch to move them around. Any help or tips would be greatly appreciated! I’ll send updates of any progress I make