Live data from Hacker News

Generate raw WAV output by hooking malloc and read

github.com

11–20 of 26 posts

Re: Generate raw WAV output by hooking malloc and read

#15

Reminds me of when I was a kid, and I had a Tandy CoCo and a tape recorder deck that was the only way to save any programs you wrote on it. I tried playing the data tape a few times.

Yes! I used to have an Amstrad CPC 464 with a tape deck and it would play the tape through its internal speaker as it was loading a program into memory. The amount of time sat around watching screens like this:

https://www.youtube.com/watch?v=OvChkOHgDIo

Re: Generate raw WAV output by hooking malloc and read

#16

void* read( int fd, void * data, size_t count) { ... gen_square_wave( 44100 , CLAMP(count, 20, 20000 ), CLAMP( sizeof(data), 100 , 1700), 0.7 ); I don't get it, isn't sizeof(data) always the same, and usually either 4 or 8?

Since sizeof is a compile-time construct, it's always always the same (in C; in C++ there are templates to consider)

Re: Generate raw WAV output by hooking malloc and read

#17

It sounds like when I piped /dev/random to a midi device. (Or was it /dev/urandom and TiMidity++?) It was like demos; I would be stunned at the emergent complexity and compactness, and it would only elicit shrugs from friends.

I'm reminded of some of my favourite C 1-liners for synthesis:

    main(t){
        for(t=0;;t++)
            putchar(t*(((t>>12)|(t>>8))&(63&(t>>4))));
            //putchar(t>>7|t%45)&(t>>8|t%35)&(t>>11|t%20); // try this too!
    }
.. there's a whole world of 1-liners for synthesis out there, and some of them, frankly, are astounding. Sound is such a beautiful way to understand math ..

Re: Generate raw WAV output by hooking malloc and read

#18
post #17

It sounds like when I piped /dev/random to a midi device. (Or was it /dev/urandom and TiMidity++?) It was like demos; I would be stunned at the emergent complexity and compactness, and it would only elicit shrugs from friends.

I'm reminded of some of my favourite C 1-liners for synthesis: main(t){ for(t=0;;t++) putchar(t*(((t>>12)|(t>>8))&(63&(t>>4)))); //putchar(t>>7|t%45)&(t>>8|t%35)&(t>>11|t%20); // try this too! } .. there's a whole world of 1-liners for synthesis out there, and some of them, frankly, are astounding. Sound is such a beautiful way to understand math ..

These are called bytebeat nowadays.

See viznut's (seminal) intro to the genre.

http://countercomplex.blogspot.fi/2011/10/algorithmic-sympho...

https://www.youtube.com/watch?v=GtQdIYUtAHg

Re: Generate raw WAV output by hooking malloc and read

#19

void* read( int fd, void * data, size_t count) { ... gen_square_wave( 44100 , CLAMP(count, 20, 20000 ), CLAMP( sizeof(data), 100 , 1700), 0.7 ); I don't get it, isn't sizeof(data) always the same, and usually either 4 or 8?

I haven't read the code, but it looks like this is a bug, or at least superfluous

Re: Generate raw WAV output by hooking malloc and read

#20

void* read( int fd, void * data, size_t count) { ... gen_square_wave( 44100 , CLAMP(count, 20, 20000 ), CLAMP( sizeof(data), 100 , 1700), 0.7 ); I don't get it, isn't sizeof(data) always the same, and usually either 4 or 8?

Yeah, the result of the sizeof operator always compiles to a constant. It may vary from system to system and compiler to compiler, but it's written into the executable as a constant.
Post reply on HN