I want to do something fun, play a wasm file's raw data as sound
- User
I want to do something fun, play a wasm file's raw data as sound
- Assistant
Playing the raw data of a WebAssembly (WASM) file directly as sound isn't typically straightforward, because WASM files contain compiled binary code, not sound wave data. However, if for some context we consider performing experimental audio synthesis by interpreting the binary data as audio samples, one way to achieve a sound output would be to read the raw WASM binary data and interpret it as raw audio data.
- User
Sora.js:359 The AudioContext was not allowed to start. It must be resumed (or created) after a user gesture on the page. https://goo.gl/7K7WLu
- Assistant
The message you're seeing is related to an autoplay policy enforced by modern browsers to improve the user experience by preventing audio from automatically playing without the user's consent. To start the
AudioContext, you need to initiate it in response to a user interaction, such as a button click. - User
sound managed to play and analyzing it brings up nice patterns. How can I analyze and display these patterns?
- Assistant
- User
When you dump the ROM of a GBA by forcing it to crash it will play its entire stack context as sound, therefore allowing you to get the source code. Can you do the same for wasm?
- Assistant
The technique you're describing for dumping the Game Boy Advance (GBA) ROM involves leveraging a glitch or exploit that causes the console to execute unintended code paths, which may include outputting the contents of memory as audio. This is specific to the hardware and software architecture of the GBA and related to how it handles memory and executes code.
- User
I'm still interested on being able to analyze a wasm file by sound though. The sound plays and repeats several patterns that are related to code structure wihich is interesting and could be used for decompiling
- Assistant
- User
- Assistant
- User
now I noticed something here, we're fetching the arraybuffers of the wasm. Unless this contains the actual source code of the wasm then we're simply playing arraybuffers. Wasm has binary data which we can represent as sound
- Assistant
You're absolutely right that fetching the array buffer of a WASM file and attempting to play it as sound results in playing the binary data that constitutes the WASM module itself, not the source code. WebAssembly (WASM) binaries are a compilation target for higher-level languages like C, C++, Rust, or AssemblyScript. They consist of a binary format designed to be an efficient, portable bytecode that can be executed on the web.
- User
I'm trying to do something known as raw data noise
- Assistant
- User
When we play the wasm here's what we're actually playing
code2sound:26 ArrayBuffer(874840) byteLength : 874840 detached : false maxByteLength : 874840 resizable : false [[Prototype]] : ArrayBuffer [[Int8Array]] : Int8Array(874840) [[Uint8Array]] : Uint8Array(874840) [[Int16Array]] : Int16Array(437420) [[Int32Array]] : Int32Array(218710) [[ArrayBufferByteLength]] : 874840 [[ArrayBufferData]] : 9123
- Assistant
The information you've provided indicates that you have an with a of bytes. This buffer is the raw binary content of the WebAssembly (WASM) file that you've loaded. The itself is a generic container representing a fixed-length raw binary data buffer.
- User
I want to play the actual source code was the sound not the arraybuffer. The wasm file has raw data aka bytes that we can play
- Assistant
- User
- Assistant
- User
// INSERT OPERATION LOGIC HERE, REPLACING INSTANCE WITH EQUIVALENT C MECHANICS // …
You never managed to actually write the logic whihc is what I need
- Assistant