0xDEAFBEEF

Guide for Reconstructing Media: Noumenon

Summary: obtain the C source code and token's parameters values from Ethereum blockchain. Replace the variables in the C file where indicated. Compile and run the program,obtaining the raw output (BMP and WAV files). Encode the raw output to MP4,MP3 using ffmpeg.

Step 1: Obtain the C source code file and your token's parameters

Use a web3 client or etherscan.io to interact with the contract at https://etherscan.io/address/0xd7483426ea2edc69cc446859e20d61de1bae4d22.

Use the getTokenParams() function, passing your token ID.

Note the 'p1', 'p2', 'p3' parameter values that you will later need. 'codeLocation0' is the address of the transaction that contains the C source code. Visit that transaction address on etherscan, in this example it's https://etherscan.io/tx/0x7a8b6f7089aeabb0f55d0b5af8b996734afaee764d8aa25fe347d47394158474 Press 'Click to see More' and view the 'Input Data' field as UTF-8.

Copy and paste the C source code into a file on your computer named main.c.

Step 2: Replace the parameters variable with token's unique random hash

Near the top of the C source file, there is a function init_token_params():
void init_token_params() {
  // insert token ID...
  token_params.noumenon_token_id = 0;
  
  // ...and the parameters returned from smart contract function getTokenParam(tokenID,x);
  // token ID of the most recently generated Chronophotograph
  // insert return value of getTokenParam(tokenID,1)
  token_params.chronophotograph_token_id = 0;

  // blocknumber when the Chronophotograph was generated
  // insert return value of getTokenParam(tokenID,2)
  token_params.blocknumber = 0;

  // epoch of the Chronophotograph
  // insert return value of getTokenParam(tokenID,3)
  token_params.epoch = 0;
}

Replace your token ID, and replace the indicated values with the 'p1','p2','p3' values previously read through getTokenParams(). For example:
void init_token_params() {
  // insert token ID...
  token_params.noumenon_token_id = 17;
  
  // ...and the parameters returned from smart contract function getTokenParam(tokenID,x);
  // token ID of the most recently generated Chronophotograph
  // insert return value of getTokenParam(tokenID,1)
  token_params.chronophotograph_token_id = 261;

  // blocknumber when the Chronophotograph was generated
  // insert return value of getTokenParam(tokenID,2)
  token_params.blocknumber = 19867740;

  // epoch of the Chronophotograph
  // insert return value of getTokenParam(tokenID,3)
  token_params.epoch = 19;
}

Step 3: Install a C compiler for your platform.

Linux is the recommended platform, and GNU GCC is the recommended C compiler, available through default package managers. On Mac, you may be able to use Homebrew. On Windows, try GNU GCC binaries.

Step 4: Compile and run the program.

Code conforms to the ISO c99 standard. Only library dependency is C math library. Pass '-lm' to gcc. Assumes architecture is little endian (all Intel processors)

First, create directory to store output images:
$ mkdir 'frames'
Next, compile and run. Optionally pass '-Ofast' flag to enable optimization (faster rendering).
$ gcc -Ofast main.c -lm && ./a.out

This will produce:
a. Numbered image files in BMP file format stored in 'frames' directory. 24 FPS(frames per second)
b. Audio file named 'output.wav' in WAV format, stereo, 44.1khz, 16bit depth

This is the 'raw' information representing digital audio signals and image pixel intensities.

Step 5: Encode raw output to chosen media format(MP3, MP4, JPG, PNG, etc)

This raw information can be encoded perceptually using whatever tools exist at the time of reconstruction. At present, for example, opensource tools such as imagemagick and ffmpeg can be used to encode images,video and audio in different format for popular distributions. Linux platform is recommended, ffmpeg is available from default package manager. On Mac platform, use Homebrew to install ffmpeg.

Examples:

Encode images and audio into an MP4 video file:

$ ffmpeg -framerate 24 -i frames/frame%04d.bmp -i output.wav -crf 20  -c:v libx264 -c:a aac -b:a 192k -pix_fmt yuv420p -shortest -y audiovisual.mp4