Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gordol/ld_preload-sounds
Generates raw WAV output by hooking malloc() and read().
https://github.com/gordol/ld_preload-sounds
Last synced: 1 day ago
JSON representation
Generates raw WAV output by hooking malloc() and read().
- Host: GitHub
- URL: https://github.com/gordol/ld_preload-sounds
- Owner: gordol
- Created: 2014-07-20T13:08:01.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-01-02T10:27:12.000Z (almost 10 years ago)
- Last Synced: 2024-08-02T05:06:46.323Z (3 months ago)
- Language: C
- Homepage:
- Size: 208 KB
- Stars: 193
- Watchers: 11
- Forks: 11
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
ld_preload sounds
=================Generates WAV output by hooking malloc() and read(). Adding support for other calls should be pretty easy, pull-requests are much welcomed!
Also, it should go without saying... but I will say it anyway... __this is experimental__. Hooking memory and read calls could break things horribly, I accidentally blew out a buch of my vim configs at one point while first starting to write this becuase I thought it would be neat to hook the editor while making more changes, and yeah... I broke it. So consider yourself warned... I do not wish to be responsible if you break your system, lose files, etc... Be sure you have backups of any files touched by the programs you're running through this, you have backups anyway, don't you? Don't you?
To build, run ```make```, you know the drill. ;)
To try it out, run the ```writeWav``` script with the program and parameters you with to experiment with.
A wav file will be created in the current directory with a name of the current timestamp if you run with writeWav.Otherwise, if you wish, you may LD_PRELOAD writeWav.so manually. If you preload manually, however, there are some environment vars that you should be aware of:
__Required__:
* writeWav_out (default: none)__Optional__:
* writeWav_noread (default: false) If true, we will not use read() calls to generate data.
* writeWav_nomalloc (default: false) If true, we will not use malloc() calls to generate data.If you want to tweak the output, you may do so in ```writeWav.c``` near the top:
```c
/*
* General wave generation parameters.
*
* parameter 1 - wave frequency in Hertz; should be clamped to a sane range
* (e. g. 20-20000 Hz) with CLAMP_u(freq, min, max)
* parameter 2 - wave duration in milliseconds
* parameter 3 - wave amplitude (0.0-1.0)
*//*
* Size-based wave generatrion for malloc() calls.
*
* size - allocated memory size in bytes
*/
#define MALLOC_WAVE_PARAMS(size) \
CLAMP_u(size, 20u, 10000u), 20, 0.7f/*
* Size and runtime based wave generation for malloc() calls.
*
* size - see above
* ticks - number of consumed CPU clock ticks since program start
*/
#define MALLOC_WAVE_TICKS_PARAMS(size, ticks) \
CLAMP_u(ticks, 20u, 20000u), 10, 0.7f/*
* Size based wave generation for read() calls.
*
* requested - requested amount of bytes to read
* returned - actual amounts of bytes read
*/
#define READ_WAVE_PARAMS(requested, returned) \
CLAMP_u(requested, 20u, 20000u), CLAMP_u(returned, 100, 1700), 0.7f
```You can listen to some examples of the output here:
* https://soundcloud.com/glowdon/jingy-compiler-1
* https://soundcloud.com/glowdon/the-sounds-of-malloc
* https://soundcloud.com/glowdon/malloc-read-hook-self-compileMany thanks to [@davidfoerster](https://github.com/davidfoerster) and others for the forks and improvements!