Export macro output

Audacity: 3.2.2
Python: 3.9.2
Windows: 10

I am trying to export a very small sample file to a macro executable. I can get data from the stdin pipe and write that data to a file just fine. The problem is the data looks like both a wav and an mp3. The header says RIFF[4bytes]WAVEfmt as expected. The 4byte file size is way off and the following bytes define the metadata as id3 tags, which should not be in a wav (or at least not at the beginning!). I was under the impression the metadata was not included in the output when using an external macro.


Actual Header Output:

52 49 46 46 7C C2 BA 1C 00 57 41 56 45 66 6D 74 20 10 00 00 00 03 00 02 00 44 C2 AC 00 00 20 62 05 00 08 00 20 00 69 64 33 20 90 00 00 00 49 44 33 03 00 00 00 00 01 06 43 4F 4D 4D 00 00 00 08 00 00 00 00 00 00 00 6C 6B 6D 54 49 54 32 00 00 00 04 00 00 00 34 35 36 54 58 58 58 00 00 00 16 00 00 00 53 6F 66 74 77 61 72 65 00 4C 61 76 66 35 39 2E 30 2E 31 30 30 54 44 52 43 00 00 00 04 00 00 00 64 65 66 54 41 4C 42 00 00 00 04 00 00 00 37 38 39 54 50 45 31 00 00 00 04 00 00 00 31 32 33 54 43 4F 4E 00 00 00 04 00 00 00 68 69 6A 54 52 43 4B 00 00 00 04 00 00 00 61 62 63 64 61 74 61 C3 80 C2

The output of the header isn’t really important to begin with, I am going to be stripping the current headers and writing custom ones just need to split the data bytes. So with the output from audacity and manually crafted valid wav header, the file plays as garbled trash. So my question is what format is this output in? I am using surrogateescape in python and I don’t exactly know what that does, not sure what the proper encoding format is.

How exactly are you doing that?

for line in sys.stdin:
        y+=line
    print(y)

this prints to console in audacity the output is encoded text. if I save to a file I need to choose an encoding method, using utf-8 with surrogates escaped seems to remove some of the data. Using unicode escaped doesn’t convert to bytes correctly.

You will need to give more information. What “console in Audacity” are you talking about? It is not at all clear what you are doing or how we might be able to help.

nC5Vwfk.jpeg
The only output console that audacity has. Seen is encoded text directly from the stdin pipe.

Please be more specific.
I can see that it’s not the Nyquist console, or the Audacity log. It looks like it might be one of the message windows from one of the scripting commands. I shouldn’t have to guess what you mean.

I am looking for a method to export binary data directly to an executable.

I see the option to export headerless raw data, which is precisely the data I want, but it saves a .raw file. I can already read and manipulate binary data of existing files so this doesn’t really save me any work.

You are not answering my questions, so I can’t help you.