Search code examples
c#file-iovst

Read specific parts of ASCII file in C#


I am trying to make a FXB file previewer (VST preset banks for those who don't know) for Sylenth1 banks. I have encoded the FXB as an ASCII string and had it print to the console. The preset names show up fine. My issue is that the parameters for the oscillators, filters and effects are encoded as random characters (mainly "?" and fairly big spaces).

Console window Underlined in red: file header (?)

Underlined in blue: preset name (which I want to keep)

Underlined in yellow: osc/FX/filter parameters (which I want to discard from the string)

Here's the code I wrote:

    byte[] arr = File.ReadAllBytes(Properties.Resources.pointer); /* pointer is a string in resources I
used to point to the external FXB file for testing */
    System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
    string fstr = enc.GetString(arr);
    Console.Write(fstr);
    Console.ReadKey();

I had written a foreach loop to replace every unwanted character with string.Empty, but it also removes parts of the preset names (e.g. the L from "Lead"), leaves the spaces intact and creates new ones, so I deleted it.

My end goal for those that are curious is this:

Preset 1
Preset 2
Preset 3
Preset 4
...

I'm at a total loss. I've tried different solutions from various websites and Stack Overflow posts, but none gave me the desired result.

(I also noticed that the preset names have almost the same space between them (~ 200 chars apart), can I use the difference to exclude the unwanted parts?)


Solution

  • I found the answer to this myself. I basically somewhat reverse engineered the FXB in a hex editor, and proceeded to load specific bytes of the file (31 to be exact) in order to encode those in a string and have that print to the console.

    I managed to do so by literally counting how many bytes there are from the beginning to the 1st preset name, then from the end of the preset name (31 bytes) to the beginning of the other preset name, and so on.

    For those who are interested, I am going to develop a GUI version of it in the future. But it does (and probably will) support only Sylenth1 v2 soundbanks/FXBs.

    Also thanks to the people who reached out. They helped in their own way.